3 # Copyright (C) 2015 Red Hat, Inc.
6 # Markus Armbruster <armbru@redhat.com>
8 # This work is licensed under the terms of the GNU GPL, version 2 or later.
9 # See the COPYING file in the top-level directory.
18 # Command query-qmp-schema exposes the QMP wire ABI as an array of
19 # SchemaInfo. This lets QMP clients figure out what commands and
20 # events are available in this QEMU, and their parameters and results.
22 # However, the SchemaInfo can't reflect all the rules and restrictions
23 # that apply to QMP. It's interface introspection (figuring out
24 # what's there), not interface specification. The specification is in
27 # Furthermore, while we strive to keep the QMP wire format
28 # backwards-compatible across qemu versions, the introspection output
29 # is not guaranteed to have the same stability. For example, one
30 # version of qemu may list an object member as an optional
31 # non-variant, while another lists the same member only through the
32 # object's variants; or the type of a member may change from a generic
33 # string into a specific enum or from one specific type into an
34 # alternate that includes the original type alongside something else.
36 # Returns: array of @SchemaInfo, where each element describes an
37 # entity in the ABI: command, event, type, ...
39 # The order of the various SchemaInfo is unspecified; however, all
40 # names are guaranteed to be unique (no name will be duplicated with
41 # different meta-types).
43 # Note: the QAPI schema is also used to help define *internal*
44 # interfaces, by defining QAPI types. These are not part of the QMP
45 # wire ABI, and therefore not returned by this command.
49 { 'command': 'query-qmp-schema',
50 'returns': [ 'SchemaInfo' ],
51 'gen': false } # just to simplify qmp_query_json()
56 # This is a @SchemaInfo's meta type, i.e. the kind of entity it
59 # @builtin: a predefined type such as 'int' or 'bool'.
61 # @enum: an enumeration type
63 # @array: an array type
65 # @object: an object type (struct or union)
67 # @alternate: an alternate type
69 # @command: a QMP command
75 { 'enum': 'SchemaMetaType',
76 'data': [ 'builtin', 'enum', 'array', 'object', 'alternate',
77 'command', 'event' ] }
82 # @name: the entity's name, inherited from @base.
83 # The SchemaInfo is always referenced by this name.
84 # Commands and events have the name defined in the QAPI schema.
85 # Unlike command and event names, type names are not part of
86 # the wire ABI. Consequently, type names are meaningless
87 # strings here, although they are still guaranteed unique
88 # regardless of @meta-type.
90 # @meta-type: the entity's meta type, inherited from @base.
92 # Additional members depend on the value of @meta-type.
96 { 'union': 'SchemaInfo',
97 'base': { 'name': 'str', 'meta-type': 'SchemaMetaType' },
98 'discriminator': 'meta-type',
100 'builtin': 'SchemaInfoBuiltin',
101 'enum': 'SchemaInfoEnum',
102 'array': 'SchemaInfoArray',
103 'object': 'SchemaInfoObject',
104 'alternate': 'SchemaInfoAlternate',
105 'command': 'SchemaInfoCommand',
106 'event': 'SchemaInfoEvent' } }
109 # @SchemaInfoBuiltin:
111 # Additional SchemaInfo members for meta-type 'builtin'.
113 # @json-type: the JSON type used for this type on the wire.
117 { 'struct': 'SchemaInfoBuiltin',
118 'data': { 'json-type': 'JSONType' } }
123 # The four primitive and two structured types according to RFC 7159
124 # section 1, plus 'int' (split off 'number'), plus the obvious top
129 { 'enum': 'JSONType',
130 'data': [ 'string', 'number', 'int', 'boolean', 'null',
131 'object', 'array', 'value' ] }
136 # Additional SchemaInfo members for meta-type 'enum'.
138 # @values: the enumeration type's values, in no particular order.
140 # Values of this type are JSON string on the wire.
144 { 'struct': 'SchemaInfoEnum',
145 'data': { 'values': ['str'] } }
150 # Additional SchemaInfo members for meta-type 'array'.
152 # @element-type: the array type's element type.
154 # Values of this type are JSON array on the wire.
158 { 'struct': 'SchemaInfoArray',
159 'data': { 'element-type': 'str' } }
164 # Additional SchemaInfo members for meta-type 'object'.
166 # @members: the object type's (non-variant) members, in no particular order.
168 # @tag: the name of the member serving as type tag.
169 # An element of @members with this name must exist.
171 # @variants: variant members, i.e. additional members that
172 # depend on the type tag's value. Present exactly when
173 # @tag is present. The variants are in no particular order,
174 # and may even differ from the order of the values of the
175 # enum type of the @tag.
177 # Values of this type are JSON object on the wire.
181 { 'struct': 'SchemaInfoObject',
182 'data': { 'members': [ 'SchemaInfoObjectMember' ],
184 '*variants': [ 'SchemaInfoObjectVariant' ] } }
187 # @SchemaInfoObjectMember:
191 # @name: the member's name, as defined in the QAPI schema.
193 # @type: the name of the member's type.
195 # @default: default when used as command parameter.
196 # If absent, the parameter is mandatory.
197 # If present, the value must be null. The parameter is
198 # optional, and behavior when it's missing is not specified
200 # Future extension: if present and non-null, the parameter
201 # is optional, and defaults to this value.
205 { 'struct': 'SchemaInfoObjectMember',
206 'data': { 'name': 'str', 'type': 'str', '*default': 'any' } }
207 # @default's type must be null or match @type
210 # @SchemaInfoObjectVariant:
212 # The variant members for a value of the type tag.
214 # @case: a value of the type tag.
216 # @type: the name of the object type that provides the variant members
217 # when the type tag has value @case.
221 { 'struct': 'SchemaInfoObjectVariant',
222 'data': { 'case': 'str', 'type': 'str' } }
225 # @SchemaInfoAlternate:
227 # Additional SchemaInfo members for meta-type 'alternate'.
229 # @members: the alternate type's members, in no particular order.
230 # The members' wire encoding is distinct, see
231 # docs/devel/qapi-code-gen.txt section Alternate types.
233 # On the wire, this can be any of the members.
237 { 'struct': 'SchemaInfoAlternate',
238 'data': { 'members': [ 'SchemaInfoAlternateMember' ] } }
241 # @SchemaInfoAlternateMember:
243 # An alternate member.
245 # @type: the name of the member's type.
249 { 'struct': 'SchemaInfoAlternateMember',
250 'data': { 'type': 'str' } }
253 # @SchemaInfoCommand:
255 # Additional SchemaInfo members for meta-type 'command'.
257 # @arg-type: the name of the object type that provides the command's
260 # @ret-type: the name of the command's result type.
262 # @allow-oob: whether the command allows out-of-band execution.
265 # @allow-preconfig: command can be executed in preconfig runstate,
266 # default: false (Since 3.0)
268 # TODO: @success-response (currently irrelevant, because it's QGA, not QMP)
272 { 'struct': 'SchemaInfoCommand',
273 'data': { 'arg-type': 'str', 'ret-type': 'str',
274 'allow-oob': 'bool', 'allow-preconfig': 'bool' } }
279 # Additional SchemaInfo members for meta-type 'event'.
281 # @arg-type: the name of the object type that provides the event's
286 { 'struct': 'SchemaInfoEvent',
287 'data': { 'arg-type': 'str' } }