From nobody Tue Feb 10 12:40:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1618004022; cv=none; d=zohomail.com; s=zohoarc; b=GKJp1qKo8LRO3S3RiFh5kxpCyQPV/2bfPBT/Eg812S0Ja/9ZH7EOEzHIRxaji6aJZ7UVFzNTSnt2Coij6RMe8sm3z+t+oTeHg1wdTEcWEgyM0YKwDnk6F+/JLkbJ14T2T1+QU9iNUaA4ccOxNf1TEpuClPwLOO8Dyq5voYCr7h0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618004022; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a1JqsBZ5iRPcNb8hrP8HZgedc5ZzjFn5zychhgd9TT0=; b=X4T4QHlyVY7l4RPuAC+5nNBA/CZUIMzeGmoMBkq30vQhaFI8yii55bnM+Gz/LXwW43/kXQFGZtTdUkV4bEt8q8M4C57dCdNk5NKE5DlYBZZMnKZK9Gu5srGMe7WH51VvO1V0hsFZ3iA7NrsAhJbEtD2UasjBe1nHJ0i/FHW1Zkg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1618004022479981.4056914127017; Fri, 9 Apr 2021 14:33:42 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-420-3aam8bMIM8KsIwvpTZoq_g-1; Fri, 09 Apr 2021 17:33:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0D76801814; Fri, 9 Apr 2021 21:33:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8AAEF6F99B; Fri, 9 Apr 2021 21:33:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5241D5534D; Fri, 9 Apr 2021 21:33:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 139LXD20032631 for ; Fri, 9 Apr 2021 17:33:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id AFC2C5D6AD; Fri, 9 Apr 2021 21:33:13 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-113-25.phx2.redhat.com [10.3.113.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74BF65D6A1; Fri, 9 Apr 2021 21:33:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618004021; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=a1JqsBZ5iRPcNb8hrP8HZgedc5ZzjFn5zychhgd9TT0=; b=YlGhGDdB4wkr4YleP3X6E71ive+nOAwHQ8s100nRoeFRgyVYRiKhEhuzLuKv5EnfjZ/o6p CHeZhKsJQC/V4aaVUehI6K9v+U9lN4C6Qw70dcUjz++V1Ypn6FJm97VwCJb6MJG+nEvpxD F+Yp5IbGAGeJWryOro+Z9o2KGNM6S2I= X-MC-Unique: 3aam8bMIM8KsIwvpTZoq_g-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH 06/11] nodedev: driver: Introduce internal mdevctl commands enum Date: Fri, 9 Apr 2021 16:33:01 -0500 Message-Id: <20210409213306.3971286-7-jjongsma@redhat.com> In-Reply-To: <20210409213306.3971286-1-jjongsma@redhat.com> References: <20210409213306.3971286-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Erik Skultety This is not a 1:1 mapping to mdevctl because mdevctl doesn't support a 'create' command. It uses 'start' for both starting a defined device as well as creating a transient one. To make our code more readable in that regard and not second-guess what does a specific "start" instance mean, use "create" internally instead only to translate it to "start" just before executing mdevctl. Signed-off-by: Erik Skultety Signed-off-by: Jonathon Jongsma --- src/node_device/node_device_driver.c | 7 +++++++ src/node_device/node_device_driver.h | 19 +++++++++++++++++++ tests/nodedevmdevctltest.c | 12 ++---------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index e9147ec0f9..c25558cf05 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -47,6 +47,13 @@ =20 virNodeDeviceDriverStatePtr driver; =20 + +VIR_ENUM_IMPL(virMdevctlCommand, + MDEVCTL_CMD_LAST, + "start", "stop", "define", "undefine", "create" +); + + virDrvOpenStatus nodeConnectOpen(virConnectPtr conn, virConnectAuthPtr auth G_GNUC_UNUSED, diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_de= vice_driver.h index 0e3f6dbf28..aaeed588e8 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -33,6 +33,25 @@ int udevNodeRegister(void); #endif =20 + +typedef enum { + MDEVCTL_CMD_START, + MDEVCTL_CMD_STOP, + MDEVCTL_CMD_DEFINE, + MDEVCTL_CMD_UNDEFINE, + + /* mdevctl actually doesn't have a 'create' command, it will be replac= ed + * with 'start' eventually in nodeDeviceGetMdevctlCommand, but this cl= ear + * separation makes our code more readable in terms of knowing when we= 're + * starting a defined device and when we're creating a transient one */ + MDEVCTL_CMD_CREATE, + + MDEVCTL_CMD_LAST, +} virMdevctlCommand; + +VIR_ENUM_DECL(virMdevctlCommand); + + void nodeDeviceLock(void); =20 diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 427299e171..8a37dd2e80 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -10,19 +10,11 @@ =20 #define VIR_FROM_THIS VIR_FROM_NODEDEV =20 -typedef enum { - MDEVCTL_CMD_START, - MDEVCTL_CMD_STOP, - MDEVCTL_CMD_DEFINE, - MDEVCTL_CMD_UNDEFINE, - MDEVCTL_CMD_CREATE, -} MdevctlCmd; - struct startTestInfo { const char *virt_type; int create; const char *filename; - MdevctlCmd command; + virMdevctlCommand command; }; =20 /* capture stdin passed to command */ @@ -141,7 +133,7 @@ testMdevctlCreateOrDefineHelper(const void *data) typedef virCommand* (*GetStopUndefineCmdFunc)(const char *uuid, char **err= buf); struct UuidCommandTestInfo { const char *filename; - MdevctlCmd command; + virMdevctlCommand command; }; =20 static int --=20 2.26.3