mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-06 09:55:46 +00:00
nodedev: Remove GetMdevctl*Command() wrappers
These per-command generator functions were only exposed in the header to allow the commandline generation to be tested. Now that we have a generic mdevctl command generator, we can get rid of the per-command wrappers and reduce the noise in the header. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
87b31fe8a2
commit
073862febe
@ -717,7 +717,7 @@ nodeDeviceFindAddressByName(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static virCommand *
|
virCommand *
|
||||||
nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def,
|
nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def,
|
||||||
virMdevctlCommand cmd_type,
|
virMdevctlCommand cmd_type,
|
||||||
char **outbuf,
|
char **outbuf,
|
||||||
@ -790,30 +790,15 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def,
|
|||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
virCommand*
|
|
||||||
nodeDeviceGetMdevctlCreateCommand(virNodeDeviceDef *def,
|
|
||||||
char **uuid_out,
|
|
||||||
char **errmsg)
|
|
||||||
{
|
|
||||||
return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_CREATE, uuid_out, errmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
virCommand*
|
|
||||||
nodeDeviceGetMdevctlDefineCommand(virNodeDeviceDef *def,
|
|
||||||
char **uuid_out,
|
|
||||||
char **errmsg)
|
|
||||||
{
|
|
||||||
return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_DEFINE, uuid_out, errmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virMdevctlCreate(virNodeDeviceDef *def, char **uuid, char **errmsg)
|
virMdevctlCreate(virNodeDeviceDef *def, char **uuid, char **errmsg)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlCreateCommand(def, uuid,
|
g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlCommand(def,
|
||||||
errmsg);
|
MDEVCTL_CMD_CREATE,
|
||||||
|
uuid,
|
||||||
|
errmsg);
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -833,7 +818,9 @@ static int
|
|||||||
virMdevctlDefine(virNodeDeviceDef *def, char **uuid, char **errmsg)
|
virMdevctlDefine(virNodeDeviceDef *def, char **uuid, char **errmsg)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlDefineCommand(def, uuid, errmsg);
|
g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlCommand(def,
|
||||||
|
MDEVCTL_CMD_DEFINE,
|
||||||
|
uuid, errmsg);
|
||||||
|
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
return -1;
|
return -1;
|
||||||
@ -936,34 +923,13 @@ nodeDeviceCreateXML(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virCommand *
|
|
||||||
nodeDeviceGetMdevctlStopCommand(virNodeDeviceDef *def,
|
|
||||||
char **errmsg)
|
|
||||||
{
|
|
||||||
return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_STOP, NULL, errmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
virCommand *
|
|
||||||
nodeDeviceGetMdevctlUndefineCommand(virNodeDeviceDef *def,
|
|
||||||
char **errmsg)
|
|
||||||
{
|
|
||||||
return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_UNDEFINE, NULL, errmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
virCommand *
|
|
||||||
nodeDeviceGetMdevctlStartCommand(virNodeDeviceDef *def,
|
|
||||||
char **errmsg)
|
|
||||||
{
|
|
||||||
return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_START, NULL, errmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virMdevctlStop(virNodeDeviceDef *def, char **errmsg)
|
virMdevctlStop(virNodeDeviceDef *def, char **errmsg)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
g_autoptr(virCommand) cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
|
|
||||||
cmd = nodeDeviceGetMdevctlStopCommand(def, errmsg);
|
cmd = nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_STOP, NULL, errmsg);
|
||||||
|
|
||||||
if (virCommandRun(cmd, &status) < 0 || status != 0)
|
if (virCommandRun(cmd, &status) < 0 || status != 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -978,7 +944,7 @@ virMdevctlUndefine(virNodeDeviceDef *def, char **errmsg)
|
|||||||
int status;
|
int status;
|
||||||
g_autoptr(virCommand) cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
|
|
||||||
cmd = nodeDeviceGetMdevctlUndefineCommand(def, errmsg);
|
cmd = nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_UNDEFINE, NULL, errmsg);
|
||||||
|
|
||||||
if (virCommandRun(cmd, &status) < 0 || status != 0)
|
if (virCommandRun(cmd, &status) < 0 || status != 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -993,7 +959,7 @@ virMdevctlStart(virNodeDeviceDef *def, char **errmsg)
|
|||||||
int status;
|
int status;
|
||||||
g_autoptr(virCommand) cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
|
|
||||||
cmd = nodeDeviceGetMdevctlStartCommand(def, errmsg);
|
cmd = nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_START, NULL, errmsg);
|
||||||
|
|
||||||
if (virCommandRun(cmd, &status) < 0 || status != 0)
|
if (virCommandRun(cmd, &status) < 0 || status != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -142,22 +142,10 @@ nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn,
|
|||||||
int callbackID);
|
int callbackID);
|
||||||
|
|
||||||
virCommand *
|
virCommand *
|
||||||
nodeDeviceGetMdevctlCreateCommand(virNodeDeviceDef *def,
|
nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def,
|
||||||
char **uuid_out,
|
virMdevctlCommand cmd_type,
|
||||||
char **errmsg);
|
char **outbuf,
|
||||||
|
char **errbuf);
|
||||||
virCommand*
|
|
||||||
nodeDeviceGetMdevctlDefineCommand(virNodeDeviceDef *def,
|
|
||||||
char **uuid_out,
|
|
||||||
char **errmsg);
|
|
||||||
|
|
||||||
virCommand *
|
|
||||||
nodeDeviceGetMdevctlStopCommand(virNodeDeviceDef *def,
|
|
||||||
char **errmsg);
|
|
||||||
|
|
||||||
virCommand *
|
|
||||||
nodeDeviceGetMdevctlUndefineCommand(virNodeDeviceDef *def,
|
|
||||||
char **errmsg);
|
|
||||||
|
|
||||||
virCommand *
|
virCommand *
|
||||||
nodeDeviceGetMdevctlListCommand(bool defined,
|
nodeDeviceGetMdevctlListCommand(bool defined,
|
||||||
@ -180,10 +168,6 @@ nodeDeviceGenerateName(virNodeDeviceDef *def,
|
|||||||
bool nodeDeviceDefCopyFromMdevctl(virNodeDeviceDef *dst,
|
bool nodeDeviceDefCopyFromMdevctl(virNodeDeviceDef *dst,
|
||||||
virNodeDeviceDef *src);
|
virNodeDeviceDef *src);
|
||||||
|
|
||||||
virCommand*
|
|
||||||
nodeDeviceGetMdevctlStartCommand(virNodeDeviceDef *def,
|
|
||||||
char **errmsg);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
nodeDeviceCreate(virNodeDevice *dev,
|
nodeDeviceCreate(virNodeDevice *dev,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
@ -38,7 +38,7 @@ typedef virCommand* (*MdevctlCmdFunc)(virNodeDeviceDef *, char **, char **);
|
|||||||
static int
|
static int
|
||||||
testMdevctlCreateOrDefine(const char *virt_type,
|
testMdevctlCreateOrDefine(const char *virt_type,
|
||||||
int create,
|
int create,
|
||||||
MdevctlCmdFunc mdevctl_cmd_func,
|
virMdevctlCommand cmd_type,
|
||||||
const char *mdevxml,
|
const char *mdevxml,
|
||||||
const char *cmdfile,
|
const char *cmdfile,
|
||||||
const char *jsonfile)
|
const char *jsonfile)
|
||||||
@ -59,7 +59,7 @@ testMdevctlCreateOrDefine(const char *virt_type,
|
|||||||
|
|
||||||
/* this function will set a stdin buffer containing the json configuration
|
/* this function will set a stdin buffer containing the json configuration
|
||||||
* of the device. The json value is captured in the callback above */
|
* of the device. The json value is captured in the callback above */
|
||||||
cmd = mdevctl_cmd_func(def, &uuid, &errmsg);
|
cmd = nodeDeviceGetMdevctlCommand(def, cmd_type, &uuid, &errmsg);
|
||||||
|
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -88,22 +88,11 @@ static int
|
|||||||
testMdevctlCreateOrDefineHelper(const void *data)
|
testMdevctlCreateOrDefineHelper(const void *data)
|
||||||
{
|
{
|
||||||
const struct startTestInfo *info = data;
|
const struct startTestInfo *info = data;
|
||||||
const char *cmd;
|
const char *cmd = virMdevctlCommandTypeToString(info->command);
|
||||||
MdevctlCmdFunc func;
|
|
||||||
g_autofree char *mdevxml = NULL;
|
g_autofree char *mdevxml = NULL;
|
||||||
g_autofree char *cmdlinefile = NULL;
|
g_autofree char *cmdlinefile = NULL;
|
||||||
g_autofree char *jsonfile = NULL;
|
g_autofree char *jsonfile = NULL;
|
||||||
|
|
||||||
if (info->command == MDEVCTL_CMD_CREATE) {
|
|
||||||
cmd = "create";
|
|
||||||
func = nodeDeviceGetMdevctlCreateCommand;
|
|
||||||
} else if (info->command == MDEVCTL_CMD_DEFINE) {
|
|
||||||
cmd = "define";
|
|
||||||
func = nodeDeviceGetMdevctlDefineCommand;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
mdevxml = g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir,
|
mdevxml = g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir,
|
||||||
info->filename);
|
info->filename);
|
||||||
cmdlinefile = g_strdup_printf("%s/nodedevmdevctldata/%s-%s.argv",
|
cmdlinefile = g_strdup_printf("%s/nodedevmdevctldata/%s-%s.argv",
|
||||||
@ -111,7 +100,7 @@ testMdevctlCreateOrDefineHelper(const void *data)
|
|||||||
jsonfile = g_strdup_printf("%s/nodedevmdevctldata/%s-%s.json", abs_srcdir,
|
jsonfile = g_strdup_printf("%s/nodedevmdevctldata/%s-%s.json", abs_srcdir,
|
||||||
info->filename, cmd);
|
info->filename, cmd);
|
||||||
|
|
||||||
return testMdevctlCreateOrDefine(info->virt_type, info->create, func,
|
return testMdevctlCreateOrDefine(info->virt_type, info->create, info->command,
|
||||||
mdevxml, cmdlinefile, jsonfile);
|
mdevxml, cmdlinefile, jsonfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +111,7 @@ struct UuidCommandTestInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
testMdevctlUuidCommand(GetStopUndefineCmdFunc func,
|
testMdevctlUuidCommand(virMdevctlCommand command,
|
||||||
const char *mdevxml, const char *outfile)
|
const char *mdevxml, const char *outfile)
|
||||||
{
|
{
|
||||||
g_autoptr(virNodeDeviceDef) def = NULL;
|
g_autoptr(virNodeDeviceDef) def = NULL;
|
||||||
@ -136,7 +125,7 @@ testMdevctlUuidCommand(GetStopUndefineCmdFunc func,
|
|||||||
if (!(def = virNodeDeviceDefParseFile(mdevxml, EXISTING_DEVICE, "QEMU")))
|
if (!(def = virNodeDeviceDefParseFile(mdevxml, EXISTING_DEVICE, "QEMU")))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
cmd = func(def, &errmsg);
|
cmd = nodeDeviceGetMdevctlCommand(def, command, NULL, &errmsg);
|
||||||
|
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -161,30 +150,16 @@ static int
|
|||||||
testMdevctlUuidCommandHelper(const void *data)
|
testMdevctlUuidCommandHelper(const void *data)
|
||||||
{
|
{
|
||||||
const struct UuidCommandTestInfo *info = data;
|
const struct UuidCommandTestInfo *info = data;
|
||||||
GetStopUndefineCmdFunc func;
|
const char *cmd = virMdevctlCommandTypeToString(info->command);
|
||||||
const char *cmd;
|
|
||||||
g_autofree char *cmdlinefile = NULL;
|
g_autofree char *cmdlinefile = NULL;
|
||||||
g_autofree char *mdevxml = NULL;
|
g_autofree char *mdevxml = NULL;
|
||||||
|
|
||||||
if (info->command == MDEVCTL_CMD_STOP) {
|
|
||||||
cmd = "stop";
|
|
||||||
func = nodeDeviceGetMdevctlStopCommand;
|
|
||||||
} else if (info->command == MDEVCTL_CMD_UNDEFINE) {
|
|
||||||
cmd = "undefine";
|
|
||||||
func = nodeDeviceGetMdevctlUndefineCommand;
|
|
||||||
}else if (info->command == MDEVCTL_CMD_START) {
|
|
||||||
cmd = "start";
|
|
||||||
func = nodeDeviceGetMdevctlStartCommand;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
mdevxml = g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir,
|
mdevxml = g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir,
|
||||||
info->filename);
|
info->filename);
|
||||||
cmdlinefile = g_strdup_printf("%s/nodedevmdevctldata/mdevctl-%s.argv",
|
cmdlinefile = g_strdup_printf("%s/nodedevmdevctldata/mdevctl-%s.argv",
|
||||||
abs_srcdir, cmd);
|
abs_srcdir, cmd);
|
||||||
|
|
||||||
return testMdevctlUuidCommand(func, mdevxml, cmdlinefile);
|
return testMdevctlUuidCommand(info->command, mdevxml, cmdlinefile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user