]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nodedev: driver: Introduce internal mdevctl commands enum
authorErik Skultety <eskultet@redhat.com>
Wed, 31 Mar 2021 13:20:50 +0000 (15:20 +0200)
committerJonathon Jongsma <jjongsma@redhat.com>
Mon, 19 Apr 2021 15:24:13 +0000 (10:24 -0500)
This is not a 1:1 mapping to mdevctl commands because mdevctl doesn't
support a separate 'create' command. mdevctl uses 'start' for both
starting a pre-defined device as well as for creating and starting a new
transient device. The libvirt code will be more readable if we treat
these as separate commands. When we need to actually execute mdevctl,
the 'create' command will be translated into the appropriate 'mdevctl
start' command.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
src/node_device/node_device_driver.c
src/node_device/node_device_driver.h
tests/nodedevmdevctltest.c

index 107e48c925fe8d0b833c7151962436c7ef499d8d..f83f2083de32b0abb14011b0ac7044c79c2e371f 100644 (file)
@@ -50,6 +50,13 @@ VIR_LOG_INIT("node_device.node_device_driver");
 
 virNodeDeviceDriverState *driver;
 
+
+VIR_ENUM_IMPL(virMdevctlCommand,
+              MDEVCTL_CMD_LAST,
+              "start", "stop", "define", "undefine", "create"
+);
+
+
 virDrvOpenStatus
 nodeConnectOpen(virConnectPtr conn,
                 virConnectAuthPtr auth G_GNUC_UNUSED,
index 4101e34a8fd23e153947e124100251a71dfcade4..d06efbf3540240e295803919ebdd119dffc00a0a 100644 (file)
@@ -33,6 +33,25 @@ int
 udevNodeRegister(void);
 #endif
 
+
+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 replaced
+     * with 'start' eventually in nodeDeviceGetMdevctlCommand, but this clear
+     * 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);
 
index 188e521f59345b6d6df28ba266c1d81fe7417010..cf8de852a8e9a40c4f1eba7fb778977f6fbb584b 100644 (file)
 
 #define VIR_FROM_THIS VIR_FROM_NODEDEV
 
-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;
 };
 
 /* capture stdin passed to command */
@@ -126,7 +118,7 @@ testMdevctlCreateOrDefineHelper(const void *data)
 typedef virCommand* (*GetStopUndefineCmdFunc)(const char *uuid, char **errbuf);
 struct UuidCommandTestInfo {
     const char *filename;
-    MdevctlCmd command;
+    virMdevctlCommand command;
 };
 
 static int