Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 1 | # -*- Mode: Python -*- |
| 2 | # |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 3 | # Copyright (C) 2015 Red Hat, Inc. |
| 4 | # |
| 5 | # Authors: |
| 6 | # Markus Armbruster <armbru@redhat.com> |
| 7 | # |
| 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. |
| 10 | |
| 11 | ## |
Markus Armbruster | a885cd3 | 2017-08-24 21:13:54 +0200 | [diff] [blame] | 12 | # = QMP introspection |
| 13 | ## |
| 14 | |
| 15 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 16 | # @query-qmp-schema: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 17 | # |
| 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. |
| 21 | # |
| 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 |
| 25 | # the QAPI schema. |
| 26 | # |
Eric Blake | 39a65e2 | 2015-11-11 10:50:02 -0700 | [diff] [blame] | 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. |
| 35 | # |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 36 | # Returns: array of @SchemaInfo, where each element describes an |
| 37 | # entity in the ABI: command, event, type, ... |
| 38 | # |
Eric Blake | f545504 | 2015-11-05 23:35:36 -0700 | [diff] [blame] | 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). |
| 42 | # |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 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. |
| 46 | # |
| 47 | # Since: 2.5 |
| 48 | ## |
| 49 | { 'command': 'query-qmp-schema', |
| 50 | 'returns': [ 'SchemaInfo' ], |
| 51 | 'gen': false } # just to simplify qmp_query_json() |
| 52 | |
| 53 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 54 | # @SchemaMetaType: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 55 | # |
| 56 | # This is a @SchemaInfo's meta type, i.e. the kind of entity it |
| 57 | # describes. |
| 58 | # |
| 59 | # @builtin: a predefined type such as 'int' or 'bool'. |
| 60 | # |
| 61 | # @enum: an enumeration type |
| 62 | # |
| 63 | # @array: an array type |
| 64 | # |
| 65 | # @object: an object type (struct or union) |
| 66 | # |
| 67 | # @alternate: an alternate type |
| 68 | # |
| 69 | # @command: a QMP command |
| 70 | # |
| 71 | # @event: a QMP event |
| 72 | # |
| 73 | # Since: 2.5 |
| 74 | ## |
| 75 | { 'enum': 'SchemaMetaType', |
| 76 | 'data': [ 'builtin', 'enum', 'array', 'object', 'alternate', |
| 77 | 'command', 'event' ] } |
| 78 | |
| 79 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 80 | # @SchemaInfo: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 81 | # |
| 82 | # @name: the entity's name, inherited from @base. |
Marc-André Lureau | 5807ff8 | 2017-01-13 15:41:21 +0100 | [diff] [blame] | 83 | # The SchemaInfo is always referenced by this name. |
Markus Armbruster | 1a9a507 | 2015-09-16 13:06:29 +0200 | [diff] [blame] | 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 |
Eric Blake | f545504 | 2015-11-05 23:35:36 -0700 | [diff] [blame] | 87 | # strings here, although they are still guaranteed unique |
| 88 | # regardless of @meta-type. |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 89 | # |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 90 | # @meta-type: the entity's meta type, inherited from @base. |
| 91 | # |
| 92 | # Additional members depend on the value of @meta-type. |
| 93 | # |
| 94 | # Since: 2.5 |
| 95 | ## |
| 96 | { 'union': 'SchemaInfo', |
Eric Blake | 3666a97 | 2016-03-17 16:48:40 -0600 | [diff] [blame] | 97 | 'base': { 'name': 'str', 'meta-type': 'SchemaMetaType' }, |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 98 | 'discriminator': 'meta-type', |
| 99 | 'data': { |
| 100 | 'builtin': 'SchemaInfoBuiltin', |
| 101 | 'enum': 'SchemaInfoEnum', |
| 102 | 'array': 'SchemaInfoArray', |
| 103 | 'object': 'SchemaInfoObject', |
| 104 | 'alternate': 'SchemaInfoAlternate', |
| 105 | 'command': 'SchemaInfoCommand', |
| 106 | 'event': 'SchemaInfoEvent' } } |
| 107 | |
| 108 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 109 | # @SchemaInfoBuiltin: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 110 | # |
| 111 | # Additional SchemaInfo members for meta-type 'builtin'. |
| 112 | # |
| 113 | # @json-type: the JSON type used for this type on the wire. |
| 114 | # |
| 115 | # Since: 2.5 |
| 116 | ## |
| 117 | { 'struct': 'SchemaInfoBuiltin', |
| 118 | 'data': { 'json-type': 'JSONType' } } |
| 119 | |
| 120 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 121 | # @JSONType: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 122 | # |
Markus Armbruster | 37aded9 | 2018-08-23 18:40:25 +0200 | [diff] [blame] | 123 | # The four primitive and two structured types according to RFC 8259 |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 124 | # section 1, plus 'int' (split off 'number'), plus the obvious top |
| 125 | # type 'value'. |
| 126 | # |
| 127 | # Since: 2.5 |
| 128 | ## |
| 129 | { 'enum': 'JSONType', |
| 130 | 'data': [ 'string', 'number', 'int', 'boolean', 'null', |
| 131 | 'object', 'array', 'value' ] } |
| 132 | |
| 133 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 134 | # @SchemaInfoEnum: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 135 | # |
| 136 | # Additional SchemaInfo members for meta-type 'enum'. |
| 137 | # |
Eric Blake | f545504 | 2015-11-05 23:35:36 -0700 | [diff] [blame] | 138 | # @values: the enumeration type's values, in no particular order. |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 139 | # |
| 140 | # Values of this type are JSON string on the wire. |
| 141 | # |
| 142 | # Since: 2.5 |
| 143 | ## |
| 144 | { 'struct': 'SchemaInfoEnum', |
| 145 | 'data': { 'values': ['str'] } } |
| 146 | |
| 147 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 148 | # @SchemaInfoArray: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 149 | # |
| 150 | # Additional SchemaInfo members for meta-type 'array'. |
| 151 | # |
| 152 | # @element-type: the array type's element type. |
| 153 | # |
| 154 | # Values of this type are JSON array on the wire. |
| 155 | # |
| 156 | # Since: 2.5 |
| 157 | ## |
| 158 | { 'struct': 'SchemaInfoArray', |
| 159 | 'data': { 'element-type': 'str' } } |
| 160 | |
| 161 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 162 | # @SchemaInfoObject: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 163 | # |
| 164 | # Additional SchemaInfo members for meta-type 'object'. |
| 165 | # |
Eric Blake | f545504 | 2015-11-05 23:35:36 -0700 | [diff] [blame] | 166 | # @members: the object type's (non-variant) members, in no particular order. |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 167 | # |
Markus Armbruster | 1d8bda1 | 2017-03-15 13:57:06 +0100 | [diff] [blame] | 168 | # @tag: the name of the member serving as type tag. |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 169 | # An element of @members with this name must exist. |
| 170 | # |
Markus Armbruster | 1d8bda1 | 2017-03-15 13:57:06 +0100 | [diff] [blame] | 171 | # @variants: variant members, i.e. additional members that |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 172 | # depend on the type tag's value. Present exactly when |
Eric Blake | f545504 | 2015-11-05 23:35:36 -0700 | [diff] [blame] | 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. |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 176 | # |
| 177 | # Values of this type are JSON object on the wire. |
| 178 | # |
| 179 | # Since: 2.5 |
| 180 | ## |
| 181 | { 'struct': 'SchemaInfoObject', |
| 182 | 'data': { 'members': [ 'SchemaInfoObjectMember' ], |
| 183 | '*tag': 'str', |
| 184 | '*variants': [ 'SchemaInfoObjectVariant' ] } } |
| 185 | |
| 186 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 187 | # @SchemaInfoObjectMember: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 188 | # |
| 189 | # An object member. |
| 190 | # |
| 191 | # @name: the member's name, as defined in the QAPI schema. |
| 192 | # |
| 193 | # @type: the name of the member's type. |
| 194 | # |
Markus Armbruster | 1d8bda1 | 2017-03-15 13:57:06 +0100 | [diff] [blame] | 195 | # @default: default when used as command parameter. |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 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 |
| 199 | # here. |
| 200 | # Future extension: if present and non-null, the parameter |
| 201 | # is optional, and defaults to this value. |
| 202 | # |
| 203 | # Since: 2.5 |
| 204 | ## |
| 205 | { 'struct': 'SchemaInfoObjectMember', |
| 206 | 'data': { 'name': 'str', 'type': 'str', '*default': 'any' } } |
| 207 | # @default's type must be null or match @type |
| 208 | |
| 209 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 210 | # @SchemaInfoObjectVariant: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 211 | # |
| 212 | # The variant members for a value of the type tag. |
| 213 | # |
| 214 | # @case: a value of the type tag. |
| 215 | # |
| 216 | # @type: the name of the object type that provides the variant members |
| 217 | # when the type tag has value @case. |
| 218 | # |
| 219 | # Since: 2.5 |
| 220 | ## |
| 221 | { 'struct': 'SchemaInfoObjectVariant', |
| 222 | 'data': { 'case': 'str', 'type': 'str' } } |
| 223 | |
| 224 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 225 | # @SchemaInfoAlternate: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 226 | # |
| 227 | # Additional SchemaInfo members for meta-type 'alternate'. |
| 228 | # |
Eric Blake | f545504 | 2015-11-05 23:35:36 -0700 | [diff] [blame] | 229 | # @members: the alternate type's members, in no particular order. |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 230 | # The members' wire encoding is distinct, see |
Philippe Mathieu-Daudé | b3125e7 | 2017-07-28 19:46:03 -0300 | [diff] [blame] | 231 | # docs/devel/qapi-code-gen.txt section Alternate types. |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 232 | # |
| 233 | # On the wire, this can be any of the members. |
| 234 | # |
| 235 | # Since: 2.5 |
| 236 | ## |
| 237 | { 'struct': 'SchemaInfoAlternate', |
| 238 | 'data': { 'members': [ 'SchemaInfoAlternateMember' ] } } |
| 239 | |
| 240 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 241 | # @SchemaInfoAlternateMember: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 242 | # |
| 243 | # An alternate member. |
| 244 | # |
| 245 | # @type: the name of the member's type. |
| 246 | # |
| 247 | # Since: 2.5 |
| 248 | ## |
| 249 | { 'struct': 'SchemaInfoAlternateMember', |
| 250 | 'data': { 'type': 'str' } } |
| 251 | |
| 252 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 253 | # @SchemaInfoCommand: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 254 | # |
| 255 | # Additional SchemaInfo members for meta-type 'command'. |
| 256 | # |
| 257 | # @arg-type: the name of the object type that provides the command's |
| 258 | # parameters. |
| 259 | # |
| 260 | # @ret-type: the name of the command's result type. |
| 261 | # |
Markus Armbruster | 25b1ef3 | 2018-07-18 11:05:57 +0200 | [diff] [blame] | 262 | # @allow-oob: whether the command allows out-of-band execution, |
| 263 | # defaults to false (Since: 2.12) |
Peter Xu | 876c675 | 2018-03-09 17:00:00 +0800 | [diff] [blame] | 264 | # |
Marc-André Lureau | e22da43 | 2017-01-13 15:41:17 +0100 | [diff] [blame] | 265 | # TODO: @success-response (currently irrelevant, because it's QGA, not QMP) |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 266 | # |
| 267 | # Since: 2.5 |
| 268 | ## |
| 269 | { 'struct': 'SchemaInfoCommand', |
Peter Xu | 876c675 | 2018-03-09 17:00:00 +0800 | [diff] [blame] | 270 | 'data': { 'arg-type': 'str', 'ret-type': 'str', |
Markus Armbruster | 25b1ef3 | 2018-07-18 11:05:57 +0200 | [diff] [blame] | 271 | '*allow-oob': 'bool' } } |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 272 | |
| 273 | ## |
Marc-André Lureau | 5072f7b | 2016-11-17 19:54:55 +0400 | [diff] [blame] | 274 | # @SchemaInfoEvent: |
Markus Armbruster | 39a1815 | 2015-09-16 13:06:28 +0200 | [diff] [blame] | 275 | # |
| 276 | # Additional SchemaInfo members for meta-type 'event'. |
| 277 | # |
| 278 | # @arg-type: the name of the object type that provides the event's |
| 279 | # parameters. |
| 280 | # |
| 281 | # Since: 2.5 |
| 282 | ## |
| 283 | { 'struct': 'SchemaInfoEvent', |
| 284 | 'data': { 'arg-type': 'str' } } |