nodedev: driver: Create a generic mdevctl command translator

Currently there are dedicated wrappers to construct mdevctl command.
These are mostly fine except for the one that translates both "start"
and "define" commands, only because mdevctl takes the same set of
arguments. Instead, keep the wrappers, but let them call a single
global translator that handles all the mdevctl command differences and
commonalities.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
Erik Skultety
2021-03-31 15:24:47 +02:00
committed by Jonathon Jongsma
parent 92fdc1f0cb
commit 87b31fe8a2
3 changed files with 79 additions and 56 deletions

View File

@@ -115,7 +115,7 @@ testMdevctlCreateOrDefineHelper(const void *data)
mdevxml, cmdlinefile, jsonfile);
}
typedef virCommand* (*GetStopUndefineCmdFunc)(const char *uuid, char **errbuf);
typedef virCommand* (*GetStopUndefineCmdFunc)(virNodeDeviceDef *def, char **errbuf);
struct UuidCommandTestInfo {
const char *filename;
virMdevctlCommand command;
@@ -136,7 +136,7 @@ testMdevctlUuidCommand(GetStopUndefineCmdFunc func,
if (!(def = virNodeDeviceDefParseFile(mdevxml, EXISTING_DEVICE, "QEMU")))
goto cleanup;
cmd = func(def->caps->data.mdev.uuid, &errmsg);
cmd = func(def, &errmsg);
if (!cmd)
goto cleanup;