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