]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: qapi: Simplify value handling in virQEMUQAPISchemaTraverse
authorPeter Krempa <pkrempa@redhat.com>
Wed, 15 Aug 2018 06:32:04 +0000 (08:32 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 24 Aug 2018 13:58:33 +0000 (15:58 +0200)
Introduce a few variables so that we can easily access the modifier
character and also don't have to do pointer arithmetic when selecting
the schema entries. This will simplify adding of new modifier
characters.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_qapi.c

index d277ef1bde54d882d6749e9dd25238008f703af5..fea66833364952ecb58f21748109c7b5dee02a06 100644 (file)
@@ -25,6 +25,8 @@
 #include "virerror.h"
 #include "virlog.h"
 
+#include "c-ctype.h"
+
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
 VIR_LOG_INIT("qemu.qemu_qapi");
@@ -75,6 +77,8 @@ virQEMUQAPISchemaTraverse(const char *baseName,
 {
     virJSONValuePtr base;
     const char *metatype;
+    const char *querystr;
+    char modifier;
 
     while (1) {
         if (!(base = virHashLookup(schema, baseName)))
@@ -93,13 +97,19 @@ virQEMUQAPISchemaTraverse(const char *baseName,
 
             continue;
         } else if (STREQ(metatype, "object")) {
-            if (**query == '+')
+            querystr = *query;
+            modifier = **query;
+
+            if (!c_isalpha(modifier))
+                querystr++;
+
+            if (modifier == '+')
                 baseName = virQEMUQAPISchemaObjectGetType("variants",
-                                                          *query + 1,
+                                                          querystr,
                                                           "case", base);
             else
                 baseName = virQEMUQAPISchemaObjectGetType("members",
-                                                          *query,
+                                                          querystr,
                                                           "name", base);
 
             if (!baseName)
@@ -139,6 +149,9 @@ virQEMUQAPISchemaTraverse(const char *baseName,
  * +variant_discriminator: In the case of unionized objects, select a
  *                         specific case to introspect.
  *
+ * If the name of any (sub)attribute starts with non-alphabetical symbols it
+ * needs to be prefixed by a single space.
+ *
  * Array types are automatically flattened to the singular type. Alternate
  * types are currently not supported.
  *