]>
Commit | Line | Data |
---|---|---|
39a18158 MA |
1 | # -*- Mode: Python -*- |
2 | # | |
3 | # QAPI/QMP introspection | |
4 | # | |
5 | # Copyright (C) 2015 Red Hat, Inc. | |
6 | # | |
7 | # Authors: | |
8 | # Markus Armbruster <[email protected]> | |
9 | # | |
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. | |
12 | ||
13 | ## | |
14 | # @query-qmp-schema | |
15 | # | |
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. | |
19 | # | |
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 | |
23 | # the QAPI schema. | |
24 | # | |
39a65e2c EB |
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. | |
33 | # | |
39a18158 MA |
34 | # Returns: array of @SchemaInfo, where each element describes an |
35 | # entity in the ABI: command, event, type, ... | |
36 | # | |
f5455044 EB |
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). | |
40 | # | |
39a18158 MA |
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. | |
44 | # | |
45 | # Since: 2.5 | |
46 | ## | |
47 | { 'command': 'query-qmp-schema', | |
48 | 'returns': [ 'SchemaInfo' ], | |
49 | 'gen': false } # just to simplify qmp_query_json() | |
50 | ||
51 | ## | |
52 | # @SchemaMetaType | |
53 | # | |
54 | # This is a @SchemaInfo's meta type, i.e. the kind of entity it | |
55 | # describes. | |
56 | # | |
57 | # @builtin: a predefined type such as 'int' or 'bool'. | |
58 | # | |
59 | # @enum: an enumeration type | |
60 | # | |
61 | # @array: an array type | |
62 | # | |
63 | # @object: an object type (struct or union) | |
64 | # | |
65 | # @alternate: an alternate type | |
66 | # | |
67 | # @command: a QMP command | |
68 | # | |
69 | # @event: a QMP event | |
70 | # | |
71 | # Since: 2.5 | |
72 | ## | |
73 | { 'enum': 'SchemaMetaType', | |
74 | 'data': [ 'builtin', 'enum', 'array', 'object', 'alternate', | |
75 | 'command', 'event' ] } | |
76 | ||
77 | ## | |
78 | # @SchemaInfoBase | |
79 | # | |
80 | # Members common to any @SchemaInfo. | |
81 | # | |
82 | # Since: 2.5 | |
83 | ## | |
84 | { 'struct': 'SchemaInfoBase', | |
85 | 'data': { 'name': 'str', 'meta-type': 'SchemaMetaType' } } | |
86 | ||
87 | ## | |
88 | # @SchemaInfo | |
89 | # | |
90 | # @name: the entity's name, inherited from @base. | |
1a9a507b MA |
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 | |
f5455044 EB |
94 | # strings here, although they are still guaranteed unique |
95 | # regardless of @meta-type. | |
39a18158 MA |
96 | # |
97 | # All references to other SchemaInfo are by name. | |
98 | # | |
39a18158 MA |
99 | # @meta-type: the entity's meta type, inherited from @base. |
100 | # | |
101 | # Additional members depend on the value of @meta-type. | |
102 | # | |
103 | # Since: 2.5 | |
104 | ## | |
105 | { 'union': 'SchemaInfo', | |
106 | 'base': 'SchemaInfoBase', | |
107 | 'discriminator': 'meta-type', | |
108 | 'data': { | |
109 | 'builtin': 'SchemaInfoBuiltin', | |
110 | 'enum': 'SchemaInfoEnum', | |
111 | 'array': 'SchemaInfoArray', | |
112 | 'object': 'SchemaInfoObject', | |
113 | 'alternate': 'SchemaInfoAlternate', | |
114 | 'command': 'SchemaInfoCommand', | |
115 | 'event': 'SchemaInfoEvent' } } | |
116 | ||
117 | ## | |
118 | # @SchemaInfoBuiltin | |
119 | # | |
120 | # Additional SchemaInfo members for meta-type 'builtin'. | |
121 | # | |
122 | # @json-type: the JSON type used for this type on the wire. | |
123 | # | |
124 | # Since: 2.5 | |
125 | ## | |
126 | { 'struct': 'SchemaInfoBuiltin', | |
127 | 'data': { 'json-type': 'JSONType' } } | |
128 | ||
129 | ## | |
130 | # @JSONType | |
131 | # | |
132 | # The four primitive and two structured types according to RFC 7159 | |
133 | # section 1, plus 'int' (split off 'number'), plus the obvious top | |
134 | # type 'value'. | |
135 | # | |
136 | # Since: 2.5 | |
137 | ## | |
138 | { 'enum': 'JSONType', | |
139 | 'data': [ 'string', 'number', 'int', 'boolean', 'null', | |
140 | 'object', 'array', 'value' ] } | |
141 | ||
142 | ## | |
143 | # @SchemaInfoEnum | |
144 | # | |
145 | # Additional SchemaInfo members for meta-type 'enum'. | |
146 | # | |
f5455044 | 147 | # @values: the enumeration type's values, in no particular order. |
39a18158 MA |
148 | # |
149 | # Values of this type are JSON string on the wire. | |
150 | # | |
151 | # Since: 2.5 | |
152 | ## | |
153 | { 'struct': 'SchemaInfoEnum', | |
154 | 'data': { 'values': ['str'] } } | |
155 | ||
156 | ## | |
157 | # @SchemaInfoArray | |
158 | # | |
159 | # Additional SchemaInfo members for meta-type 'array'. | |
160 | # | |
161 | # @element-type: the array type's element type. | |
162 | # | |
163 | # Values of this type are JSON array on the wire. | |
164 | # | |
165 | # Since: 2.5 | |
166 | ## | |
167 | { 'struct': 'SchemaInfoArray', | |
168 | 'data': { 'element-type': 'str' } } | |
169 | ||
170 | ## | |
171 | # @SchemaInfoObject | |
172 | # | |
173 | # Additional SchemaInfo members for meta-type 'object'. | |
174 | # | |
f5455044 | 175 | # @members: the object type's (non-variant) members, in no particular order. |
39a18158 MA |
176 | # |
177 | # @tag: #optional the name of the member serving as type tag. | |
178 | # An element of @members with this name must exist. | |
179 | # | |
180 | # @variants: #optional variant members, i.e. additional members that | |
181 | # depend on the type tag's value. Present exactly when | |
f5455044 EB |
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. | |
39a18158 MA |
185 | # |
186 | # Values of this type are JSON object on the wire. | |
187 | # | |
188 | # Since: 2.5 | |
189 | ## | |
190 | { 'struct': 'SchemaInfoObject', | |
191 | 'data': { 'members': [ 'SchemaInfoObjectMember' ], | |
192 | '*tag': 'str', | |
193 | '*variants': [ 'SchemaInfoObjectVariant' ] } } | |
194 | ||
195 | ## | |
196 | # @SchemaInfoObjectMember | |
197 | # | |
198 | # An object member. | |
199 | # | |
200 | # @name: the member's name, as defined in the QAPI schema. | |
201 | # | |
202 | # @type: the name of the member's type. | |
203 | # | |
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 | |
208 | # here. | |
209 | # Future extension: if present and non-null, the parameter | |
210 | # is optional, and defaults to this value. | |
211 | # | |
212 | # Since: 2.5 | |
213 | ## | |
214 | { 'struct': 'SchemaInfoObjectMember', | |
215 | 'data': { 'name': 'str', 'type': 'str', '*default': 'any' } } | |
216 | # @default's type must be null or match @type | |
217 | ||
218 | ## | |
219 | # @SchemaInfoObjectVariant | |
220 | # | |
221 | # The variant members for a value of the type tag. | |
222 | # | |
223 | # @case: a value of the type tag. | |
224 | # | |
225 | # @type: the name of the object type that provides the variant members | |
226 | # when the type tag has value @case. | |
227 | # | |
228 | # Since: 2.5 | |
229 | ## | |
230 | { 'struct': 'SchemaInfoObjectVariant', | |
231 | 'data': { 'case': 'str', 'type': 'str' } } | |
232 | ||
233 | ## | |
234 | # @SchemaInfoAlternate | |
235 | # | |
236 | # Additional SchemaInfo members for meta-type 'alternate'. | |
237 | # | |
f5455044 | 238 | # @members: the alternate type's members, in no particular order. |
39a18158 MA |
239 | # The members' wire encoding is distinct, see |
240 | # docs/qapi-code-gen.txt section Alternate types. | |
241 | # | |
242 | # On the wire, this can be any of the members. | |
243 | # | |
244 | # Since: 2.5 | |
245 | ## | |
246 | { 'struct': 'SchemaInfoAlternate', | |
247 | 'data': { 'members': [ 'SchemaInfoAlternateMember' ] } } | |
248 | ||
249 | ## | |
250 | # @SchemaInfoAlternateMember | |
251 | # | |
252 | # An alternate member. | |
253 | # | |
254 | # @type: the name of the member's type. | |
255 | # | |
256 | # Since: 2.5 | |
257 | ## | |
258 | { 'struct': 'SchemaInfoAlternateMember', | |
259 | 'data': { 'type': 'str' } } | |
260 | ||
261 | ## | |
262 | # @SchemaInfoCommand | |
263 | # | |
264 | # Additional SchemaInfo members for meta-type 'command'. | |
265 | # | |
266 | # @arg-type: the name of the object type that provides the command's | |
267 | # parameters. | |
268 | # | |
269 | # @ret-type: the name of the command's result type. | |
270 | # | |
271 | # TODO @success-response (currently irrelevant, because it's QGA, not QMP) | |
272 | # | |
273 | # Since: 2.5 | |
274 | ## | |
275 | { 'struct': 'SchemaInfoCommand', | |
276 | 'data': { 'arg-type': 'str', 'ret-type': 'str' } } | |
277 | ||
278 | ## | |
279 | # @SchemaInfoEvent | |
280 | # | |
281 | # Additional SchemaInfo members for meta-type 'event'. | |
282 | # | |
283 | # @arg-type: the name of the object type that provides the event's | |
284 | # parameters. | |
285 | # | |
286 | # Since: 2.5 | |
287 | ## | |
288 | { 'struct': 'SchemaInfoEvent', | |
289 | 'data': { 'arg-type': 'str' } } |