3 # QAPI/QMP introspection
5 # Copyright (C) 2015 Red Hat, Inc.
8 # Markus Armbruster <armbru@redhat.com>
10 # This work is licensed under the terms of the GNU GPL, version 2 or later.
11 # See the COPYING file in the top-level directory.
16 # Command query-qmp-schema exposes the QMP wire ABI as an array of
17 # SchemaInfo. This lets QMP clients figure out what commands and
18 # events are available in this QEMU, and their parameters and results.
20 # However, the SchemaInfo can't reflect all the rules and restrictions
21 # that apply to QMP. It's interface introspection (figuring out
22 # what's there), not interface specification. The specification is in
25 # Returns: array of @SchemaInfo, where each element describes an
26 # entity in the ABI: command, event, type, ...
28 # Note: the QAPI schema is also used to help define *internal*
29 # interfaces, by defining QAPI types. These are not part of the QMP
30 # wire ABI, and therefore not returned by this command.
34 { 'command': 'query-qmp-schema',
35 'returns': [ 'SchemaInfo' ],
36 'gen': false } # just to simplify qmp_query_json()
41 # This is a @SchemaInfo's meta type, i.e. the kind of entity it
44 # @builtin: a predefined type such as 'int' or 'bool'.
46 # @enum: an enumeration type
48 # @array: an array type
50 # @object: an object type (struct or union)
52 # @alternate: an alternate type
54 # @command: a QMP command
60 { 'enum': 'SchemaMetaType',
61 'data': [ 'builtin', 'enum', 'array', 'object', 'alternate',
62 'command', 'event' ] }
67 # Members common to any @SchemaInfo.
71 { 'struct': 'SchemaInfoBase',
72 'data': { 'name': 'str', 'meta-type': 'SchemaMetaType' } }
77 # @name: the entity's name, inherited from @base.
78 # Commands and events have the name defined in the QAPI schema.
79 # Unlike command and event names, type names are not part of
80 # the wire ABI. Consequently, type names are meaningless
83 # All references to other SchemaInfo are by name.
85 # @meta-type: the entity's meta type, inherited from @base.
87 # Additional members depend on the value of @meta-type.
91 { 'union': 'SchemaInfo',
92 'base': 'SchemaInfoBase',
93 'discriminator': 'meta-type',
95 'builtin': 'SchemaInfoBuiltin',
96 'enum': 'SchemaInfoEnum',
97 'array': 'SchemaInfoArray',
98 'object': 'SchemaInfoObject',
99 'alternate': 'SchemaInfoAlternate',
100 'command': 'SchemaInfoCommand',
101 'event': 'SchemaInfoEvent' } }
106 # Additional SchemaInfo members for meta-type 'builtin'.
108 # @json-type: the JSON type used for this type on the wire.
112 { 'struct': 'SchemaInfoBuiltin',
113 'data': { 'json-type': 'JSONType' } }
118 # The four primitive and two structured types according to RFC 7159
119 # section 1, plus 'int' (split off 'number'), plus the obvious top
124 { 'enum': 'JSONType',
125 'data': [ 'string', 'number', 'int', 'boolean', 'null',
126 'object', 'array', 'value' ] }
131 # Additional SchemaInfo members for meta-type 'enum'.
133 # @values: the enumeration type's values.
135 # Values of this type are JSON string on the wire.
139 { 'struct': 'SchemaInfoEnum',
140 'data': { 'values': ['str'] } }
145 # Additional SchemaInfo members for meta-type 'array'.
147 # @element-type: the array type's element type.
149 # Values of this type are JSON array on the wire.
153 { 'struct': 'SchemaInfoArray',
154 'data': { 'element-type': 'str' } }
159 # Additional SchemaInfo members for meta-type 'object'.
161 # @members: the object type's (non-variant) members.
163 # @tag: #optional the name of the member serving as type tag.
164 # An element of @members with this name must exist.
166 # @variants: #optional variant members, i.e. additional members that
167 # depend on the type tag's value. Present exactly when
170 # Values of this type are JSON object on the wire.
174 { 'struct': 'SchemaInfoObject',
175 'data': { 'members': [ 'SchemaInfoObjectMember' ],
177 '*variants': [ 'SchemaInfoObjectVariant' ] } }
180 # @SchemaInfoObjectMember
184 # @name: the member's name, as defined in the QAPI schema.
186 # @type: the name of the member's type.
188 # @default: #optional default when used as command parameter.
189 # If absent, the parameter is mandatory.
190 # If present, the value must be null. The parameter is
191 # optional, and behavior when it's missing is not specified
193 # Future extension: if present and non-null, the parameter
194 # is optional, and defaults to this value.
198 { 'struct': 'SchemaInfoObjectMember',
199 'data': { 'name': 'str', 'type': 'str', '*default': 'any' } }
200 # @default's type must be null or match @type
203 # @SchemaInfoObjectVariant
205 # The variant members for a value of the type tag.
207 # @case: a value of the type tag.
209 # @type: the name of the object type that provides the variant members
210 # when the type tag has value @case.
214 { 'struct': 'SchemaInfoObjectVariant',
215 'data': { 'case': 'str', 'type': 'str' } }
218 # @SchemaInfoAlternate
220 # Additional SchemaInfo members for meta-type 'alternate'.
222 # @members: the alternate type's members.
223 # The members' wire encoding is distinct, see
224 # docs/qapi-code-gen.txt section Alternate types.
226 # On the wire, this can be any of the members.
230 { 'struct': 'SchemaInfoAlternate',
231 'data': { 'members': [ 'SchemaInfoAlternateMember' ] } }
234 # @SchemaInfoAlternateMember
236 # An alternate member.
238 # @type: the name of the member's type.
242 { 'struct': 'SchemaInfoAlternateMember',
243 'data': { 'type': 'str' } }
248 # Additional SchemaInfo members for meta-type 'command'.
250 # @arg-type: the name of the object type that provides the command's
253 # @ret-type: the name of the command's result type.
255 # TODO @success-response (currently irrelevant, because it's QGA, not QMP)
259 { 'struct': 'SchemaInfoCommand',
260 'data': { 'arg-type': 'str', 'ret-type': 'str' } }
265 # Additional SchemaInfo members for meta-type 'event'.
267 # @arg-type: the name of the object type that provides the event's
272 { 'struct': 'SchemaInfoEvent',
273 'data': { 'arg-type': 'str' } }