* arguments, so provide a common implementation that can be wrapped by a more
* specific function */
static virCommand*
-nodeDeviceGetMdevctlDefineStartCommand(virNodeDeviceDef *def,
- const char *subcommand,
- char **uuid_out,
- char **errmsg)
+nodeDeviceGetMdevctlDefineCreateCommand(virNodeDeviceDef *def,
+ const char *subcommand,
+ char **uuid_out,
+ char **errmsg)
{
virCommand *cmd;
g_autofree char *json = NULL;
}
virCommand*
-nodeDeviceGetMdevctlStartCommand(virNodeDeviceDef *def,
+nodeDeviceGetMdevctlCreateCommand(virNodeDeviceDef *def,
char **uuid_out,
char **errmsg)
{
- return nodeDeviceGetMdevctlDefineStartCommand(def, "start", uuid_out,
- errmsg);
+ return nodeDeviceGetMdevctlDefineCreateCommand(def, "start", uuid_out,
+ errmsg);
}
virCommand*
char **uuid_out,
char **errmsg)
{
- return nodeDeviceGetMdevctlDefineStartCommand(def, "define", uuid_out,
- errmsg);
+ return nodeDeviceGetMdevctlDefineCreateCommand(def, "define", uuid_out,
+ errmsg);
}
static int
-virMdevctlStart(virNodeDeviceDef *def, char **uuid, char **errmsg)
+virMdevctlCreate(virNodeDeviceDef *def, char **uuid, char **errmsg)
{
int status;
- g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlStartCommand(def, uuid,
- errmsg);
+ g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlCreateCommand(def, uuid,
+ errmsg);
if (!cmd)
return -1;
return NULL;
}
- if (virMdevctlStart(def, &uuid, &errmsg) < 0) {
+ if (virMdevctlCreate(def, &uuid, &errmsg) < 0) {
if (errmsg)
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to start mediated device '%s': %s"),
}
virCommand *
-nodeDeviceGetMdevctlCreateCommand(const char *uuid, char **errmsg)
+nodeDeviceGetMdevctlStartCommand(const char *uuid, char **errmsg)
{
virCommand *cmd = virCommandNewArgList(MDEVCTL,
"start",
static int
-virMdevctlCreate(virNodeDeviceDef *def, char **errmsg)
+virMdevctlStart(virNodeDeviceDef *def, char **errmsg)
{
int status;
g_autoptr(virCommand) cmd = NULL;
- cmd = nodeDeviceGetMdevctlCreateCommand(def->caps->data.mdev.uuid, errmsg);
+ cmd = nodeDeviceGetMdevctlStartCommand(def->caps->data.mdev.uuid, errmsg);
if (virCommandRun(cmd, &status) < 0 || status != 0)
return -1;
if (nodeDeviceHasCapability(def, VIR_NODE_DEV_CAP_MDEV)) {
g_autofree char *errmsg = NULL;
- if (virMdevctlCreate(def, &errmsg) < 0) {
+ if (virMdevctlStart(def, &errmsg) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to create mediated device: %s"),
errmsg && errmsg[0] ? errmsg : "Unknown Error");
static int
-testMdevctlStartOrDefine(const char *virt_type,
- int create,
- MdevctlCmdFunc mdevctl_cmd_func,
- const char *mdevxml,
- const char *cmdfile,
- const char *jsonfile)
+testMdevctlCreateOrDefine(const char *virt_type,
+ int create,
+ MdevctlCmdFunc mdevctl_cmd_func,
+ const char *mdevxml,
+ const char *cmdfile,
+ const char *jsonfile)
{
g_autoptr(virNodeDeviceDef) def = NULL;
virNodeDeviceObj *obj = NULL;
}
static int
-testMdevctlStartOrDefineHelper(const void *data)
+testMdevctlCreateOrDefineHelper(const void *data)
{
const struct startTestInfo *info = data;
const char *cmd;
g_autofree char *cmdlinefile = NULL;
g_autofree char *jsonfile = NULL;
- if (info->command == MDEVCTL_CMD_START) {
- cmd = "start";
- func = nodeDeviceGetMdevctlStartCommand;
+ if (info->command == MDEVCTL_CMD_CREATE) {
+ cmd = "create";
+ func = nodeDeviceGetMdevctlCreateCommand;
} else if (info->command == MDEVCTL_CMD_DEFINE) {
cmd = "define";
func = nodeDeviceGetMdevctlDefineCommand;
jsonfile = g_strdup_printf("%s/nodedevmdevctldata/%s-%s.json", abs_srcdir,
info->filename, cmd);
- return testMdevctlStartOrDefine(info->virt_type, info->create, func,
- mdevxml, cmdlinefile, jsonfile);
+ return testMdevctlCreateOrDefine(info->virt_type, info->create, func,
+ mdevxml, cmdlinefile, jsonfile);
}
typedef virCommand* (*GetStopUndefineCmdFunc)(const char *uuid, char **errbuf);
} else if (info->command == MDEVCTL_CMD_UNDEFINE) {
cmd = "undefine";
func = nodeDeviceGetMdevctlUndefineCommand;
- }else if (info->command == MDEVCTL_CMD_CREATE) {
- cmd = "create";
- func = nodeDeviceGetMdevctlCreateCommand;
+ }else if (info->command == MDEVCTL_CMD_START) {
+ cmd = "start";
+ func = nodeDeviceGetMdevctlStartCommand;
} else {
return -1;
}
#define DO_TEST_CMD(desc, virt_type, create, filename, command) \
do { \
struct startTestInfo info = { virt_type, create, filename, command }; \
- DO_TEST_FULL(desc, testMdevctlStartOrDefineHelper, &info); \
+ DO_TEST_FULL(desc, testMdevctlCreateOrDefineHelper, &info); \
} \
while (0)
-#define DO_TEST_START(filename) \
- DO_TEST_CMD("mdevctl start " filename, "QEMU", CREATE_DEVICE, filename, MDEVCTL_CMD_START)
+#define DO_TEST_CREATE(filename) \
+ DO_TEST_CMD("mdevctl create " filename, "QEMU", CREATE_DEVICE, filename, MDEVCTL_CMD_CREATE)
#define DO_TEST_DEFINE(filename) \
DO_TEST_CMD("mdevctl define " filename, "QEMU", CREATE_DEVICE, filename, MDEVCTL_CMD_DEFINE)
#define DO_TEST_UNDEFINE(filename) \
DO_TEST_UUID_COMMAND_FULL("mdevctl undefine " filename, filename, MDEVCTL_CMD_UNDEFINE)
-#define DO_TEST_CREATE(filename) \
- DO_TEST_UUID_COMMAND_FULL("mdevctl create " filename, filename, MDEVCTL_CMD_CREATE)
+#define DO_TEST_START(filename) \
+ DO_TEST_UUID_COMMAND_FULL("mdevctl start " filename, filename, MDEVCTL_CMD_START)
#define DO_TEST_LIST_DEFINED() \
DO_TEST_FULL("mdevctl list --defined", testMdevctlListDefined, NULL)
#define DO_TEST_PARSE_JSON(filename) \
DO_TEST_FULL("parse mdevctl json " filename, testMdevctlParse, filename)
- /* Test mdevctl start commands */
- DO_TEST_START("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366");
- DO_TEST_START("mdev_fedc4916_1ca8_49ac_b176_871d16c13076");
- DO_TEST_START("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9");
+ DO_TEST_CREATE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366");
+ DO_TEST_CREATE("mdev_fedc4916_1ca8_49ac_b176_871d16c13076");
+ DO_TEST_CREATE("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9");
/* Test mdevctl stop command, pass an arbitrary uuid */
DO_TEST_STOP("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366");
DO_TEST_UNDEFINE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366");
- DO_TEST_CREATE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366");
+ DO_TEST_START("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366");
done:
nodedevTestDriverFree(driver);