xref: /openbmc/qemu/qapi/introspect.json (revision 77dd098a)
1# -*- Mode: Python -*-
2# vim: filetype=python
3#
4# Copyright (C) 2015 Red Hat, Inc.
5#
6# Authors:
7#  Markus Armbruster <armbru@redhat.com>
8#
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.
11
12##
13# = QMP introspection
14##
15
16##
17# @query-qmp-schema:
18#
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.
22#
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
26# the QAPI schema.
27#
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.
36#
37# Returns: array of @SchemaInfo, where each element describes an
38#     entity in the ABI: command, event, type, ...
39#
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).
43#
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.
47#
48# Since: 2.5
49##
50{ 'command': 'query-qmp-schema',
51  'returns': [ 'SchemaInfo' ],
52  'allow-preconfig': true }
53
54##
55# @SchemaMetaType:
56#
57# This is a @SchemaInfo's meta type, i.e. the kind of entity it
58# describes.
59#
60# @builtin: a predefined type such as 'int' or 'bool'.
61#
62# @enum: an enumeration type
63#
64# @array: an array type
65#
66# @object: an object type (struct or union)
67#
68# @alternate: an alternate type
69#
70# @command: a QMP command
71#
72# @event: a QMP event
73#
74# Since: 2.5
75##
76{ 'enum': 'SchemaMetaType',
77  'data': [ 'builtin', 'enum', 'array', 'object', 'alternate',
78            'command', 'event' ] }
79
80##
81# @SchemaInfo:
82#
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.
89#
90# @meta-type: the entity's meta type, inherited from @base.
91#
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)
95#
96# Since: 2.5
97##
98{ 'union': 'SchemaInfo',
99  'base': { 'name': 'str', 'meta-type': 'SchemaMetaType',
100            '*features': [ 'str' ] },
101  'discriminator': 'meta-type',
102  'data': {
103      'builtin': 'SchemaInfoBuiltin',
104      'enum': 'SchemaInfoEnum',
105      'array': 'SchemaInfoArray',
106      'object': 'SchemaInfoObject',
107      'alternate': 'SchemaInfoAlternate',
108      'command': 'SchemaInfoCommand',
109      'event': 'SchemaInfoEvent' } }
110
111##
112# @SchemaInfoBuiltin:
113#
114# Additional SchemaInfo members for meta-type 'builtin'.
115#
116# @json-type: the JSON type used for this type on the wire.
117#
118# Since: 2.5
119##
120{ 'struct': 'SchemaInfoBuiltin',
121  'data': { 'json-type': 'JSONType' } }
122
123##
124# @JSONType:
125#
126# The four primitive and two structured types according to RFC 8259
127# section 1, plus 'int' (split off 'number'), plus the obvious top
128# type 'value'.
129#
130# @string: JSON string
131#
132# @number: JSON number
133#
134# @int: JSON number that is an integer
135#
136# @boolean: literal ``false`` or ``true``
137#
138# @null: literal ``null``
139#
140# @object: JSON object
141#
142# @array: JSON array
143#
144# @value: any JSON value
145#
146# Since: 2.5
147##
148{ 'enum': 'JSONType',
149  'data': [ 'string', 'number', 'int', 'boolean', 'null',
150            'object', 'array', 'value' ] }
151
152##
153# @SchemaInfoEnum:
154#
155# Additional SchemaInfo members for meta-type 'enum'.
156#
157# @members: the enum type's members, in no particular order (since
158#     6.2).
159#
160# @values: the enumeration type's member names, in no particular
161#     order.  Redundant with @members.  Just for backward
162#     compatibility.
163#
164# Features:
165#
166# @deprecated: Member @values is deprecated.  Use @members instead.
167#
168# Values of this type are JSON string on the wire.
169#
170# Since: 2.5
171##
172{ 'struct': 'SchemaInfoEnum',
173  'data': { 'members': [ 'SchemaInfoEnumMember' ],
174            'values': { 'type': [ 'str' ],
175                        'features': [ 'deprecated' ] } } }
176
177##
178# @SchemaInfoEnumMember:
179#
180# An object member.
181#
182# @name: the member's name, as defined in the QAPI schema.
183#
184# @features: names of features associated with the member, in no
185#     particular order.
186#
187# Since: 6.2
188##
189{ 'struct': 'SchemaInfoEnumMember',
190  'data': { 'name': 'str', '*features': [ 'str' ] } }
191
192##
193# @SchemaInfoArray:
194#
195# Additional SchemaInfo members for meta-type 'array'.
196#
197# @element-type: the array type's element type.
198#
199# Values of this type are JSON array on the wire.
200#
201# Since: 2.5
202##
203{ 'struct': 'SchemaInfoArray',
204  'data': { 'element-type': 'str' } }
205
206##
207# @SchemaInfoObject:
208#
209# Additional SchemaInfo members for meta-type 'object'.
210#
211# @members: the object type's (non-variant) members, in no particular
212#     order.
213#
214# @tag: the name of the member serving as type tag.  An element of
215#     @members with this name must exist.
216#
217# @variants: variant members, i.e. additional members that depend on
218#     the type tag's value.  Present exactly when @tag is present.
219#     The variants are in no particular order, and may even differ
220#     from the order of the values of the enum type of the @tag.
221#
222# Values of this type are JSON object on the wire.
223#
224# Since: 2.5
225##
226{ 'struct': 'SchemaInfoObject',
227  'data': { 'members': [ 'SchemaInfoObjectMember' ],
228            '*tag': 'str',
229            '*variants': [ 'SchemaInfoObjectVariant' ] } }
230
231##
232# @SchemaInfoObjectMember:
233#
234# An object member.
235#
236# @name: the member's name, as defined in the QAPI schema.
237#
238# @type: the name of the member's type.
239#
240# @default: default when used as command parameter.  If absent, the
241#     parameter is mandatory.  If present, the value must be null.
242#     The parameter is optional, and behavior when it's missing is not
243#     specified here.  Future extension: if present and non-null, the
244#     parameter is optional, and defaults to this value.
245#
246# @features: names of features associated with the member, in no
247#     particular order.  (since 5.0)
248#
249# Since: 2.5
250##
251{ 'struct': 'SchemaInfoObjectMember',
252  'data': { 'name': 'str', 'type': 'str', '*default': 'any',
253# @default's type must be null or match @type
254            '*features': [ 'str' ] } }
255
256##
257# @SchemaInfoObjectVariant:
258#
259# The variant members for a value of the type tag.
260#
261# @case: a value of the type tag.
262#
263# @type: the name of the object type that provides the variant members
264#     when the type tag has value @case.
265#
266# Since: 2.5
267##
268{ 'struct': 'SchemaInfoObjectVariant',
269  'data': { 'case': 'str', 'type': 'str' } }
270
271##
272# @SchemaInfoAlternate:
273#
274# Additional SchemaInfo members for meta-type 'alternate'.
275#
276# @members: the alternate type's members, in no particular order.  The
277#     members' wire encoding is distinct, see
278#     :doc:`/devel/qapi-code-gen` section Alternate types.
279#
280# On the wire, this can be any of the members.
281#
282# Since: 2.5
283##
284{ 'struct': 'SchemaInfoAlternate',
285  'data': { 'members': [ 'SchemaInfoAlternateMember' ] } }
286
287##
288# @SchemaInfoAlternateMember:
289#
290# An alternate member.
291#
292# @type: the name of the member's type.
293#
294# Since: 2.5
295##
296{ 'struct': 'SchemaInfoAlternateMember',
297  'data': { 'type': 'str' } }
298
299##
300# @SchemaInfoCommand:
301#
302# Additional SchemaInfo members for meta-type 'command'.
303#
304# @arg-type: the name of the object type that provides the command's
305#     parameters.
306#
307# @ret-type: the name of the command's result type.
308#
309# @allow-oob: whether the command allows out-of-band execution,
310#     defaults to false (Since: 2.12)
311#
312# TODO: @success-response (currently irrelevant, because it's QGA, not
313#     QMP)
314#
315# Since: 2.5
316##
317{ 'struct': 'SchemaInfoCommand',
318  'data': { 'arg-type': 'str', 'ret-type': 'str',
319            '*allow-oob': 'bool' } }
320
321##
322# @SchemaInfoEvent:
323#
324# Additional SchemaInfo members for meta-type 'event'.
325#
326# @arg-type: the name of the object type that provides the event's
327#     parameters.
328#
329# Since: 2.5
330##
331{ 'struct': 'SchemaInfoEvent',
332  'data': { 'arg-type': 'str' } }
333