1*42b633dbSJohn Snow====================== 2*42b633dbSJohn SnowThe Sphinx QAPI Domain 3*42b633dbSJohn Snow====================== 4*42b633dbSJohn Snow 5*42b633dbSJohn SnowAn extension to the `rST syntax 6*42b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html>`_ 7*42b633dbSJohn Snowin Sphinx is provided by the QAPI Domain, located in 8*42b633dbSJohn Snow``docs/sphinx/qapi_domain.py``. This extension is analogous to the 9*42b633dbSJohn Snow`Python Domain 10*42b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/domains/python.html>`_ 11*42b633dbSJohn Snowincluded with Sphinx, but provides special directives and roles 12*42b633dbSJohn Snowspeciically for annotating and documenting QAPI definitions 13*42b633dbSJohn Snowspecifically. 14*42b633dbSJohn Snow 15*42b633dbSJohn SnowA `Domain 16*42b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/domains/index.html>`_ 17*42b633dbSJohn Snowprovides a set of special rST directives and cross-referencing roles to 18*42b633dbSJohn SnowSphinx for understanding rST markup written to document a specific 19*42b633dbSJohn Snowlanguage. By itself, this QAPI extension is only sufficient to parse rST 20*42b633dbSJohn Snowmarkup written by hand; the `autodoc 21*42b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html>`_ 22*42b633dbSJohn Snowfunctionality is provided elsewhere, in ``docs/sphinx/qapidoc.py``, by 23*42b633dbSJohn Snowthe "Transmogrifier". 24*42b633dbSJohn Snow 25*42b633dbSJohn SnowIt is not expected that any developer nor documentation writer would 26*42b633dbSJohn Snownever need to write *nor* read these special rST forms. However, in the 27*42b633dbSJohn Snowevent that something needs to be debugged, knowing the syntax of the 28*42b633dbSJohn Snowdomain is quite handy. This reference may also be useful as a guide for 29*42b633dbSJohn Snowunderstanding the QAPI Domain extension code itself. Although most of 30*42b633dbSJohn Snowthese forms will not be needed for documentation writing purposes, 31*42b633dbSJohn Snowunderstanding the cross-referencing syntax *will* be helpful when 32*42b633dbSJohn Snowwriting rST documentation elsewhere, or for enriching the body of 33*42b633dbSJohn SnowQAPIDoc blocks themselves. 34*42b633dbSJohn Snow 35*42b633dbSJohn Snow 36*42b633dbSJohn SnowConcepts 37*42b633dbSJohn Snow======== 38*42b633dbSJohn Snow 39*42b633dbSJohn SnowThe QAPI Domain itself provides no mechanisms for reading the QAPI 40*42b633dbSJohn SnowSchema or generating documentation from code that exists. It is merely 41*42b633dbSJohn Snowthe rST syntax used to describe things. For instance, the Sphinx Python 42*42b633dbSJohn Snowdomain adds syntax like ``:py:func:`` for describing Python functions in 43*42b633dbSJohn Snowdocumentation, but it's the autodoc module that is responsible for 44*42b633dbSJohn Snowreading python code and generating such syntax. QAPI is analagous here: 45*42b633dbSJohn Snowqapidoc.py is responsible for reading the QAPI Schema and generating rST 46*42b633dbSJohn Snowsyntax, and qapi_domain.py is responsible for translating that special 47*42b633dbSJohn Snowsyntax and providing APIs for Sphinx internals. 48*42b633dbSJohn Snow 49*42b633dbSJohn SnowIn other words: 50*42b633dbSJohn Snow 51*42b633dbSJohn Snowqapi_domain.py adds syntax like ``.. qapi:command::`` to Sphinx, and 52*42b633dbSJohn Snowqapidoc.py transforms the documentation in ``qapi/*.json`` into rST 53*42b633dbSJohn Snowusing directives defined by the domain. 54*42b633dbSJohn Snow 55*42b633dbSJohn SnowOr even shorter: 56*42b633dbSJohn Snow 57*42b633dbSJohn Snow``:py:`` is to ``:qapi:`` as *autodoc* is to *qapidoc*. 58*42b633dbSJohn Snow 59*42b633dbSJohn Snow 60*42b633dbSJohn SnowInfo Field Lists 61*42b633dbSJohn Snow================ 62*42b633dbSJohn Snow 63*42b633dbSJohn Snow`Field lists 64*42b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#field-lists>`_ 65*42b633dbSJohn Snoware a standard syntax in reStructuredText. Sphinx `extends that syntax 66*42b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/domains/python.html#info-field-lists>`_ 67*42b633dbSJohn Snowto give certain field list entries special meaning and parsing to, for 68*42b633dbSJohn Snowexample, add cross-references. The QAPI Domain takes advantage of this 69*42b633dbSJohn Snowfield list extension to document things like Arguments, Members, Values, 70*42b633dbSJohn Snowand so on. 71*42b633dbSJohn Snow 72*42b633dbSJohn SnowThe special parsing and handling of info field lists in Sphinx is provided by 73*42b633dbSJohn Snowthree main classes; Field, GroupedField, and TypedField. The behavior 74*42b633dbSJohn Snowand formatting for each configured field list entry in the domain 75*42b633dbSJohn Snowchanges depending on which class is used. 76*42b633dbSJohn Snow 77*42b633dbSJohn SnowField: 78*42b633dbSJohn Snow * Creates an ungrouped field: i.e., each entry will create its own 79*42b633dbSJohn Snow section and they will not be combined. 80*42b633dbSJohn Snow * May *optionally* support an argument. 81*42b633dbSJohn Snow * May apply cross-reference roles to *either* the argument *or* the 82*42b633dbSJohn Snow content body, both, or neither. 83*42b633dbSJohn Snow 84*42b633dbSJohn SnowThis is used primarily for entries which are not expected to be 85*42b633dbSJohn Snowrepeated, i.e., items that may only show up at most once. The QAPI 86*42b633dbSJohn Snowdomain uses this class for "Errors" section. 87*42b633dbSJohn Snow 88*42b633dbSJohn SnowGroupedField: 89*42b633dbSJohn Snow * Creates a grouped field: i.e. multiple adjacent entries will be 90*42b633dbSJohn Snow merged into one section, and the content will form a bulleted list. 91*42b633dbSJohn Snow * *Must* take an argument. 92*42b633dbSJohn Snow * May optionally apply a cross-reference role to the argument, but not 93*42b633dbSJohn Snow the body. 94*42b633dbSJohn Snow * Can be configured to remove the bulleted list if there is only a 95*42b633dbSJohn Snow single entry. 96*42b633dbSJohn Snow * All items will be generated with the form: "argument -- body" 97*42b633dbSJohn Snow 98*42b633dbSJohn SnowThis is used for entries which are expected to be repeated, but aren't 99*42b633dbSJohn Snowexpected to have two arguments, i.e. types without names, or names 100*42b633dbSJohn Snowwithout types. The QAPI domain uses this class for features, returns, 101*42b633dbSJohn Snowand enum values. 102*42b633dbSJohn Snow 103*42b633dbSJohn SnowTypedField: 104*42b633dbSJohn Snow * Creates a grouped, typed field. Multiple adjacent entres will be 105*42b633dbSJohn Snow merged into one section, and the content will form a bulleted list. 106*42b633dbSJohn Snow * *Must* take at least one argument, but supports up to two - 107*42b633dbSJohn Snow nominally, a name and a type. 108*42b633dbSJohn Snow * May optionally apply a cross-reference role to the type or the name 109*42b633dbSJohn Snow argument, but not the body. 110*42b633dbSJohn Snow * Can be configured to remove the bulleted list if there is only a 111*42b633dbSJohn Snow single entry. 112*42b633dbSJohn Snow * All items will be generated with the form "name (type) -- body" 113*42b633dbSJohn Snow 114*42b633dbSJohn SnowThis is used for entries that are expected to be repeated and will have 115*42b633dbSJohn Snowa name, a type, and a description. The QAPI domain uses this class for 116*42b633dbSJohn Snowarguments, alternatives, and members. Wherever type names are referenced 117*42b633dbSJohn Snowbelow, They must be a valid, documented type that will be 118*42b633dbSJohn Snowcross-referenced in the HTML output; or one of the built-in JSON types 119*42b633dbSJohn Snow(string, number, int, boolean, null, value, q_empty). 120*42b633dbSJohn Snow 121*42b633dbSJohn Snow 122*42b633dbSJohn Snow``:feat:`` 123*42b633dbSJohn Snow---------- 124*42b633dbSJohn Snow 125*42b633dbSJohn SnowDocument a feature attached to a QAPI definition. 126*42b633dbSJohn Snow 127*42b633dbSJohn Snow:availability: This field list is available in the body of Command, 128*42b633dbSJohn Snow Event, Enum, Object and Alternate directives. 129*42b633dbSJohn Snow:syntax: ``:feat name: Lorem ipsum, dolor sit amet...`` 130*42b633dbSJohn Snow:type: `sphinx.util.docfields.GroupedField 131*42b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.GroupedField.html?private=1>`_ 132*42b633dbSJohn Snow 133*42b633dbSJohn SnowExample:: 134*42b633dbSJohn Snow 135*42b633dbSJohn Snow .. qapi:object:: BlockdevOptionsVirtioBlkVhostVdpa 136*42b633dbSJohn Snow :since: 7.2 137*42b633dbSJohn Snow :ifcond: CONFIG_BLKIO 138*42b633dbSJohn Snow 139*42b633dbSJohn Snow Driver specific block device options for the virtio-blk-vhost-vdpa 140*42b633dbSJohn Snow backend. 141*42b633dbSJohn Snow 142*42b633dbSJohn Snow :memb string path: path to the vhost-vdpa character device. 143*42b633dbSJohn Snow :feat fdset: Member ``path`` supports the special "/dev/fdset/N" path 144*42b633dbSJohn Snow (since 8.1) 145*42b633dbSJohn Snow 146*42b633dbSJohn Snow 147*42b633dbSJohn Snow``:arg:`` 148*42b633dbSJohn Snow--------- 149*42b633dbSJohn Snow 150*42b633dbSJohn SnowDocument an argument to a QAPI command. 151*42b633dbSJohn Snow 152*42b633dbSJohn Snow:availability: This field list is only available in the body of the 153*42b633dbSJohn Snow Command directive. 154*42b633dbSJohn Snow:syntax: ``:arg type name: description`` 155*42b633dbSJohn Snow:type: `sphinx.util.docfields.TypedField 156*42b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.TypedField.html?private=1>`_ 157*42b633dbSJohn Snow 158*42b633dbSJohn Snow 159*42b633dbSJohn SnowExample:: 160*42b633dbSJohn Snow 161*42b633dbSJohn Snow .. qapi:command:: job-pause 162*42b633dbSJohn Snow :since: 3.0 163*42b633dbSJohn Snow 164*42b633dbSJohn Snow Pause an active job. 165*42b633dbSJohn Snow 166*42b633dbSJohn Snow This command returns immediately after marking the active job for 167*42b633dbSJohn Snow pausing. Pausing an already paused job is an error. 168*42b633dbSJohn Snow 169*42b633dbSJohn Snow The job will pause as soon as possible, which means transitioning 170*42b633dbSJohn Snow into the PAUSED state if it was RUNNING, or into STANDBY if it was 171*42b633dbSJohn Snow READY. The corresponding JOB_STATUS_CHANGE event will be emitted. 172*42b633dbSJohn Snow 173*42b633dbSJohn Snow Cancelling a paused job automatically resumes it. 174*42b633dbSJohn Snow 175*42b633dbSJohn Snow :arg string id: The job identifier. 176*42b633dbSJohn Snow 177*42b633dbSJohn Snow 178*42b633dbSJohn Snow``:error:`` 179*42b633dbSJohn Snow----------- 180*42b633dbSJohn Snow 181*42b633dbSJohn SnowDocument the error condition(s) of a QAPI command. 182*42b633dbSJohn Snow 183*42b633dbSJohn Snow:availability: This field list is only available in the body of the 184*42b633dbSJohn Snow Command directive. 185*42b633dbSJohn Snow:syntax: ``:error: Lorem ipsum dolor sit amet ...`` 186*42b633dbSJohn Snow:type: `sphinx.util.docfields.Field 187*42b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.Field.html?private=1>`_ 188*42b633dbSJohn Snow 189*42b633dbSJohn SnowThe format of the :errors: field list description is free-form rST. The 190*42b633dbSJohn Snowalternative spelling ":errors:" is also permitted, but strictly 191*42b633dbSJohn Snowanalogous. 192*42b633dbSJohn Snow 193*42b633dbSJohn SnowExample:: 194*42b633dbSJohn Snow 195*42b633dbSJohn Snow .. qapi:command:: block-job-set-speed 196*42b633dbSJohn Snow :since: 1.1 197*42b633dbSJohn Snow 198*42b633dbSJohn Snow Set maximum speed for a background block operation. 199*42b633dbSJohn Snow 200*42b633dbSJohn Snow This command can only be issued when there is an active block job. 201*42b633dbSJohn Snow 202*42b633dbSJohn Snow Throttling can be disabled by setting the speed to 0. 203*42b633dbSJohn Snow 204*42b633dbSJohn Snow :arg string device: The job identifier. This used to be a device 205*42b633dbSJohn Snow name (hence the name of the parameter), but since QEMU 2.7 it 206*42b633dbSJohn Snow can have other values. 207*42b633dbSJohn Snow :arg int speed: the maximum speed, in bytes per second, or 0 for 208*42b633dbSJohn Snow unlimited. Defaults to 0. 209*42b633dbSJohn Snow :error: 210*42b633dbSJohn Snow - If no background operation is active on this device, 211*42b633dbSJohn Snow DeviceNotActive 212*42b633dbSJohn Snow 213*42b633dbSJohn Snow 214*42b633dbSJohn Snow``:return:`` 215*42b633dbSJohn Snow------------- 216*42b633dbSJohn Snow 217*42b633dbSJohn SnowDocument the return type(s) and value(s) of a QAPI command. 218*42b633dbSJohn Snow 219*42b633dbSJohn Snow:availability: This field list is only available in the body of the 220*42b633dbSJohn Snow Command directive. 221*42b633dbSJohn Snow:syntax: ``:return type: Lorem ipsum dolor sit amet ...`` 222*42b633dbSJohn Snow:type: `sphinx.util.docfields.GroupedField 223*42b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.GroupedField.html?private=1>`_ 224*42b633dbSJohn Snow 225*42b633dbSJohn Snow 226*42b633dbSJohn SnowExample:: 227*42b633dbSJohn Snow 228*42b633dbSJohn Snow .. qapi:command:: query-replay 229*42b633dbSJohn Snow :since: 5.2 230*42b633dbSJohn Snow 231*42b633dbSJohn Snow Retrieve the record/replay information. It includes current 232*42b633dbSJohn Snow instruction count which may be used for ``replay-break`` and 233*42b633dbSJohn Snow ``replay-seek`` commands. 234*42b633dbSJohn Snow 235*42b633dbSJohn Snow :return ReplayInfo: record/replay information. 236*42b633dbSJohn Snow 237*42b633dbSJohn Snow .. qmp-example:: 238*42b633dbSJohn Snow 239*42b633dbSJohn Snow -> { "execute": "query-replay" } 240*42b633dbSJohn Snow <- { "return": { 241*42b633dbSJohn Snow "mode": "play", "filename": "log.rr", "icount": 220414 } 242*42b633dbSJohn Snow } 243*42b633dbSJohn Snow 244*42b633dbSJohn Snow 245*42b633dbSJohn Snow``:value:`` 246*42b633dbSJohn Snow----------- 247*42b633dbSJohn Snow 248*42b633dbSJohn SnowDocument a possible value for a QAPI enum. 249*42b633dbSJohn Snow 250*42b633dbSJohn Snow:availability: This field list is only available in the body of the Enum 251*42b633dbSJohn Snow directive. 252*42b633dbSJohn Snow:syntax: ``:value name: Lorem ipsum, dolor sit amet ...`` 253*42b633dbSJohn Snow:type: `sphinx.util.docfields.GroupedField 254*42b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.GroupedField.html?private=1>`_ 255*42b633dbSJohn Snow 256*42b633dbSJohn SnowExample:: 257*42b633dbSJohn Snow 258*42b633dbSJohn Snow .. qapi:enum:: QapiErrorClass 259*42b633dbSJohn Snow :since: 1.2 260*42b633dbSJohn Snow 261*42b633dbSJohn Snow QEMU error classes 262*42b633dbSJohn Snow 263*42b633dbSJohn Snow :value GenericError: this is used for errors that don't require a specific 264*42b633dbSJohn Snow error class. This should be the default case for most errors 265*42b633dbSJohn Snow :value CommandNotFound: the requested command has not been found 266*42b633dbSJohn Snow :value DeviceNotActive: a device has failed to be become active 267*42b633dbSJohn Snow :value DeviceNotFound: the requested device has not been found 268*42b633dbSJohn Snow :value KVMMissingCap: the requested operation can't be fulfilled because a 269*42b633dbSJohn Snow required KVM capability is missing 270*42b633dbSJohn Snow 271*42b633dbSJohn Snow 272*42b633dbSJohn Snow``:alt:`` 273*42b633dbSJohn Snow------------ 274*42b633dbSJohn Snow 275*42b633dbSJohn SnowDocument a possible branch for a QAPI alternate. 276*42b633dbSJohn Snow 277*42b633dbSJohn Snow:availability: This field list is only available in the body of the 278*42b633dbSJohn Snow Alternate directive. 279*42b633dbSJohn Snow:syntax: ``:alt type name: Lorem ipsum, dolor sit amet ...`` 280*42b633dbSJohn Snow:type: `sphinx.util.docfields.TypedField 281*42b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.TypedField.html?private=1>`_ 282*42b633dbSJohn Snow 283*42b633dbSJohn SnowAs a limitation of Sphinx, we must document the "name" of the branch in 284*42b633dbSJohn Snowaddition to the type, even though this information is not visible on the 285*42b633dbSJohn Snowwire in the QMP protocol format. This limitation *may* be lifted at a 286*42b633dbSJohn Snowfuture date. 287*42b633dbSJohn Snow 288*42b633dbSJohn SnowExample:: 289*42b633dbSJohn Snow 290*42b633dbSJohn Snow .. qapi:alternate:: StrOrNull 291*42b633dbSJohn Snow :since: 2.10 292*42b633dbSJohn Snow 293*42b633dbSJohn Snow This is a string value or the explicit lack of a string (null 294*42b633dbSJohn Snow pointer in C). Intended for cases when 'optional absent' already 295*42b633dbSJohn Snow has a different meaning. 296*42b633dbSJohn Snow 297*42b633dbSJohn Snow :alt string s: the string value 298*42b633dbSJohn Snow :alt null n: no string value 299*42b633dbSJohn Snow 300*42b633dbSJohn Snow 301*42b633dbSJohn Snow``:memb:`` 302*42b633dbSJohn Snow---------- 303*42b633dbSJohn Snow 304*42b633dbSJohn SnowDocument a member of an Event or Object. 305*42b633dbSJohn Snow 306*42b633dbSJohn Snow:availability: This field list is available in the body of Event or 307*42b633dbSJohn Snow Object directives. 308*42b633dbSJohn Snow:syntax: ``:memb type name: Lorem ipsum, dolor sit amet ...`` 309*42b633dbSJohn Snow:type: `sphinx.util.docfields.TypedField 310*42b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.TypedField.html?private=1>`_ 311*42b633dbSJohn Snow 312*42b633dbSJohn SnowThis is fundamentally the same as ``:arg:`` and ``:alt:``, but uses the 313*42b633dbSJohn Snow"Members" phrasing for Events and Objects (Structs and Unions). 314*42b633dbSJohn Snow 315*42b633dbSJohn SnowExample:: 316*42b633dbSJohn Snow 317*42b633dbSJohn Snow .. qapi:event:: JOB_STATUS_CHANGE 318*42b633dbSJohn Snow :since: 3.0 319*42b633dbSJohn Snow 320*42b633dbSJohn Snow Emitted when a job transitions to a different status. 321*42b633dbSJohn Snow 322*42b633dbSJohn Snow :memb string id: The job identifier 323*42b633dbSJohn Snow :memb JobStatus status: The new job status 324*42b633dbSJohn Snow 325*42b633dbSJohn Snow 326*42b633dbSJohn SnowArbitrary field lists 327*42b633dbSJohn Snow--------------------- 328*42b633dbSJohn Snow 329*42b633dbSJohn SnowOther field list names, while valid rST syntax, are prohibited inside of 330*42b633dbSJohn SnowQAPI directives to help prevent accidental misspellings of info field 331*42b633dbSJohn Snowlist names. If you want to add a new arbitrary "non-value-added" field 332*42b633dbSJohn Snowlist to QAPI documentation, you must add the field name to the allow 333*42b633dbSJohn Snowlist in ``docs/conf.py`` 334*42b633dbSJohn Snow 335*42b633dbSJohn SnowFor example:: 336*42b633dbSJohn Snow 337*42b633dbSJohn Snow qapi_allowed_fields = { 338*42b633dbSJohn Snow "see also", 339*42b633dbSJohn Snow } 340*42b633dbSJohn Snow 341*42b633dbSJohn SnowWill allow you to add arbitrary field lists in QAPI directives:: 342*42b633dbSJohn Snow 343*42b633dbSJohn Snow .. qapi:command:: x-fake-command 344*42b633dbSJohn Snow 345*42b633dbSJohn Snow :see also: Lorem ipsum, dolor sit amet ... 346*42b633dbSJohn Snow 347*42b633dbSJohn Snow 348*42b633dbSJohn SnowCross-references 349*42b633dbSJohn Snow================ 350*42b633dbSJohn Snow 351*42b633dbSJohn SnowCross-reference `roles 352*42b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html>`_ 353*42b633dbSJohn Snowin the QAPI domain are modeled closely after the `Python 354*42b633dbSJohn Snowcross-referencing syntax 355*42b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/domains/python.html#cross-referencing-python-objects>`_. 356*42b633dbSJohn Snow 357*42b633dbSJohn SnowQAPI definitions can be referenced using the standard `any 358*42b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/referencing.html#role-any>`_ 359*42b633dbSJohn Snowrole cross-reference syntax, such as with ```query-blockstats```. In 360*42b633dbSJohn Snowthe event that disambiguation is needed, cross-references can also be 361*42b633dbSJohn Snowwritten using a number of explicit cross-reference roles: 362*42b633dbSJohn Snow 363*42b633dbSJohn Snow* ``:qapi:mod:`block-core``` -- Reference a QAPI module. The link will 364*42b633dbSJohn Snow take you to the beginning of that section in the documentation. 365*42b633dbSJohn Snow* ``:qapi:cmd:`query-block``` -- Reference a QAPI command. 366*42b633dbSJohn Snow* ``:qapi:event:`JOB_STATUS_CHANGE``` -- Reference a QAPI event. 367*42b633dbSJohn Snow* ``:qapi:enum:`QapiErrorClass``` -- Reference a QAPI enum. 368*42b633dbSJohn Snow* ``:qapi:obj:`BlockdevOptionsVirtioBlkVhostVdpa`` -- Reference a QAPI 369*42b633dbSJohn Snow object (struct or union) 370*42b633dbSJohn Snow* ``:qapi:alt:`StrOrNull``` -- Reference a QAPI alternate. 371*42b633dbSJohn Snow* ``:qapi:type:`BlockDirtyInfo``` -- Reference *any* QAPI type; this 372*42b633dbSJohn Snow excludes modules, commands, and events. 373*42b633dbSJohn Snow* ``:qapi:any:`block-job-set-speed``` -- Reference absolutely any QAPI entity. 374*42b633dbSJohn Snow 375*42b633dbSJohn SnowType arguments in info field lists are converted into references as if 376*42b633dbSJohn Snowyou had used the ``:qapi:type:`` role. All of the special syntax below 377*42b633dbSJohn Snowapplies to both info field lists and standalone explicit 378*42b633dbSJohn Snowcross-references. 379*42b633dbSJohn Snow 380*42b633dbSJohn Snow 381*42b633dbSJohn SnowType decorations 382*42b633dbSJohn Snow---------------- 383*42b633dbSJohn Snow 384*42b633dbSJohn SnowType names in references can be surrounded by brackets, like 385*42b633dbSJohn Snow``[typename]``, to indicate an array of that type. The cross-reference 386*42b633dbSJohn Snowwill apply only to the type name between the brackets. For example; 387*42b633dbSJohn Snow``:qapi:type:`[Qcow2BitmapInfoFlags]``` renders to: 388*42b633dbSJohn Snow:qapi:type:`[Qcow2BitmapInfoFlags]` 389*42b633dbSJohn Snow 390*42b633dbSJohn SnowTo indicate an optional argument/member in a field list, the type name 391*42b633dbSJohn Snowcan be suffixed with ``?``. The cross-reference will be transformed to 392*42b633dbSJohn Snow"type, Optional" with the link applying only to the type name. For 393*42b633dbSJohn Snowexample; ``:qapi:type:`BitmapSyncMode?``` renders to: 394*42b633dbSJohn Snow:qapi:type:`BitmapSyncMode?` 395*42b633dbSJohn Snow 396*42b633dbSJohn Snow 397*42b633dbSJohn SnowNamespaces 398*42b633dbSJohn Snow---------- 399*42b633dbSJohn Snow 400*42b633dbSJohn SnowMimicking the `Python domain target specification syntax 401*42b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/domains/python.html#target-specification>`_, 402*42b633dbSJohn SnowQAPI allows you to specify the fully qualified path for a data 403*42b633dbSJohn Snowtype. QAPI enforces globally unique names, so it's unlikely you'll need 404*42b633dbSJohn Snowthis specific feature, but it may be extended in the near future to 405*42b633dbSJohn Snowallow referencing identically named commands and data types from 406*42b633dbSJohn Snowdifferent utilities; i.e. QEMU Storage Daemon vs QMP. 407*42b633dbSJohn Snow 408*42b633dbSJohn Snow* A module can be explicitly provided; 409*42b633dbSJohn Snow ``:qapi:type:`block-core.BitmapSyncMode``` will render to: 410*42b633dbSJohn Snow :qapi:type:`block-core.BitmapSyncMode` 411*42b633dbSJohn Snow* If you don't want to display the "fully qualified" name, it can be 412*42b633dbSJohn Snow prefixed with a tilde; ``:qapi:type:`~block-core.BitmapSyncMode``` 413*42b633dbSJohn Snow will render to: :qapi:type:`~block-core.BitmapSyncMode` 414*42b633dbSJohn Snow 415*42b633dbSJohn Snow 416*42b633dbSJohn SnowCustom link text 417*42b633dbSJohn Snow---------------- 418*42b633dbSJohn Snow 419*42b633dbSJohn SnowThe name of a cross-reference link can be explicitly overridden like 420*42b633dbSJohn Snow`most stock Sphinx references 421*42b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/referencing.html#syntax>`_ 422*42b633dbSJohn Snowusing the ``custom text <target>`` syntax. 423*42b633dbSJohn Snow 424*42b633dbSJohn SnowFor example, ``:qapi:cmd:`Merge dirty bitmaps 425*42b633dbSJohn Snow<block-dirty-bitmap-merge>``` will render as: :qapi:cmd:`Merge dirty 426*42b633dbSJohn Snowbitmaps <block-dirty-bitmap-merge>` 427*42b633dbSJohn Snow 428*42b633dbSJohn Snow 429*42b633dbSJohn SnowDirectives 430*42b633dbSJohn Snow========== 431*42b633dbSJohn Snow 432*42b633dbSJohn SnowThe QAPI domain adds a number of custom directives for documenting 433*42b633dbSJohn Snowvarious QAPI/QMP entities. The syntax is plain rST, and follows this 434*42b633dbSJohn Snowgeneral format:: 435*42b633dbSJohn Snow 436*42b633dbSJohn Snow .. qapi:directive:: argument 437*42b633dbSJohn Snow :option: 438*42b633dbSJohn Snow :another-option: with an argument 439*42b633dbSJohn Snow 440*42b633dbSJohn Snow Content body, arbitrary rST is allowed here. 441*42b633dbSJohn Snow 442*42b633dbSJohn Snow 443*42b633dbSJohn SnowSphinx standard options 444*42b633dbSJohn Snow----------------------- 445*42b633dbSJohn Snow 446*42b633dbSJohn SnowAll QAPI directives inherit a number of `standard options 447*42b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/domains/index.html#basic-markup>`_ 448*42b633dbSJohn Snowfrom Sphinx's ObjectDescription class. 449*42b633dbSJohn Snow 450*42b633dbSJohn SnowThe dashed spellings of the below options were added in Sphinx 7.2, the 451*42b633dbSJohn Snowundashed spellings are currently retained as aliases, but will be 452*42b633dbSJohn Snowremoved in a future version. 453*42b633dbSJohn Snow 454*42b633dbSJohn Snow* ``:no-index:`` and ``:noindex:`` -- Do not add this item into the 455*42b633dbSJohn Snow Index, and do not make it available for cross-referencing. 456*42b633dbSJohn Snow* ``no-index-entry:`` and ``:noindexentry:`` -- Do not add this item 457*42b633dbSJohn Snow into the Index, but allow it to be cross-referenced. 458*42b633dbSJohn Snow* ``no-contents-entry`` and ``:nocontentsentry:`` -- Exclude this item 459*42b633dbSJohn Snow from the Table of Contents. 460*42b633dbSJohn Snow* ``no-typesetting`` -- Create TOC, Index and cross-referencing 461*42b633dbSJohn Snow entities, but don't actually display the content. 462*42b633dbSJohn Snow 463*42b633dbSJohn Snow 464*42b633dbSJohn SnowQAPI standard options 465*42b633dbSJohn Snow--------------------- 466*42b633dbSJohn Snow 467*42b633dbSJohn SnowAll QAPI directives -- *except* for module -- support these common options. 468*42b633dbSJohn Snow 469*42b633dbSJohn Snow* ``:module: modname`` -- Borrowed from the Python domain, this option allows 470*42b633dbSJohn Snow you to override the module association of a given definition. 471*42b633dbSJohn Snow* ``:since: x.y`` -- Allows the documenting of "Since" information, which is 472*42b633dbSJohn Snow displayed in the signature bar. 473*42b633dbSJohn Snow* ``:ifcond: CONDITION`` -- Allows the documenting of conditional availability 474*42b633dbSJohn Snow information, which is displayed in an eyecatch just below the 475*42b633dbSJohn Snow signature bar. 476*42b633dbSJohn Snow* ``:deprecated:`` -- Adds an eyecatch just below the signature bar that 477*42b633dbSJohn Snow advertises that this definition is deprecated and should be avoided. 478*42b633dbSJohn Snow* ``:unstable:`` -- Adds an eyecatch just below the signature bar that 479*42b633dbSJohn Snow advertises that this definition is unstable and should not be used in 480*42b633dbSJohn Snow production code. 481*42b633dbSJohn Snow 482*42b633dbSJohn Snow 483*42b633dbSJohn Snowqapi:module 484*42b633dbSJohn Snow----------- 485*42b633dbSJohn Snow 486*42b633dbSJohn SnowThe ``qapi:module`` directive marks the start of a QAPI module. It may have 487*42b633dbSJohn Snowa content body, but it can be omitted. All subsequent QAPI directives 488*42b633dbSJohn Snoware associated with the most recent module; this effects their "fully 489*42b633dbSJohn Snowqualified" name, but has no other effect. 490*42b633dbSJohn Snow 491*42b633dbSJohn SnowExample:: 492*42b633dbSJohn Snow 493*42b633dbSJohn Snow .. qapi:module:: block-core 494*42b633dbSJohn Snow 495*42b633dbSJohn Snow Welcome to the block-core module! 496*42b633dbSJohn Snow 497*42b633dbSJohn SnowWill be rendered as: 498*42b633dbSJohn Snow 499*42b633dbSJohn Snow.. qapi:module:: block-core 500*42b633dbSJohn Snow :noindex: 501*42b633dbSJohn Snow 502*42b633dbSJohn Snow Welcome to the block-core module! 503*42b633dbSJohn Snow 504*42b633dbSJohn Snow 505*42b633dbSJohn Snowqapi:command 506*42b633dbSJohn Snow------------ 507*42b633dbSJohn Snow 508*42b633dbSJohn SnowThis directive documents a QMP command. It may use any of the standard 509*42b633dbSJohn SnowSphinx or QAPI options, and the documentation body may contain 510*42b633dbSJohn Snow``:arg:``, ``:feat:``, ``:error:``, or ``:return:`` info field list 511*42b633dbSJohn Snowentries. 512*42b633dbSJohn Snow 513*42b633dbSJohn SnowExample:: 514*42b633dbSJohn Snow 515*42b633dbSJohn Snow .. qapi:command:: x-fake-command 516*42b633dbSJohn Snow :since: 42.0 517*42b633dbSJohn Snow :unstable: 518*42b633dbSJohn Snow 519*42b633dbSJohn Snow This command is fake, so it can't hurt you! 520*42b633dbSJohn Snow 521*42b633dbSJohn Snow :arg int foo: Your favorite number. 522*42b633dbSJohn Snow :arg string? bar: Your favorite season. 523*42b633dbSJohn Snow :return [string]: A lovely computer-written poem for you. 524*42b633dbSJohn Snow 525*42b633dbSJohn Snow 526*42b633dbSJohn SnowWill be rendered as: 527*42b633dbSJohn Snow 528*42b633dbSJohn Snow .. qapi:command:: x-fake-command 529*42b633dbSJohn Snow :noindex: 530*42b633dbSJohn Snow :since: 42.0 531*42b633dbSJohn Snow :unstable: 532*42b633dbSJohn Snow 533*42b633dbSJohn Snow This command is fake, so it can't hurt you! 534*42b633dbSJohn Snow 535*42b633dbSJohn Snow :arg int foo: Your favorite number. 536*42b633dbSJohn Snow :arg string? bar: Your favorite season. 537*42b633dbSJohn Snow :return [string]: A lovely computer-written poem for you. 538*42b633dbSJohn Snow 539*42b633dbSJohn Snow 540*42b633dbSJohn Snowqapi:event 541*42b633dbSJohn Snow---------- 542*42b633dbSJohn Snow 543*42b633dbSJohn SnowThis directive documents a QMP event. It may use any of the standard 544*42b633dbSJohn SnowSphinx or QAPI options, and the documentation body may contain 545*42b633dbSJohn Snow``:memb:`` or ``:feat:`` info field list entries. 546*42b633dbSJohn Snow 547*42b633dbSJohn SnowExample:: 548*42b633dbSJohn Snow 549*42b633dbSJohn Snow .. qapi:event:: COMPUTER_IS_RUINED 550*42b633dbSJohn Snow :since: 0.1 551*42b633dbSJohn Snow :deprecated: 552*42b633dbSJohn Snow 553*42b633dbSJohn Snow This event is emitted when your computer is *extremely* ruined. 554*42b633dbSJohn Snow 555*42b633dbSJohn Snow :memb string reason: Diagnostics as to what caused your computer to 556*42b633dbSJohn Snow be ruined. 557*42b633dbSJohn Snow :feat sadness: When present, the diagnostic message will also 558*42b633dbSJohn Snow explain how sad the computer is as a result of your wrongdoings. 559*42b633dbSJohn Snow 560*42b633dbSJohn SnowWill be rendered as: 561*42b633dbSJohn Snow 562*42b633dbSJohn Snow.. qapi:event:: COMPUTER_IS_RUINED 563*42b633dbSJohn Snow :noindex: 564*42b633dbSJohn Snow :since: 0.1 565*42b633dbSJohn Snow :deprecated: 566*42b633dbSJohn Snow 567*42b633dbSJohn Snow This event is emitted when your computer is *extremely* ruined. 568*42b633dbSJohn Snow 569*42b633dbSJohn Snow :memb string reason: Diagnostics as to what caused your computer to 570*42b633dbSJohn Snow be ruined. 571*42b633dbSJohn Snow :feat sadness: When present, the diagnostic message will also explain 572*42b633dbSJohn Snow how sad the computer is as a result of your wrongdoings. 573*42b633dbSJohn Snow 574*42b633dbSJohn Snow 575*42b633dbSJohn Snowqapi:enum 576*42b633dbSJohn Snow--------- 577*42b633dbSJohn Snow 578*42b633dbSJohn SnowThis directive documents a QAPI enum. It may use any of the standard 579*42b633dbSJohn SnowSphinx or QAPI options, and the documentation body may contain 580*42b633dbSJohn Snow``:value:`` or ``:feat:`` info field list entries. 581*42b633dbSJohn Snow 582*42b633dbSJohn SnowExample:: 583*42b633dbSJohn Snow 584*42b633dbSJohn Snow .. qapi:enum:: Mood 585*42b633dbSJohn Snow :ifcond: LIB_PERSONALITY 586*42b633dbSJohn Snow 587*42b633dbSJohn Snow This enum represents your virtual machine's current mood! 588*42b633dbSJohn Snow 589*42b633dbSJohn Snow :value Happy: Your VM is content and well-fed. 590*42b633dbSJohn Snow :value Hungry: Your VM needs food. 591*42b633dbSJohn Snow :value Melancholic: Your VM is experiencing existential angst. 592*42b633dbSJohn Snow :value Petulant: Your VM is throwing a temper tantrum. 593*42b633dbSJohn Snow 594*42b633dbSJohn SnowWill be rendered as: 595*42b633dbSJohn Snow 596*42b633dbSJohn Snow.. qapi:enum:: Mood 597*42b633dbSJohn Snow :noindex: 598*42b633dbSJohn Snow :ifcond: LIB_PERSONALITY 599*42b633dbSJohn Snow 600*42b633dbSJohn Snow This enum represents your virtual machine's current mood! 601*42b633dbSJohn Snow 602*42b633dbSJohn Snow :value Happy: Your VM is content and well-fed. 603*42b633dbSJohn Snow :value Hungry: Your VM needs food. 604*42b633dbSJohn Snow :value Melancholic: Your VM is experiencing existential angst. 605*42b633dbSJohn Snow :value Petulant: Your VM is throwing a temper tantrum. 606*42b633dbSJohn Snow 607*42b633dbSJohn Snow 608*42b633dbSJohn Snowqapi:object 609*42b633dbSJohn Snow----------- 610*42b633dbSJohn Snow 611*42b633dbSJohn SnowThis directive documents a QAPI structure or union and represents a QMP 612*42b633dbSJohn Snowobject. It may use any of the standard Sphinx or QAPI options, and the 613*42b633dbSJohn Snowdocumentation body may contain ``:memb:`` or ``:feat:`` info field list 614*42b633dbSJohn Snowentries. 615*42b633dbSJohn Snow 616*42b633dbSJohn SnowExample:: 617*42b633dbSJohn Snow 618*42b633dbSJohn Snow .. qapi:object:: BigBlobOfStuff 619*42b633dbSJohn Snow 620*42b633dbSJohn Snow This object has a bunch of disparate and unrelated things in it. 621*42b633dbSJohn Snow 622*42b633dbSJohn Snow :memb int Birthday: Your birthday, represented in seconds since the 623*42b633dbSJohn Snow UNIX epoch. 624*42b633dbSJohn Snow :memb [string] Fav-Foods: A list of your favorite foods. 625*42b633dbSJohn Snow :memb boolean? Bizarre-Docs: True if the documentation reference 626*42b633dbSJohn Snow should be strange. 627*42b633dbSJohn Snow 628*42b633dbSJohn SnowWill be rendered as: 629*42b633dbSJohn Snow 630*42b633dbSJohn Snow.. qapi:object:: BigBlobOfStuff 631*42b633dbSJohn Snow :noindex: 632*42b633dbSJohn Snow 633*42b633dbSJohn Snow This object has a bunch of disparate and unrelated things in it. 634*42b633dbSJohn Snow 635*42b633dbSJohn Snow :memb int Birthday: Your birthday, represented in seconds since the 636*42b633dbSJohn Snow UNIX epoch. 637*42b633dbSJohn Snow :memb [string] Fav-Foods: A list of your favorite foods. 638*42b633dbSJohn Snow :memb boolean? Bizarre-Docs: True if the documentation reference 639*42b633dbSJohn Snow should be strange. 640*42b633dbSJohn Snow 641*42b633dbSJohn Snow 642*42b633dbSJohn Snowqapi:alternate 643*42b633dbSJohn Snow-------------- 644*42b633dbSJohn Snow 645*42b633dbSJohn SnowThis directive documents a QAPI alternate. It may use any of the 646*42b633dbSJohn Snowstandard Sphinx or QAPI options, and the documentation body may contain 647*42b633dbSJohn Snow``:alt:`` or ``:feat:`` info field list entries. 648*42b633dbSJohn Snow 649*42b633dbSJohn SnowExample:: 650*42b633dbSJohn Snow 651*42b633dbSJohn Snow .. qapi:alternate:: ErrorCode 652*42b633dbSJohn Snow 653*42b633dbSJohn Snow This alternate represents an Error Code from the VM. 654*42b633dbSJohn Snow 655*42b633dbSJohn Snow :alt int ec: An error code, like the type you're used to. 656*42b633dbSJohn Snow :alt string em: An expletive-laced error message, if your 657*42b633dbSJohn Snow computer is feeling particularly cranky and tired of your 658*42b633dbSJohn Snow antics. 659*42b633dbSJohn Snow 660*42b633dbSJohn SnowWill be rendered as: 661*42b633dbSJohn Snow 662*42b633dbSJohn Snow.. qapi:alternate:: ErrorCode 663*42b633dbSJohn Snow :noindex: 664*42b633dbSJohn Snow 665*42b633dbSJohn Snow This alternate represents an Error Code from the VM. 666*42b633dbSJohn Snow 667*42b633dbSJohn Snow :alt int ec: An error code, like the type you're used to. 668*42b633dbSJohn Snow :alt string em: An expletive-laced error message, if your 669*42b633dbSJohn Snow computer is feeling particularly cranky and tired of your 670*42b633dbSJohn Snow antics. 671