mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +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,
|
||||
virMdevctlCommand cmd_type,
|
||||
char **outbuf,
|
||||
@ -790,30 +790,15 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def,
|
||||
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
|
||||
virMdevctlCreate(virNodeDeviceDef *def, char **uuid, char **errmsg)
|
||||
{
|
||||
int status;
|
||||
g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlCreateCommand(def, uuid,
|
||||
errmsg);
|
||||
g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlCommand(def,
|
||||
MDEVCTL_CMD_CREATE,
|
||||
uuid,
|
||||
errmsg);
|
||||
if (!cmd)
|
||||
return -1;
|
||||
|
||||
@ -833,7 +818,9 @@ static int
|
||||
virMdevctlDefine(virNodeDeviceDef *def, char **uuid, char **errmsg)
|
||||
{
|
||||
int status;
|
||||
g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlDefineCommand(def, uuid, errmsg);
|
||||
g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlCommand(def,
|
||||
MDEVCTL_CMD_DEFINE,
|
||||
uuid, errmsg);
|
||||
|
||||
if (!cmd)
|
||||
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
|
||||
virMdevctlStop(virNodeDeviceDef *def, char **errmsg)
|
||||
{
|
||||
int status;
|
||||
g_autoptr(virCommand) cmd = NULL;
|
||||
|
||||
cmd = nodeDeviceGetMdevctlStopCommand(def, errmsg);
|
||||
cmd = nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_STOP, NULL, errmsg);
|
||||
|
||||
if (virCommandRun(cmd, &status) < 0 || status != 0)
|
||||
return -1;
|
||||
@ -978,7 +944,7 @@ virMdevctlUndefine(virNodeDeviceDef *def, char **errmsg)
|
||||
int status;
|
||||
g_autoptr(virCommand) cmd = NULL;
|
||||
|
||||
cmd = nodeDeviceGetMdevctlUndefineCommand(def, errmsg);
|
||||
cmd = nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_UNDEFINE, NULL, errmsg);
|
||||
|
||||
if (virCommandRun(cmd, &status) < 0 || status != 0)
|
||||
return -1;
|
||||
@ -993,7 +959,7 @@ virMdevctlStart(virNodeDeviceDef *def, char **errmsg)
|
||||
int status;
|
||||
g_autoptr(virCommand) cmd = NULL;
|
||||
|
||||
cmd = nodeDeviceGetMdevctlStartCommand(def, errmsg);
|
||||
cmd = nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_START, NULL, errmsg);
|
||||
|
||||
if (virCommandRun(cmd, &status) < 0 || status != 0)
|
||||
return -1;
|
||||
|
@ -142,22 +142,10 @@ nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn,
|
||||
int callbackID);
|
||||
|
||||
virCommand *
|
||||
nodeDeviceGetMdevctlCreateCommand(virNodeDeviceDef *def,
|
||||
char **uuid_out,
|
||||
char **errmsg);
|
||||
|
||||
virCommand*
|
||||
nodeDeviceGetMdevctlDefineCommand(virNodeDeviceDef *def,
|
||||
char **uuid_out,
|
||||
char **errmsg);
|
||||
|
||||
virCommand *
|
||||
nodeDeviceGetMdevctlStopCommand(virNodeDeviceDef *def,
|
||||
char **errmsg);
|
||||
|
||||
virCommand *
|
||||
nodeDeviceGetMdevctlUndefineCommand(virNodeDeviceDef *def,
|
||||
char **errmsg);
|
||||
nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def,
|
||||
virMdevctlCommand cmd_type,
|
||||
char **outbuf,
|
||||
char **errbuf);
|
||||
|
||||
virCommand *
|
||||
nodeDeviceGetMdevctlListCommand(bool defined,
|
||||
@ -180,10 +168,6 @@ nodeDeviceGenerateName(virNodeDeviceDef *def,
|
||||
bool nodeDeviceDefCopyFromMdevctl(virNodeDeviceDef *dst,
|
||||
virNodeDeviceDef *src);
|
||||
|
||||
virCommand*
|
||||
nodeDeviceGetMdevctlStartCommand(virNodeDeviceDef *def,
|
||||
char **errmsg);
|
||||
|
||||
int
|
||||
nodeDeviceCreate(virNodeDevice *dev,
|
||||
unsigned int flags);
|
||||
|
@ -38,7 +38,7 @@ typedef virCommand* (*MdevctlCmdFunc)(virNodeDeviceDef *, char **, char **);
|
||||
static int
|
||||
testMdevctlCreateOrDefine(const char *virt_type,
|
||||
int create,
|
||||
MdevctlCmdFunc mdevctl_cmd_func,
|
||||
virMdevctlCommand cmd_type,
|
||||
const char *mdevxml,
|
||||
const char *cmdfile,
|
||||
const char *jsonfile)
|
||||
@ -59,7 +59,7 @@ testMdevctlCreateOrDefine(const char *virt_type,
|
||||
|
||||
/* this function will set a stdin buffer containing the json configuration
|
||||
* 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)
|
||||
goto cleanup;
|
||||
@ -88,22 +88,11 @@ static int
|
||||
testMdevctlCreateOrDefineHelper(const void *data)
|
||||
{
|
||||
const struct startTestInfo *info = data;
|
||||
const char *cmd;
|
||||
MdevctlCmdFunc func;
|
||||
const char *cmd = virMdevctlCommandTypeToString(info->command);
|
||||
g_autofree char *mdevxml = NULL;
|
||||
g_autofree char *cmdlinefile = 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,
|
||||
info->filename);
|
||||
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,
|
||||
info->filename, cmd);
|
||||
|
||||
return testMdevctlCreateOrDefine(info->virt_type, info->create, func,
|
||||
return testMdevctlCreateOrDefine(info->virt_type, info->create, info->command,
|
||||
mdevxml, cmdlinefile, jsonfile);
|
||||
}
|
||||
|
||||
@ -122,7 +111,7 @@ struct UuidCommandTestInfo {
|
||||
};
|
||||
|
||||
static int
|
||||
testMdevctlUuidCommand(GetStopUndefineCmdFunc func,
|
||||
testMdevctlUuidCommand(virMdevctlCommand command,
|
||||
const char *mdevxml, const char *outfile)
|
||||
{
|
||||
g_autoptr(virNodeDeviceDef) def = NULL;
|
||||
@ -136,7 +125,7 @@ testMdevctlUuidCommand(GetStopUndefineCmdFunc func,
|
||||
if (!(def = virNodeDeviceDefParseFile(mdevxml, EXISTING_DEVICE, "QEMU")))
|
||||
goto cleanup;
|
||||
|
||||
cmd = func(def, &errmsg);
|
||||
cmd = nodeDeviceGetMdevctlCommand(def, command, NULL, &errmsg);
|
||||
|
||||
if (!cmd)
|
||||
goto cleanup;
|
||||
@ -161,30 +150,16 @@ static int
|
||||
testMdevctlUuidCommandHelper(const void *data)
|
||||
{
|
||||
const struct UuidCommandTestInfo *info = data;
|
||||
GetStopUndefineCmdFunc func;
|
||||
const char *cmd;
|
||||
const char *cmd = virMdevctlCommandTypeToString(info->command);
|
||||
g_autofree char *cmdlinefile = 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,
|
||||
info->filename);
|
||||
cmdlinefile = g_strdup_printf("%s/nodedevmdevctldata/mdevctl-%s.argv",
|
||||
abs_srcdir, cmd);
|
||||
|
||||
return testMdevctlUuidCommand(func, mdevxml, cmdlinefile);
|
||||
return testMdevctlUuidCommand(info->command, mdevxml, cmdlinefile);
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user