mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-17 21:26:13 -07:00
qapi: Add feature flags to struct types
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.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20190606153803.5278-2-armbru@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
2ea8e96da2
commit
6a8c0b5102
10 changed files with 114 additions and 18 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue