4 # Copyright (C) 2015 Red Hat, Inc.
7 # Markus Armbruster <armbru@redhat.com>
9 # This work is licensed under the terms of the GNU GPL, version 2 or later.
10 # See the COPYING file in the top-level directory.
19 # Command query-qmp-schema exposes the QMP wire ABI as an array of
20 # SchemaInfo. This lets QMP clients figure out what commands and
21 # events are available in this QEMU, and their parameters and results.
23 # However, the SchemaInfo can't reflect all the rules and restrictions
24 # that apply to QMP. It's interface introspection (figuring out
25 # what's there), not interface specification. The specification is in
28 # Furthermore, while we strive to keep the QMP wire format
29 # backwards-compatible across qemu versions, the introspection output
30 # is not guaranteed to have the same stability. For example, one
31 # version of qemu may list an object member as an optional
32 # non-variant, while another lists the same member only through the
33 # object's variants; or the type of a member may change from a generic
34 # string into a specific enum or from one specific type into an
35 # alternate that includes the original type alongside something else.
37 # Returns: array of @SchemaInfo, where each element describes an
38 # entity in the ABI: command, event, type, ...
40 # The order of the various SchemaInfo is unspecified; however, all
41 # names are guaranteed to be unique (no name will be duplicated
42 # with different meta-types).
44 # Note: the QAPI schema is also used to help define *internal*
45 # interfaces, by defining QAPI types. These are not part of the
46 # QMP wire ABI, and therefore not returned by this command.
50 { 'command': 'query-qmp-schema',
51 'returns': [ 'SchemaInfo' ],
52 'allow-preconfig': true }
57 # This is a @SchemaInfo's meta type, i.e. the kind of entity it
60 # @builtin: a predefined type such as 'int' or 'bool'.
62 # @enum: an enumeration type
64 # @array: an array type
66 # @object: an object type (struct or union)
68 # @alternate: an alternate type
70 # @command: a QMP command
76 { 'enum': 'SchemaMetaType',
77 'data': [ 'builtin', 'enum', 'array', 'object', 'alternate',
78 'command', 'event' ] }
83 # @name: the entity's name, inherited from @base. The SchemaInfo is
84 # always referenced by this name. Commands and events have the
85 # name defined in the QAPI schema. Unlike command and event
86 # names, type names are not part of the wire ABI. Consequently,
87 # type names are meaningless strings here, although they are still
88 # guaranteed unique regardless of @meta-type.
90 # @meta-type: the entity's meta type, inherited from @base.
92 # @features: names of features associated with the entity, in no
93 # particular order. (since 4.1 for object types, 4.2 for
94 # commands, 5.0 for the rest)
96 # Additional members depend on the value of @meta-type.
100 { 'union': 'SchemaInfo',
101 'base': { 'name': 'str', 'meta-type': 'SchemaMetaType',
102 '*features': [ 'str' ] },
103 'discriminator': 'meta-type',
105 'builtin': 'SchemaInfoBuiltin',
106 'enum': 'SchemaInfoEnum',
107 'array': 'SchemaInfoArray',
108 'object': 'SchemaInfoObject',
109 'alternate': 'SchemaInfoAlternate',
110 'command': 'SchemaInfoCommand',
111 'event': 'SchemaInfoEvent' } }
114 # @SchemaInfoBuiltin:
116 # Additional SchemaInfo members for meta-type 'builtin'.
118 # @json-type: the JSON type used for this type on the wire.
122 { 'struct': 'SchemaInfoBuiltin',
123 'data': { 'json-type': 'JSONType' } }
128 # The four primitive and two structured types according to RFC 8259
129 # section 1, plus 'int' (split off 'number'), plus the obvious top
134 { 'enum': 'JSONType',
135 'data': [ 'string', 'number', 'int', 'boolean', 'null',
136 'object', 'array', 'value' ] }
141 # Additional SchemaInfo members for meta-type 'enum'.
143 # @members: the enum type's members, in no particular order (since
146 # @values: the enumeration type's member names, in no particular
147 # order. Redundant with @members. Just for backward
152 # @deprecated: Member @values is deprecated. Use @members instead.
154 # Values of this type are JSON string on the wire.
158 { 'struct': 'SchemaInfoEnum',
159 'data': { 'members': [ 'SchemaInfoEnumMember' ],
160 'values': { 'type': [ 'str' ],
161 'features': [ 'deprecated' ] } } }
164 # @SchemaInfoEnumMember:
168 # @name: the member's name, as defined in the QAPI schema.
170 # @features: names of features associated with the member, in no
175 { 'struct': 'SchemaInfoEnumMember',
176 'data': { 'name': 'str', '*features': [ 'str' ] } }
181 # Additional SchemaInfo members for meta-type 'array'.
183 # @element-type: the array type's element type.
185 # Values of this type are JSON array on the wire.
189 { 'struct': 'SchemaInfoArray',
190 'data': { 'element-type': 'str' } }
195 # Additional SchemaInfo members for meta-type 'object'.
197 # @members: the object type's (non-variant) members, in no particular
200 # @tag: the name of the member serving as type tag. An element of
201 # @members with this name must exist.
203 # @variants: variant members, i.e. additional members that depend on
204 # the type tag's value. Present exactly when @tag is present.
205 # The variants are in no particular order, and may even differ
206 # from the order of the values of the enum type of the @tag.
208 # Values of this type are JSON object on the wire.
212 { 'struct': 'SchemaInfoObject',
213 'data': { 'members': [ 'SchemaInfoObjectMember' ],
215 '*variants': [ 'SchemaInfoObjectVariant' ] } }
218 # @SchemaInfoObjectMember:
222 # @name: the member's name, as defined in the QAPI schema.
224 # @type: the name of the member's type.
226 # @default: default when used as command parameter. If absent, the
227 # parameter is mandatory. If present, the value must be null.
228 # The parameter is optional, and behavior when it's missing is not
229 # specified here. Future extension: if present and non-null, the
230 # parameter is optional, and defaults to this value.
232 # @features: names of features associated with the member, in no
233 # particular order. (since 5.0)
237 { 'struct': 'SchemaInfoObjectMember',
238 'data': { 'name': 'str', 'type': 'str', '*default': 'any',
239 # @default's type must be null or match @type
240 '*features': [ 'str' ] } }
243 # @SchemaInfoObjectVariant:
245 # The variant members for a value of the type tag.
247 # @case: a value of the type tag.
249 # @type: the name of the object type that provides the variant members
250 # when the type tag has value @case.
254 { 'struct': 'SchemaInfoObjectVariant',
255 'data': { 'case': 'str', 'type': 'str' } }
258 # @SchemaInfoAlternate:
260 # Additional SchemaInfo members for meta-type 'alternate'.
262 # @members: the alternate type's members, in no particular order. The
263 # members' wire encoding is distinct, see
264 # :doc:`/devel/qapi-code-gen` section Alternate types.
266 # On the wire, this can be any of the members.
270 { 'struct': 'SchemaInfoAlternate',
271 'data': { 'members': [ 'SchemaInfoAlternateMember' ] } }
274 # @SchemaInfoAlternateMember:
276 # An alternate member.
278 # @type: the name of the member's type.
282 { 'struct': 'SchemaInfoAlternateMember',
283 'data': { 'type': 'str' } }
286 # @SchemaInfoCommand:
288 # Additional SchemaInfo members for meta-type 'command'.
290 # @arg-type: the name of the object type that provides the command's
293 # @ret-type: the name of the command's result type.
295 # @allow-oob: whether the command allows out-of-band execution,
296 # defaults to false (Since: 2.12)
298 # TODO: @success-response (currently irrelevant, because it's QGA, not
303 { 'struct': 'SchemaInfoCommand',
304 'data': { 'arg-type': 'str', 'ret-type': 'str',
305 '*allow-oob': 'bool' } }
310 # Additional SchemaInfo members for meta-type 'event'.
312 # @arg-type: the name of the object type that provides the event's
317 { 'struct': 'SchemaInfoEvent',
318 'data': { 'arg-type': 'str' } }