aboutsummaryrefslogtreecommitdiff
path: root/docs/devel/qapi-code-gen.txt
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-06-13 11:58:00 +0100
committerPeter Maydell <peter.maydell@linaro.org>2019-06-13 11:58:00 +0100
commit4747524f9f243ca5ff1f146d37e423c00e923ee1 (patch)
tree487c935041a08eba8a83c3399ca6a9aacfc6c1fe /docs/devel/qapi-code-gen.txt
parent8e23e34d989d5ce542fa26425f091fc61e1f23f4 (diff)
parent157dd363955b961ef378eb1f7817c31a7fa94d10 (diff)
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2019-06-12' into staging
QAPI patches for 2019-06-12 # gpg: Signature made Wed 12 Jun 2019 17:44:50 BST # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2019-06-12: qapi: Simplify how QAPIDoc implements its state machine file-posix: Add dynamic-auto-read-only QAPI feature qapi: Allow documentation for features qapi: Disentangle QAPIDoc code tests/qapi-schema: Error case tests for features in structs tests/qapi-schema: Test for good feature lists in structs qapi: Add feature flags to struct types block/gluster: update .help of BLOCK_OPT_PREALLOC option block/file-posix: update .help of BLOCK_OPT_PREALLOC option qapi/block-core: update documentation of preallocation parameter qdev: Delete unused LostTickPolicy "merge" Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'docs/devel/qapi-code-gen.txt')
-rw-r--r--docs/devel/qapi-code-gen.txt38
1 files changed, 38 insertions, 0 deletions
diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
index b517b0cfbf..e8ec8ac1de 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.txt
@@ -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.