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 # Furthermore, while we strive to keep the QMP wire format
26 # backwards-compatible across qemu versions, the introspection output
27 # is not guaranteed to have the same stability. For example, one
28 # version of qemu may list an object member as an optional
29 # non-variant, while another lists the same member only through the
30 # object's variants; or the type of a member may change from a generic
31 # string into a specific enum or from one specific type into an
32 # alternate that includes the original type alongside something else.
34 # Returns: array of @SchemaInfo, where each element describes an
35 # entity in the ABI: command, event, type, ...
37 # The order of the various SchemaInfo is unspecified; however, all
38 # names are guaranteed to be unique (no name will be duplicated with
39 # different meta-types).
41 # Note: the QAPI schema is also used to help define *internal*
42 # interfaces, by defining QAPI types. These are not part of the QMP
43 # wire ABI, and therefore not returned by this command.
47 { 'command': 'query-qmp-schema',
48 'returns': [ 'SchemaInfo' ],
49 'gen': false } # just to simplify qmp_query_json()
54 # This is a @SchemaInfo's meta type, i.e. the kind of entity it
57 # @builtin: a predefined type such as 'int' or 'bool'.
59 # @enum: an enumeration type
61 # @array: an array type
63 # @object: an object type (struct or union)
65 # @alternate: an alternate type
67 # @command: a QMP command
73 { 'enum': 'SchemaMetaType',
74 'data': [ 'builtin', 'enum', 'array', 'object', 'alternate',
75 'command', 'event' ] }
80 # Members common to any @SchemaInfo.
84 { 'struct': 'SchemaInfoBase',
85 'data': { 'name': 'str', 'meta-type': 'SchemaMetaType' } }
90 # @name: the entity's name, inherited from @base.
91 # Commands and events have the name defined in the QAPI schema.
92 # Unlike command and event names, type names are not part of
93 # the wire ABI. Consequently, type names are meaningless
94 # strings here, although they are still guaranteed unique
95 # regardless of @meta-type.
97 # All references to other SchemaInfo are by name.
99 # @meta-type: the entity's meta type, inherited from @base.
101 # Additional members depend on the value of @meta-type.
105 { 'union': 'SchemaInfo',
106 'base': 'SchemaInfoBase',
107 'discriminator': 'meta-type',
109 'builtin': 'SchemaInfoBuiltin',
110 'enum': 'SchemaInfoEnum',
111 'array': 'SchemaInfoArray',
112 'object': 'SchemaInfoObject',
113 'alternate': 'SchemaInfoAlternate',
114 'command': 'SchemaInfoCommand',
115 'event': 'SchemaInfoEvent' } }
120 # Additional SchemaInfo members for meta-type 'builtin'.
122 # @json-type: the JSON type used for this type on the wire.
126 { 'struct': 'SchemaInfoBuiltin',
127 'data': { 'json-type': 'JSONType' } }
132 # The four primitive and two structured types according to RFC 7159
133 # section 1, plus 'int' (split off 'number'), plus the obvious top
138 { 'enum': 'JSONType',
139 'data': [ 'string', 'number', 'int', 'boolean', 'null',
140 'object', 'array', 'value' ] }
145 # Additional SchemaInfo members for meta-type 'enum'.
147 # @values: the enumeration type's values, in no particular order.
149 # Values of this type are JSON string on the wire.
153 { 'struct': 'SchemaInfoEnum',
154 'data': { 'values': ['str'] } }
159 # Additional SchemaInfo members for meta-type 'array'.
161 # @element-type: the array type's element type.
163 # Values of this type are JSON array on the wire.
167 { 'struct': 'SchemaInfoArray',
168 'data': { 'element-type': 'str' } }
173 # Additional SchemaInfo members for meta-type 'object'.
175 # @members: the object type's (non-variant) members, in no particular order.
177 # @tag: #optional the name of the member serving as type tag.
178 # An element of @members with this name must exist.
180 # @variants: #optional variant members, i.e. additional members that
181 # depend on the type tag's value. Present exactly when
182 # @tag is present. The variants are in no particular order,
183 # and may even differ from the order of the values of the
184 # enum type of the @tag.
186 # Values of this type are JSON object on the wire.
190 { 'struct': 'SchemaInfoObject',
191 'data': { 'members': [ 'SchemaInfoObjectMember' ],
193 '*variants': [ 'SchemaInfoObjectVariant' ] } }
196 # @SchemaInfoObjectMember
200 # @name: the member's name, as defined in the QAPI schema.
202 # @type: the name of the member's type.
204 # @default: #optional default when used as command parameter.
205 # If absent, the parameter is mandatory.
206 # If present, the value must be null. The parameter is
207 # optional, and behavior when it's missing is not specified
209 # Future extension: if present and non-null, the parameter
210 # is optional, and defaults to this value.
214 { 'struct': 'SchemaInfoObjectMember',
215 'data': { 'name': 'str', 'type': 'str', '*default': 'any' } }
216 # @default's type must be null or match @type
219 # @SchemaInfoObjectVariant
221 # The variant members for a value of the type tag.
223 # @case: a value of the type tag.
225 # @type: the name of the object type that provides the variant members
226 # when the type tag has value @case.
230 { 'struct': 'SchemaInfoObjectVariant',
231 'data': { 'case': 'str', 'type': 'str' } }
234 # @SchemaInfoAlternate
236 # Additional SchemaInfo members for meta-type 'alternate'.
238 # @members: the alternate type's members, in no particular order.
239 # The members' wire encoding is distinct, see
240 # docs/qapi-code-gen.txt section Alternate types.
242 # On the wire, this can be any of the members.
246 { 'struct': 'SchemaInfoAlternate',
247 'data': { 'members': [ 'SchemaInfoAlternateMember' ] } }
250 # @SchemaInfoAlternateMember
252 # An alternate member.
254 # @type: the name of the member's type.
258 { 'struct': 'SchemaInfoAlternateMember',
259 'data': { 'type': 'str' } }
264 # Additional SchemaInfo members for meta-type 'command'.
266 # @arg-type: the name of the object type that provides the command's
269 # @ret-type: the name of the command's result type.
271 # TODO @success-response (currently irrelevant, because it's QGA, not QMP)
275 { 'struct': 'SchemaInfoCommand',
276 'data': { 'arg-type': 'str', 'ret-type': 'str' } }
281 # Additional SchemaInfo members for meta-type 'event'.
283 # @arg-type: the name of the object type that provides the event's
288 { 'struct': 'SchemaInfoEvent',
289 'data': { 'arg-type': 'str' } }