Starting from QEMU-6.2 enum members are reported as an array of objects
under new name "values" so that extra data can be reported for each
member.
Modify the code so that we prefer 'members' and skip 'values' completely
if we've used 'members'.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
Reviewed-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_qapi.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c
index 165ecf1180..790f7c0fee 100644
--- a/src/qemu/qemu_qapi.c
+++ b/src/qemu/qemu_qapi.c
@@ -243,6 +243,7 @@ virQEMUQAPISchemaTraverseEnum(virJSONValue *cur,
{
const char *query = virQEMUQAPISchemaTraverseContextNextQuery(ctxt);
virJSONValue *values;
+ virJSONValue *members;
size_t i;
if (query[0] != '^')
@@ -253,6 +254,22 @@ virQEMUQAPISchemaTraverseEnum(virJSONValue *cur,
query++;
+ /* qemu-6.2 added a "members" array superseding "values" */
+ if ((members = virJSONValueObjectGetArray(cur, "members"))) {
+ for (i = 0; i < virJSONValueArraySize(members); i++) {
+ virJSONValue *member = virJSONValueArrayGet(members, i);
+ const char *name;
+
+ if (!member || !(name = virJSONValueObjectGetString(member,
"name")))
+ return -2;
+
+ if (STREQ(name, query))
+ return 1;
+ }
+
+ return 0;
+ }
+
if (!(values = virJSONValueObjectGetArray(cur, "values")))
return -2;
--
2.31.1