mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-02 04:15:46 +00:00
testQEMUSchemaValidateEnum: Refactor logic to simplify switching to new QMP schema format
QEMU-6.2 is reporting enum values in the new 'members' array which we'll be switching to. Rewrite the logic so that adding the new checker is more straightforward. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
626b53ba9b
commit
91453650f3
@ -324,7 +324,6 @@ testQEMUSchemaValidateEnum(virJSONValue *obj,
|
|||||||
{
|
{
|
||||||
const char *objstr;
|
const char *objstr;
|
||||||
virJSONValue *values = NULL;
|
virJSONValue *values = NULL;
|
||||||
virJSONValue *value;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (virJSONValueGetType(obj) != VIR_JSON_TYPE_STRING) {
|
if (virJSONValueGetType(obj) != VIR_JSON_TYPE_STRING) {
|
||||||
@ -334,14 +333,9 @@ testQEMUSchemaValidateEnum(virJSONValue *obj,
|
|||||||
|
|
||||||
objstr = virJSONValueGetString(obj);
|
objstr = virJSONValueGetString(obj);
|
||||||
|
|
||||||
if (!(values = virJSONValueObjectGetArray(root, "values"))) {
|
if ((values = virJSONValueObjectGetArray(root, "values"))) {
|
||||||
virBufferAsprintf(ctxt->debug, "ERROR: missing enum values in schema '%s'",
|
|
||||||
NULLSTR(virJSONValueObjectGetString(root, "name")));
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < virJSONValueArraySize(values); i++) {
|
for (i = 0; i < virJSONValueArraySize(values); i++) {
|
||||||
value = virJSONValueArrayGet(values, i);
|
virJSONValue *value = virJSONValueArrayGet(values, i);
|
||||||
|
|
||||||
if (STREQ_NULLABLE(objstr, virJSONValueGetString(value))) {
|
if (STREQ_NULLABLE(objstr, virJSONValueGetString(value))) {
|
||||||
virBufferAsprintf(ctxt->debug, "'%s' OK", NULLSTR(objstr));
|
virBufferAsprintf(ctxt->debug, "'%s' OK", NULLSTR(objstr));
|
||||||
@ -354,6 +348,11 @@ testQEMUSchemaValidateEnum(virJSONValue *obj,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virBufferAsprintf(ctxt->debug, "ERROR: missing enum values in schema '%s'",
|
||||||
|
NULLSTR(virJSONValueObjectGetString(root, "name")));
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
testQEMUSchemaValidateArray(virJSONValue *objs,
|
testQEMUSchemaValidateArray(virJSONValue *objs,
|
||||||
|
Loading…
Reference in New Issue
Block a user