diff mbox series

[RFC,25/32] qapi-introspect: Include command line options information

Message ID 20171002152552.27999-26-armbru@redhat.com
State New
Headers show
Series Command line QAPIfication | expand

Commit Message

Markus Armbruster Oct. 2, 2017, 3:25 p.m. UTC
Make query-qmp-schema describe command line options in addition to QMP
commands and events.  Simple, but it pushes query-qmp-schema beyond
QMP.  Perhaps options introspection should be separate.  Perhaps not
for the same reason QMP and command line are defined in the same
schema: they share many types.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qapi/introspect.json       | 22 ++++++++++++++++++++--
 scripts/qapi-introspect.py | 10 +++++++++-
 2 files changed, 29 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/qapi/introspect.json b/qapi/introspect.json
index 5b3e6e9d78..0b6be5b19c 100644
--- a/qapi/introspect.json
+++ b/qapi/introspect.json
@@ -70,11 +70,13 @@ 
 #
 # @event: a QMP event
 #
+# @option: a command line option (since 2.11)
+#
 # Since: 2.5
 ##
 { 'enum': 'SchemaMetaType',
   'data': [ 'builtin', 'enum', 'array', 'object', 'alternate',
-            'command', 'event' ] }
+            'command', 'event', 'option' ] }
 
 ##
 # @SchemaInfo:
@@ -103,7 +105,8 @@ 
       'object': 'SchemaInfoObject',
       'alternate': 'SchemaInfoAlternate',
       'command': 'SchemaInfoCommand',
-      'event': 'SchemaInfoEvent' } }
+      'event': 'SchemaInfoEvent',
+      'option': 'SchemaInfoOption' } }
 
 ##
 # @SchemaInfoBuiltin:
@@ -278,3 +281,18 @@ 
 ##
 { 'struct': 'SchemaInfoEvent',
   'data': { 'arg-type': 'str' } }
+
+##
+# @SchemaInfoOption:
+#
+# Additional SchemaInfo members for meta-type 'option'.
+#
+# @arg-type: the name of the object type that provides the option's
+#            parameters.
+#
+# @short: the option character, if any.
+#
+# Since: 2.11
+##
+{ 'struct': 'SchemaInfoOption',
+  'data': { 'arg-type': 'str', '*short': 'str' } }
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index 52404b07ab..650e5597b0 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -108,7 +108,7 @@  const char %(c_name)s[] = %(c_string)s;
         return self._name(typ.name)
 
     def _gen_json(self, name, mtype, obj):
-        if mtype not in ('command', 'event', 'builtin', 'array'):
+        if mtype not in ('command', 'event', 'option', 'builtin', 'array'):
             name = self._name(name)
         obj['name'] = name
         obj['meta-type'] = mtype
@@ -161,6 +161,14 @@  const char %(c_name)s[] = %(c_string)s;
         arg_type = arg_type or self._schema.the_empty_object_type
         self._gen_json(name, 'event', {'arg-type': self._use_type(arg_type)})
 
+    def visit_option(self, name, info, arg_type, short, implied_key,
+                     boxed, help_):
+        arg_type = arg_type or self._schema.the_empty_object_type
+        obj = {'arg-type': self._use_type(arg_type)}
+        if short:
+            obj['short'] = short
+        self._gen_json(name, 'option', obj)
+
 parser = common_argument_parser()
 # Debugging aid: unmask QAPI schema's type names
 # We normally mask them, because they're not QMP wire ABI