mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the schema through, which meant that we were not validating any of those tests for correct usage according to the schema. In the process of mechanically altering tests to pass the schema through, use VIR_AUTOPTR on all of the affected test instances. The next patch will do some further cleanups that it exposes. Tested by using this hack, where the test mistakenly passed pre-patch, but correctly diagnosed the garbage post-patch: | diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c | index 53a7de8b77..86d8450814 100644 | --- i/src/qemu/qemu_monitor_json.c | +++ w/src/qemu/qemu_monitor_json.c | @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon, | if (reason) | *reason = VIR_DOMAIN_PAUSED_UNKNOWN; | | - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL))) | + if (!(cmd = qemuMonitorJSONMakeCommand("query-status", | + "s:garbage", "foo", NULL))) | return -1; | | if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) Suggested-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com> Acked-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
09083437ff
commit
4b658bfe4b
@ -48,6 +48,12 @@ struct _testQemuMonitorJSONSimpleFuncData {
|
||||
virHashTablePtr schema;
|
||||
};
|
||||
|
||||
typedef struct _testGenericData testGenericData;
|
||||
struct _testGenericData {
|
||||
virDomainXMLOptionPtr xmlopt;
|
||||
virHashTablePtr schema;
|
||||
};
|
||||
|
||||
const char *queryBlockReply =
|
||||
"{"
|
||||
" \"return\": ["
|
||||
@ -142,15 +148,16 @@ const char *queryBlockReply =
|
||||
"}";
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONGetStatus(const void *data)
|
||||
testQemuMonitorJSONGetStatus(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
bool running = false;
|
||||
virDomainPausedReason reason = 0;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-status",
|
||||
@ -231,22 +238,22 @@ testQemuMonitorJSONGetStatus(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONGetVersion(const void *data)
|
||||
testQemuMonitorJSONGetVersion(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
int major;
|
||||
int minor;
|
||||
int micro;
|
||||
char *package = NULL;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-version",
|
||||
@ -333,23 +340,24 @@ testQemuMonitorJSONGetVersion(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
VIR_FREE(package);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONGetMachines(const void *data)
|
||||
testQemuMonitorJSONGetMachines(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
qemuMonitorMachineInfoPtr *info;
|
||||
int ninfo = 0;
|
||||
const char *null = NULL;
|
||||
size_t i;
|
||||
|
||||
if (!test)
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-machines",
|
||||
@ -411,7 +419,6 @@ testQemuMonitorJSONGetMachines(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
for (i = 0; i < ninfo; i++)
|
||||
qemuMonitorMachineInfoFree(info[i]);
|
||||
VIR_FREE(info);
|
||||
@ -421,16 +428,17 @@ testQemuMonitorJSONGetMachines(const void *data)
|
||||
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONGetCPUDefinitions(const void *data)
|
||||
testQemuMonitorJSONGetCPUDefinitions(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
qemuMonitorCPUDefInfoPtr *cpus = NULL;
|
||||
int ncpus = 0;
|
||||
size_t i;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-cpu-definitions",
|
||||
@ -495,7 +503,6 @@ testQemuMonitorJSONGetCPUDefinitions(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
for (i = 0; i < ncpus; i++)
|
||||
qemuMonitorCPUDefInfoFree(cpus[i]);
|
||||
VIR_FREE(cpus);
|
||||
@ -504,16 +511,17 @@ testQemuMonitorJSONGetCPUDefinitions(const void *data)
|
||||
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONGetCommands(const void *data)
|
||||
testQemuMonitorJSONGetCommands(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
char **commands = NULL;
|
||||
int ncommands = 0;
|
||||
size_t i;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-commands",
|
||||
@ -560,7 +568,6 @@ testQemuMonitorJSONGetCommands(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
for (i = 0; i < ncommands; i++)
|
||||
VIR_FREE(commands[i]);
|
||||
VIR_FREE(commands);
|
||||
@ -569,15 +576,16 @@ testQemuMonitorJSONGetCommands(const void *data)
|
||||
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONGetTPMModels(const void *data)
|
||||
testQemuMonitorJSONGetTPMModels(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
char **tpmmodels = NULL;
|
||||
int ntpmmodels = 0;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-tpm-models",
|
||||
@ -615,23 +623,23 @@ testQemuMonitorJSONGetTPMModels(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
virStringListFree(tpmmodels);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
|
||||
testQemuMonitorJSONGetCommandLineOptionParameters(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
char **params = NULL;
|
||||
int nparams = 0;
|
||||
bool found = false;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-command-line-options",
|
||||
@ -731,7 +739,6 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
virStringListFree(params);
|
||||
return ret;
|
||||
}
|
||||
@ -776,6 +783,7 @@ testQemuMonitorJSONAttachChardev(const void *opaque)
|
||||
|
||||
static int
|
||||
qemuMonitorJSONTestAttachOneChardev(virDomainXMLOptionPtr xmlopt,
|
||||
virHashTablePtr schema,
|
||||
const char *label,
|
||||
virDomainChrSourceDefPtr chr,
|
||||
const char *expectargs,
|
||||
@ -801,7 +809,7 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOptionPtr xmlopt,
|
||||
data.chr = chr;
|
||||
data.fail = fail;
|
||||
data.expectPty = expectPty;
|
||||
if (!(data.test = qemuMonitorTestNewSimple(true, xmlopt)))
|
||||
if (!(data.test = qemuMonitorTestNewSchema(xmlopt, schema)))
|
||||
goto cleanup;
|
||||
|
||||
if (qemuMonitorTestAddItemExpect(data.test, "chardev-add",
|
||||
@ -821,14 +829,15 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOptionPtr xmlopt,
|
||||
}
|
||||
|
||||
static int
|
||||
qemuMonitorJSONTestAttachChardev(virDomainXMLOptionPtr xmlopt)
|
||||
qemuMonitorJSONTestAttachChardev(virDomainXMLOptionPtr xmlopt,
|
||||
virHashTablePtr schema)
|
||||
{
|
||||
virDomainChrSourceDef chr;
|
||||
int ret = 0;
|
||||
|
||||
#define CHECK(label, fail, expectargs) \
|
||||
if (qemuMonitorJSONTestAttachOneChardev(xmlopt, label, &chr, expectargs, \
|
||||
NULL, NULL, fail) < 0) \
|
||||
if (qemuMonitorJSONTestAttachOneChardev(xmlopt, schema, label, &chr, \
|
||||
expectargs, NULL, NULL, fail) < 0) \
|
||||
ret = -1
|
||||
|
||||
chr = (virDomainChrSourceDef) { .type = VIR_DOMAIN_CHR_TYPE_NULL };
|
||||
@ -840,7 +849,7 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOptionPtr xmlopt)
|
||||
"{'id':'alias','backend':{'type':'null','data':{}}}");
|
||||
|
||||
chr = (virDomainChrSourceDef) { .type = VIR_DOMAIN_CHR_TYPE_PTY };
|
||||
if (qemuMonitorJSONTestAttachOneChardev(xmlopt, "pty", &chr,
|
||||
if (qemuMonitorJSONTestAttachOneChardev(xmlopt, schema, "pty", &chr,
|
||||
"{'id':'alias',"
|
||||
"'backend':{'type':'pty',"
|
||||
"'data':{}}}",
|
||||
@ -938,13 +947,14 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOptionPtr xmlopt)
|
||||
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONDetachChardev(const void *data)
|
||||
testQemuMonitorJSONDetachChardev(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return ret;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "chardev-remove", "{\"return\": {}}") < 0)
|
||||
@ -957,7 +967,6 @@ testQemuMonitorJSONDetachChardev(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -971,16 +980,17 @@ testQemuMonitorJSONDetachChardev(const void *data)
|
||||
* {"name": "type", "type": "string"}]}
|
||||
*/
|
||||
static int
|
||||
testQemuMonitorJSONGetListPaths(const void *data)
|
||||
testQemuMonitorJSONGetListPaths(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
qemuMonitorJSONListPathPtr *paths;
|
||||
int npaths = 0;
|
||||
size_t i;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "qom-list",
|
||||
@ -1030,7 +1040,6 @@ testQemuMonitorJSONGetListPaths(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
for (i = 0; i < npaths; i++)
|
||||
qemuMonitorJSONListPathFree(paths[i]);
|
||||
VIR_FREE(paths);
|
||||
@ -1049,14 +1058,15 @@ testQemuMonitorJSONGetListPaths(const void *data)
|
||||
* {"return": true}
|
||||
*/
|
||||
static int
|
||||
testQemuMonitorJSONGetObjectProperty(const void *data)
|
||||
testQemuMonitorJSONGetObjectProperty(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
qemuMonitorJSONObjectProperty prop;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "qom-get",
|
||||
@ -1080,7 +1090,6 @@ testQemuMonitorJSONGetObjectProperty(const void *data)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1092,14 +1101,15 @@ testQemuMonitorJSONGetObjectProperty(const void *data)
|
||||
* false is not a good idea...
|
||||
*/
|
||||
static int
|
||||
testQemuMonitorJSONSetObjectProperty(const void *data)
|
||||
testQemuMonitorJSONSetObjectProperty(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
qemuMonitorJSONObjectProperty prop;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "qom-set",
|
||||
@ -1138,23 +1148,23 @@ testQemuMonitorJSONSetObjectProperty(const void *data)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONGetDeviceAliases(const void *data)
|
||||
testQemuMonitorJSONGetDeviceAliases(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
char **aliases = NULL;
|
||||
const char **alias;
|
||||
const char *expected[] = {
|
||||
"virtio-disk25", "video0", "serial0", "ide0-0-0", "usb", NULL };
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test,
|
||||
@ -1199,20 +1209,20 @@ testQemuMonitorJSONGetDeviceAliases(const void *data)
|
||||
|
||||
cleanup:
|
||||
virStringListFree(aliases);
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONCPU(const void *data)
|
||||
testQemuMonitorJSONCPU(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
bool running = false;
|
||||
virDomainPausedReason reason = 0;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "stop", "{\"return\": {}}") < 0 ||
|
||||
@ -1258,7 +1268,6 @@ testQemuMonitorJSONCPU(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1399,10 +1408,10 @@ testQEMUMonitorJSONqemuMonitorJSONQueryCPUsHelper(qemuMonitorTestPtr test,
|
||||
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
struct qemuMonitorQueryCpusEntry expect_slow[] = {
|
||||
{0, 17622, (char *) "/machine/unattached/device[0]", true},
|
||||
@ -1414,8 +1423,9 @@ testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const void *data)
|
||||
{0, 17629, (char *) "/machine/unattached/device[0]", false},
|
||||
{1, 17630, (char *) "/machine/unattached/device[1]", false},
|
||||
};
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-cpus",
|
||||
@ -1488,19 +1498,19 @@ testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONGetBalloonInfo(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONGetBalloonInfo(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
unsigned long long currmem;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-balloon",
|
||||
@ -1524,19 +1534,19 @@ testQemuMonitorJSONqemuMonitorJSONGetBalloonInfo(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONGetVirtType(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONGetVirtType(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
virDomainVirtType virtType;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-kvm",
|
||||
@ -1576,7 +1586,6 @@ testQemuMonitorJSONqemuMonitorJSONGetVirtType(const void *data)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1606,15 +1615,16 @@ testHashEqualQemuDomainDiskInfo(const void *value1, const void *value2)
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONGetBlockInfo(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONGetBlockInfo(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
virHashTablePtr blockDevices = NULL, expectedBlockDevices = NULL;
|
||||
struct qemuDomainDiskInfo *info;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (!(blockDevices = virHashCreate(32, virHashValueFree)) ||
|
||||
@ -1680,18 +1690,18 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockInfo(const void *data)
|
||||
cleanup:
|
||||
virHashFree(blockDevices);
|
||||
virHashFree(expectedBlockDevices);
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInfo(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInfo(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
virHashTablePtr blockstats = NULL;
|
||||
qemuBlockStatsPtr stats;
|
||||
int ret = -1;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
const char *reply =
|
||||
"{"
|
||||
@ -1780,7 +1790,7 @@ testQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInfo(const void *data)
|
||||
" \"id\": \"libvirt-11\""
|
||||
"}";
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (!(blockstats = virHashCreate(10, virHashValueFree)))
|
||||
@ -1840,21 +1850,21 @@ testQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInfo(const void *data)
|
||||
#undef CHECK0FULL
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
virHashFree(blockstats);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONGetMigrationCacheSize(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONGetMigrationCacheSize(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
unsigned long long cacheSize;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-migrate-cache-size",
|
||||
@ -1878,20 +1888,20 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCacheSize(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONGetMigrationStats(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONGetMigrationStats(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
qemuMonitorMigrationStats stats, expectedStats;
|
||||
char *error = NULL;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
memset(&expectedStats, 0, sizeof(expectedStats));
|
||||
@ -1949,7 +1959,6 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationStats(const void *data)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
VIR_FREE(error);
|
||||
return ret;
|
||||
}
|
||||
@ -1978,18 +1987,19 @@ testHashEqualChardevInfo(const void *value1, const void *value2)
|
||||
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONGetChardevInfo(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONGetChardevInfo(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
virHashTablePtr info = NULL, expectedInfo = NULL;
|
||||
qemuMonitorChardevInfo info0 = { NULL, VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT };
|
||||
qemuMonitorChardevInfo info1 = { (char *) "/dev/pts/21", VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED };
|
||||
qemuMonitorChardevInfo info2 = { (char *) "/dev/pts/20", VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT };
|
||||
qemuMonitorChardevInfo info3 = { NULL, VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED };
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (!(info = virHashCreate(32, qemuMonitorChardevInfoFree)) ||
|
||||
@ -2045,7 +2055,6 @@ testQemuMonitorJSONqemuMonitorJSONGetChardevInfo(const void *data)
|
||||
cleanup:
|
||||
virHashFree(info);
|
||||
virHashFree(expectedInfo);
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2099,14 +2108,15 @@ testValidateGetBlockIoThrottle(const virDomainBlockIoTuneInfo *info,
|
||||
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
virDomainBlockIoTuneInfo info, expectedInfo;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
expectedInfo = (virDomainBlockIoTuneInfo) {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, NULL, 15, 16, 17, 18, 19, 20};
|
||||
@ -2149,19 +2159,19 @@ testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(const void *data)
|
||||
cleanup:
|
||||
VIR_FREE(info.group_name);
|
||||
VIR_FREE(expectedInfo.group_name);
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONGetTargetArch(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONGetTargetArch(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
char *arch;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-target",
|
||||
@ -2186,15 +2196,14 @@ testQemuMonitorJSONqemuMonitorJSONGetTargetArch(const void *data)
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(arch);
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
const char *cap;
|
||||
char **caps = NULL;
|
||||
@ -2210,8 +2219,9 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities(const void *data)
|
||||
" ],"
|
||||
" \"id\": \"libvirt-22\""
|
||||
"}";
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-migrate-capabilities", reply) < 0 ||
|
||||
@ -2244,21 +2254,21 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities(const void *data)
|
||||
|
||||
cleanup:
|
||||
virJSONValueFree(json);
|
||||
qemuMonitorTestFree(test);
|
||||
virStringListFree(caps);
|
||||
virBitmapFree(bitmap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONSendKey(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONSendKey(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
unsigned int keycodes[] = {43, 26, 46, 32};
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "send-key",
|
||||
@ -2271,19 +2281,19 @@ testQemuMonitorJSONqemuMonitorJSONSendKey(const void *data)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONSendKeyHoldtime(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONSendKeyHoldtime(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
unsigned int keycodes[] = {43, 26, 46, 32};
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItemParams(test, "send-key",
|
||||
@ -2303,15 +2313,14 @@ testQemuMonitorJSONqemuMonitorJSONSendKeyHoldtime(const void *data)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorSupportsActiveCommit(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorSupportsActiveCommit(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
const char *error1 =
|
||||
"{"
|
||||
@ -2327,8 +2336,9 @@ testQemuMonitorJSONqemuMonitorSupportsActiveCommit(const void *data)
|
||||
" \"desc\": \"Parameter 'top' is missing\""
|
||||
" }"
|
||||
"}";
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItemParams(test, "block-commit", error1,
|
||||
@ -2349,15 +2359,14 @@ testQemuMonitorJSONqemuMonitorSupportsActiveCommit(const void *data)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONGetDumpGuestMemoryCapability(const void *data)
|
||||
testQemuMonitorJSONqemuMonitorJSONGetDumpGuestMemoryCapability(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
int cap;
|
||||
const char *reply =
|
||||
@ -2372,8 +2381,9 @@ testQemuMonitorJSONqemuMonitorJSONGetDumpGuestMemoryCapability(const void *data)
|
||||
" },"
|
||||
" \"id\": \"libvirt-9\""
|
||||
"}";
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-dump-guest-memory-capability",
|
||||
@ -2392,13 +2402,13 @@ testQemuMonitorJSONqemuMonitorJSONGetDumpGuestMemoryCapability(const void *data)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct testCPUData {
|
||||
const char *name;
|
||||
virDomainXMLOptionPtr xmlopt;
|
||||
virHashTablePtr schema;
|
||||
};
|
||||
|
||||
|
||||
@ -2406,15 +2416,15 @@ static int
|
||||
testQemuMonitorJSONGetCPUData(const void *opaque)
|
||||
{
|
||||
const struct testCPUData *data = opaque;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, data->xmlopt);
|
||||
virCPUDataPtr cpuData = NULL;
|
||||
char *jsonFile = NULL;
|
||||
char *dataFile = NULL;
|
||||
char *jsonStr = NULL;
|
||||
char *actual = NULL;
|
||||
int ret = -1;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (virAsprintf(&jsonFile,
|
||||
@ -2465,19 +2475,19 @@ testQemuMonitorJSONGetCPUData(const void *opaque)
|
||||
VIR_FREE(jsonStr);
|
||||
VIR_FREE(actual);
|
||||
virCPUDataFree(cpuData);
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONGetNonExistingCPUData(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr) opaque;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
virCPUDataPtr cpuData = NULL;
|
||||
int rv, ret = -1;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "qom-list",
|
||||
@ -2508,22 +2518,22 @@ testQemuMonitorJSONGetNonExistingCPUData(const void *opaque)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
virCPUDataFree(cpuData);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONGetIOThreads(const void *data)
|
||||
testQemuMonitorJSONGetIOThreads(const void *opaque)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||
qemuMonitorIOThreadInfoPtr *info;
|
||||
int ninfo = 0;
|
||||
int ret = -1;
|
||||
size_t i;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-iothreads",
|
||||
@ -2575,7 +2585,6 @@ testQemuMonitorJSONGetIOThreads(const void *data)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuMonitorTestFree(test);
|
||||
for (i = 0; i < ninfo; i++)
|
||||
VIR_FREE(info[i]);
|
||||
VIR_FREE(info);
|
||||
@ -2588,6 +2597,7 @@ struct testCPUInfoData {
|
||||
size_t maxvcpus;
|
||||
virDomainXMLOptionPtr xmlopt;
|
||||
bool fast;
|
||||
virHashTablePtr schema;
|
||||
};
|
||||
|
||||
|
||||
@ -2656,7 +2666,6 @@ static int
|
||||
testQemuMonitorCPUInfo(const void *opaque)
|
||||
{
|
||||
const struct testCPUInfoData *data = opaque;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, data->xmlopt);
|
||||
virDomainObjPtr vm = NULL;
|
||||
char *queryCpusFile = NULL;
|
||||
char *queryHotpluggableFile = NULL;
|
||||
@ -2668,8 +2677,9 @@ testQemuMonitorCPUInfo(const void *opaque)
|
||||
qemuMonitorCPUInfoPtr vcpus = NULL;
|
||||
int rc;
|
||||
int ret = -1;
|
||||
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||
|
||||
if (!test)
|
||||
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
|
||||
return -1;
|
||||
|
||||
if (virAsprintf(&queryCpusFile,
|
||||
@ -2725,7 +2735,6 @@ testQemuMonitorCPUInfo(const void *opaque)
|
||||
VIR_FREE(queryHotpluggableStr);
|
||||
VIR_FREE(actual);
|
||||
qemuMonitorCPUInfoFree(vcpus, data->maxvcpus);
|
||||
qemuMonitorTestFree(test);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2913,8 +2922,11 @@ mymain(void)
|
||||
}
|
||||
|
||||
#define DO_TEST(name) \
|
||||
if (virTestRun(# name, testQemuMonitorJSON ## name, driver.xmlopt) < 0) \
|
||||
ret = -1
|
||||
do { \
|
||||
testGenericData data = { driver.xmlopt, qapiData.schema }; \
|
||||
if (virTestRun(# name, testQemuMonitorJSON ## name, &data) < 0) \
|
||||
ret = -1; \
|
||||
} while (0)
|
||||
|
||||
#define DO_TEST_SIMPLE(CMD, FNC, ...) \
|
||||
simpleFunc = (testQemuMonitorJSONSimpleFuncData) {.cmd = CMD, .func = FNC, \
|
||||
@ -2933,7 +2945,7 @@ mymain(void)
|
||||
|
||||
#define DO_TEST_CPU_DATA(name) \
|
||||
do { \
|
||||
struct testCPUData data = { name, driver.xmlopt }; \
|
||||
struct testCPUData data = { name, driver.xmlopt, qapiData.schema }; \
|
||||
const char *label = "GetCPUData(" name ")"; \
|
||||
if (virTestRun(label, testQemuMonitorJSONGetCPUData, &data) < 0) \
|
||||
ret = -1; \
|
||||
@ -2941,7 +2953,8 @@ mymain(void)
|
||||
|
||||
#define DO_TEST_CPU_INFO(name, maxvcpus) \
|
||||
do { \
|
||||
struct testCPUInfoData data = {name, maxvcpus, driver.xmlopt, false}; \
|
||||
struct testCPUInfoData data = {name, maxvcpus, driver.xmlopt, false, \
|
||||
qapiData.schema}; \
|
||||
if (virTestRun("GetCPUInfo(" name ")", testQemuMonitorCPUInfo, \
|
||||
&data) < 0) \
|
||||
ret = -1; \
|
||||
@ -2949,7 +2962,8 @@ mymain(void)
|
||||
|
||||
#define DO_TEST_CPU_INFO_FAST(name, maxvcpus) \
|
||||
do { \
|
||||
struct testCPUInfoData data = {name, maxvcpus, driver.xmlopt, true}; \
|
||||
struct testCPUInfoData data = {name, maxvcpus, driver.xmlopt, true, \
|
||||
qapiData.schema }; \
|
||||
if (virTestRun("GetCPUInfo(" name ")", testQemuMonitorCPUInfo, \
|
||||
&data) < 0) \
|
||||
ret = -1; \
|
||||
@ -2962,7 +2976,7 @@ mymain(void)
|
||||
DO_TEST(GetCommands);
|
||||
DO_TEST(GetTPMModels);
|
||||
DO_TEST(GetCommandLineOptionParameters);
|
||||
if (qemuMonitorJSONTestAttachChardev(driver.xmlopt) < 0)
|
||||
if (qemuMonitorJSONTestAttachChardev(driver.xmlopt, qapiData.schema) < 0)
|
||||
ret = -1;
|
||||
DO_TEST(DetachChardev);
|
||||
DO_TEST(GetListPaths);
|
||||
|
Loading…
Reference in New Issue
Block a user