Skip to contentSkip to conversation

qapi: convert remaining "simple" intro sections

PATCH Superseded John Snow 2 participants 9 messages Sep 15 – Sep 16

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

John Snow

author
#0 lore raw

v3 cover qapi: convert remaining "simple" intro sections

v3:
- Fix python typing issue with hotfix from below ...
- Rebase on top of armbru/qapi-not-next
v2:
- Fix stub insertion algorithm for some "TODO:" replacement cases

Hello, this work converts the remaining "simple" intro sections in the QAPI schema to use the new syntax. This is part of our ongoing effort to add the mythical "inliner" to our generated QMP documentation.

This batch covers structures that *are* likely to be inlined, and thus have introductory paragraphs that are quite likely to be omitted when the member documentation is copied into other contexts (e.g. as arguments for command documentation, or as members of a branch for commands that accept union arguments.)

"simple" here is a non-technical distinction that means a single paragraph of text followed by an existing section boundary that naturally already delineates what comprises the intro.

If you are a non-QAPI maintainer who has been CC'd on this series, you may wish to review what information is being codified as the "intro" (The indented paragraph) and keep in mind that in the future, this text may not be visible to the end-user reading our QMP documentation if this structure is utilized as the 'base' for another struct, used as the arguments for a command or event, or used as branch of a union. This series keeps it pretty simple, and every conversion herein is being codified as "the intro", i.e. "not crucial to understanding the behavior of the members of this struct".

This is the last of the brain-dead, simple conversions apart from any new cases that may have been merged during the development of this series. The remaining patches all convert or split longer paragraphs and require more scrutiny.

We're almost back to reviewing actual code! Hang in there, everybody.

John Snow (7):
qapi: convert remaining simple intros for block-export.json
qapi: convert remaining simple intros for cxl.json
qapi: convert remaining simple intros for machine.json
qapi: convert remaining simple intros for block-core.json qapi/parser: fix intermediate "intro" detection
qapi: convert intro sections with "TODO" markers
qapi: convert intro sections followed by notes/examples

 qapi/block-core.json   | 45 ++++++++++++++++++------------------------
 qapi/block-export.json | 19 ++++++++----------
 qapi/cxl.json          | 14 +++++--------
 qapi/machine.json      | 15 +++++---------
 qapi/migration.json    | 25 +++++++++--------------
 qapi/misc.json         |  3 +--
 qapi/net.json          |  9 +++------
 qapi/run-state.json    |  7 +++----
 qapi/yank.json         |  5 +----
 scripts/qapi/parser.py |  7 +++++++
 10 files changed, 61 insertions(+), 88 deletions(-)
Signature · 1 line
2.55.0
author
#1 lore raw

PATCH v3 1/7 qapi: convert remaining simple intros for block-export.json

These are either structs or unions that are used in an inlinable
context: i.e. the generated documentation is likely to feature a version of this documentation block that does not include the intro in context of another command, event, or structure.

---
 qapi/block-export.json | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
qapi/block-export.json +8 -11
index 2893c6456d5..e9f7e72c8ee 100644
@@ -37,10 +37,9 @@
 
 ##
 # @NbdServerOptions:
-#
-# Keep this type consistent with the `NbdServerOptionsLegacy` type.
-# The only intended difference is using `SocketAddress` instead of
-# `SocketAddressLegacy`.
+#     Keep this type consistent with the `NbdServerOptionsLegacy`
+#     type.  The only intended difference is using `SocketAddress`
+#     instead of `SocketAddressLegacy`.
 #
 # @addr: Address on which to listen (since 4.2).
 ##
@@ -50,10 +49,9 @@
 
 ##
 # @NbdServerOptionsLegacy:
-#
-# Keep this type consistent with the `NbdServerOptions` type.  The
-# only intended difference is using `SocketAddressLegacy` instead of
-# `SocketAddress`.
+#     Keep this type consistent with the `NbdServerOptions` type.  The
+#     only intended difference is using `SocketAddressLegacy` instead
+#     of `SocketAddress`.
 #
 # @addr: Address on which to listen (since 1.3).
 ##
@@ -339,9 +337,8 @@
 
 ##
 # @BlockExportOptions:
-#
-# Describes a block export, i.e. how single node should be exported on
-# an external interface.
+#     Describes a block export, i.e. how single node should be
+#     exported on an external interface.
 #
 # @type: Block export type
 #
Signature · 1 line
2.55.0
author
#2 lore raw

PATCH v3 2/7 qapi: convert remaining simple intros for cxl.json

In reply to John Snow

These are either structs or unions that are used in an inlinable
context: i.e. the generated documentation is likely to feature a version of this documentation block that does not include the intro in context of another command, event, or structure.

---
 qapi/cxl.json | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
qapi/cxl.json +5 -9
index 631d4def2ac..9422d5a0e2d 100644
@@ -32,9 +32,8 @@
 
 ##
 # @CXLCommonEventBase:
-#
-# Common event base for a CXL Event (CXL r3.2 8.2.10.2.1
-# Table 8-55 Common Event Record Format).
+#     Common event base for a CXL Event (CXL r3.2 8.2.10.2.1 Table
+#     8-55 Common Event Record Format).
 #
 # @path: CXL type 3 device canonical QOM path
 #
@@ -63,8 +62,7 @@
 
 ##
 # @CXLGeneralMediaEvent:
-#
-# Event record for a General Media Event (CXL r3.2 8.2.10.2.1.1).
+#     Event record for a General Media Event (CXL r3.2 8.2.10.2.1.1).
 #
 # @dpa: Device Physical Address (relative to @path device).  Note
 #     lower bits include some flags.  See CXL r3.2 Table 8-57 General
@@ -129,8 +127,7 @@
 
 ##
 # @CXLDRAMEvent:
-#
-# Event record for a DRAM Event (CXL r3.2 8.2.10.2.1.2).
+#     Event record for a DRAM Event (CXL r3.2 8.2.10.2.1.2).
 #
 # @dpa: Device Physical Address (relative to @path device).  Note
 #     lower bits include some flags.  See CXL r3.2 Table 8-58 DRAM
@@ -211,8 +208,7 @@
 
 ##
 # @CXLMemModuleEvent:
-#
-# Event record for a Memory Module Event (CXL r3.2 8.2.10.2.1.3).
+#     Event record for a Memory Module Event (CXL r3.2 8.2.10.2.1.3).
 #
 # @type: Device Event Type.  See CXL r3.2 Table 8-59 Memory Module
 #     Event Record for bit definitions for bit definiions.
Signature · 1 line
2.55.0
author
#3 lore raw

PATCH v3 3/7 qapi: convert remaining simple intros for machine.json

In reply to John Snow

These are either structs or unions that are used in an inlinable
context: i.e. the generated documentation is likely to feature a version of this documentation block that does not include the intro in context of another command, event, or structure.

---
 qapi/machine.json | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
qapi/machine.json +1 -2
index f1f2c393824..a58e373dd70 100644
@@ -449,8 +449,7 @@
 
 ##
 # @NumaOptions:
-#
-# A discriminated record of NUMA options.  (for OptsVisitor)
+#     A discriminated record of NUMA options.  (for OptsVisitor)
 #
 # @type: NUMA option type
 #
Signature · 1 line
2.55.0
author
#4 lore raw

PATCH v3 4/7 qapi: convert remaining simple intros for block-core.json

In reply to John Snow

These are either structs or unions that are used in an inlinable
context: i.e. the generated documentation is likely to feature a version of this documentation block that does not include the intro in context of another command, event, or structure.

---
 qapi/block-core.json | 45 +++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 26 deletions(-)
qapi/block-core.json +19 -26
index 1ca147285e7..88218e38d02 100644
@@ -4462,9 +4462,8 @@
 
 ##
 # @BlockdevOptionsCurlHttp:
-#
-# Driver specific block device options for HTTP connections over the
-# curl backend.  URLs must start with "http://".
+#     Driver specific block device options for HTTP connections over
+#     the curl backend.  URLs must start with "http://".
 #
 # @cookie: List of cookies to set; format is "name1=content1;
 #     name2=content2;" as explained by CURLOPT_COOKIE(3).  Defaults to
@@ -4488,9 +4487,8 @@
 
 ##
 # @BlockdevOptionsCurlHttps:
-#
-# Driver specific block device options for HTTPS connections over the
-# curl backend.  URLs must start with "https://".
+#     Driver specific block device options for HTTPS connections over
+#     the curl backend.  URLs must start with "https://".
 #
 # @sslverify: Whether to verify the SSL certificate's validity
 #     (defaults to true)
@@ -4503,9 +4501,8 @@
 
 ##
 # @BlockdevOptionsCurlFtp:
-#
-# Driver specific block device options for FTP connections over the
-# curl backend.  URLs must start with "ftp://".
+#     Driver specific block device options for FTP connections over
+#     the curl backend.  URLs must start with "ftp://".
 #
 # Since: 2.9
 ##
@@ -4515,9 +4512,8 @@
 
 ##
 # @BlockdevOptionsCurlFtps:
-#
-# Driver specific block device options for FTPS connections over the
-# curl backend.  URLs must start with "ftps://".
+#     Driver specific block device options for FTPS connections over
+#     the curl backend.  URLs must start with "ftps://".
 #
 # @sslverify: Whether to verify the SSL certificate's validity
 #     (defaults to true)
@@ -4643,14 +4639,13 @@
 
 ##
 # @BlockdevOptionsCbw:
-#
-# Driver specific block device options for the copy-before-write
-# driver, which does so called copy-before-write operations: when data
-# is written to the filter, the filter first reads corresponding
-# blocks from its file child and copies them to @target child.  After
-# successfully copying, the write request is propagated to file child.
-# If copying fails, the original write request is failed too and no
-# data is written to file child.
+#     Driver specific block device options for the copy-before-write
+#     driver, which does so called copy-before-write operations: when
+#     data is written to the filter, the filter first reads
+#     corresponding blocks from its file child and copies them to
+#     @target child.  After successfully copying, the write request is
+#     propagated to file child.  If copying fails, the original write
+#     request is failed too and no data is written to file child.
 #
 # @target: The target for copy-before-write operations.
 #
@@ -4686,9 +4681,8 @@
 
 ##
 # @BlockdevOptions:
-#
-# Options for creating a block device.  Many options are available for
-# all block devices, independent of the block driver:
+#     Options for creating a block device.  Many options are available
+#     for all block devices, independent of the block driver:
 #
 # @driver: block driver name
 #
@@ -5473,9 +5467,8 @@
 
 ##
 # @BlockdevAmendOptionsQcow2:
-#
-# Driver specific image amend options for qcow2.  For now, only
-# encryption options can be amended
+#     Driver specific image amend options for qcow2.  For now, only
+#     encryption options can be amended
 #
 # @encrypt: Encryption options to be amended
 #
Signature · 1 line
2.55.0
author
#5 lore raw

PATCH v3 5/7 qapi/parser: fix intermediate "intro" detection

In reply to John Snow

In 43e7ad1a3fa5, I adjusted the insertion algorithm for inserting something after the "introduction" to cope with both the old and new syntax while we converted QAPI to the new syntax. There's a bug in that code that only shows up in a handful of cases and only when using the new syntax while this affordance/flex code is still enabled.

In the case that we do actually have a real bona-fide intro section, we want to insert directly after that real-deal intro section, not after any plaintext sections that may follow it. This code adjusts the temporary code to strongly prefer inserting after the actual intro section if it exists.

Once again: once conversion is done, you will be delighted by how much of this ugly code goes away.

---
 scripts/qapi/parser.py | 7 +++++++
 1 file changed, 7 insertions(+)
scripts/qapi/parser.py +7 -0
index 9e14c2f7921..79f03062eea 100644
@@ -845,6 +845,13 @@ def _insert_after_intro(
         needed and ``_insert_near_kind(QAPIDoc.Kind.INTRO, ...)`` will
         be sufficient.
         """
+        first = self.all_sections[0]
+        if first.text and first.kind == QAPIDoc.Kind.INTRO:
+            # First section is introduction and is non-empty: insert here.
+            # Rest assured all of this ugliness will very soon go away.
+            # Pinkie-swear.
+            self._insert_near_kind(QAPIDoc.Kind.INTRO, section, after=True)
+
         index = 0
         for index, ref_section in enumerate(self.all_sections):
             if ref_section.kind.name in ("PLAIN", "INTRO"):
Signature · 1 line
2.55.0
author
#7 lore raw

PATCH v3 6/7 qapi: convert intro sections with "TODO" markers

In reply to John Snow

This patch converts intro sections that are immediately followed by a "TODO:" that was formerly used to demarcate the stub member insertion point.

---
 qapi/machine.json   |  7 ++-----
 qapi/migration.json | 10 ++--------
 qapi/net.json       |  9 +++------
 qapi/yank.json      |  5 +----
 4 files changed, 8 insertions(+), 23 deletions(-)
qapi/machine.json +2 -5
index a58e373dd70..84d95c8d87f 100644
@@ -1244,11 +1244,8 @@
 
 ##
 # @query-memory-size-summary:
-#
-# Return the amount of initially allocated and present hotpluggable
-# (if enabled) memory in bytes.
-#
-# TODO: This line is a hack to separate the example from the body
+#     Return the amount of initially allocated and present
+#     hotpluggable (if enabled) memory in bytes.
 #
 # .. qmp-example::
 #
qapi/migration.json +2 -8
index 0428f777882..d571c06fc20 100644
@@ -1617,10 +1617,7 @@
 
 ##
 # @query-xen-replication-status:
-#
-# Query replication status while the vm is running.
-#
-# TODO: This line is a hack to separate the example from the body
+#     Query replication status while the vm is running.
 #
 # .. qmp-example::
 #
@@ -1670,10 +1667,7 @@
 
 ##
 # @query-colo-status:
-#
-# Query COLO status while the vm is running.
-#
-# TODO: This line is a hack to separate the example from the body
+#     Query COLO status while the vm is running.
 #
 # .. qmp-example::
 #
qapi/net.json +3 -6
index 526108ca0bb..d0bacb4dcfe 100644
@@ -1159,12 +1159,9 @@
 
 ##
 # @announce-self:
-#
-# Trigger generation of broadcast RARP frames to update network
-# switches.  This can be useful when network bonds fail-over the
-# active slave.
-#
-# TODO: This line is a hack to separate the example from the body
+#     Trigger generation of broadcast RARP frames to update network
+#     switches.  This can be useful when network bonds fail-over the
+#     active slave.
 #
 # .. qmp-example::
 #
qapi/yank.json +1 -4
index 8ac4b773653..187a0952e66 100644
@@ -96,10 +96,7 @@
 
 ##
 # @query-yank:
-#
-# Query yank instances.  See `YankInstance` for more information.
-#
-# TODO: This line is a hack to separate the example from the body
+#     Query yank instances.  See `YankInstance` for more information.
 #
 # .. qmp-example::
 #
Signature · 1 line
2.55.0
author
#8 lore raw

PATCH v3 7/7 qapi: convert intro sections followed by notes/examples

In reply to John Snow

These provide a rather natural cutoff point, but technically this does introduce a new intro/details split to these documentation blocks.

---
 qapi/machine.json   |  5 ++---
 qapi/migration.json | 15 +++++++--------
 qapi/misc.json      |  3 +--
 qapi/run-state.json |  7 +++----
 4 files changed, 13 insertions(+), 17 deletions(-)
qapi/machine.json +2 -3
index 84d95c8d87f..276258d9e5c 100644
@@ -1209,9 +1209,8 @@
 
 ##
 # @HV_BALLOON_STATUS_REPORT:
-#
-# Emitted when the hv-balloon driver receives a "STATUS" message from
-# the guest.
+#     Emitted when the hv-balloon driver receives a "STATUS" message
+#     from the guest.
 #
 # .. note:: This event is rate-limited.
 #
qapi/migration.json +7 -8
index d571c06fc20..a272e701385 100644
@@ -1254,10 +1254,10 @@
 
 ##
 # @migrate_cancel:
-#
-# Cancel the currently executing migration process.  Allows a new
-# migration to be started right after.  When postcopy-ram is in use,
-# cancelling is not allowed after the postcopy phase has started.
+#     Cancel the currently executing migration process.  Allows a new
+#     migration to be started right after.  When postcopy-ram is in
+#     use, cancelling is not allowed after the postcopy phase has
+#     started.
 #
 # .. note:: This command succeeds even if there is no migration
 #    process running.
@@ -1632,8 +1632,8 @@
 
 ##
 # @xen-colo-do-checkpoint:
-#
-# Xen uses this command to notify replication to trigger a checkpoint.
+#     Xen uses this command to notify replication to trigger a
+#     checkpoint.
 #
 # .. qmp-example::
 #
@@ -1700,8 +1700,7 @@
 
 ##
 # @migrate-pause:
-#
-# Pause a migration.  Currently it only supports postcopy.
+#     Pause a migration.  Currently it only supports postcopy.
 #
 # .. qmp-example::
 #
qapi/misc.json +1 -2
index b7d08532768..b62cabc2b79 100644
@@ -103,8 +103,7 @@
 
 ##
 # @query-iothreads:
-#
-# Return a list of information about each iothread.
+#     Return a list of information about each iothread.
 #
 # .. note:: This list excludes the QEMU main loop thread, which is not
 #    declared using the ``-object iothread`` command-line option.  It
qapi/run-state.json +3 -4
index 703ca1bb5b9..8bbd9884087 100644
@@ -232,10 +232,9 @@
 
 ##
 # @SUSPEND_DISK:
-#
-# Emitted when guest enters a hardware suspension state with data
-# saved on disk, for example, S4 state, which is sometimes called
-# hibernate state
+#     Emitted when guest enters a hardware suspension state with data
+#     saved on disk, for example, S4 state, which is sometimes called
+#     hibernate state
 #
 # .. note:: QEMU shuts down (similar to event `SHUTDOWN`) when
 #    entering this state.
Signature · 1 line
2.55.0
#6 lore raw

Re: [PATCH v3 5/7] qapi/parser: fix intermediate "intro" detection

In reply to John Snow
Quoted 28 lines · John Snow

In 43e7ad1a3fa5, I adjusted the insertion algorithm for inserting something after the "introduction" to cope with both the old and new syntax while we converted QAPI to the new syntax. There's a bug in that code that only shows up in a handful of cases and only when using the new syntax while this affordance/flex code is still enabled.

In the case that we do actually have a real bona-fide intro section, we want to insert directly after that real-deal intro section, not after any plaintext sections that may follow it. This code adjusts the temporary code to strongly prefer inserting after the actual intro section if it exists.

Once again: once conversion is done, you will be delighted by how much of this ugly code goes away.

---
 scripts/qapi/parser.py | 7 +++++++
 1 file changed, 7 insertions(+)
scripts/qapi/parser.py +0 -0
index 9e14c2f7921..79f03062eea 100644
@@ -845,6 +845,13 @@ def _insert_after_intro(
         needed and ``_insert_near_kind(QAPIDoc.Kind.INTRO, ...)`` will
         be sufficient.
         """

scripts/qapi/parser.py def _insert_after_intro( · line 857

Quoted 10 lines
scripts/qapi/parser.py +7 -0
+        first = self.all_sections[0]
+        if first.text and first.kind == QAPIDoc.Kind.INTRO:
+            # First section is introduction and is non-empty: insert here.
+            # Rest assured all of this ugliness will very soon go away.
+            # Pinkie-swear.
+            self._insert_near_kind(QAPIDoc.Kind.INTRO, section, after=True)
+
         index = 0
         for index, ref_section in enumerate(self.all_sections):
             if ref_section.kind.name in ("PLAIN", "INTRO"):

This seems to insert generated sections twice, but only sometimes.

Two examples:

Command query-status (Since: 0.14)

Query the run status of the VM

Return:
"StatusInfo"

+ Return:
+ "StatusInfo"
+

      Example::

         -> { "execute": "query-status" }
         <- { "return": { "running": true,
                          "status": "running" } }

and

Enum DisplayProtocol (Since: 7.0)

Display protocols which support changing password options.

Values:
* **vnc** -- Not documented

+ * **vnc** -- Not documented
+
* **spice** -- Not documented