summary refs log tree commit diff stats
path: root/scripts
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2023-04-20 11:26:19 +0100
committerMarkus Armbruster <armbru@redhat.com>2023-04-26 07:52:45 +0200
commita17dbc4b79a28ffb9511f192474ffefd88214cde (patch)
tree1a4fde556d2f94e3e908f4368ef9862d34340ef9 /scripts
parent1e148b545fccc2a83a57269849de9a21e11c17da (diff)
downloadfocaccia-qemu-a17dbc4b79a28ffb9511f192474ffefd88214cde.tar.gz
focaccia-qemu-a17dbc4b79a28ffb9511f192474ffefd88214cde.zip
qapi: allow unions to contain further unions
This extends the QAPI schema validation to permit unions inside unions,
provided the checks for clashing fields pass.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20230420102619.348173-4-berrange@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi/schema.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 27e336577f..231ebf61ba 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -465,9 +465,10 @@ class QAPISchemaObjectType(QAPISchemaType):
     # on behalf of info, which is not necessarily self.info
     def check_clash(self, info, seen):
         assert self._checked
-        assert not self.variants       # not implemented
         for m in self.members:
             m.check_clash(info, seen)
+        if self.variants:
+            self.variants.check_clash(info, seen)
 
     def connect_doc(self, doc=None):
         super().connect_doc(doc)
@@ -656,8 +657,7 @@ class QAPISchemaVariants:
                         self.info,
                         "branch '%s' is not a value of %s"
                         % (v.name, self.tag_member.type.describe()))
-                if (not isinstance(v.type, QAPISchemaObjectType)
-                        or v.type.variants):
+                if not isinstance(v.type, QAPISchemaObjectType):
                     raise QAPISemError(
                         self.info,
                         "%s cannot use %s"