diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 107e48c925..f83f2083de 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -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, diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_device_driver.h index 4101e34a8f..d06efbf354 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 + +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); diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 188e521f59..cf8de852a8 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -10,19 +10,11 @@ #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