142b633dbSJohn Snow====================== 242b633dbSJohn SnowThe Sphinx QAPI Domain 342b633dbSJohn Snow====================== 442b633dbSJohn Snow 542b633dbSJohn SnowAn extension to the `rST syntax 642b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html>`_ 742b633dbSJohn Snowin Sphinx is provided by the QAPI Domain, located in 842b633dbSJohn Snow``docs/sphinx/qapi_domain.py``. This extension is analogous to the 942b633dbSJohn Snow`Python Domain 1042b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/domains/python.html>`_ 1142b633dbSJohn Snowincluded with Sphinx, but provides special directives and roles 1242b633dbSJohn Snowspeciically for annotating and documenting QAPI definitions 1342b633dbSJohn Snowspecifically. 1442b633dbSJohn Snow 1542b633dbSJohn SnowA `Domain 1642b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/domains/index.html>`_ 1742b633dbSJohn Snowprovides a set of special rST directives and cross-referencing roles to 1842b633dbSJohn SnowSphinx for understanding rST markup written to document a specific 1942b633dbSJohn Snowlanguage. By itself, this QAPI extension is only sufficient to parse rST 2042b633dbSJohn Snowmarkup written by hand; the `autodoc 2142b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html>`_ 2242b633dbSJohn Snowfunctionality is provided elsewhere, in ``docs/sphinx/qapidoc.py``, by 2342b633dbSJohn Snowthe "Transmogrifier". 2442b633dbSJohn Snow 2542b633dbSJohn SnowIt is not expected that any developer nor documentation writer would 2642b633dbSJohn Snownever need to write *nor* read these special rST forms. However, in the 2742b633dbSJohn Snowevent that something needs to be debugged, knowing the syntax of the 2842b633dbSJohn Snowdomain is quite handy. This reference may also be useful as a guide for 2942b633dbSJohn Snowunderstanding the QAPI Domain extension code itself. Although most of 3042b633dbSJohn Snowthese forms will not be needed for documentation writing purposes, 3142b633dbSJohn Snowunderstanding the cross-referencing syntax *will* be helpful when 3242b633dbSJohn Snowwriting rST documentation elsewhere, or for enriching the body of 3342b633dbSJohn SnowQAPIDoc blocks themselves. 3442b633dbSJohn Snow 3542b633dbSJohn Snow 3642b633dbSJohn SnowConcepts 3742b633dbSJohn Snow======== 3842b633dbSJohn Snow 3942b633dbSJohn SnowThe QAPI Domain itself provides no mechanisms for reading the QAPI 4042b633dbSJohn SnowSchema or generating documentation from code that exists. It is merely 4142b633dbSJohn Snowthe rST syntax used to describe things. For instance, the Sphinx Python 4242b633dbSJohn Snowdomain adds syntax like ``:py:func:`` for describing Python functions in 4342b633dbSJohn Snowdocumentation, but it's the autodoc module that is responsible for 44*22e6d702SStefan Weil viareading Python code and generating such syntax. QAPI is analogous here: 4542b633dbSJohn Snowqapidoc.py is responsible for reading the QAPI Schema and generating rST 4642b633dbSJohn Snowsyntax, and qapi_domain.py is responsible for translating that special 4742b633dbSJohn Snowsyntax and providing APIs for Sphinx internals. 4842b633dbSJohn Snow 4942b633dbSJohn SnowIn other words: 5042b633dbSJohn Snow 5142b633dbSJohn Snowqapi_domain.py adds syntax like ``.. qapi:command::`` to Sphinx, and 5242b633dbSJohn Snowqapidoc.py transforms the documentation in ``qapi/*.json`` into rST 5342b633dbSJohn Snowusing directives defined by the domain. 5442b633dbSJohn Snow 5542b633dbSJohn SnowOr even shorter: 5642b633dbSJohn Snow 5742b633dbSJohn Snow``:py:`` is to ``:qapi:`` as *autodoc* is to *qapidoc*. 5842b633dbSJohn Snow 5942b633dbSJohn Snow 6042b633dbSJohn SnowInfo Field Lists 6142b633dbSJohn Snow================ 6242b633dbSJohn Snow 6342b633dbSJohn Snow`Field lists 6442b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#field-lists>`_ 6542b633dbSJohn Snoware a standard syntax in reStructuredText. Sphinx `extends that syntax 6642b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/domains/python.html#info-field-lists>`_ 6742b633dbSJohn Snowto give certain field list entries special meaning and parsing to, for 6842b633dbSJohn Snowexample, add cross-references. The QAPI Domain takes advantage of this 6942b633dbSJohn Snowfield list extension to document things like Arguments, Members, Values, 7042b633dbSJohn Snowand so on. 7142b633dbSJohn Snow 7242b633dbSJohn SnowThe special parsing and handling of info field lists in Sphinx is provided by 7342b633dbSJohn Snowthree main classes; Field, GroupedField, and TypedField. The behavior 7442b633dbSJohn Snowand formatting for each configured field list entry in the domain 7542b633dbSJohn Snowchanges depending on which class is used. 7642b633dbSJohn Snow 7742b633dbSJohn SnowField: 7842b633dbSJohn Snow * Creates an ungrouped field: i.e., each entry will create its own 7942b633dbSJohn Snow section and they will not be combined. 8042b633dbSJohn Snow * May *optionally* support an argument. 8142b633dbSJohn Snow * May apply cross-reference roles to *either* the argument *or* the 8242b633dbSJohn Snow content body, both, or neither. 8342b633dbSJohn Snow 8442b633dbSJohn SnowThis is used primarily for entries which are not expected to be 8542b633dbSJohn Snowrepeated, i.e., items that may only show up at most once. The QAPI 8642b633dbSJohn Snowdomain uses this class for "Errors" section. 8742b633dbSJohn Snow 8842b633dbSJohn SnowGroupedField: 8942b633dbSJohn Snow * Creates a grouped field: i.e. multiple adjacent entries will be 9042b633dbSJohn Snow merged into one section, and the content will form a bulleted list. 9142b633dbSJohn Snow * *Must* take an argument. 9242b633dbSJohn Snow * May optionally apply a cross-reference role to the argument, but not 9342b633dbSJohn Snow the body. 9442b633dbSJohn Snow * Can be configured to remove the bulleted list if there is only a 9542b633dbSJohn Snow single entry. 9642b633dbSJohn Snow * All items will be generated with the form: "argument -- body" 9742b633dbSJohn Snow 9842b633dbSJohn SnowThis is used for entries which are expected to be repeated, but aren't 9942b633dbSJohn Snowexpected to have two arguments, i.e. types without names, or names 10042b633dbSJohn Snowwithout types. The QAPI domain uses this class for features, returns, 10142b633dbSJohn Snowand enum values. 10242b633dbSJohn Snow 10342b633dbSJohn SnowTypedField: 10442b633dbSJohn Snow * Creates a grouped, typed field. Multiple adjacent entres will be 10542b633dbSJohn Snow merged into one section, and the content will form a bulleted list. 10642b633dbSJohn Snow * *Must* take at least one argument, but supports up to two - 10742b633dbSJohn Snow nominally, a name and a type. 10842b633dbSJohn Snow * May optionally apply a cross-reference role to the type or the name 10942b633dbSJohn Snow argument, but not the body. 11042b633dbSJohn Snow * Can be configured to remove the bulleted list if there is only a 11142b633dbSJohn Snow single entry. 11242b633dbSJohn Snow * All items will be generated with the form "name (type) -- body" 11342b633dbSJohn Snow 11442b633dbSJohn SnowThis is used for entries that are expected to be repeated and will have 11542b633dbSJohn Snowa name, a type, and a description. The QAPI domain uses this class for 11642b633dbSJohn Snowarguments, alternatives, and members. Wherever type names are referenced 11742b633dbSJohn Snowbelow, They must be a valid, documented type that will be 11842b633dbSJohn Snowcross-referenced in the HTML output; or one of the built-in JSON types 11942b633dbSJohn Snow(string, number, int, boolean, null, value, q_empty). 12042b633dbSJohn Snow 12142b633dbSJohn Snow 12242b633dbSJohn Snow``:feat:`` 12342b633dbSJohn Snow---------- 12442b633dbSJohn Snow 12542b633dbSJohn SnowDocument a feature attached to a QAPI definition. 12642b633dbSJohn Snow 12742b633dbSJohn Snow:availability: This field list is available in the body of Command, 12842b633dbSJohn Snow Event, Enum, Object and Alternate directives. 12942b633dbSJohn Snow:syntax: ``:feat name: Lorem ipsum, dolor sit amet...`` 13042b633dbSJohn Snow:type: `sphinx.util.docfields.GroupedField 13142b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.GroupedField.html?private=1>`_ 13242b633dbSJohn Snow 13342b633dbSJohn SnowExample:: 13442b633dbSJohn Snow 13542b633dbSJohn Snow .. qapi:object:: BlockdevOptionsVirtioBlkVhostVdpa 13642b633dbSJohn Snow :since: 7.2 13742b633dbSJohn Snow :ifcond: CONFIG_BLKIO 13842b633dbSJohn Snow 13942b633dbSJohn Snow Driver specific block device options for the virtio-blk-vhost-vdpa 14042b633dbSJohn Snow backend. 14142b633dbSJohn Snow 14242b633dbSJohn Snow :memb string path: path to the vhost-vdpa character device. 14342b633dbSJohn Snow :feat fdset: Member ``path`` supports the special "/dev/fdset/N" path 14442b633dbSJohn Snow (since 8.1) 14542b633dbSJohn Snow 14642b633dbSJohn Snow 14742b633dbSJohn Snow``:arg:`` 14842b633dbSJohn Snow--------- 14942b633dbSJohn Snow 15042b633dbSJohn SnowDocument an argument to a QAPI command. 15142b633dbSJohn Snow 15242b633dbSJohn Snow:availability: This field list is only available in the body of the 15342b633dbSJohn Snow Command directive. 15442b633dbSJohn Snow:syntax: ``:arg type name: description`` 15542b633dbSJohn Snow:type: `sphinx.util.docfields.TypedField 15642b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.TypedField.html?private=1>`_ 15742b633dbSJohn Snow 15842b633dbSJohn Snow 15942b633dbSJohn SnowExample:: 16042b633dbSJohn Snow 16142b633dbSJohn Snow .. qapi:command:: job-pause 16242b633dbSJohn Snow :since: 3.0 16342b633dbSJohn Snow 16442b633dbSJohn Snow Pause an active job. 16542b633dbSJohn Snow 16642b633dbSJohn Snow This command returns immediately after marking the active job for 16742b633dbSJohn Snow pausing. Pausing an already paused job is an error. 16842b633dbSJohn Snow 16942b633dbSJohn Snow The job will pause as soon as possible, which means transitioning 17042b633dbSJohn Snow into the PAUSED state if it was RUNNING, or into STANDBY if it was 17142b633dbSJohn Snow READY. The corresponding JOB_STATUS_CHANGE event will be emitted. 17242b633dbSJohn Snow 17342b633dbSJohn Snow Cancelling a paused job automatically resumes it. 17442b633dbSJohn Snow 17542b633dbSJohn Snow :arg string id: The job identifier. 17642b633dbSJohn Snow 17742b633dbSJohn Snow 17842b633dbSJohn Snow``:error:`` 17942b633dbSJohn Snow----------- 18042b633dbSJohn Snow 18142b633dbSJohn SnowDocument the error condition(s) of a QAPI command. 18242b633dbSJohn Snow 18342b633dbSJohn Snow:availability: This field list is only available in the body of the 18442b633dbSJohn Snow Command directive. 18542b633dbSJohn Snow:syntax: ``:error: Lorem ipsum dolor sit amet ...`` 18642b633dbSJohn Snow:type: `sphinx.util.docfields.Field 18742b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.Field.html?private=1>`_ 18842b633dbSJohn Snow 18942b633dbSJohn SnowThe format of the :errors: field list description is free-form rST. The 19042b633dbSJohn Snowalternative spelling ":errors:" is also permitted, but strictly 19142b633dbSJohn Snowanalogous. 19242b633dbSJohn Snow 19342b633dbSJohn SnowExample:: 19442b633dbSJohn Snow 19542b633dbSJohn Snow .. qapi:command:: block-job-set-speed 19642b633dbSJohn Snow :since: 1.1 19742b633dbSJohn Snow 19842b633dbSJohn Snow Set maximum speed for a background block operation. 19942b633dbSJohn Snow 20042b633dbSJohn Snow This command can only be issued when there is an active block job. 20142b633dbSJohn Snow 20242b633dbSJohn Snow Throttling can be disabled by setting the speed to 0. 20342b633dbSJohn Snow 20442b633dbSJohn Snow :arg string device: The job identifier. This used to be a device 20542b633dbSJohn Snow name (hence the name of the parameter), but since QEMU 2.7 it 20642b633dbSJohn Snow can have other values. 20742b633dbSJohn Snow :arg int speed: the maximum speed, in bytes per second, or 0 for 20842b633dbSJohn Snow unlimited. Defaults to 0. 20942b633dbSJohn Snow :error: 21042b633dbSJohn Snow - If no background operation is active on this device, 21142b633dbSJohn Snow DeviceNotActive 21242b633dbSJohn Snow 21342b633dbSJohn Snow 21442b633dbSJohn Snow``:return:`` 21542b633dbSJohn Snow------------- 21642b633dbSJohn Snow 21742b633dbSJohn SnowDocument the return type(s) and value(s) of a QAPI command. 21842b633dbSJohn Snow 21942b633dbSJohn Snow:availability: This field list is only available in the body of the 22042b633dbSJohn Snow Command directive. 22142b633dbSJohn Snow:syntax: ``:return type: Lorem ipsum dolor sit amet ...`` 22242b633dbSJohn Snow:type: `sphinx.util.docfields.GroupedField 22342b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.GroupedField.html?private=1>`_ 22442b633dbSJohn Snow 22542b633dbSJohn Snow 22642b633dbSJohn SnowExample:: 22742b633dbSJohn Snow 22842b633dbSJohn Snow .. qapi:command:: query-replay 22942b633dbSJohn Snow :since: 5.2 23042b633dbSJohn Snow 23142b633dbSJohn Snow Retrieve the record/replay information. It includes current 23242b633dbSJohn Snow instruction count which may be used for ``replay-break`` and 23342b633dbSJohn Snow ``replay-seek`` commands. 23442b633dbSJohn Snow 23542b633dbSJohn Snow :return ReplayInfo: record/replay information. 23642b633dbSJohn Snow 23742b633dbSJohn Snow .. qmp-example:: 23842b633dbSJohn Snow 23942b633dbSJohn Snow -> { "execute": "query-replay" } 24042b633dbSJohn Snow <- { "return": { 24142b633dbSJohn Snow "mode": "play", "filename": "log.rr", "icount": 220414 } 24242b633dbSJohn Snow } 24342b633dbSJohn Snow 24442b633dbSJohn Snow 24542b633dbSJohn Snow``:value:`` 24642b633dbSJohn Snow----------- 24742b633dbSJohn Snow 24842b633dbSJohn SnowDocument a possible value for a QAPI enum. 24942b633dbSJohn Snow 25042b633dbSJohn Snow:availability: This field list is only available in the body of the Enum 25142b633dbSJohn Snow directive. 25242b633dbSJohn Snow:syntax: ``:value name: Lorem ipsum, dolor sit amet ...`` 25342b633dbSJohn Snow:type: `sphinx.util.docfields.GroupedField 25442b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.GroupedField.html?private=1>`_ 25542b633dbSJohn Snow 25642b633dbSJohn SnowExample:: 25742b633dbSJohn Snow 25842b633dbSJohn Snow .. qapi:enum:: QapiErrorClass 25942b633dbSJohn Snow :since: 1.2 26042b633dbSJohn Snow 26142b633dbSJohn Snow QEMU error classes 26242b633dbSJohn Snow 26342b633dbSJohn Snow :value GenericError: this is used for errors that don't require a specific 26442b633dbSJohn Snow error class. This should be the default case for most errors 26542b633dbSJohn Snow :value CommandNotFound: the requested command has not been found 26642b633dbSJohn Snow :value DeviceNotActive: a device has failed to be become active 26742b633dbSJohn Snow :value DeviceNotFound: the requested device has not been found 26842b633dbSJohn Snow :value KVMMissingCap: the requested operation can't be fulfilled because a 26942b633dbSJohn Snow required KVM capability is missing 27042b633dbSJohn Snow 27142b633dbSJohn Snow 27242b633dbSJohn Snow``:alt:`` 27342b633dbSJohn Snow------------ 27442b633dbSJohn Snow 27542b633dbSJohn SnowDocument a possible branch for a QAPI alternate. 27642b633dbSJohn Snow 27742b633dbSJohn Snow:availability: This field list is only available in the body of the 27842b633dbSJohn Snow Alternate directive. 27942b633dbSJohn Snow:syntax: ``:alt type name: Lorem ipsum, dolor sit amet ...`` 28042b633dbSJohn Snow:type: `sphinx.util.docfields.TypedField 28142b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.TypedField.html?private=1>`_ 28242b633dbSJohn Snow 28342b633dbSJohn SnowAs a limitation of Sphinx, we must document the "name" of the branch in 28442b633dbSJohn Snowaddition to the type, even though this information is not visible on the 28542b633dbSJohn Snowwire in the QMP protocol format. This limitation *may* be lifted at a 28642b633dbSJohn Snowfuture date. 28742b633dbSJohn Snow 28842b633dbSJohn SnowExample:: 28942b633dbSJohn Snow 29042b633dbSJohn Snow .. qapi:alternate:: StrOrNull 29142b633dbSJohn Snow :since: 2.10 29242b633dbSJohn Snow 29342b633dbSJohn Snow This is a string value or the explicit lack of a string (null 29442b633dbSJohn Snow pointer in C). Intended for cases when 'optional absent' already 29542b633dbSJohn Snow has a different meaning. 29642b633dbSJohn Snow 29742b633dbSJohn Snow :alt string s: the string value 29842b633dbSJohn Snow :alt null n: no string value 29942b633dbSJohn Snow 30042b633dbSJohn Snow 30142b633dbSJohn Snow``:memb:`` 30242b633dbSJohn Snow---------- 30342b633dbSJohn Snow 30442b633dbSJohn SnowDocument a member of an Event or Object. 30542b633dbSJohn Snow 30642b633dbSJohn Snow:availability: This field list is available in the body of Event or 30742b633dbSJohn Snow Object directives. 30842b633dbSJohn Snow:syntax: ``:memb type name: Lorem ipsum, dolor sit amet ...`` 30942b633dbSJohn Snow:type: `sphinx.util.docfields.TypedField 31042b633dbSJohn Snow <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.TypedField.html?private=1>`_ 31142b633dbSJohn Snow 31242b633dbSJohn SnowThis is fundamentally the same as ``:arg:`` and ``:alt:``, but uses the 31342b633dbSJohn Snow"Members" phrasing for Events and Objects (Structs and Unions). 31442b633dbSJohn Snow 31542b633dbSJohn SnowExample:: 31642b633dbSJohn Snow 31742b633dbSJohn Snow .. qapi:event:: JOB_STATUS_CHANGE 31842b633dbSJohn Snow :since: 3.0 31942b633dbSJohn Snow 32042b633dbSJohn Snow Emitted when a job transitions to a different status. 32142b633dbSJohn Snow 32242b633dbSJohn Snow :memb string id: The job identifier 32342b633dbSJohn Snow :memb JobStatus status: The new job status 32442b633dbSJohn Snow 32542b633dbSJohn Snow 32642b633dbSJohn SnowArbitrary field lists 32742b633dbSJohn Snow--------------------- 32842b633dbSJohn Snow 32942b633dbSJohn SnowOther field list names, while valid rST syntax, are prohibited inside of 33042b633dbSJohn SnowQAPI directives to help prevent accidental misspellings of info field 33142b633dbSJohn Snowlist names. If you want to add a new arbitrary "non-value-added" field 33242b633dbSJohn Snowlist to QAPI documentation, you must add the field name to the allow 33342b633dbSJohn Snowlist in ``docs/conf.py`` 33442b633dbSJohn Snow 33542b633dbSJohn SnowFor example:: 33642b633dbSJohn Snow 33742b633dbSJohn Snow qapi_allowed_fields = { 33842b633dbSJohn Snow "see also", 33942b633dbSJohn Snow } 34042b633dbSJohn Snow 34142b633dbSJohn SnowWill allow you to add arbitrary field lists in QAPI directives:: 34242b633dbSJohn Snow 34342b633dbSJohn Snow .. qapi:command:: x-fake-command 34442b633dbSJohn Snow 34542b633dbSJohn Snow :see also: Lorem ipsum, dolor sit amet ... 34642b633dbSJohn Snow 34742b633dbSJohn Snow 34842b633dbSJohn SnowCross-references 34942b633dbSJohn Snow================ 35042b633dbSJohn Snow 35142b633dbSJohn SnowCross-reference `roles 35242b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html>`_ 35342b633dbSJohn Snowin the QAPI domain are modeled closely after the `Python 35442b633dbSJohn Snowcross-referencing syntax 35542b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/domains/python.html#cross-referencing-python-objects>`_. 35642b633dbSJohn Snow 35742b633dbSJohn SnowQAPI definitions can be referenced using the standard `any 35842b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/referencing.html#role-any>`_ 35942b633dbSJohn Snowrole cross-reference syntax, such as with ```query-blockstats```. In 36042b633dbSJohn Snowthe event that disambiguation is needed, cross-references can also be 36142b633dbSJohn Snowwritten using a number of explicit cross-reference roles: 36242b633dbSJohn Snow 36342b633dbSJohn Snow* ``:qapi:mod:`block-core``` -- Reference a QAPI module. The link will 36442b633dbSJohn Snow take you to the beginning of that section in the documentation. 36542b633dbSJohn Snow* ``:qapi:cmd:`query-block``` -- Reference a QAPI command. 36642b633dbSJohn Snow* ``:qapi:event:`JOB_STATUS_CHANGE``` -- Reference a QAPI event. 36742b633dbSJohn Snow* ``:qapi:enum:`QapiErrorClass``` -- Reference a QAPI enum. 36842b633dbSJohn Snow* ``:qapi:obj:`BlockdevOptionsVirtioBlkVhostVdpa`` -- Reference a QAPI 36942b633dbSJohn Snow object (struct or union) 37042b633dbSJohn Snow* ``:qapi:alt:`StrOrNull``` -- Reference a QAPI alternate. 37142b633dbSJohn Snow* ``:qapi:type:`BlockDirtyInfo``` -- Reference *any* QAPI type; this 37242b633dbSJohn Snow excludes modules, commands, and events. 37342b633dbSJohn Snow* ``:qapi:any:`block-job-set-speed``` -- Reference absolutely any QAPI entity. 37442b633dbSJohn Snow 37542b633dbSJohn SnowType arguments in info field lists are converted into references as if 37642b633dbSJohn Snowyou had used the ``:qapi:type:`` role. All of the special syntax below 37742b633dbSJohn Snowapplies to both info field lists and standalone explicit 37842b633dbSJohn Snowcross-references. 37942b633dbSJohn Snow 38042b633dbSJohn Snow 38142b633dbSJohn SnowType decorations 38242b633dbSJohn Snow---------------- 38342b633dbSJohn Snow 38442b633dbSJohn SnowType names in references can be surrounded by brackets, like 38542b633dbSJohn Snow``[typename]``, to indicate an array of that type. The cross-reference 38642b633dbSJohn Snowwill apply only to the type name between the brackets. For example; 38742b633dbSJohn Snow``:qapi:type:`[Qcow2BitmapInfoFlags]``` renders to: 388d85f7efeSJohn Snow:qapi:type:`[QMP:Qcow2BitmapInfoFlags]` 38942b633dbSJohn Snow 39042b633dbSJohn SnowTo indicate an optional argument/member in a field list, the type name 39142b633dbSJohn Snowcan be suffixed with ``?``. The cross-reference will be transformed to 39242b633dbSJohn Snow"type, Optional" with the link applying only to the type name. For 39342b633dbSJohn Snowexample; ``:qapi:type:`BitmapSyncMode?``` renders to: 394d85f7efeSJohn Snow:qapi:type:`QMP:BitmapSyncMode?` 39542b633dbSJohn Snow 39642b633dbSJohn Snow 39742b633dbSJohn SnowNamespaces 39842b633dbSJohn Snow---------- 39942b633dbSJohn Snow 40042b633dbSJohn SnowMimicking the `Python domain target specification syntax 40142b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/domains/python.html#target-specification>`_, 40242b633dbSJohn SnowQAPI allows you to specify the fully qualified path for a data 4037127e14fSJohn Snowtype. 40442b633dbSJohn Snow 4057127e14fSJohn Snow* A namespace can be explicitly provided; 4067127e14fSJohn Snow e.g. ``:qapi:type:`QMP:BitmapSyncMode`` 40742b633dbSJohn Snow* A module can be explicitly provided; 408d85f7efeSJohn Snow ``:qapi:type:`QMP:block-core.BitmapSyncMode``` will render to: 409d85f7efeSJohn Snow :qapi:type:`QMP:block-core.BitmapSyncMode` 41042b633dbSJohn Snow* If you don't want to display the "fully qualified" name, it can be 411d85f7efeSJohn Snow prefixed with a tilde; ``:qapi:type:`~QMP:block-core.BitmapSyncMode``` 412d85f7efeSJohn Snow will render to: :qapi:type:`~QMP:block-core.BitmapSyncMode` 41342b633dbSJohn Snow 41442b633dbSJohn Snow 4157127e14fSJohn SnowTarget resolution 4167127e14fSJohn Snow----------------- 4177127e14fSJohn Snow 4187127e14fSJohn SnowAny cross-reference to a QAPI type, whether using the ```any``` style of 4197127e14fSJohn Snowreference or the more explicit ```:qapi:any:`target``` syntax, allows 4207127e14fSJohn Snowfor the presence or absence of either the namespace or module 4217127e14fSJohn Snowinformation. 4227127e14fSJohn Snow 4237127e14fSJohn SnowWhen absent, their value will be inferred from context by the presence 4247127e14fSJohn Snowof any ``qapi:namespace`` or ``qapi:module`` directives preceding the 4257127e14fSJohn Snowcross-reference. 4267127e14fSJohn Snow 4277127e14fSJohn SnowIf no results are found when using the inferred values, other 4287127e14fSJohn Snownamespaces/modules will be searched as a last resort; but any explicitly 4297127e14fSJohn Snowprovided values must always match in order to succeed. 4307127e14fSJohn Snow 4317127e14fSJohn SnowThis allows for efficient cross-referencing with a minimum of syntax in 4327127e14fSJohn Snowthe large majority of cases, but additional context or namespace markup 4337127e14fSJohn Snowmay be required outside of the QAPI reference documents when linking to 4347127e14fSJohn Snowitems that share a name across multiple documented QAPI schema. 4357127e14fSJohn Snow 4367127e14fSJohn Snow 43742b633dbSJohn SnowCustom link text 43842b633dbSJohn Snow---------------- 43942b633dbSJohn Snow 44042b633dbSJohn SnowThe name of a cross-reference link can be explicitly overridden like 44142b633dbSJohn Snow`most stock Sphinx references 44242b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/referencing.html#syntax>`_ 44342b633dbSJohn Snowusing the ``custom text <target>`` syntax. 44442b633dbSJohn Snow 44542b633dbSJohn SnowFor example, ``:qapi:cmd:`Merge dirty bitmaps 44642b633dbSJohn Snow<block-dirty-bitmap-merge>``` will render as: :qapi:cmd:`Merge dirty 447d85f7efeSJohn Snowbitmaps <QMP:block-dirty-bitmap-merge>` 44842b633dbSJohn Snow 44942b633dbSJohn Snow 45042b633dbSJohn SnowDirectives 45142b633dbSJohn Snow========== 45242b633dbSJohn Snow 45342b633dbSJohn SnowThe QAPI domain adds a number of custom directives for documenting 45442b633dbSJohn Snowvarious QAPI/QMP entities. The syntax is plain rST, and follows this 45542b633dbSJohn Snowgeneral format:: 45642b633dbSJohn Snow 45742b633dbSJohn Snow .. qapi:directive:: argument 45842b633dbSJohn Snow :option: 45942b633dbSJohn Snow :another-option: with an argument 46042b633dbSJohn Snow 46142b633dbSJohn Snow Content body, arbitrary rST is allowed here. 46242b633dbSJohn Snow 46342b633dbSJohn Snow 46442b633dbSJohn SnowSphinx standard options 46542b633dbSJohn Snow----------------------- 46642b633dbSJohn Snow 46742b633dbSJohn SnowAll QAPI directives inherit a number of `standard options 46842b633dbSJohn Snow<https://www.sphinx-doc.org/en/master/usage/domains/index.html#basic-markup>`_ 46942b633dbSJohn Snowfrom Sphinx's ObjectDescription class. 47042b633dbSJohn Snow 47142b633dbSJohn SnowThe dashed spellings of the below options were added in Sphinx 7.2, the 47242b633dbSJohn Snowundashed spellings are currently retained as aliases, but will be 47342b633dbSJohn Snowremoved in a future version. 47442b633dbSJohn Snow 47542b633dbSJohn Snow* ``:no-index:`` and ``:noindex:`` -- Do not add this item into the 47642b633dbSJohn Snow Index, and do not make it available for cross-referencing. 47742b633dbSJohn Snow* ``no-index-entry:`` and ``:noindexentry:`` -- Do not add this item 47842b633dbSJohn Snow into the Index, but allow it to be cross-referenced. 47942b633dbSJohn Snow* ``no-contents-entry`` and ``:nocontentsentry:`` -- Exclude this item 48042b633dbSJohn Snow from the Table of Contents. 48142b633dbSJohn Snow* ``no-typesetting`` -- Create TOC, Index and cross-referencing 48242b633dbSJohn Snow entities, but don't actually display the content. 48342b633dbSJohn Snow 48442b633dbSJohn Snow 48542b633dbSJohn SnowQAPI standard options 48642b633dbSJohn Snow--------------------- 48742b633dbSJohn Snow 4887c7247b2SJohn SnowAll QAPI directives -- *except* for namespace and module -- support 4897c7247b2SJohn Snowthese common options. 49042b633dbSJohn Snow 4919ca404f0SJohn Snow* ``:namespace: name`` -- This option allows you to override the 4929ca404f0SJohn Snow namespace association of a given definition. 49342b633dbSJohn Snow* ``:module: modname`` -- Borrowed from the Python domain, this option allows 49442b633dbSJohn Snow you to override the module association of a given definition. 49542b633dbSJohn Snow* ``:since: x.y`` -- Allows the documenting of "Since" information, which is 49642b633dbSJohn Snow displayed in the signature bar. 49742b633dbSJohn Snow* ``:ifcond: CONDITION`` -- Allows the documenting of conditional availability 49842b633dbSJohn Snow information, which is displayed in an eyecatch just below the 49942b633dbSJohn Snow signature bar. 50042b633dbSJohn Snow* ``:deprecated:`` -- Adds an eyecatch just below the signature bar that 50142b633dbSJohn Snow advertises that this definition is deprecated and should be avoided. 50242b633dbSJohn Snow* ``:unstable:`` -- Adds an eyecatch just below the signature bar that 50342b633dbSJohn Snow advertises that this definition is unstable and should not be used in 50442b633dbSJohn Snow production code. 50542b633dbSJohn Snow 50642b633dbSJohn Snow 5077c7247b2SJohn Snowqapi:namespace 5087c7247b2SJohn Snow-------------- 5097c7247b2SJohn Snow 5107c7247b2SJohn SnowThe ``qapi:namespace`` directive marks the start of a QAPI namespace. It 5117c7247b2SJohn Snowdoes not take a content body, nor any options. All subsequent QAPI 5127c7247b2SJohn Snowdirectives are associated with the most recent namespace. This affects 5137c7247b2SJohn Snowthe definition's "fully qualified name", allowing two different 5147c7247b2SJohn Snownamespaces to create an otherwise identically named definition. 5157c7247b2SJohn Snow 5167127e14fSJohn SnowThis directive also influences how reference resolution works for any 517*22e6d702SStefan Weil viareferences that do not explicitly specify a namespace, so this directive 5187127e14fSJohn Snowcan be used to nudge references into preferring targets from within that 5197127e14fSJohn Snownamespace. 5207127e14fSJohn Snow 5217c7247b2SJohn SnowExample:: 5227c7247b2SJohn Snow 5237c7247b2SJohn Snow .. qapi:namespace:: QMP 5247c7247b2SJohn Snow 5257c7247b2SJohn Snow 5267c7247b2SJohn SnowThis directive has no visible effect. 5277c7247b2SJohn Snow 5287c7247b2SJohn Snow 52942b633dbSJohn Snowqapi:module 53042b633dbSJohn Snow----------- 53142b633dbSJohn Snow 53242b633dbSJohn SnowThe ``qapi:module`` directive marks the start of a QAPI module. It may have 53342b633dbSJohn Snowa content body, but it can be omitted. All subsequent QAPI directives 53442b633dbSJohn Snoware associated with the most recent module; this effects their "fully 53542b633dbSJohn Snowqualified" name, but has no other effect. 53642b633dbSJohn Snow 53742b633dbSJohn SnowExample:: 53842b633dbSJohn Snow 53942b633dbSJohn Snow .. qapi:module:: block-core 54042b633dbSJohn Snow 54142b633dbSJohn Snow Welcome to the block-core module! 54242b633dbSJohn Snow 54342b633dbSJohn SnowWill be rendered as: 54442b633dbSJohn Snow 54542b633dbSJohn Snow.. qapi:module:: block-core 54642b633dbSJohn Snow :noindex: 54742b633dbSJohn Snow 54842b633dbSJohn Snow Welcome to the block-core module! 54942b633dbSJohn Snow 55042b633dbSJohn Snow 55142b633dbSJohn Snowqapi:command 55242b633dbSJohn Snow------------ 55342b633dbSJohn Snow 55442b633dbSJohn SnowThis directive documents a QMP command. It may use any of the standard 55542b633dbSJohn SnowSphinx or QAPI options, and the documentation body may contain 55642b633dbSJohn Snow``:arg:``, ``:feat:``, ``:error:``, or ``:return:`` info field list 55742b633dbSJohn Snowentries. 55842b633dbSJohn Snow 55942b633dbSJohn SnowExample:: 56042b633dbSJohn Snow 56142b633dbSJohn Snow .. qapi:command:: x-fake-command 56242b633dbSJohn Snow :since: 42.0 56342b633dbSJohn Snow :unstable: 56442b633dbSJohn Snow 56542b633dbSJohn Snow This command is fake, so it can't hurt you! 56642b633dbSJohn Snow 56742b633dbSJohn Snow :arg int foo: Your favorite number. 56842b633dbSJohn Snow :arg string? bar: Your favorite season. 56942b633dbSJohn Snow :return [string]: A lovely computer-written poem for you. 57042b633dbSJohn Snow 57142b633dbSJohn Snow 57242b633dbSJohn SnowWill be rendered as: 57342b633dbSJohn Snow 57442b633dbSJohn Snow .. qapi:command:: x-fake-command 57542b633dbSJohn Snow :noindex: 57642b633dbSJohn Snow :since: 42.0 57742b633dbSJohn Snow :unstable: 57842b633dbSJohn Snow 57942b633dbSJohn Snow This command is fake, so it can't hurt you! 58042b633dbSJohn Snow 58142b633dbSJohn Snow :arg int foo: Your favorite number. 58242b633dbSJohn Snow :arg string? bar: Your favorite season. 58342b633dbSJohn Snow :return [string]: A lovely computer-written poem for you. 58442b633dbSJohn Snow 58542b633dbSJohn Snow 58642b633dbSJohn Snowqapi:event 58742b633dbSJohn Snow---------- 58842b633dbSJohn Snow 58942b633dbSJohn SnowThis directive documents a QMP event. It may use any of the standard 59042b633dbSJohn SnowSphinx or QAPI options, and the documentation body may contain 59142b633dbSJohn Snow``:memb:`` or ``:feat:`` info field list entries. 59242b633dbSJohn Snow 59342b633dbSJohn SnowExample:: 59442b633dbSJohn Snow 59542b633dbSJohn Snow .. qapi:event:: COMPUTER_IS_RUINED 59642b633dbSJohn Snow :since: 0.1 59742b633dbSJohn Snow :deprecated: 59842b633dbSJohn Snow 59942b633dbSJohn Snow This event is emitted when your computer is *extremely* ruined. 60042b633dbSJohn Snow 60142b633dbSJohn Snow :memb string reason: Diagnostics as to what caused your computer to 60242b633dbSJohn Snow be ruined. 60342b633dbSJohn Snow :feat sadness: When present, the diagnostic message will also 60442b633dbSJohn Snow explain how sad the computer is as a result of your wrongdoings. 60542b633dbSJohn Snow 60642b633dbSJohn SnowWill be rendered as: 60742b633dbSJohn Snow 60842b633dbSJohn Snow.. qapi:event:: COMPUTER_IS_RUINED 60942b633dbSJohn Snow :noindex: 61042b633dbSJohn Snow :since: 0.1 61142b633dbSJohn Snow :deprecated: 61242b633dbSJohn Snow 61342b633dbSJohn Snow This event is emitted when your computer is *extremely* ruined. 61442b633dbSJohn Snow 61542b633dbSJohn Snow :memb string reason: Diagnostics as to what caused your computer to 61642b633dbSJohn Snow be ruined. 61742b633dbSJohn Snow :feat sadness: When present, the diagnostic message will also explain 61842b633dbSJohn Snow how sad the computer is as a result of your wrongdoings. 61942b633dbSJohn Snow 62042b633dbSJohn Snow 62142b633dbSJohn Snowqapi:enum 62242b633dbSJohn Snow--------- 62342b633dbSJohn Snow 62442b633dbSJohn SnowThis directive documents a QAPI enum. It may use any of the standard 62542b633dbSJohn SnowSphinx or QAPI options, and the documentation body may contain 62642b633dbSJohn Snow``:value:`` or ``:feat:`` info field list entries. 62742b633dbSJohn Snow 62842b633dbSJohn SnowExample:: 62942b633dbSJohn Snow 63042b633dbSJohn Snow .. qapi:enum:: Mood 63142b633dbSJohn Snow :ifcond: LIB_PERSONALITY 63242b633dbSJohn Snow 63342b633dbSJohn Snow This enum represents your virtual machine's current mood! 63442b633dbSJohn Snow 63542b633dbSJohn Snow :value Happy: Your VM is content and well-fed. 63642b633dbSJohn Snow :value Hungry: Your VM needs food. 63742b633dbSJohn Snow :value Melancholic: Your VM is experiencing existential angst. 63842b633dbSJohn Snow :value Petulant: Your VM is throwing a temper tantrum. 63942b633dbSJohn Snow 64042b633dbSJohn SnowWill be rendered as: 64142b633dbSJohn Snow 64242b633dbSJohn Snow.. qapi:enum:: Mood 64342b633dbSJohn Snow :noindex: 64442b633dbSJohn Snow :ifcond: LIB_PERSONALITY 64542b633dbSJohn Snow 64642b633dbSJohn Snow This enum represents your virtual machine's current mood! 64742b633dbSJohn Snow 64842b633dbSJohn Snow :value Happy: Your VM is content and well-fed. 64942b633dbSJohn Snow :value Hungry: Your VM needs food. 65042b633dbSJohn Snow :value Melancholic: Your VM is experiencing existential angst. 65142b633dbSJohn Snow :value Petulant: Your VM is throwing a temper tantrum. 65242b633dbSJohn Snow 65342b633dbSJohn Snow 65442b633dbSJohn Snowqapi:object 65542b633dbSJohn Snow----------- 65642b633dbSJohn Snow 65742b633dbSJohn SnowThis directive documents a QAPI structure or union and represents a QMP 65842b633dbSJohn Snowobject. It may use any of the standard Sphinx or QAPI options, and the 65942b633dbSJohn Snowdocumentation body may contain ``:memb:`` or ``:feat:`` info field list 66042b633dbSJohn Snowentries. 66142b633dbSJohn Snow 66242b633dbSJohn SnowExample:: 66342b633dbSJohn Snow 66442b633dbSJohn Snow .. qapi:object:: BigBlobOfStuff 66542b633dbSJohn Snow 66642b633dbSJohn Snow This object has a bunch of disparate and unrelated things in it. 66742b633dbSJohn Snow 66842b633dbSJohn Snow :memb int Birthday: Your birthday, represented in seconds since the 66942b633dbSJohn Snow UNIX epoch. 67042b633dbSJohn Snow :memb [string] Fav-Foods: A list of your favorite foods. 67142b633dbSJohn Snow :memb boolean? Bizarre-Docs: True if the documentation reference 67242b633dbSJohn Snow should be strange. 67342b633dbSJohn Snow 67442b633dbSJohn SnowWill be rendered as: 67542b633dbSJohn Snow 67642b633dbSJohn Snow.. qapi:object:: BigBlobOfStuff 67742b633dbSJohn Snow :noindex: 67842b633dbSJohn Snow 67942b633dbSJohn Snow This object has a bunch of disparate and unrelated things in it. 68042b633dbSJohn Snow 68142b633dbSJohn Snow :memb int Birthday: Your birthday, represented in seconds since the 68242b633dbSJohn Snow UNIX epoch. 68342b633dbSJohn Snow :memb [string] Fav-Foods: A list of your favorite foods. 68442b633dbSJohn Snow :memb boolean? Bizarre-Docs: True if the documentation reference 68542b633dbSJohn Snow should be strange. 68642b633dbSJohn Snow 68742b633dbSJohn Snow 68842b633dbSJohn Snowqapi:alternate 68942b633dbSJohn Snow-------------- 69042b633dbSJohn Snow 69142b633dbSJohn SnowThis directive documents a QAPI alternate. It may use any of the 69242b633dbSJohn Snowstandard Sphinx or QAPI options, and the documentation body may contain 69342b633dbSJohn Snow``:alt:`` or ``:feat:`` info field list entries. 69442b633dbSJohn Snow 69542b633dbSJohn SnowExample:: 69642b633dbSJohn Snow 69742b633dbSJohn Snow .. qapi:alternate:: ErrorCode 69842b633dbSJohn Snow 69942b633dbSJohn Snow This alternate represents an Error Code from the VM. 70042b633dbSJohn Snow 70142b633dbSJohn Snow :alt int ec: An error code, like the type you're used to. 70242b633dbSJohn Snow :alt string em: An expletive-laced error message, if your 70342b633dbSJohn Snow computer is feeling particularly cranky and tired of your 70442b633dbSJohn Snow antics. 70542b633dbSJohn Snow 70642b633dbSJohn SnowWill be rendered as: 70742b633dbSJohn Snow 70842b633dbSJohn Snow.. qapi:alternate:: ErrorCode 70942b633dbSJohn Snow :noindex: 71042b633dbSJohn Snow 71142b633dbSJohn Snow This alternate represents an Error Code from the VM. 71242b633dbSJohn Snow 71342b633dbSJohn Snow :alt int ec: An error code, like the type you're used to. 71442b633dbSJohn Snow :alt string em: An expletive-laced error message, if your 71542b633dbSJohn Snow computer is feeling particularly cranky and tired of your 71642b633dbSJohn Snow antics. 717