Skip to contentSkip to conversation

QAPI patches for 2019-06-12

GIT PULL Applied Markus Armbruster 2 participants 13 messages Jun 12, 2019 – Jun 13, 2019 Block layer

lore
Share & tools
lore
#0 lore raw

The following changes since commit a050901d4b40092dc356b59912c6df39e389c7b9:

Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-4.1-20190612' into staging (2019-06-12 14:43:47 +0100)

are available in the Git repository at:

git://repo.or.cz/qemu/armbru.git tags/pull-qapi-2019-06-12

for you to fetch changes up to 157dd363955b961ef378eb1f7817c31a7fa94d10:

qapi: Simplify how QAPIDoc implements its state machine (2019-06-12 18:37:17 +0200)

----------------------------------------------------------------
QAPI patches for 2019-06-12

----------------------------------------------------------------
Kevin Wolf (6):
qapi: Add feature flags to struct types tests/qapi-schema: Test for good feature lists in structs tests/qapi-schema: Error case tests for features in structs
qapi: Disentangle QAPIDoc code
qapi: Allow documentation for features
file-posix: Add dynamic-auto-read-only QAPI feature

Markus Armbruster (2):
qdev: Delete unused LostTickPolicy "merge"
qapi: Simplify how QAPIDoc implements its state machine

Stefano Garzarella (3):
qapi/block-core: update documentation of preallocation parameter block/file-posix: update .help of BLOCK_OPT_PREALLOC option block/gluster: update .help of BLOCK_OPT_PREALLOC option

 block/file-posix.c                             |   6 +-
 block/gluster.c                                |   9 +-
 docs/devel/qapi-code-gen.txt                   |  38 ++++
 qapi/block-core.json                           |  33 +++-
 qapi/introspect.json                           |   6 +-
 qapi/misc.json                                 |   6 +-
 scripts/qapi/common.py                         | 243 +++++++++++++++++++++----
 scripts/qapi/doc.py                            |  15 +-
 scripts/qapi/introspect.py                     |   6 +-
 scripts/qapi/types.py                          |   3 +-
 scripts/qapi/visit.py                          |   3 +-
 tests/Makefile.include                         |   6 +
 tests/qapi-schema/double-type.err              |   2 +-
 tests/qapi-schema/features-bad-type.err        |   1 +
 tests/qapi-schema/features-bad-type.exit       |   1 +
 tests/qapi-schema/features-bad-type.json       |   3 +
 tests/qapi-schema/features-bad-type.out        |   0
 tests/qapi-schema/features-duplicate-name.err  |   1 +
 tests/qapi-schema/features-duplicate-name.exit |   1 +
 tests/qapi-schema/features-duplicate-name.json |   3 +
 tests/qapi-schema/features-duplicate-name.out  |   0
 tests/qapi-schema/features-missing-name.err    |   1 +
 tests/qapi-schema/features-missing-name.exit   |   1 +
 tests/qapi-schema/features-missing-name.json   |   3 +
 tests/qapi-schema/features-missing-name.out    |   0
 tests/qapi-schema/features-name-bad-type.err   |   1 +
 tests/qapi-schema/features-name-bad-type.exit  |   1 +
 tests/qapi-schema/features-name-bad-type.json  |   3 +
 tests/qapi-schema/features-name-bad-type.out   |   0
 tests/qapi-schema/features-no-list.err         |   1 +
 tests/qapi-schema/features-no-list.exit        |   1 +
 tests/qapi-schema/features-no-list.json        |   3 +
 tests/qapi-schema/features-no-list.out         |   0
 tests/qapi-schema/features-unknown-key.err     |   2 +
 tests/qapi-schema/features-unknown-key.exit    |   1 +
 tests/qapi-schema/features-unknown-key.json    |   3 +
 tests/qapi-schema/features-unknown-key.out     |   0
 tests/qapi-schema/qapi-schema-test.json        |  39 ++++
 tests/qapi-schema/qapi-schema-test.out         |  43 +++++
 tests/qapi-schema/test-qapi.py                 |   7 +-
 tests/qapi-schema/unknown-expr-key.err         |   2 +-
 tests/test-qmp-cmds.c                          |   8 +
 42 files changed, 447 insertions(+), 59 deletions(-)
 create mode 100644 tests/qapi-schema/features-bad-type.err
 create mode 100644 tests/qapi-schema/features-bad-type.exit
 create mode 100644 tests/qapi-schema/features-bad-type.json
 create mode 100644 tests/qapi-schema/features-bad-type.out
 create mode 100644 tests/qapi-schema/features-duplicate-name.err
 create mode 100644 tests/qapi-schema/features-duplicate-name.exit
 create mode 100644 tests/qapi-schema/features-duplicate-name.json
 create mode 100644 tests/qapi-schema/features-duplicate-name.out
 create mode 100644 tests/qapi-schema/features-missing-name.err
 create mode 100644 tests/qapi-schema/features-missing-name.exit
 create mode 100644 tests/qapi-schema/features-missing-name.json
 create mode 100644 tests/qapi-schema/features-missing-name.out
 create mode 100644 tests/qapi-schema/features-name-bad-type.err
 create mode 100644 tests/qapi-schema/features-name-bad-type.exit
 create mode 100644 tests/qapi-schema/features-name-bad-type.json
 create mode 100644 tests/qapi-schema/features-name-bad-type.out
 create mode 100644 tests/qapi-schema/features-no-list.err
 create mode 100644 tests/qapi-schema/features-no-list.exit
 create mode 100644 tests/qapi-schema/features-no-list.json
 create mode 100644 tests/qapi-schema/features-no-list.out
 create mode 100644 tests/qapi-schema/features-unknown-key.err
 create mode 100644 tests/qapi-schema/features-unknown-key.exit
 create mode 100644 tests/qapi-schema/features-unknown-key.json
 create mode 100644 tests/qapi-schema/features-unknown-key.out
Signature · 1 line
2.21.0
#1 lore raw

[Qemu-devel] [PULL 01/11] qdev: Delete unused LostTickPolicy "merge"

Commit 4e4fa398db6 "qdev: Introduce lost tick policy property" (v1.1.0) created PropertyType PROP_TYPE_LOSTTICKPOLICY with values "discard", "delay", "merge", and "slew". Value "merge" has never been used. Delete it.

Message-Id: <[email protected]>

---
 qapi/misc.json | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
qapi/misc.json +1 -5
index 8b3ca4fdd3..dc4cf9da20 100644
@@ -172,17 +172,13 @@
 # @delay: continue to deliver ticks at the normal rate.  Guest time will be
 #         delayed due to the late tick
 #
-# @merge: merge the missed tick(s) into one tick and inject.  Guest time
-#         may be delayed, depending on how the OS reacts to the merging
-#         of ticks
-#
 # @slew: deliver ticks at a higher rate to catch up with the missed tick. The
 #        guest time should not be delayed once catchup is complete.
 #
 # Since: 2.0
 ##
 { 'enum': 'LostTickPolicy',
-  'data': ['discard', 'delay', 'merge', 'slew' ] }
+  'data': ['discard', 'delay', 'slew' ] }
 
 ##
 # @add_client:
Signature · 1 line
2.21.0
#2 lore raw

[Qemu-devel] [PULL 07/11] tests/qapi-schema: Error case tests for features in structs

In reply to Markus Armbruster

From: Kevin Wolf <[email protected]>

Message-Id: <[email protected]>

---
 tests/Makefile.include                         | 6 ++++++
 tests/qapi-schema/features-bad-type.err        | 1 +
 tests/qapi-schema/features-bad-type.exit       | 1 +
 tests/qapi-schema/features-bad-type.json       | 3 +++
 tests/qapi-schema/features-bad-type.out        | 0
 tests/qapi-schema/features-duplicate-name.err  | 1 +
 tests/qapi-schema/features-duplicate-name.exit | 1 +
 tests/qapi-schema/features-duplicate-name.json | 3 +++
 tests/qapi-schema/features-duplicate-name.out  | 0
 tests/qapi-schema/features-missing-name.err    | 1 +
 tests/qapi-schema/features-missing-name.exit   | 1 +
 tests/qapi-schema/features-missing-name.json   | 3 +++
 tests/qapi-schema/features-missing-name.out    | 0
 tests/qapi-schema/features-name-bad-type.err   | 1 +
 tests/qapi-schema/features-name-bad-type.exit  | 1 +
 tests/qapi-schema/features-name-bad-type.json  | 3 +++
 tests/qapi-schema/features-name-bad-type.out   | 0
 tests/qapi-schema/features-no-list.err         | 1 +
 tests/qapi-schema/features-no-list.exit        | 1 +
 tests/qapi-schema/features-no-list.json        | 3 +++
 tests/qapi-schema/features-no-list.out         | 0
 tests/qapi-schema/features-unknown-key.err     | 2 ++
 tests/qapi-schema/features-unknown-key.exit    | 1 +
 tests/qapi-schema/features-unknown-key.json    | 3 +++
 tests/qapi-schema/features-unknown-key.out     | 0
 25 files changed, 37 insertions(+)
 create mode 100644 tests/qapi-schema/features-bad-type.err
 create mode 100644 tests/qapi-schema/features-bad-type.exit
 create mode 100644 tests/qapi-schema/features-bad-type.json
 create mode 100644 tests/qapi-schema/features-bad-type.out
 create mode 100644 tests/qapi-schema/features-duplicate-name.err
 create mode 100644 tests/qapi-schema/features-duplicate-name.exit
 create mode 100644 tests/qapi-schema/features-duplicate-name.json
 create mode 100644 tests/qapi-schema/features-duplicate-name.out
 create mode 100644 tests/qapi-schema/features-missing-name.err
 create mode 100644 tests/qapi-schema/features-missing-name.exit
 create mode 100644 tests/qapi-schema/features-missing-name.json
 create mode 100644 tests/qapi-schema/features-missing-name.out
 create mode 100644 tests/qapi-schema/features-name-bad-type.err
 create mode 100644 tests/qapi-schema/features-name-bad-type.exit
 create mode 100644 tests/qapi-schema/features-name-bad-type.json
 create mode 100644 tests/qapi-schema/features-name-bad-type.out
 create mode 100644 tests/qapi-schema/features-no-list.err
 create mode 100644 tests/qapi-schema/features-no-list.exit
 create mode 100644 tests/qapi-schema/features-no-list.json
 create mode 100644 tests/qapi-schema/features-no-list.out
 create mode 100644 tests/qapi-schema/features-unknown-key.err
 create mode 100644 tests/qapi-schema/features-unknown-key.exit
 create mode 100644 tests/qapi-schema/features-unknown-key.json
 create mode 100644 tests/qapi-schema/features-unknown-key.out
tests/Makefile.include +6 -0
index 0cd5f465b7..db750dd6d0 100644
@@ -378,6 +378,12 @@ qapi-schema += event-boxed-empty.json
 qapi-schema += event-case.json
 qapi-schema += event-member-invalid-dict.json
 qapi-schema += event-nest-struct.json
+qapi-schema += features-bad-type.json
+qapi-schema += features-duplicate-name.json
+qapi-schema += features-missing-name.json
+qapi-schema += features-name-bad-type.json
+qapi-schema += features-no-list.json
+qapi-schema += features-unknown-key.json
 qapi-schema += flat-union-array-branch.json
 qapi-schema += flat-union-bad-base.json
 qapi-schema += flat-union-bad-discriminator.json
tests/qapi-schema/features-bad-type.err new file +1 -0
new file mode 100644
index 0000000000..5fb95c2f90
@@ -0,0 +1 @@
+tests/qapi-schema/features-bad-type.json:1: Feature of struct FeatureStruct0 requires a string name
tests/qapi-schema/features-bad-type.exit new file +1 -0
new file mode 100644
index 0000000000..d00491fd7e
@@ -0,0 +1 @@
+1
tests/qapi-schema/features-bad-type.json new file +3 -0
new file mode 100644
index 0000000000..57db5540e7
@@ -0,0 +1,3 @@
+{ 'struct': 'FeatureStruct0',
+  'data': { 'foo': 'int' },
+  'features': [ [ 'a feature cannot be an array' ] ] }
tests/qapi-schema/features-bad-type.out new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
tests/qapi-schema/features-duplicate-name.err new file +1 -0
new file mode 100644
index 0000000000..c0a4cccae6
@@ -0,0 +1 @@
+tests/qapi-schema/features-duplicate-name.json:1: 'foo' (feature of FeatureStruct0) collides with 'foo' (feature of FeatureStruct0)
tests/qapi-schema/features-duplicate-name.exit new file +1 -0
new file mode 100644
index 0000000000..d00491fd7e
@@ -0,0 +1 @@
+1
tests/qapi-schema/features-duplicate-name.json new file +3 -0
new file mode 100644
index 0000000000..29358e6220
@@ -0,0 +1,3 @@
+{ 'struct': 'FeatureStruct0',
+  'data': { 'foo': 'int' },
+  'features': [ 'foo', 'bar', 'foo' ] }
tests/qapi-schema/features-duplicate-name.out new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
tests/qapi-schema/features-missing-name.err new file +1 -0
new file mode 100644
index 0000000000..4f1d2715aa
@@ -0,0 +1 @@
+tests/qapi-schema/features-missing-name.json:1: Key 'name' is missing from feature of struct FeatureStruct0
tests/qapi-schema/features-missing-name.exit new file +1 -0
new file mode 100644
index 0000000000..d00491fd7e
@@ -0,0 +1 @@
+1
tests/qapi-schema/features-missing-name.json new file +3 -0
new file mode 100644
index 0000000000..2314f97c00
@@ -0,0 +1,3 @@
+{ 'struct': 'FeatureStruct0',
+  'data': { 'foo': 'int' },
+  'features': [ { 'if': 'defined(NAMELESS_FEATURES)' } ] }
tests/qapi-schema/features-missing-name.out new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
tests/qapi-schema/features-name-bad-type.err new file +1 -0
new file mode 100644
index 0000000000..8a3eecb972
@@ -0,0 +1 @@
+tests/qapi-schema/features-name-bad-type.json:1: Feature of struct FeatureStruct0 requires a string name
tests/qapi-schema/features-name-bad-type.exit new file +1 -0
new file mode 100644
index 0000000000..d00491fd7e
@@ -0,0 +1 @@
+1
tests/qapi-schema/features-name-bad-type.json new file +3 -0
new file mode 100644
index 0000000000..b07139978a
@@ -0,0 +1,3 @@
+{ 'struct': 'FeatureStruct0',
+  'data': { 'foo': 'int' },
+  'features': [ { 'name': { 'feature-type': 'object' } } ] }
tests/qapi-schema/features-name-bad-type.out new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
tests/qapi-schema/features-no-list.err new file +1 -0
new file mode 100644
index 0000000000..61ed68612b
@@ -0,0 +1 @@
+tests/qapi-schema/features-no-list.json:1: Struct 'FeatureStruct0' requires an array for 'features'
tests/qapi-schema/features-no-list.exit new file +1 -0
new file mode 100644
index 0000000000..d00491fd7e
@@ -0,0 +1 @@
+1
tests/qapi-schema/features-no-list.json new file +3 -0
new file mode 100644
index 0000000000..9484fd94fc
@@ -0,0 +1,3 @@
+{ 'struct': 'FeatureStruct0',
+  'data': { 'foo': 'int' },
+  'features': 'bar' }
tests/qapi-schema/features-no-list.out new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
tests/qapi-schema/features-unknown-key.err new file +2 -0
new file mode 100644
index 0000000000..a1d693030d
@@ -0,0 +1,2 @@
+tests/qapi-schema/features-unknown-key.json:1: Unknown key 'colour' in feature of struct FeatureStruct0
+Valid keys are 'if', 'name'.
tests/qapi-schema/features-unknown-key.exit new file +1 -0
new file mode 100644
index 0000000000..d00491fd7e
@@ -0,0 +1 @@
+1
tests/qapi-schema/features-unknown-key.json new file +3 -0
new file mode 100644
index 0000000000..134df3b503
@@ -0,0 +1,3 @@
+{ 'struct': 'FeatureStruct0',
+  'data': { 'foo': 'int' },
+  'features': [ { 'name': 'bar', 'colour': 'red' } ] }
tests/qapi-schema/features-unknown-key.out new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
2.21.0
#3 lore raw

[Qemu-devel] [PULL 02/11] qapi/block-core: update documentation of preallocation parameter

In reply to Markus Armbruster

From: Stefano Garzarella <[email protected]>

Add default and available values in the documentation block of each block device or protocol that supports the 'preallocation' parameter during the image creation.

Message-Id: <[email protected]>

---
 qapi/block-core.json | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
qapi/block-core.json +14 -6
index 1defcde048..175ccfe896 100644
@@ -4121,7 +4121,10 @@
 #
 # @filename         Filename for the new image file
 # @size             Size of the virtual disk in bytes
-# @preallocation    Preallocation mode for the new image (default: off)
+# @preallocation    Preallocation mode for the new image (default: off;
+#                   allowed values: off,
+#                   falloc (if defined CONFIG_POSIX_FALLOCATE),
+#                   full (if defined CONFIG_POSIX))
 # @nocow            Turn off copy-on-write (valid only on btrfs; default: off)
 #
 # Since: 2.12
@@ -4139,7 +4142,10 @@
 #
 # @location         Where to store the new image file
 # @size             Size of the virtual disk in bytes
-# @preallocation    Preallocation mode for the new image (default: off)
+# @preallocation    Preallocation mode for the new image (default: off;
+#                   allowed values: off,
+#                   falloc (if defined CONFIG_GLUSTERFS_FALLOCATE),
+#                   full (if defined CONFIG_GLUSTERFS_ZEROFILL))
 #
 # Since: 2.12
 ##
@@ -4243,7 +4249,8 @@
 # @backing-fmt      Name of the block driver to use for the backing file
 # @encrypt          Encryption options if the image should be encrypted
 # @cluster-size     qcow2 cluster size in bytes (default: 65536)
-# @preallocation    Preallocation mode for the new image (default: off)
+# @preallocation    Preallocation mode for the new image (default: off;
+#                   allowed values: off, falloc, full, metadata)
 # @lazy-refcounts   True if refcounts may be updated lazily (default: off)
 # @refcount-bits    Width of reference counts in bits (default: 16)
 #
@@ -4426,7 +4433,8 @@
 # @location         Where to store the new image file
 # @size             Size of the virtual disk in bytes
 # @backing-file     File name of a base image
-# @preallocation    Preallocation mode (allowed values: off, full)
+# @preallocation    Preallocation mode for the new image (default: off;
+#                   allowed values: off, full)
 # @redundancy       Redundancy of the image
 # @object-size      Object size of the image
 #
@@ -4461,8 +4469,8 @@
 #
 # @file             Node to create the image format on
 # @size             Size of the virtual disk in bytes
-# @preallocation    Preallocation mode for the new image (allowed values: off,
-#                   metadata; default: off)
+# @preallocation    Preallocation mode for the new image (default: off;
+#                   allowed values: off, metadata)
 #
 # Since: 2.12
 ##
Signature · 1 line
2.21.0
#4 lore raw

[Qemu-devel] [PULL 04/11] block/gluster: update .help of BLOCK_OPT_PREALLOC option

In reply to Markus Armbruster

From: Stefano Garzarella <[email protected]>

Add missing 'falloc' among the allowed values of 'preallocation' option; show it and 'full' only when they are supported. ('falloc' is supported if defined CONFIG_GLUSTERFS_FALLOCATE, 'full' is supported if defined CONFIG_GLUSTERFS_ZEROFILL)

Message-Id: <[email protected]>

---
 block/gluster.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
block/gluster.c +8 -1
index dc16f0c329..62f8ff2147 100644
@@ -98,7 +98,14 @@ static QemuOptsList qemu_gluster_create_opts = {
         {
             .name = BLOCK_OPT_PREALLOC,
             .type = QEMU_OPT_STRING,
-            .help = "Preallocation mode (allowed values: off, full)"
+            .help = "Preallocation mode (allowed values: off"
+#ifdef CONFIG_GLUSTERFS_FALLOCATE
+                    ", falloc"
+#endif
+#ifdef CONFIG_GLUSTERFS_ZEROFILL
+                    ", full"
+#endif
+                    ")"
         },
         {
             .name = GLUSTER_OPT_DEBUG,
Signature · 1 line
2.21.0
#5 lore raw

[Qemu-devel] [PULL 05/11] qapi: Add feature flags to struct types

In reply to Markus Armbruster

From: Kevin Wolf <[email protected]>

Sometimes, the behaviour of QEMU changes without a change in the QMP syntax (usually by allowing values or operations that previously resulted in an error). QMP clients may still need to know whether they can rely on the changed behavior.

Let's add feature flags to the QAPI schema language, so that we can make such changes visible with schema introspection.

An example for a schema definition using feature flags looks like this:

    { 'struct': 'TestType',
      'data': { 'number': 'int' },
      'features': [ 'allow-negative-numbers' ] }

Introspection information then looks like this:

    { "name": "TestType", "meta-type": "object",
      "members": [
          { "name": "number", "type": "int" } ],
      "features": [ "allow-negative-numbers" ] }

This patch implements feature flags only for struct types. We'll implement them more widely as needed.

Message-Id: <[email protected]>

---
 docs/devel/qapi-code-gen.txt           | 38 +++++++++++++++
 qapi/introspect.json                   |  6 ++-
 scripts/qapi/common.py                 | 66 ++++++++++++++++++++++----
 scripts/qapi/doc.py                    |  3 +-
 scripts/qapi/introspect.py             |  6 ++-
 scripts/qapi/types.py                  |  3 +-
 scripts/qapi/visit.py                  |  3 +-
 tests/qapi-schema/double-type.err      |  2 +-
 tests/qapi-schema/test-qapi.py         |  3 +-
 tests/qapi-schema/unknown-expr-key.err |  2 +-
 10 files changed, 114 insertions(+), 18 deletions(-)
docs/devel/qapi-code-gen.txt +38 -0
index b517b0cfbf..e8ec8ac1de 100644
@@ -719,6 +719,34 @@ any non-empty complex type (struct, union, or alternate), and a
 pointer to that QAPI type is passed as a single argument.
 
 
+=== Features ===
+
+Sometimes, the behaviour of QEMU changes compatibly, but without a
+change in the QMP syntax (usually by allowing values or operations that
+previously resulted in an error). QMP clients may still need to know
+whether the extension is available.
+
+For this purpose, a list of features can be specified for a struct type.
+This is exposed to the client as a list of string, where each string
+signals that this build of QEMU shows a certain behaviour.
+
+In the schema, features can be specified as simple strings, for example:
+
+{ 'struct': 'TestType',
+  'data': { 'number': 'int' },
+  'features': [ 'allow-negative-numbers' ] }
+
+Another option is to specify features as dictionaries, where the key
+'name' specifies the feature string to be exposed to clients:
+
+{ 'struct': 'TestType',
+  'data': { 'number': 'int' },
+  'features': [ { 'name': 'allow-negative-numbers' } ] }
+
+This expanded form is necessary if you want to make the feature
+conditional (see below in "Configuring the schema").
+
+
 === Downstream extensions ===
 
 QAPI schema names that are externally visible, say in the Client JSON
@@ -771,6 +799,16 @@ Example: a conditional 'bar' enum member.
   [ 'foo',
     { 'name' : 'bar', 'if': 'defined(IFCOND)' } ] }
 
+Similarly, features can be specified as a dictionary with a 'name' and
+an 'if' key.
+
+Example: a conditional 'allow-negative-numbers' feature
+
+{ 'struct': 'TestType',
+  'data': { 'number': 'int' },
+  'features': [ { 'name': 'allow-negative-numbers',
+                  'if' 'defined(IFCOND)' } ] }
+
 Please note that you are responsible to ensure that the C code will
 compile with an arbitrary combination of conditions, since the
 generators are unable to check it at this point.
qapi/introspect.json +5 -1
index 3d22166b2b..1843c1cb17 100644
@@ -174,6 +174,9 @@
 #            and may even differ from the order of the values of the
 #            enum type of the @tag.
 #
+# @features: names of features associated with the type, in no particular
+#            order. (since: 4.1)
+#
 # Values of this type are JSON object on the wire.
 #
 # Since: 2.5
@@ -181,7 +184,8 @@
 { 'struct': 'SchemaInfoObject',
   'data': { 'members': [ 'SchemaInfoObjectMember' ],
             '*tag': 'str',
-            '*variants': [ 'SchemaInfoObjectVariant' ] } }
+            '*variants': [ 'SchemaInfoObjectVariant' ],
+            '*features': [ 'str' ] } }
 
 ##
 # @SchemaInfoObjectMember:
scripts/qapi/common.py +56 -10

170 lines not on this page · raw message

scripts/qapi/doc.py +2 -1
index 5c8c136899..433e9fcbfb 100755
@@ -220,7 +220,8 @@ class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor):
                                body=texi_entity(doc, 'Values', ifcond,
                                                 member_func=texi_enum_value)))
 
-    def visit_object_type(self, name, info, ifcond, base, members, variants):
+    def visit_object_type(self, name, info, ifcond, base, members, variants,
+                          features):
         doc = self.cur_doc
         if base and base.is_implicit():
             base = None
scripts/qapi/introspect.py +5 -1
index f7f2ca07e4..f62cf0a2e1 100644
@@ -188,11 +188,15 @@ const QLitObject %(c_name)s = %(c_string)s;
         self._gen_qlit('[' + element + ']', 'array', {'element-type': element},
                        ifcond)
 
-    def visit_object_type_flat(self, name, info, ifcond, members, variants):
+    def visit_object_type_flat(self, name, info, ifcond, members, variants,
+                               features):
         obj = {'members': [self._gen_member(m) for m in members]}
         if variants:
             obj.update(self._gen_variants(variants.tag_member.name,
                                           variants.variants))
+        if features:
+            obj['features'] = [(f.name, {'if': f.ifcond}) for f in features]
+
         self._gen_qlit(name, 'object', obj, ifcond)
 
     def visit_alternate_type(self, name, info, ifcond, variants):
scripts/qapi/types.py +2 -1
index 2bd6fcd44f..3edd9374aa 100644
@@ -227,7 +227,8 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor):
             self._genh.add(gen_array(name, element_type))
             self._gen_type_cleanup(name)
 
-    def visit_object_type(self, name, info, ifcond, base, members, variants):
+    def visit_object_type(self, name, info, ifcond, base, members, variants,
+                          features):
         # Nothing to do for the special empty builtin
         if name == 'q_empty':
             return
scripts/qapi/visit.py +2 -1
index fd356151d2..484ebb66ad 100644
@@ -324,7 +324,8 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
             self._genh.add(gen_visit_decl(name))
             self._genc.add(gen_visit_list(name, element_type))
 
-    def visit_object_type(self, name, info, ifcond, base, members, variants):
+    def visit_object_type(self, name, info, ifcond, base, members, variants,
+                          features):
         # Nothing to do for the special empty builtin
         if name == 'q_empty':
             return
tests/qapi-schema/double-type.err +1 -1
index 799193dba1..69457173a7 100644
@@ -1,2 +1,2 @@
 tests/qapi-schema/double-type.json:2: Unknown key 'command' in struct 'bar'
-Valid keys are 'base', 'data', 'if', 'struct'.
+Valid keys are 'base', 'data', 'features', 'if', 'struct'.
tests/qapi-schema/test-qapi.py +2 -1
index d21fca01fc..f2d6815c86 100644
@@ -38,7 +38,8 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
         print('array %s %s' % (name, element_type.name))
         self._print_if(ifcond)
 
-    def visit_object_type(self, name, info, ifcond, base, members, variants):
+    def visit_object_type(self, name, info, ifcond, base, members, variants,
+                          features):
         print('object %s' % name)
         if base:
             print('    base %s' % base.name)
tests/qapi-schema/unknown-expr-key.err +1 -1
index 6ff8bb99c5..4340eaf894 100644
@@ -1,2 +1,2 @@
 tests/qapi-schema/unknown-expr-key.json:2: Unknown keys 'bogus', 'phony' in struct 'bar'
-Valid keys are 'base', 'data', 'if', 'struct'.
+Valid keys are 'base', 'data', 'features', 'if', 'struct'.
Signature · 1 line
2.21.0
#6 lore raw

[Qemu-devel] [PULL 06/11] tests/qapi-schema: Test for good feature lists in structs

In reply to Markus Armbruster

From: Kevin Wolf <[email protected]>

Message-Id: <[email protected]>

---
 tests/qapi-schema/qapi-schema-test.json | 39 ++++++++++++++++++++++
 tests/qapi-schema/qapi-schema-test.out  | 43 +++++++++++++++++++++++++
 tests/qapi-schema/test-qapi.py          |  4 +++
 tests/test-qmp-cmds.c                   |  8 +++++
 4 files changed, 94 insertions(+)
tests/qapi-schema/qapi-schema-test.json +39 -0
index 0952c68734..c6d59acc3e 100644
@@ -242,3 +242,42 @@
   { 'foo': 'TestIfStruct',
     'bar': { 'type': ['TestIfEnum'], 'if': 'defined(TEST_IF_EVT_BAR)' } },
   'if': 'defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)' }
+
+# test 'features' for structs
+
+{ 'struct': 'FeatureStruct0',
+  'data': { 'foo': 'int' },
+  'features': [] }
+{ 'struct': 'FeatureStruct1',
+  'data': { 'foo': 'int' },
+  'features': [ 'feature1' ] }
+{ 'struct': 'FeatureStruct2',
+  'data': { 'foo': 'int' },
+  'features': [ { 'name': 'feature1' } ] }
+{ 'struct': 'FeatureStruct3',
+  'data': { 'foo': 'int' },
+  'features': [ 'feature1', 'feature2' ] }
+{ 'struct': 'FeatureStruct4',
+  'data': { 'namespace-test': 'int' },
+  'features': [ 'namespace-test', 'int', 'name', 'if' ] }
+
+{ 'struct': 'CondFeatureStruct1',
+  'data': { 'foo': 'int' },
+  'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'} ] }
+{ 'struct': 'CondFeatureStruct2',
+  'data': { 'foo': 'int' },
+  'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'},
+                { 'name': 'feature2', 'if': 'defined(TEST_IF_FEATURE_2)'} ] }
+{ 'struct': 'CondFeatureStruct3',
+  'data': { 'foo': 'int' },
+  'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)',
+                                              'defined(TEST_IF_COND_2)'] } ] }
+{ 'command': 'test-features',
+  'data': { 'fs0': 'FeatureStruct0',
+            'fs1': 'FeatureStruct1',
+            'fs2': 'FeatureStruct2',
+            'fs3': 'FeatureStruct3',
+            'fs4': 'FeatureStruct4',
+            'cfs1': 'CondFeatureStruct1',
+            'cfs2': 'CondFeatureStruct2',
+            'cfs3': 'CondFeatureStruct3' } }
tests/qapi-schema/qapi-schema-test.out +43 -0

46 lines not on this page · raw message

tests/qapi-schema/test-qapi.py +4 -0
index f2d6815c86..b0f770b9bd 100644
@@ -49,6 +49,10 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
             self._print_if(m.ifcond, 8)
         self._print_variants(variants)
         self._print_if(ifcond)
+        if features:
+            for f in features:
+                print('    feature %s' % f.name)
+                self._print_if(f.ifcond, 8)
 
     def visit_alternate_type(self, name, info, ifcond, variants):
         print('alternate %s' % name)
tests/test-qmp-cmds.c +8 -0
index f0b95dcbc3..ab389f42da 100644
@@ -43,6 +43,14 @@ void qmp_user_def_cmd1(UserDefOne * ud1, Error **errp)
 {
 }
 
+void qmp_test_features(FeatureStruct0 *fs0, FeatureStruct1 *fs1,
+                       FeatureStruct2 *fs2, FeatureStruct3 *fs3,
+                       FeatureStruct4 *fs4, CondFeatureStruct1 *cfs1,
+                       CondFeatureStruct2 *cfs2, CondFeatureStruct3 *cfs3,
+                       Error **errp)
+{
+}
+
 UserDefTwo *qmp_user_def_cmd2(UserDefOne *ud1a,
                               bool has_udb1, UserDefOne *ud1b,
                               Error **errp)
Signature · 1 line
2.21.0
#7 lore raw

[Qemu-devel] [PULL 03/11] block/file-posix: update .help of BLOCK_OPT_PREALLOC option

In reply to Markus Armbruster

From: Stefano Garzarella <[email protected]>

Show 'falloc' among the allowed values of 'preallocation' option, only when it is supported (if defined CONFIG_POSIX_FALLOCATE)

Message-Id: <[email protected]>

---
 block/file-posix.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
block/file-posix.c +5 -1
index 6e6bf3f4a5..83ab1b78ef 100644
@@ -2752,7 +2752,11 @@ static QemuOptsList raw_create_opts = {
         {
             .name = BLOCK_OPT_PREALLOC,
             .type = QEMU_OPT_STRING,
-            .help = "Preallocation mode (allowed values: off, falloc, full)"
+            .help = "Preallocation mode (allowed values: off"
+#ifdef CONFIG_POSIX_FALLOCATE
+                    ", falloc"
+#endif
+                    ", full)"
         },
         { /* end of list */ }
     }
Signature · 1 line
2.21.0
#8 lore raw

[Qemu-devel] [PULL 08/11] qapi: Disentangle QAPIDoc code

In reply to Markus Armbruster

From: Kevin Wolf <[email protected]>

Documentation comments follow a certain structure: First, we have a text with a general description (called QAPIDoc.body). After this, descriptions of the arguments follow. Finally, we have a part that contains various named sections.

The code doesn't show this structure, but just checks various attributes that indicate indirectly which part is being processed, so it happens to do the right set of things in the right phase. This is hard to follow, and adding support for documentation of features would be even harder.

This patch restructures the code so that the three parts are clearly separated. The code becomes a bit longer, but easier to follow. The resulting output remains unchanged.

Message-Id: <[email protected]>

---
 scripts/qapi/common.py | 127 +++++++++++++++++++++++++++++++++--------
 1 file changed, 102 insertions(+), 25 deletions(-)
scripts/qapi/common.py +102 -25
index 9e4b6c00b5..f40a2cd4c5 100644
@@ -120,6 +120,24 @@ class QAPIDoc(object):
         def connect(self, member):
             self.member = member
 
+    class DocPart:
+        """
+        Describes which part of the documentation we're parsing right now.
+
+        Expression documentation blocks consist of
+        * a BODY part: first line naming the expression, plus an
+          optional overview
+        * an ARGS part: description of each argument (for commands and
+          events) or member (for structs, unions and alternates),
+        * a VARIOUS part: optional tagged sections.
+
+        Free-form documentation blocks consist only of a BODY part.
+        """
+        # TODO Make it a subclass of Enum when Python 2 support is removed
+        BODY = 1
+        ARGS = 2
+        VARIOUS = 3
+
     def __init__(self, parser, info):
         # self._parser is used to report errors with QAPIParseError.  The
         # resulting error position depends on the state of the parser.
@@ -135,6 +153,7 @@ class QAPIDoc(object):
         self.sections = []
         # the current section
         self._section = self.body
+        self._part = QAPIDoc.DocPart.BODY
 
     def has_section(self, name):
         """Return True if we have a section with this name."""
@@ -144,7 +163,27 @@ class QAPIDoc(object):
         return False
 
     def append(self, line):
-        """Parse a comment line and add it to the documentation."""
+        """
+        Parse a comment line and add it to the documentation.
+
+        The way that the line is dealt with depends on which part of
+        the documentation we're parsing right now:
+
+        BODY means that we're ready to process free-form text into
+        self.body.  A symbol name is only allowed if no other text was
+        parsed yet.  It is interpreted as the symbol name that
+        describes the currently documented object.  On getting the
+        second symbol name, we proceed to ARGS.
+
+        ARGS means that we're parsing the arguments section.  Any
+        symbol name is interpreted as an argument and an ArgSection is
+        created for it.
+
+        VARIOUS is the final part where free-form sections may appear.
+        This includes named sections such as "Return:" as well as
+        unnamed paragraphs.  Symbols are not allowed any more in this
+        part.
+        """
         line = line[1:]
         if not line:
             self._append_freeform(line)
@@ -154,37 +193,85 @@ class QAPIDoc(object):
             raise QAPIParseError(self._parser, "Missing space after #")
         line = line[1:]
 
+        if self._part == QAPIDoc.DocPart.BODY:
+            self._append_body_line(line)
+        elif self._part == QAPIDoc.DocPart.ARGS:
+            self._append_args_line(line)
+        elif self._part == QAPIDoc.DocPart.VARIOUS:
+            self._append_various_line(line)
+        else:
+            assert False
+
+    def end_comment(self):
+        self._end_section()
+
+    @staticmethod
+    def _is_section_tag(name):
+        return name in ('Returns:', 'Since:',
+                        # those are often singular or plural
+                        'Note:', 'Notes:',
+                        'Example:', 'Examples:',
+                        'TODO:')
+
+    def _append_body_line(self, line):
+        name = line.split(' ', 1)[0]
         # FIXME not nice: things like '#  @foo:' and '# @foo: ' aren't
         # recognized, and get silently treated as ordinary text
-        if self.symbol:
-            self._append_symbol_line(line)
-        elif not self.body.text and line.startswith('@'):
+        if not self.symbol and not self.body.text and line.startswith('@'):
             if not line.endswith(':'):
                 raise QAPIParseError(self._parser, "Line should end with :")
             self.symbol = line[1:-1]
             # FIXME invalid names other than the empty string aren't flagged
             if not self.symbol:
                 raise QAPIParseError(self._parser, "Invalid name")
+        elif self.symbol:
+            # We already know that we document some symbol
+            if name.startswith('@') and name.endswith(':'):
+                self._part = QAPIDoc.DocPart.ARGS
+                self._append_args_line(line)
+            elif self._is_section_tag(name):
+                self._part = QAPIDoc.DocPart.VARIOUS
+                self._append_various_line(line)
+            else:
+                self._append_freeform(line.strip())
         else:
-            self._append_freeform(line)
+            # This is free-form documentation without a symbol
+            self._append_freeform(line.strip())
 
-    def end_comment(self):
-        self._end_section()
-
-    def _append_symbol_line(self, line):
+    def _append_args_line(self, line):
         name = line.split(' ', 1)[0]
 
         if name.startswith('@') and name.endswith(':'):
             line = line[len(name)+1:]
             self._start_args_section(name[1:-1])
-        elif name in ('Returns:', 'Since:',
-                      # those are often singular or plural
-                      'Note:', 'Notes:',
-                      'Example:', 'Examples:',
-                      'TODO:'):
+        elif self._is_section_tag(name):
+            self._part = QAPIDoc.DocPart.VARIOUS
+            self._append_various_line(line)
+            return
+        elif (self._section.text.endswith('\n\n')
+              and line and not line[0].isspace()):
+            self._start_section()
+            self._part = QAPIDoc.DocPart.VARIOUS
+            self._append_various_line(line)
+            return
+
+        self._append_freeform(line.strip())
+
+    def _append_various_line(self, line):
+        name = line.split(' ', 1)[0]
+
+        if name.startswith('@') and name.endswith(':'):
+            raise QAPIParseError(self._parser,
+                                 "'%s' can't follow '%s' section"
+                                 % (name, self.sections[0].name))
+        elif self._is_section_tag(name):
             line = line[len(name)+1:]
             self._start_section(name[:-1])
 
+        if (not self._section.name or
+                not self._section.name.startswith('Example')):
+            line = line.strip()
+
         self._append_freeform(line)
 
     def _start_args_section(self, name):
@@ -194,10 +281,7 @@ class QAPIDoc(object):
         if name in self.args:
             raise QAPIParseError(self._parser,
                                  "'%s' parameter name duplicated" % name)
-        if self.sections:
-            raise QAPIParseError(self._parser,
-                                 "'@%s:' can't follow '%s' section"
-                                 % (name, self.sections[0].name))
+        assert not self.sections
         self._end_section()
         self._section = QAPIDoc.ArgSection(name)
         self.args[name] = self._section
@@ -219,13 +303,6 @@ class QAPIDoc(object):
             self._section = None
 
     def _append_freeform(self, line):
-        in_arg = isinstance(self._section, QAPIDoc.ArgSection)
-        if (in_arg and self._section.text.endswith('\n\n')
-                and line and not line[0].isspace()):
-            self._start_section()
-        if (in_arg or not self._section.name
-                or not self._section.name.startswith('Example')):
-            line = line.strip()
         match = re.match(r'(@\S+:)', line)
         if match:
             raise QAPIParseError(self._parser,
Signature · 1 line
2.21.0
#9 lore raw

[Qemu-devel] [PULL 11/11] qapi: Simplify how QAPIDoc implements its state machine

In reply to Markus Armbruster

QAPIDoc uses a state machine to for processing of documentation lines. Its state is encoded as an enum QAPIDoc._state (well, as enum-like class actually, thanks to our infatuation with Python 2).

All we ever do with the state is calling the state's function to process a line of documentation. The enum values effectively serve as handles for the functions.

Eliminate the rather wordy indirection: store the function to call in QAPIDoc._append_line. Update and improve comments.

Message-Id: <[email protected]>

[Commit message typo fixed]
---
 scripts/qapi/common.py | 125 ++++++++++++++++++++++-------------------
 1 file changed, 68 insertions(+), 57 deletions(-)
scripts/qapi/common.py +68 -57
index 1164301edf..d61bfdc526 100644
@@ -102,6 +102,24 @@ class QAPISemError(QAPIError):
 
 
 class QAPIDoc(object):
+    """
+    A documentation comment block, either expression or free-form
+
+    Expression documentation blocks consist of
+
+    * a body section: one line naming the expression, followed by an
+      overview (any number of lines)
+
+    * argument sections: a description of each argument (for commands
+      and events) or member (for structs, unions and alternates)
+
+    * features sections: a description of each feature flag
+
+    * additional (non-argument) sections, possibly tagged
+
+    Free-form documentation blocks consist only of a body section.
+    """
+
     class Section(object):
         def __init__(self, name=None):
             # optional section name (argument/member or section name)
@@ -120,26 +138,6 @@ class QAPIDoc(object):
         def connect(self, member):
             self.member = member
 
-    class DocPart:
-        """
-        Describes which part of the documentation we're parsing right now.
-
-        Expression documentation blocks consist of
-        * a BODY part: first line naming the expression, plus an
-          optional overview
-        * an ARGS part: description of each argument (for commands and
-          events) or member (for structs, unions and alternates),
-        * a FEATURES part: description of each feature,
-        * a VARIOUS part: optional tagged sections.
-
-        Free-form documentation blocks consist only of a BODY part.
-        """
-        # TODO Make it a subclass of Enum when Python 2 support is removed
-        BODY = 1
-        ARGS = 2
-        FEATURES = 3
-        VARIOUS = 4
-
     def __init__(self, parser, info):
         # self._parser is used to report errors with QAPIParseError.  The
         # resulting error position depends on the state of the parser.
@@ -156,7 +154,7 @@ class QAPIDoc(object):
         self.sections = []
         # the current section
         self._section = self.body
-        self._part = QAPIDoc.DocPart.BODY
+        self._append_line = self._append_body_line
 
     def has_section(self, name):
         """Return True if we have a section with this name."""
@@ -171,21 +169,10 @@ class QAPIDoc(object):
 
         The way that the line is dealt with depends on which part of
         the documentation we're parsing right now:
-
-        BODY means that we're ready to process free-form text into
-        self.body.  A symbol name is only allowed if no other text was
-        parsed yet.  It is interpreted as the symbol name that
-        describes the currently documented object.  On getting the
-        second symbol name, we proceed to ARGS.
-
-        ARGS means that we're parsing the arguments section.  Any
-        symbol name is interpreted as an argument and an ArgSection is
-        created for it.
-
-        VARIOUS is the final part where free-form sections may appear.
-        This includes named sections such as "Return:" as well as
-        unnamed paragraphs.  Symbols are not allowed any more in this
-        part.
+        * The body section: ._append_line is ._append_body_line
+        * An argument section: ._append_line is ._append_args_line
+        * A features section: ._append_line is ._append_features_line
+        * An additional section: ._append_line is ._append_various_line
         """
         line = line[1:]
         if not line:
@@ -195,17 +182,7 @@ class QAPIDoc(object):
         if line[0] != ' ':
             raise QAPIParseError(self._parser, "Missing space after #")
         line = line[1:]
-
-        if self._part == QAPIDoc.DocPart.BODY:
-            self._append_body_line(line)
-        elif self._part == QAPIDoc.DocPart.ARGS:
-            self._append_args_line(line)
-        elif self._part == QAPIDoc.DocPart.FEATURES:
-            self._append_features_line(line)
-        elif self._part == QAPIDoc.DocPart.VARIOUS:
-            self._append_various_line(line)
-        else:
-            assert False
+        self._append_line(line)
 
     def end_comment(self):
         self._end_section()
@@ -219,6 +196,19 @@ class QAPIDoc(object):
                         'TODO:')
 
     def _append_body_line(self, line):
+        """
+        Process a line of documentation text in the body section.
+
+        If this a symbol line and it is the section's first line, this
+        is an expression documentation block for that symbol.
+
+        If it's an expression documentation block, another symbol line
+        begins the argument section for the argument named by it, and
+        a section tag begins an additional section.  Start that
+        section and append the line to it.
+
+        Else, append the line to the current section.
+        """
         name = line.split(' ', 1)[0]
         # FIXME not nice: things like '#  @foo:' and '# @foo: ' aren't
         # recognized, and get silently treated as ordinary text
@@ -230,38 +220,49 @@ class QAPIDoc(object):
             if not self.symbol:
                 raise QAPIParseError(self._parser, "Invalid name")
         elif self.symbol:
-            # We already know that we document some symbol
+            # This is an expression documentation block
             if name.startswith('@') and name.endswith(':'):
-                self._part = QAPIDoc.DocPart.ARGS
+                self._append_line = self._append_args_line
                 self._append_args_line(line)
             elif line == 'Features:':
-                self._part = QAPIDoc.DocPart.FEATURES
+                self._append_line = self._append_features_line
             elif self._is_section_tag(name):
-                self._part = QAPIDoc.DocPart.VARIOUS
+                self._append_line = self._append_various_line
                 self._append_various_line(line)
             else:
                 self._append_freeform(line.strip())
         else:
-            # This is free-form documentation without a symbol
+            # This is a free-form documentation block
             self._append_freeform(line.strip())
 
     def _append_args_line(self, line):
+        """
+        Process a line of documentation text in an argument section.
+
+        A symbol line begins the next argument section, a section tag
+        section or a non-indented line after a blank line begins an
+        additional section.  Start that section and append the line to
+        it.
+
+        Else, append the line to the current section.
+
+        """
         name = line.split(' ', 1)[0]
 
         if name.startswith('@') and name.endswith(':'):
             line = line[len(name)+1:]
             self._start_args_section(name[1:-1])
         elif self._is_section_tag(name):
-            self._part = QAPIDoc.DocPart.VARIOUS
+            self._append_line = self._append_various_line
             self._append_various_line(line)
             return
         elif (self._section.text.endswith('\n\n')
               and line and not line[0].isspace()):
             if line == 'Features:':
-                self._part = QAPIDoc.DocPart.FEATURES
+                self._append_line = self._append_features_line
             else:
                 self._start_section()
-                self._part = QAPIDoc.DocPart.VARIOUS
+                self._append_line = self._append_various_line
                 self._append_various_line(line)
             return
 
@@ -274,19 +275,29 @@ class QAPIDoc(object):
             line = line[len(name)+1:]
             self._start_features_section(name[1:-1])
         elif self._is_section_tag(name):
-            self._part = QAPIDoc.DocPart.VARIOUS
+            self._append_line = self._append_various_line
             self._append_various_line(line)
             return
         elif (self._section.text.endswith('\n\n')
               and line and not line[0].isspace()):
             self._start_section()
-            self._part = QAPIDoc.DocPart.VARIOUS
+            self._append_line = self._append_various_line
             self._append_various_line(line)
             return
 
         self._append_freeform(line.strip())
 
     def _append_various_line(self, line):
+        """
+        Process a line of documentation text in an additional section.
+
+        A symbol line is an error.
+
+        A section tag begins an additional section.  Start that
+        section and append the line to it.
+
+        Else, append the line to the current section.
+        """
         name = line.split(' ', 1)[0]
 
         if name.startswith('@') and name.endswith(':'):
Signature · 1 line
2.21.0
#10 lore raw

[Qemu-devel] [PULL 09/11] qapi: Allow documentation for features

In reply to Markus Armbruster

From: Kevin Wolf <[email protected]>

Features will be documented in a new part introduced by a "Features:" line, after arguments and before named sections.

Message-Id: <[email protected]>

---
 scripts/qapi/common.py | 43 ++++++++++++++++++++++++++++++++++++++----
 scripts/qapi/doc.py    | 12 ++++++++++++
 2 files changed, 51 insertions(+), 4 deletions(-)
scripts/qapi/common.py +39 -4
index f40a2cd4c5..1164301edf 100644
@@ -129,6 +129,7 @@ class QAPIDoc(object):
           optional overview
         * an ARGS part: description of each argument (for commands and
           events) or member (for structs, unions and alternates),
+        * a FEATURES part: description of each feature,
         * a VARIOUS part: optional tagged sections.
 
         Free-form documentation blocks consist only of a BODY part.
@@ -136,7 +137,8 @@ class QAPIDoc(object):
         # TODO Make it a subclass of Enum when Python 2 support is removed
         BODY = 1
         ARGS = 2
-        VARIOUS = 3
+        FEATURES = 3
+        VARIOUS = 4
 
     def __init__(self, parser, info):
         # self._parser is used to report errors with QAPIParseError.  The
@@ -149,6 +151,7 @@ class QAPIDoc(object):
         self.body = QAPIDoc.Section()
         # dict mapping parameter name to ArgSection
         self.args = OrderedDict()
+        self.features = OrderedDict()
         # a list of Section
         self.sections = []
         # the current section
@@ -197,6 +200,8 @@ class QAPIDoc(object):
             self._append_body_line(line)
         elif self._part == QAPIDoc.DocPart.ARGS:
             self._append_args_line(line)
+        elif self._part == QAPIDoc.DocPart.FEATURES:
+            self._append_features_line(line)
         elif self._part == QAPIDoc.DocPart.VARIOUS:
             self._append_various_line(line)
         else:
@@ -229,6 +234,8 @@ class QAPIDoc(object):
             if name.startswith('@') and name.endswith(':'):
                 self._part = QAPIDoc.DocPart.ARGS
                 self._append_args_line(line)
+            elif line == 'Features:':
+                self._part = QAPIDoc.DocPart.FEATURES
             elif self._is_section_tag(name):
                 self._part = QAPIDoc.DocPart.VARIOUS
                 self._append_various_line(line)
@@ -248,6 +255,28 @@ class QAPIDoc(object):
             self._part = QAPIDoc.DocPart.VARIOUS
             self._append_various_line(line)
             return
+        elif (self._section.text.endswith('\n\n')
+              and line and not line[0].isspace()):
+            if line == 'Features:':
+                self._part = QAPIDoc.DocPart.FEATURES
+            else:
+                self._start_section()
+                self._part = QAPIDoc.DocPart.VARIOUS
+                self._append_various_line(line)
+            return
+
+        self._append_freeform(line.strip())
+
+    def _append_features_line(self, line):
+        name = line.split(' ', 1)[0]
+
+        if name.startswith('@') and name.endswith(':'):
+            line = line[len(name)+1:]
+            self._start_features_section(name[1:-1])
+        elif self._is_section_tag(name):
+            self._part = QAPIDoc.DocPart.VARIOUS
+            self._append_various_line(line)
+            return
         elif (self._section.text.endswith('\n\n')
               and line and not line[0].isspace()):
             self._start_section()
@@ -274,17 +303,23 @@ class QAPIDoc(object):
 
         self._append_freeform(line)
 
-    def _start_args_section(self, name):
+    def _start_symbol_section(self, symbols_dict, name):
         # FIXME invalid names other than the empty string aren't flagged
         if not name:
             raise QAPIParseError(self._parser, "Invalid parameter name")
-        if name in self.args:
+        if name in symbols_dict:
             raise QAPIParseError(self._parser,
                                  "'%s' parameter name duplicated" % name)
         assert not self.sections
         self._end_section()
         self._section = QAPIDoc.ArgSection(name)
-        self.args[name] = self._section
+        symbols_dict[name] = self._section
+
+    def _start_args_section(self, name):
+        self._start_symbol_section(self.args, name)
+
+    def _start_features_section(self, name):
+        self._start_symbol_section(self.features, name)
 
     def _start_section(self, name=None):
         if name in ('Returns', 'Since') and self.has_section(name):
scripts/qapi/doc.py +12 -0
index 433e9fcbfb..5fc0fc7e06 100755
@@ -182,6 +182,17 @@ def texi_members(doc, what, base, variants, member_func):
     return '\n@b{%s:}\n@table @asis\n%s@end table\n' % (what, items)
 
 
+def texi_features(doc):
+    """Format the table of features"""
+    items = ''
+    for section in doc.features.values():
+        desc = texi_format(section.text)
+        items += '@item @code{%s}\n%s' % (section.name, desc)
+    if not items:
+        return ''
+    return '\n@b{Features:}\n@table @asis\n%s@end table\n' % (items)
+
+
 def texi_sections(doc, ifcond):
     """Format additional sections following arguments"""
     body = ''
@@ -201,6 +212,7 @@ def texi_entity(doc, what, ifcond, base=None, variants=None,
                 member_func=texi_member):
     return (texi_body(doc)
             + texi_members(doc, what, base, variants, member_func)
+            + texi_features(doc)
             + texi_sections(doc, ifcond))
 
 
Signature · 1 line
2.21.0
#11 lore raw

[Qemu-devel] [PULL 10/11] file-posix: Add dynamic-auto-read-only QAPI feature

In reply to Markus Armbruster

From: Kevin Wolf <[email protected]>

In commit 23dece19da4 ('file-posix: Make auto-read-only dynamic') , auto-read-only=on changed its behaviour in file-posix for the 4.0 release. This change cannot be detected through the usual mechanisms like schema introspection. Add a new feature flag to the schema to allow libvirt to detect the presence of the new behaviour.

Message-Id: <[email protected]>

[Comment tweaked on Eric Blake's advice]
---
 qapi/block-core.json | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
qapi/block-core.json +12 -1
index 175ccfe896..fcd054fcb1 100644
@@ -2859,6 +2859,15 @@
 #                         file is large, do not use in production.
 #                         (default: off) (since: 3.0)
 #
+# Features:
+# @dynamic-auto-read-only: If present, enabled auto-read-only means that the
+#                          driver will open the image read-only at first,
+#                          dynamically reopen the image file read-write when
+#                          the first writer is attached to the node and reopen
+#                          read-only when the last writer is detached. This
+#                          allows giving QEMU write permissions only on demand
+#                          when an operation actually needs write access.
+#
 # Since: 2.9
 ##
 { 'struct': 'BlockdevOptionsFile',
@@ -2868,7 +2877,9 @@
             '*aio': 'BlockdevAioOptions',
 	    '*drop-cache': {'type': 'bool',
 	                    'if': 'defined(CONFIG_LINUX)'},
-            '*x-check-cache-dropped': 'bool' } }
+            '*x-check-cache-dropped': 'bool' },
+  'features': [ { 'name': 'dynamic-auto-read-only',
+                  'if': 'defined(CONFIG_POSIX)' } ] }
 
 ##
 # @BlockdevOptionsNull:
Signature · 1 line
2.21.0
#12 lore raw
In reply to Markus Armbruster
Quoted 9 lines · Markus Armbruster

The following changes since commit a050901d4b40092dc356b59912c6df39e389c7b9:

Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-4.1-20190612' into staging (2019-06-12 14:43:47 +0100)

are available in the Git repository at:

git://repo.or.cz/qemu/armbru.git tags/pull-qapi-2019-06-12

Quoted 8 lines

for you to fetch changes up to 157dd363955b961ef378eb1f7817c31a7fa94d10:

qapi: Simplify how QAPIDoc implements its state machine (2019-06-12 18:37:17 +0200)

----------------------------------------------------------------
QAPI patches for 2019-06-12

----------------------------------------------------------------

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.

-- PMM