]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
testQEMUSchemaValidateEnum: Use new 'members' for 'enum' meta type
authorPeter Krempa <pkrempa@redhat.com>
Fri, 17 Sep 2021 14:26:09 +0000 (16:26 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 1 Nov 2021 16:37:15 +0000 (17:37 +0100)
Switch to the new more featured way to report enum members which will
also allow us to detect use of deprecated members.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/testutilsqemuschema.c

index 82c5994604fd66e76747c2cc1f39568d9f293d56..dfb1add90b42920ded03f914d84f30a0a03595b9 100644 (file)
@@ -324,6 +324,7 @@ testQEMUSchemaValidateEnum(virJSONValue *obj,
 {
     const char *objstr;
     virJSONValue *values = NULL;
+    virJSONValue *members = NULL;
     size_t i;
 
     if (virJSONValueGetType(obj) != VIR_JSON_TYPE_STRING) {
@@ -333,6 +334,22 @@ testQEMUSchemaValidateEnum(virJSONValue *obj,
 
     objstr = virJSONValueGetString(obj);
 
+    /* qemu-6.2 added a "members" array superseding "values" */
+    if ((members = virJSONValueObjectGetArray(root, "members"))) {
+        for (i = 0; i < virJSONValueArraySize(members); i++) {
+            virJSONValue *member = virJSONValueArrayGet(members, i);
+
+            if (STREQ_NULLABLE(objstr, virJSONValueObjectGetString(member, "name"))) {
+                virBufferAsprintf(ctxt->debug, "'%s' OK", NULLSTR(objstr));
+                return 0;
+            }
+        }
+
+        virBufferAsprintf(ctxt->debug, "ERROR: enum value '%s' is not in schema",
+                          NULLSTR(objstr));
+        return -1;
+    }
+
     if ((values = virJSONValueObjectGetArray(root, "values"))) {
         for (i = 0; i < virJSONValueArraySize(values); i++) {
             virJSONValue *value = virJSONValueArrayGet(values, i);