qemumonitorjsontest: Add a last-resort warning if object-add/device_add are QAPIfied

When netdev-add was qapified it took us by surprise and we had to
scramble to fix the internals to format conformant monitor arguments.

Add a last-resort early warning system if this happens to object-add or
device_add. Hopefully qemu developers notify us sooner than this.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Peter Krempa 2020-08-06 19:45:24 +02:00
parent 63a25dd821
commit 24793bdf28

View File

@ -2888,6 +2888,55 @@ testQAPISchemaValidate(const void *opaque)
}
/**
* testQAPISchemaObjectDeviceAdd:
*
* Purpose of this test is to add a last-resort notification that 'object-add'
* and 'device_add' are not covered by the QMP schema by surprise. Ideally QEMU
* developers will notify us before they switch so we have time to adapt our
* generators first. This didn't work out when netdev-add was converted.
*
* We validate that the QMP schema describes only the expected types and nothing
* else assuming that no new field will be added until final conversion.
*/
static int
testQAPISchemaObjectDeviceAdd(const void *opaque)
{
virHashTablePtr schema = (virHashTablePtr) opaque;
virJSONValuePtr entry;
if (virQEMUQAPISchemaPathGet("device_add/arg-type", schema, &entry) < 0) {
fprintf(stderr, "schema for 'device_add' not found\n");
return -1;
}
if (testQEMUSchemaEntryMatchTemplate(entry,
"str:driver",
"str:bus",
"str:id",
NULL) < 0) {
VIR_TEST_VERBOSE("device_add has unexpected members in schema");
return -1;
}
if (virQEMUQAPISchemaPathGet("object-add/arg-type", schema, &entry) < 0) {
fprintf(stderr, "schema for 'objectadd' not found\n");
return -1;
}
if (testQEMUSchemaEntryMatchTemplate(entry,
"str:qom-type",
"str:id",
"any:props",
NULL) < 0) {
VIR_TEST_VERBOSE("object-add has unexpected members in schema");
return -1;
}
return 0;
}
static void
testQueryJobsPrintJob(virBufferPtr buf,
qemuMonitorJobInfoPtr job)
@ -3380,6 +3429,10 @@ mymain(void)
#undef DO_TEST_QAPI_VALIDATE
if (virTestRun("validate that object-add and device_add don't have schema",
testQAPISchemaObjectDeviceAdd, qapiData.schema) < 0)
ret = -1;
#define DO_TEST_QUERY_JOBS(name) \
do { \
struct testQueryJobsData data = { name, driver.xmlopt}; \