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