Configurable policy for handling unstable interfaces
cover Configurable policy for handling unstable interfaces
Option -compat lets you configure what to do when deprecated interfaces get used. This series extends this to unstable interfaces. Works the same way. Intended for testing users of the management interfaces. It is experimental.
To make it possible, I replace the "x-" naming convention by special feature flag "unstable". See PATCH 1 for rationale.
Based on my "[PATCH v4 0/5] qapi: Add feature flags to enum members"
Based-on: Message-Id: <[email protected]>
Markus Armbruster (9):
qapi: New special feature flag "unstable"
qapi: Mark unstable QMP parts with feature 'unstable'
qapi: Eliminate QCO_NO_OPTIONS for a slight simplification
qapi: Tools for sets of special feature flags in generated code
qapi: Generalize struct member policy checking
qapi: Generalize command policy checking
qapi: Generalize enum member policy checking
qapi: Factor out compat_policy_input_ok()
qapi: Extend -compat to set policy for unstable interfaces
docs/devel/qapi-code-gen.rst | 9 +- qapi/block-core.json | 123 +++++++++++++++++------- qapi/compat.json | 6 +- qapi/migration.json | 35 +++++-- qapi/misc.json | 6 +- qapi/qom.json | 11 ++- include/qapi/compat-policy.h | 7 ++ include/qapi/qmp/dispatch.h | 6 +- include/qapi/util.h | 8 +- include/qapi/visitor-impl.h | 6 +- include/qapi/visitor.h | 17 +++- monitor/misc.c | 7 +- qapi/qapi-forward-visitor.c | 16 +-- qapi/qapi-visit-core.c | 41 ++++---- qapi/qmp-dispatch.c | 57 ++++++++--- qapi/qmp-registry.c | 4 +- qapi/qobject-input-visitor.c | 22 ++--- qapi/qobject-output-visitor.c | 13 ++- storage-daemon/qemu-storage-daemon.c | 3 +- qapi/trace-events | 4 +- qemu-options.hx | 20 +++- scripts/qapi/commands.py | 12 +-- scripts/qapi/events.py | 10 +- scripts/qapi/gen.py | 13 +++ scripts/qapi/schema.py | 11 ++- scripts/qapi/types.py | 22 +++-- scripts/qapi/visit.py | 14 +-- tests/qapi-schema/qapi-schema-test.json | 7 +- tests/qapi-schema/qapi-schema-test.out | 5 + 29 files changed, 353 insertions(+), 162 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/9 qapi: New special feature flag "unstable"
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
--- docs/devel/qapi-code-gen.rst | 9 ++++++--- tests/qapi-schema/qapi-schema-test.json | 7 +++++-- tests/qapi-schema/qapi-schema-test.out | 5 +++++ 3 files changed, 16 insertions(+), 5 deletions(-)
docs/devel/qapi-code-gen.rst +6 -3
@@ -713,6 +713,10 @@ member as deprecated. It is not supported elsewhere so far. Interfaces so marked may be withdrawn in future releases in accordance with QEMU's deprecation policy. +Feature "unstable" marks a command, event, enum value, or struct +member as unstable. It is not supported elsewhere so far. Interfaces +so marked may be withdrawn or changed incompatibly in future releases. + Naming rules and reserved names -------------------------------
@@ -746,9 +750,8 @@ Member name ``u`` and names starting with ``has-`` or ``has_`` are reserved for the generator, which uses them for unions and for tracking optional members. -Any name (command, event, type, member, or enum value) beginning with -``x-`` is marked experimental, and may be withdrawn or changed -incompatibly in a future release. +Names beginning with ``x-`` used to signify "experimental". This +convention has been replaced by special feature "unstable". Pragmas ``command-name-exceptions`` and ``member-name-exceptions`` let you violate naming rules. Use for new code is strongly discouraged. See
tests/qapi-schema/qapi-schema-test.json +5 -2
@@ -273,7 +273,7 @@ 'data': { 'foo': { 'type': 'int', 'features': [ 'deprecated' ] } }, 'features': [ 'feature1' ] } { 'struct': 'FeatureStruct2', - 'data': { 'foo': 'int' }, + 'data': { 'foo': { 'type': 'int', 'features': [ 'unstable' ] } }, 'features': [ { 'name': 'feature1' } ] } { 'struct': 'FeatureStruct3', 'data': { 'foo': 'int' },
@@ -331,7 +331,7 @@ { 'command': 'test-command-features1', 'features': [ 'deprecated' ] } { 'command': 'test-command-features3', - 'features': [ 'feature1', 'feature2' ] } + 'features': [ 'unstable', 'feature1', 'feature2' ] } { 'command': 'test-command-cond-features1', 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'} ] }
@@ -348,3 +348,6 @@ { 'event': 'TEST_EVENT_FEATURES1', 'features': [ 'deprecated' ] } + +{ 'event': 'TEST_EVENT_FEATURES2', + 'features': [ 'unstable' ] }
tests/qapi-schema/qapi-schema-test.out +5 -0
@@ -308,6 +308,7 @@ object FeatureStruct1 feature feature1 object FeatureStruct2 member foo: int optional=False + feature unstable feature feature1 object FeatureStruct3 member foo: int optional=False
@@ -373,6 +374,7 @@ command test-command-features1 None -> None feature deprecated command test-command-features3 None -> None gen=True success_response=True boxed=False oob=False preconfig=False + feature unstable feature feature1 feature feature2 command test-command-cond-features1 None -> None
@@ -394,6 +396,9 @@ event TEST_EVENT_FEATURES0 FeatureStruct1 event TEST_EVENT_FEATURES1 None boxed=False feature deprecated +event TEST_EVENT_FEATURES2 None + boxed=False + feature unstable module include/sub-module.json include sub-sub-module.json object SecondArrayRef
Signature · 1 line
2.31.1
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
Quoted 24 lines · Markus Armbruster
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
Quoted 5 lines
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Signed-off-by Markus Armbruster <[email protected]>
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
In reply to Markus ArmbrusterQuoted 9 lines · Markus Armbruster
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
Quoted 7 lines
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
Looks like there's another stable property with an "x-" prefix:
"x-remote-object", part of QOM type @RemoteObjectProperties.
Given the above "x-" properties are now stable, I take it that they cannot be renamed now, as they might break any tools using them? My guess is the tedious way is not worth it: deprecate them, and add the non-x variants as "synonyms".
Quoted 6 lines
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
FWIW, sounds good to me.
Quoted 10 lines
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Signed-off-by Markus Armbruster <[email protected]>--- docs/devel/qapi-code-gen.rst | 9 ++++++--- tests/qapi-schema/qapi-schema-test.json | 7 +++++-- tests/qapi-schema/qapi-schema-test.out | 5 +++++ 3 files changed, 16 insertions(+), 5 deletions(-)
[...]
Signature · 1 line
/kashyap
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
Quoted 13 lines · Kashyap Chamarthy
Quoted 12 lines · Markus Armbruster
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
Quoted 7 lines
Quoted 4 lines
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
Looks like there's another stable property with an "x-" prefix:
"x-remote-object", part of QOM type @RemoteObjectProperties.
IIRC "x-remote-object" and RemoteObjectProperties are not stable.
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
In reply to Kashyap ChamarthyQuoted 13 lines · Kashyap Chamarthy
Quoted 12 lines · Markus Armbruster
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
Quoted 7 lines
Quoted 4 lines
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
Looks like there's another stable property with an "x-" prefix:
"x-remote-object", part of QOM type @RemoteObjectProperties.
The union branch 'x-remote-object' isn't flagged 'unstable' (because union branches can't have feature flags), but the enumeration value 'x-remote-object' is. Sufficient, because you can't use the branch without using the enumeration value. Admittedly subtle.
I wrote a bit of code (appended) to make sure I don't miss names.
Quoted 4 lines
Given the above "x-" properties are now stable, I take it that they cannot be renamed now, as they might break any tools using them? My guess is the tedious way is not worth it: deprecate them, and add the non-x variants as "synonyms".
"x-use-canonical-path-for-ramblock-id" goes back to commit fa0cb34d22 "hostmem: use object id for memory region name with >= 4.0" (v4.0). It may have been intended to be internal back then. It wasn't anymore when commit 8db0b20415 "machine: add missing doc for memory-backend option" (v6.0) documented it:
And document that x-use-canonical-path-for-ramblock-id, is considered to be stable to make sure it won't go away by accident.
x- was intended for unstable/iternal properties, and not supposed to be stable option. However it's too late to rename (drop x-) it as it would mean that users will have to mantain both x-use-canonical-path-for-ramblock-id (for QEMU 5.0-5.2) versions and prefix-less for later versions.
Igor's reasoning still applies.
"x-origin" has always been stable. Same argument.
Quoted 8 lines
Quoted 6 lines
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
FWIW, sounds good to me.
Thanks!
Quoted 4 lines
Quoted 4 lines
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Markus Armbruster <[email protected]>--- docs/devel/qapi-code-gen.rst | 9 ++++++--- tests/qapi-schema/qapi-schema-test.json | 7 +++++-- tests/qapi-schema/qapi-schema-test.out | 5 +++++ 3 files changed, 16 insertions(+), 5 deletions(-)[...]
commit 415b71a9f6e5bc37e84895d2e767cf4cfacd279b (HEAD)
Author: Markus Armbruster <[email protected]> Date: Sat Oct 9 09:01:21 2021 +0200
qapi: Find x- without feature unstable DBG
scripts/qapi/schema.py +11 -0
@@ -14,6 +14,8 @@ # TODO catching name collisions in generated code would be nice +import sys + from collections import OrderedDict import os import re
@@ -118,6 +120,11 @@ def describe(self): return "%s '%s'" % (self.meta, self.name) +def check_have_feature_unstable(name, info, features): + if name.startswith('x-') and 'unstable' not in (f.name for f in features): + print(QAPISemError(info, f"XXX %{name} %{features}"), file=sys.stderr) + + class QAPISchemaVisitor: def visit_begin(self, schema): pass
@@ -718,6 +725,7 @@ def __init__(self, name, info, ifcond=None, features=None): self.features = features or [] def connect_doc(self, doc): + check_have_feature_unstable(self.name, self.info, self.features) super().connect_doc(doc) if doc: for f in self.features:
@@ -745,6 +753,7 @@ def __init__(self, name, info, typ, optional, ifcond=None, features=None): self.features = features or [] def check(self, schema): + check_have_feature_unstable(self.name, self.info, self.features) assert self.defined_in self.type = schema.resolve_type(self._type_name, self.info, self.describe)
@@ -789,6 +798,7 @@ def __init__(self, name, info, doc, ifcond, features, def check(self, schema): super().check(schema) + check_have_feature_unstable(self.name, self.info, self.features) if self._arg_type_name: self.arg_type = schema.resolve_type( self._arg_type_name, self.info, "command's 'data'")
@@ -844,6 +854,7 @@ def __init__(self, name, info, doc, ifcond, features, arg_type, boxed): def check(self, schema): super().check(schema) + check_have_feature_unstable(self.name, self.info, self.features) if self._arg_type_name: self.arg_type = schema.resolve_type( self._arg_type_name, self.info, "event's 'data'")
Kashyap Chamarthy
Reviewed-byRe: [PATCH 1/9] qapi: New special feature flag "unstable"
Quoted 3 lines · Markus Armbruster
Quoted 1 line · Kashyap Chamarthy
On Mon, Oct 25, 2021 at 07:25:24AM +0200, Markus Armbruster wrote:
[...]
Quoted 7 lines
Quoted 2 lines
Looks like there's another stable property with an "x-" prefix:
"x-remote-object", part of QOM type @RemoteObjectProperties.The union branch 'x-remote-object' isn't flagged 'unstable' (because union branches can't have feature flags), but the enumeration value 'x-remote-object' is. Sufficient, because you can't use the branch without using the enumeration value. Admittedly subtle.
Ah, thanks for the explanation. I missed the union branch part, which I now notice in your "[PATCH 2/9] qapi: Mark unstable QMP parts with feature 'unstable'".
Quoted 1 line
I wrote a bit of code (appended) to make sure I don't miss names.
Thanks; looks good to me.
Quoted 20 lines
Quoted 4 lines
Given the above "x-" properties are now stable, I take it that they cannot be renamed now, as they might break any tools using them? My guess is the tedious way is not worth it: deprecate them, and add the non-x variants as "synonyms".
"x-use-canonical-path-for-ramblock-id" goes back to commit
fa0cb34d22"hostmem: use object id for memory region name with >= 4.0" (v4.0). It may have been intended to be internal back then. It wasn't anymore when commit8db0b20415"machine: add missing doc for memory-backend option" (v6.0) documented it:And document that x-use-canonical-path-for-ramblock-id, is considered to be stable to make sure it won't go away by accident.
x- was intended for unstable/iternal properties, and not supposed to be stable option. However it's too late to rename (drop x-) it as it would mean that users will have to mantain both x-use-canonical-path-for-ramblock-id (for QEMU 5.0-5.2) versions and prefix-less for later versions.
Quoted 3 lines
Igor's reasoning still applies.
"x-origin" has always been stable. Same argument.
Yep, fair enough.
[...]
Quoted 56 lines
commit
415b71a9f6e5bc37e84895d2e767cf4cfacd279b(HEAD)Author: Markus Armbruster <[email protected]> Date: Sat Oct 9 09:01:21 2021 +0200qapi: Find x- without feature unstable DBG
scripts/qapi/schema.py +10
-0@@ -14,6 +14,8 @@ # TODO catching name collisions in generated code would be nice +import sys + from collections import OrderedDict import os import re@@ -118,6 +120,11 @@ def describe(self): return "%s '%s'" % (self.meta, self.name) +def check_have_feature_unstable(name, info, features): + if name.startswith('x-') and 'unstable' not in (f.name for f in features): + print(QAPISemError(info, f"XXX %{name} %{features}"), file=sys.stderr) + + class QAPISchemaVisitor: def visit_begin(self, schema): pass@@ -718,6 +725,7 @@ def __init__(self, name, info, ifcond=None, features=None): self.features = features or [] def connect_doc(self, doc): + check_have_feature_unstable(self.name, self.info, self.features) super().connect_doc(doc) if doc: for f in self.features:@@ -745,6 +753,7 @@ def __init__(self, name, info, typ, optional, ifcond=None, features=None): self.features = features or [] def check(self, schema): + check_have_feature_unstable(self.name, self.info, self.features) assert self.defined_in self.type = schema.resolve_type(self._type_name, self.info, self.describe)@@ -789,6 +798,7 @@ def __init__(self, name, info, doc, ifcond, features, def check(self, schema): super().check(schema) + check_have_feature_unstable(self.name, self.info, self.features) if self._arg_type_name: self.arg_type = schema.resolve_type( self._arg_type_name, self.info, "command's 'data'")
scripts/qapi/schema.py def __init__(self, name, info, doc, ifcond, features, arg_type, boxed): · line 860
Quoted 7 lines
scripts/qapi/schema.py +1
-0@@ -844,6 +854,7 @@ def __init__(self, name, info, doc, ifcond, features, arg_type, boxed): def check(self, schema): super().check(schema) + check_have_feature_unstable(self.name, self.info, self.features) if self._arg_type_name: self.arg_type = schema.resolve_type( self._arg_type_name, self.info, "event's 'data'")
TIL: the error class QAPISemError()
Signature · 1 line
/kashyap
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
In reply to Markus ArmbrusterQuoted 126 lines · Markus Armbruster
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Signed-off-by Markus Armbruster <[email protected]>--- docs/devel/qapi-code-gen.rst | 9 ++++++--- tests/qapi-schema/qapi-schema-test.json | 7 +++++-- tests/qapi-schema/qapi-schema-test.out | 5 +++++ 3 files changed, 16 insertions(+), 5 deletions(-)docs/devel/qapi-code-gen.rst +0
-0@@ -713,6 +713,10 @@ member as deprecated. It is not supported elsewhereso far.
Interfaces so marked may be withdrawn in future releases in accordance with QEMU's deprecation policy.docs/devel/qapi-code-gen.rst +4
-0+Feature "unstable" marks a command, event, enum value, or struct +member as unstable. It is not supported elsewhere so far. Interfaces +so marked may be withdrawn or changed incompatibly in future releases. + Naming rules and reserved names -------------------------------@@ -746,9 +750,8 @@ Member name ``u`` and names starting with ``has-`` or``has_`` are reserved
for the generator, which uses them for unions and for tracking optional members.docs/devel/qapi-code-gen.rst +2
-3-Any name (command, event, type, member, or enum value) beginning with -``x-`` is marked experimental, and may be withdrawn or changed -incompatibly in a future release. +Names beginning with ``x-`` used to signify "experimental". This +convention has been replaced by special feature "unstable". Pragmas ``command-name-exceptions`` and ``member-name-exceptions`` let you violate naming rules. Use for new code is strongly discouraged. Seetests/qapi-schema/qapi-schema-test.json +5
-2@@ -273,7 +273,7 @@ 'data': { 'foo': { 'type': 'int', 'features': [ 'deprecated' ] } }, 'features': [ 'feature1' ] } { 'struct': 'FeatureStruct2', - 'data': { 'foo': 'int' }, + 'data': { 'foo': { 'type': 'int', 'features': [ 'unstable' ] } }, 'features': [ { 'name': 'feature1' } ] } { 'struct': 'FeatureStruct3', 'data': { 'foo': 'int' },@@ -331,7 +331,7 @@ { 'command': 'test-command-features1', 'features': [ 'deprecated' ] } { 'command': 'test-command-features3', - 'features': [ 'feature1', 'feature2' ] } + 'features': [ 'unstable', 'feature1', 'feature2' ] } { 'command': 'test-command-cond-features1', 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'} ] }@@ -348,3 +348,6 @@ { 'event': 'TEST_EVENT_FEATURES1', 'features': [ 'deprecated' ] } + +{ 'event': 'TEST_EVENT_FEATURES2', + 'features': [ 'unstable' ] }tests/qapi-schema/qapi-schema-test.out +5
-1@@ -308,6 +308,7 @@ object FeatureStruct1 feature feature1 object FeatureStruct2 member foo: int optional=False + feature unstable feature feature1 object FeatureStruct3 member foo: int optional=False@@ -373,6 +374,7 @@ command test-command-features1 None -> None feature deprecated command test-command-features3 None -> None gen=True success_response=True boxed=False oob=False preconfig=False + feature unstable feature feature1 feature feature2 command test-command-cond-features1 None -> None@@ -394,6 +396,9 @@ event TEST_EVENT_FEATURES0 FeatureStruct1 event TEST_EVENT_FEATURES1 None boxed=False feature deprecated +event TEST_EVENT_FEATURES2 None + boxed=False + feature unstable module include/sub-module.json include sub-sub-module.json object SecondArrayRef --
Quoted 3 lines
2.31.1
Feels odd to combine the doc update *and* test prep, but eh, whatever.
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
Quoted 31 lines · John Snow
Quoted 29 lines · Markus Armbruster
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Signed-off-by Markus Armbruster <[email protected]>
[...]
Quoted 1 line
Feels odd to combine the doc update *and* test prep, but eh, whatever.
I admit this is what was left after patch splitting and reshuffling.
Quoted 1 line
Reviewed-by John Snow <[email protected]>
Thanks!
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
In reply to Markus ArmbrusterAm 25.10.2021 um 07:25 hat Markus Armbruster geschrieben:
Quoted 24 lines
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
Quoted 5 lines
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Signed-off-by Markus Armbruster <[email protected]>
Obviously, replacing the old convention gets rid of the old drawbacks, but adds a new one: While using x- makes it very obvious for a human user that this is an unstable feature, a feature flag in the schema will almost certainly go unnoticed in manual use.
Kevin
Re: [Libguestfs] [PATCH 1/9] qapi: New special feature flag "unstable"
Quoted 1 line · Kevin Wolf
Am 25.10.2021 um 07:25 hat Markus Armbruster geschrieben:
[...]
Quoted 10 lines
Quoted 5 lines
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Signed-off-by Markus Armbruster <[email protected]>Obviously, replacing the old convention gets rid of the old drawbacks, but adds a new one: While using x- makes it very obvious for a human user that this is an unstable feature, a feature flag in the schema will almost certainly go unnoticed in manual use.
FWIW, I wondered about it too, as I like the visual reminder of the "x-" prefix. Then I thought, "how many people besides QEMU and related tooling developers -- who would read QAPI docs anyway :) -- launch experimental QEMU commands manually?" Maybe that's too big of a leap.
Signature · 1 line
/kashyap
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
In reply to Kevin WolfQuoted 29 lines · * Kevin Wolf ([email protected]) wrote:
Am 25.10.2021 um 07:25 hat Markus Armbruster geschrieben:
Quoted 28 lines
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Quoted 6 lines
Quoted 1 line
Signed-off-by Markus Armbruster <[email protected]>Obviously, replacing the old convention gets rid of the old drawbacks, but adds a new one: While using x- makes it very obvious for a human user that this is an unstable feature, a feature flag in the schema will almost certainly go unnoticed in manual use.
Agreed, I'd keep the x- as well.
Having said that, the x- represents a few different things (that we don't currently distinguish):
- experimental
- for internal use
- for debugging/human use
Dave
Quoted 2 lines
Kevin
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
Quoted 37 lines · Dr. David Alan Gilbert
Quoted 29 lines · * Kevin Wolf ([email protected]) wrote:
Am 25.10.2021 um 07:25 hat Markus Armbruster geschrieben:
Quoted 28 lines
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Quoted 6 lines
Quoted 1 line
Signed-off-by Markus Armbruster <[email protected]>Obviously, replacing the old convention gets rid of the old drawbacks, but adds a new one: While using x- makes it very obvious for a human user that this is an unstable feature, a feature flag in the schema will almost certainly go unnoticed in manual use.
Quoted 7 lines
Agreed, I'd keep the x- as well.
Having said that, the x- represents a few different things (that we don't currently distinguish):
- experimental
- for internal use
- for debugging/human use
All of those usage scenarios have the same implication though:
Command/data format is liable to change in incompatible ways, or be deleted, with no prior warning.
I don't think we need to distinguish the use cases - some commands may belong to two or three of those use cases. All that matters is that they're considered "unstable" from an API compat POV.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
In reply to Kevin WolfQuoted 29 lines · Kevin Wolf
Am 25.10.2021 um 07:25 hat Markus Armbruster geschrieben:
Quoted 28 lines
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Quoted 6 lines
Quoted 1 line
Signed-off-by Markus Armbruster <[email protected]>Obviously, replacing the old convention gets rid of the old drawbacks, but adds a new one: While using x- makes it very obvious for a human user that this is an unstable feature, a feature flag in the schema will almost certainly go unnoticed in manual use.
I thought about this, but neglected to put it in writing. My bad.
Manual use of unstable interfaces is mostly fine. Human users can adapt to changing interfaces. HMP works that way.
Management applications are better off with a feature flag than with a naming convention we sometimes ignore.
The most potential for trouble is in between: programs that aren't full-fledged management applications.
If we want to keep "unstable" obvious to the humans who write such programs, we can continue to require "x-", in addition to the feature flag. We pay for it with renames, and the risk of forgetting to rename in time (which is what got us the awkward stable "x-use-canonical-path-for-ramblock-id"). Tradeoff. I chose not to, but if y'all think we should...
What we can't do, at least not easily, is to use *only* the "x-"
convention: it is not reliable. We'd have to add a way to say 'this is stable even though the name starts with "x-"'.
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
Am 26.10.2021 um 11:37 hat Markus Armbruster geschrieben:
Quoted 49 lines
Quoted 29 lines · Kevin Wolf
Am 25.10.2021 um 07:25 hat Markus Armbruster geschrieben:
Quoted 28 lines
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Quoted 6 lines
Quoted 1 line
Signed-off-by Markus Armbruster <[email protected]>Obviously, replacing the old convention gets rid of the old drawbacks, but adds a new one: While using x- makes it very obvious for a human user that this is an unstable feature, a feature flag in the schema will almost certainly go unnoticed in manual use.
I thought about this, but neglected to put it in writing. My bad.
Manual use of unstable interfaces is mostly fine. Human users can adapt to changing interfaces. HMP works that way.
Management applications are better off with a feature flag than with a naming convention we sometimes ignore.
The most potential for trouble is in between: programs that aren't full-fledged management applications.
Quoted 6 lines
If we want to keep "unstable" obvious to the humans who write such programs, we can continue to require "x-", in addition to the feature flag. We pay for it with renames, and the risk of forgetting to rename in time (which is what got us the awkward stable "x-use-canonical-path-for-ramblock-id"). Tradeoff. I chose not to, but if y'all think we should...
Just to clarify, I'm not implying that we should keep it. I'm merely pointing out that there is a tradeoff that requires us to make a choice. The decision for one of the options should be explicit rather than just happening as a side effect. Documenting that it was a conscious decision is probably best done by adding the reasoning for it to the commit message.
Quoted 3 lines
What we can't do, at least not easily, is to use *only* the "x-"
convention: it is not reliable. We'd have to add a way to say 'this is stable even though the name starts with "x-"'.
No question.
Kevin
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
Quoted 57 lines · Kevin Wolf
Am 26.10.2021 um 11:37 hat Markus Armbruster geschrieben:
Quoted 49 lines
Quoted 29 lines · Kevin Wolf
Am 25.10.2021 um 07:25 hat Markus Armbruster geschrieben:
Quoted 28 lines
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Quoted 6 lines
Quoted 1 line
Signed-off-by Markus Armbruster <[email protected]>Obviously, replacing the old convention gets rid of the old drawbacks, but adds a new one: While using x- makes it very obvious for a human user that this is an unstable feature, a feature flag in the schema will almost certainly go unnoticed in manual use.
I thought about this, but neglected to put it in writing. My bad.
Manual use of unstable interfaces is mostly fine. Human users can adapt to changing interfaces. HMP works that way.
Management applications are better off with a feature flag than with a naming convention we sometimes ignore.
The most potential for trouble is in between: programs that aren't full-fledged management applications.
Quoted 6 lines
If we want to keep "unstable" obvious to the humans who write such programs, we can continue to require "x-", in addition to the feature flag. We pay for it with renames, and the risk of forgetting to rename in time (which is what got us the awkward stable "x-use-canonical-path-for-ramblock-id"). Tradeoff. I chose not to, but if y'all think we should...
Quoted 6 lines
Just to clarify, I'm not implying that we should keep it. I'm merely pointing out that there is a tradeoff that requires us to make a choice. The decision for one of the options should be explicit rather than just happening as a side effect. Documenting that it was a conscious decision is probably best done by adding the reasoning for it to the commit message.
I rewrote the commit message for v2.
Thanks!
[...]
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
In reply to Markus ArmbrusterQuoted 38 lines · Markus Armbruster
Quoted 29 lines · Kevin Wolf
Am 25.10.2021 um 07:25 hat Markus Armbruster geschrieben:
Quoted 28 lines
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Quoted 6 lines
Quoted 1 line
Signed-off-by Markus Armbruster <[email protected]>Obviously, replacing the old convention gets rid of the old drawbacks, but adds a new one: While using x- makes it very obvious for a human user that this is an unstable feature, a feature flag in the schema will almost certainly go unnoticed in manual use.
Quoted 7 lines
I thought about this, but neglected to put it in writing. My bad.
Manual use of unstable interfaces is mostly fine. Human users can adapt to changing interfaces. HMP works that way.
Management applications are better off with a feature flag than with a naming convention we sometimes ignore.
We will sometimes ignore/forget the feature flag too though, so I'm not convinced there's much difference there.
Quoted 6 lines
If we want to keep "unstable" obvious to the humans who write such programs, we can continue to require "x-", in addition to the feature flag. We pay for it with renames, and the risk of forgetting to rename in time (which is what got us the awkward stable "x-use-canonical-path-for-ramblock-id"). Tradeoff. I chose not to, but if y'all think we should...
IMHO the renames arguably make life easier for mgmt apps, as they only need to check for the name without the x- prefix, and they know they won't be accidentally using the fature from an older QEMU where it was unstable because the older QEMU had a different name they won't be checking for.
We can just as easily forget to remove the "unstable" feature flag, as forget to rename.
The plus point about the feature flag is that it is aligned with the "deprecated" feature flag, and potentially aligned with a future "insecure" feature flag.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
Quoted 41 lines · Daniel P. Berrangé
Quoted 40 lines · Markus Armbruster
Quoted 29 lines · Kevin Wolf
Am 25.10.2021 um 07:25 hat Markus Armbruster geschrieben:
Quoted 28 lines
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Quoted 6 lines
Quoted 1 line
Signed-off-by Markus Armbruster <[email protected]>Obviously, replacing the old convention gets rid of the old drawbacks, but adds a new one: While using x- makes it very obvious for a human user that this is an unstable feature, a feature flag in the schema will almost certainly go unnoticed in manual use.
I thought about this, but neglected to put it in writing. My bad.
Quoted 8 lines
Quoted 5 lines
Manual use of unstable interfaces is mostly fine. Human users can adapt to changing interfaces. HMP works that way.
Management applications are better off with a feature flag than with a naming convention we sometimes ignore.
We will sometimes ignore/forget the feature flag too though, so I'm not convinced there's much difference there.
-compat unstable-input=reject,unstable-output=hide should help you stay on the straight & narrow :)
Quoted 13 lines
Quoted 6 lines
If we want to keep "unstable" obvious to the humans who write such programs, we can continue to require "x-", in addition to the feature flag. We pay for it with renames, and the risk of forgetting to rename in time (which is what got us the awkward stable "x-use-canonical-path-for-ramblock-id"). Tradeoff. I chose not to, but if y'all think we should...
IMHO the renames arguably make life easier for mgmt apps, as they only need to check for the name without the x- prefix, and they know they won't be accidentally using the fature from an older QEMU where it was unstable because the older QEMU had a different name they won't be checking for.
Quoted 6 lines
We can just as easily forget to remove the "unstable" feature flag, as forget to rename.
The plus point about the feature flag is that it is aligned with the "deprecated" feature flag, and potentially aligned with a future "insecure" feature flag.
Yup.
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
Quoted 46 lines · Markus Armbruster
Quoted 44 lines · Daniel P. Berrangé
Quoted 43 lines · Markus Armbruster
Quoted 29 lines · Kevin Wolf
Am 25.10.2021 um 07:25 hat Markus Armbruster geschrieben:
Quoted 28 lines
By convention, names starting with "x-" are experimental. The parts of external interfaces so named may be withdrawn or changed incompatibly in future releases.
Drawback: promoting something from experimental to stable involves a name change. Client code needs to be updated.
Moreover, the convention is not universally observed:
* QOM type "input-barrier" has properties "x-origin", "y-origin". Looks accidental, but it's ABI since 4.2.
* QOM types "memory-backend-file", "memory-backend-memfd", "memory-backend-ram", and "memory-backend-epc" have a property "x-use-canonical-path-for-ramblock-id" that is documented to be stable despite its name.
We could document these exceptions, but documentation helps only humans. We want to recognize "unstable" in code, like "deprecated".
Replace the convention by a new special feature flag "unstable". It will be recognized by the QAPI generator, like the existing feature flag "deprecated", and unlike regular feature flags.
This commit updates documentation and prepares tests. The next commit updates the QAPI schema. The remaining patches update the QAPI generator and wire up -compat policy checking.
Quoted 6 lines
Quoted 1 line
Signed-off-by Markus Armbruster <[email protected]>Obviously, replacing the old convention gets rid of the old drawbacks, but adds a new one: While using x- makes it very obvious for a human user that this is an unstable feature, a feature flag in the schema will almost certainly go unnoticed in manual use.
I thought about this, but neglected to put it in writing. My bad.
Manual use of unstable interfaces is mostly fine. Human users can adapt to changing interfaces. HMP works that way.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Management applications are better off with a feature flag than with a naming convention we sometimes ignore.
We will sometimes ignore/forget the feature flag too though, so I'm not convinced there's much difference there.
-compat unstable-input=reject,unstable-output=hide should help you stay on the straight & narrow :)
That's from the pov of the mgmt app. I meant from the POV of QEMU maintainers forgetting to add "unstable" flag, just as they might forget to add a "x-" prefix.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 1/9] qapi: New special feature flag "unstable"
Quoted 4 lines · Daniel P. Berrangé
Quoted 3 lines · Markus Armbruster
Quoted 1 line · Daniel P. Berrangé
On Tue, Oct 26, 2021 at 11:37:19AM +0200, Markus Armbruster wrote:
[...]
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
Management applications are better off with a feature flag than with a naming convention we sometimes ignore.
We will sometimes ignore/forget the feature flag too though, so I'm not convinced there's much difference there.
Quoted 6 lines
Quoted 2 lines
-compat unstable-input=reject,unstable-output=hide should help you stay on the straight & narrow :)
That's from the pov of the mgmt app. I meant from the POV of QEMU maintainers forgetting to add "unstable" flag, just as they might forget to add a "x-" prefix.
Got it.
My point was that feature flag "unstable" is an unequivocal signal for "this thing is unstable", while a name starting with "x-" isn't: there are exceptions.
The converse is a wash: we can forget to mark something unstable no matter how the mark works.
PATCH 2/9 qapi: Mark unstable QMP parts with feature 'unstable'
In reply to Markus ArmbrusterAdd special feature 'unstable' everywhere the name starts with 'x-', except for InputBarrierProperties member x-origin and MemoryBackendProperties member x-use-canonical-path-for-ramblock-id, because these two are actually stable.
--- qapi/block-core.json | 123 +++++++++++++++++++++++++++++++------------ qapi/migration.json | 35 +++++++++--- qapi/misc.json | 6 ++- qapi/qom.json | 11 ++-- 4 files changed, 130 insertions(+), 45 deletions(-)
qapi/block-core.json +90 -33
@@ -1438,6 +1438,9 @@ # # @x-perf: Performance options. (Since 6.0) # +# Features: +# @unstable: Member @x-perf is experimental. +# # Note: @on-source-error and @on-target-error only affect background # I/O. If an error occurs during a guest write request, the device's # rerror/werror actions will be used.
@@ -1452,7 +1455,9 @@ '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*auto-finalize': 'bool', '*auto-dismiss': 'bool', - '*filter-node-name': 'str', '*x-perf': 'BackupPerf' } } + '*filter-node-name': 'str', + '*x-perf': { 'type': 'BackupPerf', + 'features': [ 'unstable' ] } } } ## # @DriveBackup:
@@ -1916,9 +1921,13 @@ # # Get the block graph. # +# Features: +# @unstable: This command is meant for debugging. +# # Since: 4.0 ## -{ 'command': 'x-debug-query-block-graph', 'returns': 'XDbgBlockGraph' } +{ 'command': 'x-debug-query-block-graph', 'returns': 'XDbgBlockGraph', + 'features': [ 'unstable' ] } ## # @drive-mirror:
@@ -2257,6 +2266,9 @@ # # Get bitmap SHA256. # +# Features: +# @unstable: This command is meant for debugging. +# # Returns: - BlockDirtyBitmapSha256 on success # - If @node is not a valid block device, DeviceNotFound # - If @name is not found or if hashing has failed, GenericError with an
@@ -2265,7 +2277,8 @@ # Since: 2.10 ## { 'command': 'x-debug-block-dirty-bitmap-sha256', - 'data': 'BlockDirtyBitmap', 'returns': 'BlockDirtyBitmapSha256' } + 'data': 'BlockDirtyBitmap', 'returns': 'BlockDirtyBitmapSha256', + 'features': [ 'unstable' ] } ## # @blockdev-mirror:
@@ -2495,27 +2508,57 @@ # # Properties for throttle-group objects. # -# The options starting with x- are aliases for the same key without x- in -# the @limits object. As indicated by the x- prefix, this is not a stable -# interface and may be removed or changed incompatibly in the future. Use -# @limits for a supported stable interface. -# # @limits: limits to apply for this throttle group # +# Features: +# @unstable: All members starting with x- are aliases for the same key +# without x- in the @limits object. This is not a stable +# interface and may be removed or changed incompatibly in +# the future. Use @limits for a supported stable +# interface. +# # Since: 2.11 ## { 'struct': 'ThrottleGroupProperties', 'data': { '*limits': 'ThrottleLimits', - '*x-iops-total' : 'int', '*x-iops-total-max' : 'int', - '*x-iops-total-max-length' : 'int', '*x-iops-read' : 'int', - '*x-iops-read-max' : 'int', '*x-iops-read-max-length' : 'int', - '*x-iops-write' : 'int', '*x-iops-write-max' : 'int', - '*x-iops-write-max-length' : 'int', '*x-bps-total' : 'int', - '*x-bps-total-max' : 'int', '*x-bps-total-max-length' : 'int', - '*x-bps-read' : 'int', '*x-bps-read-max' : 'int', - '*x-bps-read-max-length' : 'int', '*x-bps-write' : 'int', - '*x-bps-write-max' : 'int', '*x-bps-write-max-length' : 'int', - '*x-iops-size' : 'int' } } + '*x-iops-total': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-total-max': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-total-max-length': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-read': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-read-max': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-read-max-length': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-write': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-write-max': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-write-max-length': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-total': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-total-max': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-total-max-length': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-read': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-read-max': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-read-max-length': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-write': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-write-max': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-write-max-length': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-size': { 'type': 'int', + 'features': [ 'unstable' ] } } } ## # @block-stream:
@@ -2916,6 +2959,7 @@ # read-only when the last writer is detached. This # allows giving QEMU write permissions only on demand # when an operation actually needs write access. +# @unstable: Member x-check-cache-dropped is meant for debugging. # # Since: 2.9 ##
@@ -2926,7 +2970,8 @@ '*aio': 'BlockdevAioOptions', '*drop-cache': {'type': 'bool', 'if': 'CONFIG_LINUX'}, - '*x-check-cache-dropped': 'bool' }, + '*x-check-cache-dropped': { 'type': 'bool', + 'features': [ 'unstable' ] } }, 'features': [ { 'name': 'dynamic-auto-read-only', 'if': 'CONFIG_POSIX' } ] }
@@ -4041,13 +4086,16 @@ # future requests before a successful reconnect will # immediately fail. Default 0 (Since 4.2) # +# Features: +# @unstable: Member @x-dirty-bitmap is experimental. +# # Since: 2.9 ## { 'struct': 'BlockdevOptionsNbd', 'data': { 'server': 'SocketAddress', '*export': 'str', '*tls-creds': 'str', - '*x-dirty-bitmap': 'str', + '*x-dirty-bitmap': { 'type': 'str', 'features': [ 'unstable' ] }, '*reconnect-delay': 'uint32' } } ##
@@ -4865,13 +4913,17 @@ # and replacement of an active keyslot # (possible loss of data if IO error happens) # +# Features: +# @unstable: This command is experimental. +# # Since: 5.1 ## { 'command': 'x-blockdev-amend', 'data': { 'job-id': 'str', 'node-name': 'str', 'options': 'BlockdevAmendOptions', - '*force': 'bool' } } + '*force': 'bool' }, + 'features': [ 'unstable' ] } ## # @BlockErrorAction:
@@ -5242,16 +5294,18 @@ # # @node: the name of the node that will be added. # -# Note: this command is experimental, and its API is not stable. It -# does not support all kinds of operations, all kinds of children, nor -# all block drivers. +# Features: +# @unstable: This command is experimental, and its API is not stable. It +# does not support all kinds of operations, all kinds of +# children, nor all block drivers. # -# FIXME Removing children from a quorum node means introducing gaps in the -# child indices. This cannot be represented in the 'children' list of -# BlockdevOptionsQuorum, as returned by .bdrv_refresh_filename(). +# FIXME Removing children from a quorum node means introducing +# gaps in the child indices. This cannot be represented in the +# 'children' list of BlockdevOptionsQuorum, as returned by +# .bdrv_refresh_filename(). # -# Warning: The data in a new quorum child MUST be consistent with that of -# the rest of the array. +# Warning: The data in a new quorum child MUST be consistent +# with that of the rest of the array. # # Since: 2.7 #
@@ -5280,7 +5334,8 @@ { 'command': 'x-blockdev-change', 'data' : { 'parent': 'str', '*child': 'str', - '*node': 'str' } } + '*node': 'str' }, + 'features': [ 'unstable' ] } ## # @x-blockdev-set-iothread:
@@ -5297,8 +5352,9 @@ # @force: true if the node and its children should be moved when a BlockBackend # is already attached # -# Note: this command is experimental and intended for test cases that need -# control over IOThreads only. +# Features: +# @unstable: This command is experimental and intended for test cases that +# need control over IOThreads only. # # Since: 2.12 #
@@ -5320,7 +5376,8 @@ { 'command': 'x-blockdev-set-iothread', 'data' : { 'node-name': 'str', 'iothread': 'StrOrNull', - '*force': 'bool' } } + '*force': 'bool' }, + 'features': [ 'unstable' ] } ## # @QuorumOpType:
qapi/migration.json +29 -6
@@ -452,14 +452,20 @@ # procedure starts. The VM RAM is saved with running VM. # (since 6.0) # +# Features: +# @unstable: Members @x-colo and @x-ignore-shared are experimental. +# # Since: 1.2 ## { 'enum': 'MigrationCapability', 'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks', - 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram', + 'compress', 'events', 'postcopy-ram', + { 'name': 'x-colo', 'features': [ 'unstable' ] }, + 'release-ram', 'block', 'return-path', 'pause-before-switchover', 'multifd', 'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate', - 'x-ignore-shared', 'validate-uuid', 'background-snapshot'] } + { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] }, + 'validate-uuid', 'background-snapshot'] } ## # @MigrationCapabilityStatus:
@@ -743,6 +749,9 @@ # block device name if there is one, and to their node name # otherwise. (Since 5.2) # +# Features: +# @unstable: Member @x-checkpoint-delay is experimental. +# # Since: 2.4 ## { 'enum': 'MigrationParameter',
@@ -753,7 +762,9 @@ 'cpu-throttle-initial', 'cpu-throttle-increment', 'cpu-throttle-tailslow', 'tls-creds', 'tls-hostname', 'tls-authz', 'max-bandwidth', - 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', + 'downtime-limit', + { 'name': 'x-checkpoint-delay', 'features': [ 'unstable' ] }, + 'block-incremental', 'multifd-channels', 'xbzrle-cache-size', 'max-postcopy-bandwidth', 'max-cpu-throttle', 'multifd-compression',
@@ -903,6 +914,9 @@ # block device name if there is one, and to their node name # otherwise. (Since 5.2) # +# Features: +# @unstable: Member @x-checkpoint-delay is experimental. +# # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make
@@ -925,7 +939,8 @@ '*tls-authz': 'StrOrNull', '*max-bandwidth': 'size', '*downtime-limit': 'uint64', - '*x-checkpoint-delay': 'uint32', + '*x-checkpoint-delay': { 'type': 'uint32', + 'features': [ 'unstable' ] }, '*block-incremental': 'bool', '*multifd-channels': 'uint8', '*xbzrle-cache-size': 'size',
@@ -1099,6 +1114,9 @@ # block device name if there is one, and to their node name # otherwise. (Since 5.2) # +# Features: +# @unstable: Member @x-checkpoint-delay is experimental. +# # Since: 2.4 ## { 'struct': 'MigrationParameters',
@@ -1119,7 +1137,8 @@ '*tls-authz': 'str', '*max-bandwidth': 'size', '*downtime-limit': 'uint64', - '*x-checkpoint-delay': 'uint32', + '*x-checkpoint-delay': { 'type': 'uint32', + 'features': [ 'unstable' ] }, '*block-incremental': 'bool', '*multifd-channels': 'uint8', '*xbzrle-cache-size': 'size',
@@ -1351,6 +1370,9 @@ # If sent to the Secondary, the Secondary side will run failover work, # then takes over server operation to become the service VM. # +# Features: +# @unstable: This command is experimental. +# # Since: 2.8 # # Example:
@@ -1359,7 +1381,8 @@ # <- { "return": {} } # ## -{ 'command': 'x-colo-lost-heartbeat' } +{ 'command': 'x-colo-lost-heartbeat', + 'features': [ 'unstable' ] } ## # @migrate_cancel:
qapi/misc.json +5 -1
@@ -185,6 +185,9 @@ # available during the preconfig state (i.e. when the --preconfig command # line option was in use). # +# Features: +# @unstable: This command is experimental. +# # Since 3.0 # # Returns: nothing
@@ -195,7 +198,8 @@ # <- { "return": {} } # ## -{ 'command': 'x-exit-preconfig', 'allow-preconfig': true } +{ 'command': 'x-exit-preconfig', 'allow-preconfig': true, + 'features': [ 'unstable' ] } ## # @human-monitor-command:
qapi/qom.json +6 -5
@@ -559,10 +559,8 @@ # for ramblock-id. Disable this for 4.0 # machine types or older to allow # migration with newer QEMU versions. -# This option is considered stable -# despite the x- prefix. (default: -# false generally, but true for machine -# types <= 4.0) +# (default: false generally, +# but true for machine types <= 4.0) # # Note: prealloc=true and reserve=false cannot be set at the same time. With # reserve=true, the behavior depends on the operating system: for example,
@@ -785,6 +783,9 @@ ## # @ObjectType: # +# Features: +# @unstable: Member @x-remote-object is experimental. +# # Since: 6.0 ## { 'enum': 'ObjectType',
@@ -836,7 +837,7 @@ 'tls-creds-psk', 'tls-creds-x509', 'tls-cipher-suites', - 'x-remote-object' + { 'name': 'x-remote-object', 'features': [ 'unstable' ] } ] } ##
Signature · 1 line
2.31.1
Re: [PATCH 2/9] qapi: Mark unstable QMP parts with feature 'unstable'
Quoted 6 lines · Markus Armbruster
Add special feature 'unstable' everywhere the name starts with 'x-', except for InputBarrierProperties member x-origin and MemoryBackendProperties member x-use-canonical-path-for-ramblock-id, because these two are actually stable.
Signed-off-by Markus Armbruster <[email protected]>
Re: [PATCH 2/9] qapi: Mark unstable QMP parts with feature 'unstable'
In reply to Markus ArmbrusterQuoted 18 lines · Markus Armbruster
Add special feature 'unstable' everywhere the name starts with 'x-', except for InputBarrierProperties member x-origin and MemoryBackendProperties member x-use-canonical-path-for-ramblock-id, because these two are actually stable.
Signed-off-by Markus Armbruster <[email protected]>--- qapi/block-core.json | 123 +++++++++++++++++++++++++++++++------------ qapi/migration.json | 35 +++++++++--- qapi/misc.json | 6 ++- qapi/qom.json | 11 ++-- 4 files changed, 130 insertions(+), 45 deletions(-)qapi/block-core.json +0
-0
qapi/block-core.json line 1444
Quoted 7 lines
qapi/block-core.json +3
-0@@ -1438,6 +1438,9 @@ # # @x-perf: Performance options. (Since 6.0) # +# Features: +# @unstable: Member @x-perf is experimental. +#
It'd be a lot cooler if we could annotate the unstable member directly instead of confusing it with the syntax that might describe the entire struct/union/command/etc, but ... eh, it's just a doc field, so I'm not gonna press on this. I don't have the energy to get into a doc formatting standard discussion right now, so: sure, why not?
Quoted 425 lines
qapi/block-core.json +0
-0# Note: @on-source-error and @on-target-error only affect background # I/O. If an error occurs during a guest write request, thedevice's
# rerror/werror actions will be used.qapi/block-core.json +11
-2@@ -1452,7 +1455,9 @@ '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*auto-finalize': 'bool', '*auto-dismiss': 'bool', - '*filter-node-name': 'str', '*x-perf': 'BackupPerf' } } + '*filter-node-name': 'str', + '*x-perf': { 'type': 'BackupPerf', + 'features': [ 'unstable' ] } } } ## # @DriveBackup:@@ -1916,9 +1921,13 @@ # # Get the block graph. # +# Features: +# @unstable: This command is meant for debugging. +# # Since: 4.0 ## -{ 'command': 'x-debug-query-block-graph', 'returns': 'XDbgBlockGraph' } +{ 'command': 'x-debug-query-block-graph', 'returns': 'XDbgBlockGraph', + 'features': [ 'unstable' ] } ## # @drive-mirror:@@ -2257,6 +2266,9 @@ # # Get bitmap SHA256. # +# Features: +# @unstable: This command is meant for debugging. +# # Returns: - BlockDirtyBitmapSha256 on success # - If @node is not a valid block device, DeviceNotFound # - If @name is not found or if hashing has failed, GenericErrorwith an
qapi/block-core.json +47
-16@@ -2265,7 +2277,8 @@ # Since: 2.10 ## { 'command': 'x-debug-block-dirty-bitmap-sha256', - 'data': 'BlockDirtyBitmap', 'returns': 'BlockDirtyBitmapSha256' } + 'data': 'BlockDirtyBitmap', 'returns': 'BlockDirtyBitmapSha256', + 'features': [ 'unstable' ] } ## # @blockdev-mirror:@@ -2495,27 +2508,57 @@ # # Properties for throttle-group objects. # -# The options starting with x- are aliases for the same key without x- in -# the @limits object. As indicated by the x- prefix, this is not a stable -# interface and may be removed or changed incompatibly in the future. Use -# @limits for a supported stable interface. -# # @limits: limits to apply for this throttle group # +# Features: +# @unstable: All members starting with x- are aliases for the same key +# without x- in the @limits object. This is not a stable +# interface and may be removed or changed incompatibly in +# the future. Use @limits for a supported stable +# interface. +# # Since: 2.11 ## { 'struct': 'ThrottleGroupProperties', 'data': { '*limits': 'ThrottleLimits', - '*x-iops-total' : 'int', '*x-iops-total-max' : 'int', - '*x-iops-total-max-length' : 'int', '*x-iops-read' : 'int', - '*x-iops-read-max' : 'int', '*x-iops-read-max-length' : 'int', - '*x-iops-write' : 'int', '*x-iops-write-max' : 'int', - '*x-iops-write-max-length' : 'int', '*x-bps-total' : 'int', - '*x-bps-total-max' : 'int', '*x-bps-total-max-length' : 'int', - '*x-bps-read' : 'int', '*x-bps-read-max' : 'int', - '*x-bps-read-max-length' : 'int', '*x-bps-write' : 'int', - '*x-bps-write-max' : 'int', '*x-bps-write-max-length' : 'int', - '*x-iops-size' : 'int' } } + '*x-iops-total': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-total-max': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-total-max-length': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-read': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-read-max': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-read-max-length': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-write': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-write-max': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-write-max-length': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-total': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-total-max': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-total-max-length': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-read': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-read-max': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-read-max-length': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-write': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-write-max': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-bps-write-max-length': { 'type': 'int', + 'features': [ 'unstable' ] }, + '*x-iops-size': { 'type': 'int', + 'features': [ 'unstable' ] } } } ## # @block-stream:@@ -2916,6 +2959,7 @@ # read-only when the last writer is detached.This
# allows giving QEMU write permissions only on
demand
# when an operation actually needs write access.qapi/block-core.json +7
-2+# @unstable: Member x-check-cache-dropped is meant for debugging. # # Since: 2.9 ##@@ -2926,7 +2970,8 @@ '*aio': 'BlockdevAioOptions', '*drop-cache': {'type': 'bool', 'if': 'CONFIG_LINUX'}, - '*x-check-cache-dropped': 'bool' }, + '*x-check-cache-dropped': { 'type': 'bool', + 'features': [ 'unstable' ] } }, 'features': [ { 'name': 'dynamic-auto-read-only', 'if': 'CONFIG_POSIX' } ] }@@ -4041,13 +4086,16 @@ # future requests before a successful reconnect will # immediately fail. Default 0 (Since 4.2) # +# Features: +# @unstable: Member @x-dirty-bitmap is experimental. +# # Since: 2.9 ## { 'struct': 'BlockdevOptionsNbd', 'data': { 'server': 'SocketAddress', '*export': 'str', '*tls-creds': 'str', - '*x-dirty-bitmap': 'str', + '*x-dirty-bitmap': { 'type': 'str', 'features': [ 'unstable' ] }, '*reconnect-delay': 'uint32' } }##
qapi/block-core.json +5
-3@@ -4865,13 +4913,17 @@ # and replacement of an active keyslot # (possible loss of data if IO error happens) # +# Features: +# @unstable: This command is experimental. +# # Since: 5.1 ## { 'command': 'x-blockdev-amend', 'data': { 'job-id': 'str', 'node-name': 'str', 'options': 'BlockdevAmendOptions', - '*force': 'bool' } } + '*force': 'bool' }, + 'features': [ 'unstable' ] } ## # @BlockErrorAction:@@ -5242,16 +5294,18 @@ # # @node: the name of the node that will be added. # -# Note: this command is experimental, and its API is not stable. It -# does not support all kinds of operations, all kinds of children,nor
qapi/block-core.json +4
-2-# all block drivers. +# Features: +# @unstable: This command is experimental, and its API is not stable. It +# does not support all kinds of operations, all kinds of +# children, nor all block drivers. # -# FIXME Removing children from a quorum node means introducing gapsin the
-# child indices. This cannot be represented in the 'children' list
ofqapi/block-core.json +4
-2-# BlockdevOptionsQuorum, as returned by .bdrv_refresh_filename(). +# FIXME Removing children from a quorum node means introducing +# gaps in the child indices. This cannot be represented in the +# 'children' list of BlockdevOptionsQuorum, as returned by +# .bdrv_refresh_filename(). # -# Warning: The data in a new quorum child MUST be consistent withthat of
qapi/block-core.json +4
-2-# the rest of the array. +# Warning: The data in a new quorum child MUST be consistent +# with that of the rest of the array. # # Since: 2.7 #@@ -5280,7 +5334,8 @@ { 'command': 'x-blockdev-change', 'data' : { 'parent': 'str', '*child': 'str', - '*node': 'str' } } + '*node': 'str' }, + 'features': [ 'unstable' ] } ## # @x-blockdev-set-iothread:@@ -5297,8 +5352,9 @@ # @force: true if the node and its children should be moved when aBlockBackend
# is already attached
#qapi/block-core.json +5
-3-# Note: this command is experimental and intended for test cases that need -# control over IOThreads only. +# Features: +# @unstable: This command is experimental and intended for test cases that +# need control over IOThreads only. # # Since: 2.12 #@@ -5320,7 +5376,8 @@ { 'command': 'x-blockdev-set-iothread', 'data' : { 'node-name': 'str', 'iothread': 'StrOrNull', - '*force': 'bool' } } + '*force': 'bool' }, + 'features': [ 'unstable' ] } ## # @QuorumOpType:qapi/migration.json +0
-0@@ -452,14 +452,20 @@ # procedure starts. The VM RAM is saved withrunning VM.
# (since 6.0)
#qapi/migration.json +8
-2+# Features: +# @unstable: Members @x-colo and @x-ignore-shared are experimental. +# # Since: 1.2 ## { 'enum': 'MigrationCapability', 'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks', - 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram', + 'compress', 'events', 'postcopy-ram', + { 'name': 'x-colo', 'features': [ 'unstable' ] }, + 'release-ram', 'block', 'return-path', 'pause-before-switchover', 'multifd', 'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate', - 'x-ignore-shared', 'validate-uuid', 'background-snapshot'] } + { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] }, + 'validate-uuid', 'background-snapshot'] } ## # @MigrationCapabilityStatus:@@ -743,6 +749,9 @@ # block device name if there is one, and to theirnode name
# otherwise. (Since 5.2)
#qapi/migration.json +6
-1+# Features: +# @unstable: Member @x-checkpoint-delay is experimental. +# # Since: 2.4 ## { 'enum': 'MigrationParameter',@@ -753,7 +762,9 @@ 'cpu-throttle-initial', 'cpu-throttle-increment', 'cpu-throttle-tailslow', 'tls-creds', 'tls-hostname', 'tls-authz', 'max-bandwidth', - 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', + 'downtime-limit', + { 'name': 'x-checkpoint-delay', 'features': [ 'unstable' ] }, + 'block-incremental', 'multifd-channels', 'xbzrle-cache-size', 'max-postcopy-bandwidth', 'max-cpu-throttle', 'multifd-compression',@@ -903,6 +914,9 @@ # block device name if there is one, and to theirnode name
# otherwise. (Since 5.2)
#qapi/migration.json +5
-1+# Features: +# @unstable: Member @x-checkpoint-delay is experimental. +# # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make@@ -925,7 +939,8 @@ '*tls-authz': 'StrOrNull', '*max-bandwidth': 'size', '*downtime-limit': 'uint64', - '*x-checkpoint-delay': 'uint32', + '*x-checkpoint-delay': { 'type': 'uint32', + 'features': [ 'unstable' ] }, '*block-incremental': 'bool', '*multifd-channels': 'uint8', '*xbzrle-cache-size': 'size',@@ -1099,6 +1114,9 @@ # block device name if there is one, and to theirnode name
# otherwise. (Since 5.2)
#qapi/migration.json +10
-2+# Features: +# @unstable: Member @x-checkpoint-delay is experimental. +# # Since: 2.4 ## { 'struct': 'MigrationParameters',@@ -1119,7 +1137,8 @@ '*tls-authz': 'str', '*max-bandwidth': 'size', '*downtime-limit': 'uint64', - '*x-checkpoint-delay': 'uint32', + '*x-checkpoint-delay': { 'type': 'uint32', + 'features': [ 'unstable' ] }, '*block-incremental': 'bool', '*multifd-channels': 'uint8', '*xbzrle-cache-size': 'size',@@ -1351,6 +1370,9 @@ # If sent to the Secondary, the Secondary side will run failover work, # then takes over server operation to become the service VM. # +# Features: +# @unstable: This command is experimental. +# # Since: 2.8 # # Example:@@ -1359,7 +1381,8 @@ # <- { "return": {} } # ## -{ 'command': 'x-colo-lost-heartbeat' } +{ 'command': 'x-colo-lost-heartbeat', + 'features': [ 'unstable' ] } ## # @migrate_cancel:qapi/misc.json +5
-1@@ -185,6 +185,9 @@ # available during the preconfig state (i.e. when the --preconfig command # line option was in use). # +# Features: +# @unstable: This command is experimental. +# # Since 3.0 # # Returns: nothing@@ -195,7 +198,8 @@ # <- { "return": {} } # ## -{ 'command': 'x-exit-preconfig', 'allow-preconfig': true } +{ 'command': 'x-exit-preconfig', 'allow-preconfig': true, + 'features': [ 'unstable' ] } ## # @human-monitor-command:qapi/qom.json +0
-0@@ -559,10 +559,8 @@ # for ramblock-id. Disable thisfor 4.0
# machine types or older to allow
# migration with newer QEMU
versions.qapi/qom.json +0
-3-# This option is considered stable -# despite the x- prefix. (default: -# false generally, but true formachine
qapi/qom.json +2
-1-# types <= 4.0) +# (default: false generally, +# but true for machine types <=4.0)
#
# Note: prealloc=true and reserve=false cannot be set at the same time.
With
# reserve=true, the behavior depends on the operating system: for
example,qapi/qom.json +4
-2@@ -785,6 +783,9 @@ ## # @ObjectType: # +# Features: +# @unstable: Member @x-remote-object is experimental. +# # Since: 6.0 ## { 'enum': 'ObjectType',@@ -836,7 +837,7 @@ 'tls-creds-psk', 'tls-creds-x509', 'tls-cipher-suites', - 'x-remote-object' + { 'name': 'x-remote-object', 'features': [ 'unstable' ] } ] } ## --
Quoted 3 lines
2.31.1
Seems OK, but I didn't audit for false positives/negatives. Trusting your judgment here. (It looks like Phil started to audit this in his reply to your previous commit, so I'll trust that.)
Re: [PATCH 2/9] qapi: Mark unstable QMP parts with feature 'unstable'
Quoted 25 lines · John Snow
Quoted 23 lines · Markus Armbruster
Add special feature 'unstable' everywhere the name starts with 'x-', except for InputBarrierProperties member x-origin and MemoryBackendProperties member x-use-canonical-path-for-ramblock-id, because these two are actually stable.
Signed-off-by Markus Armbruster <[email protected]>--- qapi/block-core.json | 123 +++++++++++++++++++++++++++++++------------ qapi/migration.json | 35 +++++++++--- qapi/misc.json | 6 ++- qapi/qom.json | 11 ++-- 4 files changed, 130 insertions(+), 45 deletions(-)qapi/block-core.json +2
-0@@ -1438,6 +1438,9 @@ # # @x-perf: Performance options. (Since 6.0) # +# Features: +# @unstable: Member @x-perf is experimental.
Quoted 8 lines
qapi/block-core.json line 1444
Quoted 2 lines
qapi/block-core.json +1
-0+#It'd be a lot cooler if we could annotate the unstable member directly instead of confusing it with the syntax that might describe the entire struct/union/command/etc, but ... eh, it's just a doc field, so I'm not gonna press on this. I don't have the energy to get into a doc formatting standard discussion right now, so: sure, why not?
By design, we have a single doc comment block for the entire definition.
When Kevin invented feature flags (merge commit 4747524f9f2), he added them just to struct types. He added "feature sections" for documenting features. It mirrors the "argument sections" for documenting members. Makes sense.
Aside: he neglected to update qapi-code-gen.rst section "Definition documentation", and I failed to catch it. I'll make up for it.
Peter and I then added feature flags to the remaining definitions (commit 23394b4c39 and 013b4efc9b). Feature sections make sense there, too.
I then added them to struct members (commit 84ab008687). Instead of doing something fancy for documenting feature flags of members, I simply used the existing feature sections. This conflates member features with struct features.
What could "something fancy" be? All we have for members is "argument sections", which are basically a name plus descriptive text. We'd have to add structure to that, say nest feature sections into argument sections. I have no appetite for that right now.
Quoted 17 lines
Quoted 17 lines
qapi/block-core.json +0
-0# Note: @on-source-error and @on-target-error only affect background # I/O. If an error occurs during a guest write request, thedevice's
# rerror/werror actions will be used.qapi/block-core.json +3
-1@@ -1452,7 +1455,9 @@ '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*auto-finalize': 'bool', '*auto-dismiss': 'bool', - '*filter-node-name': 'str', '*x-perf': 'BackupPerf' } } + '*filter-node-name': 'str', + '*x-perf': { 'type': 'BackupPerf', + 'features': [ 'unstable' ] } } } ## # @DriveBackup:
[...]
Quoted 3 lines
Seems OK, but I didn't audit for false positives/negatives. Trusting your judgment here. (It looks like Phil started to audit this in his reply to your previous commit, so I'll trust that.)
I'm pretty sure the x- names that don't get feature 'unstable' are actually stable; see my reply to Kashyap.
I did check git history for each that does get feature 'unstable'. Double-checking is of course welcome.
Quoted 1 line
Acked-by John Snow <[email protected]>
Thanks!
Re: [PATCH 2/9] qapi: Mark unstable QMP parts with feature 'unstable'
Quoted 47 lines · Markus Armbruster
Quoted 1 line · John Snow
On Mon, Oct 25, 2021 at 1:25 AM Markus Armbruster <[email protected]>
Quoted 24 lines · wrote:
Quoted 24 lines
Add special feature 'unstable' everywhere the name starts with 'x-', except for InputBarrierProperties member x-origin and MemoryBackendProperties member x-use-canonical-path-for-ramblock-id, because these two are actually stable.
Signed-off-by Markus Armbruster <[email protected]>--- qapi/block-core.json | 123 +++++++++++++++++++++++++++++++------------ qapi/migration.json | 35 +++++++++--- qapi/misc.json | 6 ++- qapi/qom.json | 11 ++-- 4 files changed, 130 insertions(+), 45 deletions(-)qapi/block-core.json +2
-0@@ -1438,6 +1438,9 @@ # # @x-perf: Performance options. (Since 6.0) # +# Features: +# @unstable: Member @x-perf is experimental.Quoted 8 lines
qapi/block-core.json line 1444
Quoted 2 lines
qapi/block-core.json +1
-0+#It'd be a lot cooler if we could annotate the unstable member directly instead of confusing it with the syntax that might describe the entire struct/union/command/etc, but ... eh, it's just a doc field, so I'm not gonna press on this. I don't have the energy to get into a doc formatting standard discussion right now, so: sure, why not?
By design, we have a single doc comment block for the entire definition.
When Kevin invented feature flags (merge commit
4747524f9f2), he added them just to struct types. He added "feature sections" for documenting features. It mirrors the "argument sections" for documenting members. Makes sense.Aside: he neglected to update
qapi-code-gen.rstsection "Definition documentation", and I failed to catch it. I'll make up for it.
Quoted 10 lines
Peter and I then added feature flags to the remaining definitions (commit
23394b4c39and013b4efc9b). Feature sections make sense there, too.I then added them to struct members (commit
84ab008687). Instead of doing something fancy for documenting feature flags of members, I simply used the existing feature sections. This conflates member features with struct features.
Yeah, that's the part I don't like. If this isn't the first instance of breaking the seal, though, this is the wrong time for me to comment on it. Don't worry about it for this series.
Quoted 6 lines
What could "something fancy" be? All we have for members is "argument sections", which are basically a name plus descriptive text. We'd have to add structure to that, say nest feature sections into argument sections. I have no appetite for that right now.
(Tangent below, unrelated to acceptance of this series)
Yeah, I don't have an appetite for it at the moment either. I'll have to read Marc-Andre's recent sphinx patches and see if I want to do more work -- I had a bigger prototype a few months back I didn't bring all the way home, but I am still thinking about reworking our QAPIDoc format. It's ... well. I don't really want to, but I am not sure how else to bring some of the features I want home, and I think I need some more time to think carefully through exactly what I want to do and why.
I wouldn't mind chatting about it with you sometime soon -- there's a few things to balance here, such as:
(1) Reworking the doc format would be an obnoxious amount of churn, ...
(2) ...but the Sphinx internals are really not meant to be used the way we're using them right now, ...
(3) ...but I also don't want to write our QAPI docstrings in a way that *targets* Sphinx. Not that I think we'll be dropping it any time soon, but it still feels like the wrong idea to tie them so closely together.
I'm hoping there's an opportunity to make the parsing nicer with minimal changes to the parsing and format, though. It just might require enforcing a *pinch* more structure. I could see how I feel about per-field annotations at that point. I consider them interesting for things like the Python SDK where I may want to enable/disable warnings for using deprecated stuff at the client-level. (e.g., let's say you're using Python SDK 6.2 to talk to a 6.1 client. Nothing stops you from doing this, but some commands will simply be rejected by QEMU as it won't know what you're talking about. Using deprecated fields or commands to talk to an older client will produce no visible warning from QEMU either, as it wasn't deprecated at that point in time. Still, the client may wish to know that they're asking for future trouble -- so it's a thought that client-side warnings have some play here.)
Ehhhhhhhhhhhhhhhh don't worry about it for now, I guess I'll plow forward a bit with the Sphinx stuff I'm thinking of at some point Soon:tm: and worry about where the immovable objects are when I get there. This is foot-based landmine-detection, and it works 100% of the time.
Quoted 24 lines
Quoted 17 lines
Quoted 17 lines
qapi/block-core.json +0
-0# Note: @on-source-error and @on-target-error only affect background # I/O. If an error occurs during a guest write request, thedevice's
# rerror/werror actions will be used.qapi/block-core.json +3
-1@@ -1452,7 +1455,9 @@ '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*auto-finalize': 'bool', '*auto-dismiss': 'bool', - '*filter-node-name': 'str', '*x-perf': 'BackupPerf' } } + '*filter-node-name': 'str', + '*x-perf': { 'type': 'BackupPerf', + 'features': [ 'unstable' ] } } } ## # @DriveBackup:[...]
Quoted 3 lines
Seems OK, but I didn't audit for false positives/negatives. Trusting your judgment here. (It looks like Phil started to audit this in his reply to your previous commit, so I'll trust that.)
Quoted 7 lines
I'm pretty sure the x- names that don't get feature 'unstable' are actually stable; see my reply to Kashyap.
I did check git history for each that does get feature 'unstable'. Double-checking is of course welcome.
Yeh, just explaining why it's not an R-B. I'm trying to be a bit better about reviews by not forcing myself to do "all or nothing". I trust your work, of course -- I just also did not double check it :)
I need to change the way in which I read and discuss code so that I can be more responsive.
Quoted 5 lines
Quoted 1 line
Acked-by John Snow <[email protected]>Thanks!
Re: [PATCH 2/9] qapi: Mark unstable QMP parts with feature 'unstable'
Quoted 59 lines · John Snow
Quoted 47 lines · Markus Armbruster
Quoted 1 line · John Snow
On Mon, Oct 25, 2021 at 1:25 AM Markus Armbruster <[email protected]>
Quoted 24 lines · wrote:
Quoted 24 lines
Add special feature 'unstable' everywhere the name starts with 'x-', except for InputBarrierProperties member x-origin and MemoryBackendProperties member x-use-canonical-path-for-ramblock-id, because these two are actually stable.
Signed-off-by Markus Armbruster <[email protected]>--- qapi/block-core.json | 123 +++++++++++++++++++++++++++++++------------ qapi/migration.json | 35 +++++++++--- qapi/misc.json | 6 ++- qapi/qom.json | 11 ++-- 4 files changed, 130 insertions(+), 45 deletions(-)qapi/block-core.json +2
-0@@ -1438,6 +1438,9 @@ # # @x-perf: Performance options. (Since 6.0) # +# Features: +# @unstable: Member @x-perf is experimental.Quoted 8 lines
qapi/block-core.json line 1444
Quoted 2 lines
qapi/block-core.json +1
-0+#It'd be a lot cooler if we could annotate the unstable member directly instead of confusing it with the syntax that might describe the entire struct/union/command/etc, but ... eh, it's just a doc field, so I'm not gonna press on this. I don't have the energy to get into a doc formatting standard discussion right now, so: sure, why not?
By design, we have a single doc comment block for the entire definition.
When Kevin invented feature flags (merge commit
4747524f9f2), he added them just to struct types. He added "feature sections" for documenting features. It mirrors the "argument sections" for documenting members. Makes sense.Aside: he neglected to update
qapi-code-gen.rstsection "Definition documentation", and I failed to catch it. I'll make up for it.Quoted 10 lines
Peter and I then added feature flags to the remaining definitions (commit
23394b4c39and013b4efc9b). Feature sections make sense there, too.I then added them to struct members (commit
84ab008687). Instead of doing something fancy for documenting feature flags of members, I simply used the existing feature sections. This conflates member features with struct features.
Quoted 3 lines
Yeah, that's the part I don't like. If this isn't the first instance of breaking the seal, though, this is the wrong time for me to comment on it. Don't worry about it for this series.
Okay.
Quoted 16 lines
Quoted 6 lines
What could "something fancy" be? All we have for members is "argument sections", which are basically a name plus descriptive text. We'd have to add structure to that, say nest feature sections into argument sections. I have no appetite for that right now.
(Tangent below, unrelated to acceptance of this series)
Yeah, I don't have an appetite for it at the moment either. I'll have to read Marc-Andre's recent sphinx patches and see if I want to do more work -- I had a bigger prototype a few months back I didn't bring all the way home, but I am still thinking about reworking our QAPIDoc format. It's ... well. I don't really want to, but I am not sure how else to bring some of the features I want home, and I think I need some more time to think carefully through exactly what I want to do and why.
Quoted 4 lines
I wouldn't mind chatting about it with you sometime soon -- there's a few things to balance here, such as:
(1) Reworking the doc format would be an obnoxious amount of churn, ...
Yes. But that need not be the end of the argument, it may be the beginning of one.
Quoted 2 lines
(2) ...but the Sphinx internals are really not meant to be used the way we're using them right now, ...
Happy to trust you on this one.
Quoted 3 lines
(3) ...but I also don't want to write our QAPI docstrings in a way that *targets* Sphinx. Not that I think we'll be dropping it any time soon, but it still feels like the wrong idea to tie them so closely together.
Maybe. Depends on what we get for it.
Quoted 4 lines
I'm hoping there's an opportunity to make the parsing nicer with minimal changes to the parsing and format, though. It just might require enforcing a *pinch* more structure. I could see how I feel about per-field annotations at that point.
The doc comment language is the result of a series of pragmatic decisions that got us from semi-accidental comment conventions to where we are now. Each of the decisions made sense at the time. The result is messy to describe and to parse. It's limiting and hard to grow further.
Quoted 10 lines
I consider them interesting for things like the
Python SDK where I may want to enable/disable warnings for using deprecated stuff at the client-level. (e.g., let's say you're using Python SDK 6.2 to talk to a 6.1 client. Nothing stops you from doing this, but some commands will simply be rejected by QEMU as it won't know what you're talking about. Using deprecated fields or commands to talk to an older client will produce no visible warning from QEMU either, as it wasn't deprecated at that point in time. Still, the client may wish to know that they're asking for future trouble -- so it's a thought that client-side warnings have some play here.)
Quoted 4 lines
Ehhhhhhhhhhhhhhhh don't worry about it for now, I guess I'll plow forward a bit with the Sphinx stuff I'm thinking of at some point Soon:tm: and worry about where the immovable objects are when I get there. This is foot-based landmine-detection, and it works 100% of the time.
Soldier, hand me the binoculars before you enter the minefield. Good luck!
Back to serious: I feel we need to wrap the typing hints work before we start the next big QAPI schema language project.
Quoted 25 lines
Quoted 25 lines
Quoted 15 lines
Quoted 15 lines
qapi/block-core.json +0
-0# Note: @on-source-error and @on-target-error only affect background # I/O. If an error occurs during a guest write request, thedevice's
# rerror/werror actions will be used.qapi/block-core.json +3
-1@@ -1452,7 +1455,9 @@ '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*auto-finalize': 'bool', '*auto-dismiss': 'bool', - '*filter-node-name': 'str', '*x-perf': 'BackupPerf' } } + '*filter-node-name': 'str', + '*x-perf': { 'type': 'BackupPerf', + 'features': [ 'unstable' ] } } } ## # @DriveBackup:[...]
Quoted 3 lines
Seems OK, but I didn't audit for false positives/negatives. Trusting your judgment here. (It looks like Phil started to audit this in his reply to your previous commit, so I'll trust that.)
I'm pretty sure the x- names that don't get feature 'unstable' are actually stable; see my reply to Kashyap.
Quoted 7 lines
Quoted 4 lines
I did check git history for each that does get feature 'unstable'. Double-checking is of course welcome.
Yeh, just explaining why it's not an R-B. I'm trying to be a bit better about reviews by not forcing myself to do "all or nothing". I trust your work, of course -- I just also did not double check it :)
You stating the limits of your review is useful.
Me stating the limits of my own research is also useful :)
Quoted 9 lines
I need to change the way in which I read and discuss code so that I can be more responsive.
Quoted 5 lines
Quoted 1 line
Acked-by John Snow <[email protected]>Thanks!
Re: [PATCH 2/9] qapi: Mark unstable QMP parts with feature 'unstable'
In reply to Markus ArmbrusterQuoted 23 lines · Markus Armbruster
Add special feature 'unstable' everywhere the name starts with 'x-', except for InputBarrierProperties member x-origin and MemoryBackendProperties member x-use-canonical-path-for-ramblock-id, because these two are actually stable.
Signed-off-by Markus Armbruster <[email protected]>---
qapi/block-core.json +5
-5@@ -2495,27 +2508,57 @@ # # Properties for throttle-group objects. # -# The options starting with x- are aliases for the same key without x- in -# the @limits object. As indicated by the x- prefix, this is not a stable -# interface and may be removed or changed incompatibly in the future. Use -# @limits for a supported stable interface. -# # @limits: limits to apply for this throttle group # +# Features: +# @unstable: All members starting with x- are aliases for the same key +# without x- in the @limits object. This is not a stable +# interface and may be removed or changed incompatibly in +# the future. Use @limits for a supported stable
qapi/block-core.json line 2526
Quoted 10 lines
qapi/block-core.json +4
-1+# interface. +# # Since: 2.11 ## { 'struct': 'ThrottleGroupProperties', 'data': { '*limits': 'ThrottleLimits', - '*x-iops-total' : 'int', '*x-iops-total-max' : 'int', + '*x-iops-total': { 'type': 'int', + 'features': [ 'unstable' ] },
This struct has been around since 381bd74 (v6.0); but was not listed as deprecated at the time. Do we still need it in 6.2, or have we gone enough release cycles with the saner naming without x- that we could drop this? But that is a question independent of this patch.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [PATCH 2/9] qapi: Mark unstable QMP parts with feature 'unstable'
Am 29.10.2021 um 15:07 hat Eric Blake geschrieben:
Quoted 32 lines · Markus Armbruster
Quoted 30 lines
Add special feature 'unstable' everywhere the name starts with 'x-', except for InputBarrierProperties member x-origin and MemoryBackendProperties member x-use-canonical-path-for-ramblock-id, because these two are actually stable.
Signed-off-by Markus Armbruster <[email protected]>---
qapi/block-core.json +7
-6@@ -2495,27 +2508,57 @@ # # Properties for throttle-group objects. # -# The options starting with x- are aliases for the same key without x- in -# the @limits object. As indicated by the x- prefix, this is not a stable -# interface and may be removed or changed incompatibly in the future. Use -# @limits for a supported stable interface. -# # @limits: limits to apply for this throttle group # +# Features: +# @unstable: All members starting with x- are aliases for the same key +# without x- in the @limits object. This is not a stable +# interface and may be removed or changed incompatibly in +# the future. Use @limits for a supported stable +# interface. +# # Since: 2.11 ## { 'struct': 'ThrottleGroupProperties', 'data': { '*limits': 'ThrottleLimits', - '*x-iops-total' : 'int', '*x-iops-total-max' : 'int',
Quoted 7 lines
Review line 2525
Quoted 2 lines
(quoted diff) +2
-0+ '*x-iops-total': { 'type': 'int', + 'features': [ 'unstable' ] },This struct has been around since 381bd74 (v6.0); but was not listed as deprecated at the time. Do we still need it in 6.2, or have we gone enough release cycles with the saner naming without x- that we could drop this? But that is a question independent of this patch.
There is no reason any more to use the x- options, and I think libvirt never used them anyway.
I actually have a commit in my QAPI object branch that removes these properties, but I think it still broke some tests.
Anyway, something for a separate patch.
Kevin
PATCH 3/9 qapi: Eliminate QCO_NO_OPTIONS for a slight simplification
In reply to Markus Armbruster--- include/qapi/qmp/dispatch.h | 1 - monitor/misc.c | 3 +-- scripts/qapi/commands.py | 5 +---- 3 files changed, 2 insertions(+), 7 deletions(-)
include/qapi/qmp/dispatch.h +0 -1
@@ -21,7 +21,6 @@ typedef void (QmpCommandFunc)(QDict *, QObject **, Error **); typedef enum QmpCommandOptions { - QCO_NO_OPTIONS = 0x0, QCO_NO_SUCCESS_RESP = (1U << 0), QCO_ALLOW_OOB = (1U << 1), QCO_ALLOW_PRECONFIG = (1U << 2),
monitor/misc.c +1 -2
@@ -230,8 +230,7 @@ static void monitor_init_qmp_commands(void)qmp_init_marshal (&qmp_commands); -qmp_register_command (&qmp_commands,"device_add" , qmp_device_add, -QCO_NO_OPTIONS ); +qmp_register_command (&qmp_commands,"device_add" , qmp_device_add,0 );QTAILQ_INIT (&qmp_cap_negotiation_commands); qmp_register_command(&qmp_cap_negotiation_commands, "qmp_capabilities",
scripts/qapi/commands.py +1 -4
@@ -229,15 +229,12 @@ def gen_register_command(name: str, if coroutine: options += ['QCO_COROUTINE'] - if not options: - options = ['QCO_NO_OPTIONS'] - ret = mcgen(''' qmp_register_command(cmds, "%(name)s", qmp_marshal_%(c_name)s, %(opts)s); ''', name=name, c_name=c_name(name), - opts=" | ".join(options)) + opts=' | '.join(options) or 0) return ret
Signature · 1 line
2.31.1
Re: [PATCH 3/9] qapi: Eliminate QCO_NO_OPTIONS for a slight simplification
Quoted 1 line · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>
Re: [PATCH 3/9] qapi: Eliminate QCO_NO_OPTIONS for a slight simplification
In reply to Markus ArmbrusterQuoted 47 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/qmp/dispatch.h | 1 - monitor/misc.c | 3 +-- scripts/qapi/commands.py | 5 +---- 3 files changed, 2 insertions(+), 7 deletions(-)include/qapi/qmp/dispatch.h +0
-1@@ -21,7 +21,6 @@ typedef void (QmpCommandFunc)(QDict *, QObject **, Error **); typedef enum QmpCommandOptions { - QCO_NO_OPTIONS = 0x0, QCO_NO_SUCCESS_RESP = (1U << 0), QCO_ALLOW_OOB = (1U << 1),QCO_ALLOW_PRECONFIG = (1U << 2),monitor/misc.c +1
-2@@ -230,8 +230,7 @@ static void monitor_init_qmp_commands(void)qmp_init_marshal (&qmp_commands); -qmp_register_command (&qmp_commands,"device_add" , qmp_device_add, -QCO_NO_OPTIONS ); +qmp_register_command (&qmp_commands,"device_add" , qmp_device_add,0 );QTAILQ_INIT (&qmp_cap_negotiation_commands); qmp_register_command(&qmp_cap_negotiation_commands,"
qmp_capabilities",scripts/qapi/commands.py +0
-3@@ -229,15 +229,12 @@ def gen_register_command(name: str, if coroutine: options += ['QCO_COROUTINE'] - if not options: - options = ['QCO_NO_OPTIONS'] -
scripts/qapi/commands.py def gen_register_command(name: str, · line 240
Quoted 10 lines
scripts/qapi/commands.py +1
-1ret = mcgen(''' qmp_register_command(cmds, "%(name)s", qmp_marshal_%(c_name)s, %(opts)s); ''', name=name, c_name=c_name(name), - opts=" | ".join(options)) + opts=' | '.join(options) or 0) return ret
I'm not a big fan of naked constants on the C side, but the generator simplification is nice. I suppose it's worth the trade-off if you like it better this way.
"eh".
Re: [PATCH 3/9] qapi: Eliminate QCO_NO_OPTIONS for a slight simplification
Quoted 63 lines · John Snow
Quoted 47 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/qmp/dispatch.h | 1 - monitor/misc.c | 3 +-- scripts/qapi/commands.py | 5 +---- 3 files changed, 2 insertions(+), 7 deletions(-)include/qapi/qmp/dispatch.h +0
-1@@ -21,7 +21,6 @@ typedef void (QmpCommandFunc)(QDict *, QObject **, Error **); typedef enum QmpCommandOptions { - QCO_NO_OPTIONS = 0x0, QCO_NO_SUCCESS_RESP = (1U << 0), QCO_ALLOW_OOB = (1U << 1),QCO_ALLOW_PRECONFIG = (1U << 2),monitor/misc.c +1
-2@@ -230,8 +230,7 @@ static void monitor_init_qmp_commands(void)qmp_init_marshal (&qmp_commands); -qmp_register_command (&qmp_commands,"device_add" , qmp_device_add, -QCO_NO_OPTIONS ); +qmp_register_command (&qmp_commands,"device_add" , qmp_device_add,0 );QTAILQ_INIT (&qmp_cap_negotiation_commands); qmp_register_command(&qmp_cap_negotiation_commands,"
qmp_capabilities",scripts/qapi/commands.py +0
-3@@ -229,15 +229,12 @@ def gen_register_command(name: str, if coroutine: options += ['QCO_COROUTINE'] - if not options: - options = ['QCO_NO_OPTIONS'] -scripts/qapi/commands.py def gen_register_command(name: str, · line 240
Quoted 10 lines
scripts/qapi/commands.py +1
-1ret = mcgen(''' qmp_register_command(cmds, "%(name)s", qmp_marshal_%(c_name)s, %(opts)s); ''', name=name, c_name=c_name(name), - opts=" | ".join(options)) + opts=' | '.join(options) or 0) return retI'm not a big fan of naked constants on the C side, but the generator simplification is nice. I suppose it's worth the trade-off if you like it better this way.
Quoted 1 line
"eh".
I think 0 is an okay way to say "no flags, nothing to see here, move on".
Quoted 1 line
Reviewed-by John Snow <[email protected]>
Thanks!
PATCH 4/9 qapi: Tools for sets of special feature flags in generated code
In reply to Markus ArmbrusterNew enum QapiSpecialFeature enumerates the special feature flags.
New helper gen_special_features() returns code to represent a collection of special feature flags as a bitset.
The next few commits will put them to use.
--- include/qapi/util.h | 4 ++++ scripts/qapi/gen.py | 13 +++++++++++++ scripts/qapi/schema.py | 3 +++ 3 files changed, 20 insertions(+)
include/qapi/util.h +4 -0
@@ -11,6 +11,10 @@#ifndef QAPI_UTIL_H #define QAPI_UTIL_H +typedef enum { +QAPI_DEPRECATED , +}QapiSpecialFeature ; +/* QEnumLookup flags */ #define QAPI_ENUM_DEPRECATED 1
scripts/qapi/gen.py +13 -0
@@ -29,6 +29,7 @@ mcgen, ) from .schema import ( + QAPISchemaFeature, QAPISchemaIfCond, QAPISchemaModule, QAPISchemaObjectType,
@@ -37,6 +38,18 @@ from .source import QAPISourceInfo +def gen_special_features(features: QAPISchemaFeature): + ret = '' + sep = '' + + for feat in features: + if feat.is_special(): + ret += ('%s1u << QAPI_%s' % (sep, feat.name.upper())) + sep = ' | ' + + return ret or '0' + + class QAPIGen: def __init__(self, fname: str): self.fname = fname
scripts/qapi/schema.py +3 -0
@@ -725,6 +725,9 @@ def connect_doc(self, doc): class QAPISchemaFeature(QAPISchemaMember): role = 'feature' + def is_special(self): + return self.name in ('deprecated') + class QAPISchemaObjectTypeMember(QAPISchemaMember): def __init__(self, name, info, typ, optional, ifcond=None, features=None):
Signature · 1 line
2.31.1
Re: [PATCH 4/9] qapi: Tools for sets of special feature flags in generated code
Quoted 43 lines · Markus Armbruster
New enum QapiSpecialFeature enumerates the special feature flags.
New helper
gen_special_features()returns code to represent a collection of special feature flags as a bitset.The next few commits will put them to use.
Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/util.h | 4 ++++ scripts/qapi/gen.py | 13 +++++++++++++ scripts/qapi/schema.py | 3 +++ 3 files changed, 20 insertions(+)include/qapi/util.h +4
-0@@ -11,6 +11,10 @@#ifndef QAPI_UTIL_H #define QAPI_UTIL_H +typedef enum { +QAPI_DEPRECATED , +}QapiSpecialFeature ; +/* QEnumLookup flags */ #define QAPI_ENUM_DEPRECATED 1scripts/qapi/gen.py +1
-0@@ -29,6 +29,7 @@ mcgen, ) from .schema import ( + QAPISchemaFeature, QAPISchemaIfCond, QAPISchemaModule, QAPISchemaObjectType,@@ -37,6 +38,18 @@ from .source import QAPISourceInfo
scripts/qapi/gen.py line 48
Quoted 10 lines
scripts/qapi/gen.py +7
-0+def gen_special_features(features: QAPISchemaFeature): + ret = '' + sep = '' + + for feat in features: + if feat.is_special(): + ret += ('%s1u << QAPI_%s' % (sep, feat.name.upper()))
Building the constant name here "feels" fragile, but I'll trust that the test suite and/or the compiler will catch us if we accidentally goof up this mapping. In the interest of simplicity, then, "sure, why not."
scripts/qapi/gen.py
Quoted 3 lines
scripts/qapi/gen.py +2
-0+ sep = ' | ' +
+ return ret or '0'
scripts/qapi/gen.py line 53
Quoted 2 lines
scripts/qapi/gen.py +1
-0+
Subjectively more pythonic:
special_features = [f"1u << QAPI_{feat.name.upper()}" for feat in features if feat.is_special()]
ret = ' | '.join(special_features)
return ret or '0'
A bit more dense, but more functional. Up to you, but I find join() easier to read and reason about for the presence of separators.
Quoted 9 lines
scripts/qapi/gen.py +1
-0+ class QAPIGen: def __init__(self, fname: str): self.fname = fnamescripts/qapi/schema.py +0
-0
scripts/qapi/schema.py def connect_doc(self, doc): · line 731
Quoted 7 lines
scripts/qapi/schema.py +3
-0@@ -725,6 +725,9 @@ def connect_doc(self, doc): class QAPISchemaFeature(QAPISchemaMember): role = 'feature' + def is_special(self): + return self.name in ('deprecated') +
alrighty.
(Briefly wondered: is it worth naming special features as a property of the class, but with only two names, it's probably fine enough to leave it embedded in the method logic. Only a style thing and doesn't have any actual impact that I can imagine, so ... nevermind.)
Quoted 8 lines
scripts/qapi/schema.py +0
-0class QAPISchemaObjectTypeMember(QAPISchemaMember): def __init__(self, name, info, typ, optional, ifcond=None,features=None):
--
2.31.1
Well, either way:
Re: [PATCH 4/9] qapi: Tools for sets of special feature flags in generated code
Quoted 47 lines · John Snow
Quoted 45 lines · Markus Armbruster
New enum QapiSpecialFeature enumerates the special feature flags.
New helper
gen_special_features()returns code to represent a collection of special feature flags as a bitset.The next few commits will put them to use.
Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/util.h | 4 ++++ scripts/qapi/gen.py | 13 +++++++++++++ scripts/qapi/schema.py | 3 +++ 3 files changed, 20 insertions(+)include/qapi/util.h +4
-0@@ -11,6 +11,10 @@#ifndef QAPI_UTIL_H #define QAPI_UTIL_H +typedef enum { +QAPI_DEPRECATED , +}QapiSpecialFeature ; +/* QEnumLookup flags */ #define QAPI_ENUM_DEPRECATED 1scripts/qapi/gen.py +1
-0@@ -29,6 +29,7 @@ mcgen, ) from .schema import ( + QAPISchemaFeature, QAPISchemaIfCond, QAPISchemaModule, QAPISchemaObjectType,@@ -37,6 +38,18 @@ from .source import QAPISourceInfo
Quoted 12 lines
scripts/qapi/gen.py
Quoted 8 lines
scripts/qapi/gen.py +7
-0+def gen_special_features(features: QAPISchemaFeature): + ret = '' + sep = '' + + for feat in features: + if feat.is_special(): + ret += ('%s1u << QAPI_%s' % (sep, feat.name.upper()))Building the constant name here "feels" fragile, but I'll trust that the test suite and/or the compiler will catch us if we accidentally goof up this mapping. In the interest of simplicity, then, "sure, why not."
It relies on .is_special() remaining consistent with enum QapiSpecialFeature. The C compiler should catch any screwups.
Quoted 10 lines
scripts/qapi/gen.py
Quoted 4 lines
scripts/qapi/gen.py +2
-0+ sep = ' | ' ++ return ret or '0'
scripts/qapi/gen.py line 53
Quoted 2 lines
scripts/qapi/gen.py +1
-0+Subjectively more pythonic:
Quoted 7 lines
special_features= [f"1u << QAPI_{feat.name.upper()}" for feat in features iffeat.is_special()]
ret = ' | '.join(special_features)
return ret or '0'A bit more dense, but more functional. Up to you, but I find
join()easier to read and reason about for the presence of separators.
Sold!
Quoted 19 lines
Quoted 9 lines
scripts/qapi/gen.py +1
-0+ class QAPIGen: def __init__(self, fname: str): self.fname = fnamescripts/qapi/schema.py +0
-0scripts/qapi/schema.py def connect_doc(self, doc): · line 731
Quoted 7 lines
scripts/qapi/schema.py +3
-0@@ -725,6 +725,9 @@ def connect_doc(self, doc): class QAPISchemaFeature(QAPISchemaMember): role = 'feature' + def is_special(self): + return self.name in ('deprecated') +alrighty.
Quoted 4 lines
(Briefly wondered: is it worth naming special features as a property of the class, but with only two names, it's probably fine enough to leave it embedded in the method logic. Only a style thing and doesn't have any actual impact that I can imagine, so ... nevermind.)
Let's keep it simple.
Quoted 10 lines
Quoted 7 lines
scripts/qapi/schema.py +0
-0class QAPISchemaObjectTypeMember(QAPISchemaMember): def __init__(self, name, info, typ, optional, ifcond=None,features=None):
--
2.31.1Well, either way:
Reviewed-by John Snow <[email protected]>
Thanks!
PATCH 5/9 qapi: Generalize struct member policy checking
In reply to Markus ArmbrusterThe generated visitor functions call visit_deprecated_accept() and visit_deprecated() when visiting a struct member with special feature flag 'deprecated'. This makes the feature flag visible to the actual visitors. I want to make feature flag 'unstable' visible there as well, so I can add policy for it.
To let me make it visible, replace these functions by visit_policy_reject() and visit_policy_skip(), which take the member's special features as an argument. Note that the new functions have the opposite sense, i.e. the return value flips.
--- include/qapi/visitor-impl.h | 6 ++++-- include/qapi/visitor.h | 17 +++++++++++++---- qapi/qapi-forward-visitor.c | 16 +++++++++------- qapi/qapi-visit-core.c | 22 ++++++++++++---------- qapi/qobject-input-visitor.c | 15 ++++++++++----- qapi/qobject-output-visitor.c | 9 ++++++--- qapi/trace-events | 4 ++-- scripts/qapi/visit.py | 14 +++++++------- 8 files changed, 63 insertions(+), 40 deletions(-)
include/qapi/visitor-impl.h +4 -2
@@ -114,10 +114,12 @@ struct Visitorvoid (*optional)(Visitor *v,const char *name,bool *present);/* Optional */ -bool (*deprecated_accept)(Visitor *v,const char *name,Error **errp); +bool (*policy_reject)(Visitor *v,const char *name, +unsigned special_features,Error **errp);/* Optional */ -bool (*deprecated)(Visitor *v,const char *name); +bool (*policy_skip)(Visitor *v,const char *name, +unsigned special_features);/* Must be set */ VisitorType type;
include/qapi/visitor.h +13 -4
@@ -461,22 +461,31 @@ void visit_end_alternate(Visitor *v, void **obj);bool visit_optional (Visitor *v,const char *name,bool *present);/* -* Should we reject deprecated member @name? +* Should we reject member @name due to policy? +* +* @special_features is the member's special features encoded as a +* bitset of QapiSpecialFeature. * * @name must not be NULL. This function is only useful between * visit_start_struct() and visit_end_struct(), since only objects * have deprecated members. */ -bool visit_deprecated_accept (Visitor *v,const char *name,Error **errp); +bool visit_policy_reject (Visitor *v,const char *name, +unsigned special_features,Error **errp);/* -* Should we visit deprecated member @name? +* +* Should we skip member @name due to policy? +* +* @special_features is the member's special features encoded as a +* bitset of QapiSpecialFeature. * * @name must not be NULL. This function is only useful between * visit_start_struct() and visit_end_struct(), since only objects * have deprecated members. */ -bool visit_deprecated (Visitor *v,const char *name); +bool visit_policy_skip (Visitor *v,const char *name, +unsigned special_features);/* * Set policy for handling deprecated management interfaces.
qapi/qapi-forward-visitor.c +9 -7
@@ -246,25 +246,27 @@ static void forward_field_optional(Visitor *v, const char *name, bool *present)visit_optional (ffv->target, name, present); } -static bool forward_field_deprecated_accept (Visitor *v,const char *name, -Error **errp) +static bool forward_field_policy_reject (Visitor *v,const char *name, +unsigned special_features, +Error **errp) {ForwardFieldVisitor *ffv =to_ffv (v);if (!forward_field_translate_name (ffv, &name, errp)) {return false; } -return visit_deprecated_accept (ffv->target, name, errp); +return visit_policy_reject (ffv->target, name, special_features, errp); } -static bool forward_field_deprecated (Visitor *v,const char *name) +static bool forward_field_policy_skip (Visitor *v,const char *name, +unsigned special_features) {ForwardFieldVisitor *ffv =to_ffv (v);if (!forward_field_translate_name (ffv, &name,NULL )) {return false; } -return visit_deprecated (ffv->target, name); +return visit_policy_skip (ffv->target, name, special_features); }static void forward_field_complete (Visitor *v,void *opaque)
@@ -313,8 +315,8 @@ Visitor *visitor_forward_field(Visitor *target, const char *from, const char *to v->visitor.type_any = forward_field_type_any; v->visitor.type_null = forward_field_type_null; v->visitor.optional = forward_field_optional; - v->visitor.deprecated_accept = forward_field_deprecated_accept; - v->visitor.deprecated = forward_field_deprecated; + v->visitor.policy_reject = forward_field_policy_reject; + v->visitor.policy_skip = forward_field_policy_skip; v->visitor.complete = forward_field_complete; v->visitor.free = forward_field_free;
qapi/qapi-visit-core.c +12 -10
@@ -139,22 +139,24 @@ bool visit_optional(Visitor *v, const char *name, bool *present)return *present; } -bool visit_deprecated_accept (Visitor *v,const char *name,Error **errp) +bool visit_policy_reject (Visitor *v,const char *name, +unsigned special_features,Error **errp) { -trace_visit_deprecated_accept (v, name); -if (v->deprecated_accept) { -return v->deprecated_accept (v, name, errp); +trace_visit_policy_reject (v, name); +if (v->policy_reject) { +return v->policy_reject (v, name, special_features, errp); } -return true; +return false; } -bool visit_deprecated (Visitor *v,const char *name) +bool visit_policy_skip (Visitor *v,const char *name, +unsigned special_features) { -trace_visit_deprecated (v, name); -if (v->deprecated) { -return v->deprecated (v, name); +trace_visit_policy_skip (v, name); +if (v->policy_skip) { +return v->policy_skip (v, name, special_features); } -return true; +return false; }void visit_set_policy (Visitor *v,CompatPolicy *policy)
qapi/qobject-input-visitor.c +10 -5
@@ -662,16 +662,21 @@ static void qobject_input_optional(Visitor *v, const char *name, bool *present) *present = true; } -static bool qobject_input_deprecated_accept (Visitor *v,const char *name, -Error **errp) +static bool qobject_input_policy_reject (Visitor *v,const char *name, +unsigned special_features, +Error **errp) { +if (!(special_features &&1u <<QAPI_DEPRECATED )) { +return false; + } +switch (v->compat_policy.deprecated_input) {case COMPAT_POLICY_INPUT_ACCEPT : -return true; +return false;case COMPAT_POLICY_INPUT_REJECT :error_setg (errp,"Deprecated parameter '%s' disabled by policy" , name); -return false; +return true;case COMPAT_POLICY_INPUT_CRASH :default :abort ();
@@ -712,7 +717,7 @@ static QObjectInputVisitor *qobject_input_visitor_base_new(QObject *obj) v->visitor.end_list = qobject_input_end_list; v->visitor.start_alternate = qobject_input_start_alternate; v->visitor.optional = qobject_input_optional; - v->visitor.deprecated_accept = qobject_input_deprecated_accept; + v->visitor.policy_reject = qobject_input_policy_reject; v->visitor.free = qobject_input_free; v->root =qobject_ref (obj);
qapi/qobject-output-visitor.c +6 -3
@@ -13,6 +13,7 @@*/ #include "qemu/osdep.h" +#include "qapi/compat-policy.h" #include "qapi/qobject-output-visitor.h" #include "qapi/visitor-impl.h" #include "qemu/queue.h"
@@ -208,9 +209,11 @@ static bool qobject_output_type_null(Visitor *v, const char *name,return true; } -static bool qobject_output_deprecated (Visitor *v,const char *name) +static bool qobject_output_policy_skip (Visitor *v,const char *name, +unsigned special_features) { -return v->compat_policy.deprecated_output !=COMPAT_POLICY_OUTPUT_HIDE ; +return !(special_features &&1u <<QAPI_DEPRECATED ) + || v->compat_policy.deprecated_output ==COMPAT_POLICY_OUTPUT_HIDE ; }/* Finish building, and return the root object.
@@ -262,7 +265,7 @@ Visitor *qobject_output_visitor_new(QObject **result) v->visitor.type_number = qobject_output_type_number; v->visitor.type_any = qobject_output_type_any; v->visitor.type_null = qobject_output_type_null; - v->visitor.deprecated = qobject_output_deprecated; + v->visitor.policy_skip = qobject_output_policy_skip; v->visitor.complete = qobject_output_complete; v->visitor.free = qobject_output_free;
qapi/trace-events +2 -2
@@ -17,8 +17,8 @@ visit_start_alternate(void *v, const char *name, void *obj, size_t size) "v=%p n visit_end_alternate(void *v, void *obj) "v=%p obj=%p" visit_optional(void *v, const char *name, bool *present) "v=%p name=%s present=%p" -visit_deprecated_accept(void *v, const char *name) "v=%p name=%s" -visit_deprecated(void *v, const char *name) "v=%p name=%s" +visit_policy_reject(void *v, const char *name) "v=%p name=%s" +visit_policy_skip(void *v, const char *name) "v=%p name=%s" visit_type_enum(void *v, const char *name, int *obj) "v=%p name=%s obj=%p" visit_type_int(void *v, const char *name, int64_t *obj) "v=%p name=%s obj=%p"
scripts/qapi/visit.py +7 -7
@@ -21,7 +21,7 @@ indent, mcgen, ) -from .gen import QAPISchemaModularCVisitor, ifcontext +from .gen import QAPISchemaModularCVisitor, gen_special_features, ifcontext from .schema import ( QAPISchema, QAPISchemaEnumMember,
@@ -76,7 +76,6 @@ def gen_visit_object_members(name: str, c_type=base.c_name()) for memb in members: - deprecated = 'deprecated' in [f.name for f in memb.features] ret += memb.ifcond.gen_if() if memb.optional: ret += mcgen('''
@@ -84,14 +83,15 @@ def gen_visit_object_members(name: str, ''', name=memb.name, c_name=c_name(memb.name)) indent.increase() - if deprecated: + special_features = gen_special_features(memb.features) + if special_features != '0': ret += mcgen(''' - if (!visit_deprecated_accept(v, "%(name)s", errp)) { + if (visit_policy_reject(v, "%(name)s", %(special_features)s, errp)) { return false; } - if (visit_deprecated(v, "%(name)s")) { + if (!visit_policy_skip(v, "%(name)s", %(special_features)s)) { ''', - name=memb.name) + name=memb.name, special_features=special_features) indent.increase() ret += mcgen(''' if (!visit_type_%(c_type)s(v, "%(name)s", &obj->%(c_name)s, errp)) {
@@ -100,7 +100,7 @@ def gen_visit_object_members(name: str, ''', c_type=memb.type.c_name(), name=memb.name, c_name=c_name(memb.name)) - if deprecated: + if special_features != '0': indent.decrease() ret += mcgen(''' }
Signature · 1 line
2.31.1
Re: [PATCH 5/9] qapi: Generalize struct member policy checking
Quoted 292 lines · Markus Armbruster
The generated visitor functions call
visit_deprecated_accept()andvisit_deprecated()when visiting a struct member with special feature flag 'deprecated'. This makes the feature flag visible to the actual visitors. I want to make feature flag 'unstable' visible there as well, so I can add policy for it.To let me make it visible, replace these functions by
visit_policy_reject()andvisit_policy_skip(), which take the member's special features as an argument. Note that the new functions have the opposite sense, i.e. the return value flips.Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/visitor-impl.h | 6 ++++-- include/qapi/visitor.h | 17 +++++++++++++---- qapi/qapi-forward-visitor.c | 16 +++++++++------- qapi/qapi-visit-core.c | 22 ++++++++++++---------- qapi/qobject-input-visitor.c | 15 ++++++++++----- qapi/qobject-output-visitor.c | 9 ++++++--- qapi/trace-events | 4 ++-- scripts/qapi/visit.py | 14 +++++++------- 8 files changed, 63 insertions(+), 40 deletions(-)include/qapi/visitor-impl.h +4
-2@@ -114,10 +114,12 @@ struct Visitorvoid (*optional)(Visitor *v,const char *name,bool *present);/* Optional */ -bool (*deprecated_accept)(Visitor *v,const char *name,Error **errp); +bool (*policy_reject)(Visitor *v,const char *name, +unsigned special_features,Error **errp);/* Optional */ -bool (*deprecated)(Visitor *v,const char *name); +bool (*policy_skip)(Visitor *v,const char *name, +unsigned special_features);/* Must be set */ VisitorType type;include/qapi/visitor.h +13
-4@@ -461,22 +461,31 @@ void visit_end_alternate(Visitor *v, void **obj);bool visit_optional (Visitor *v,const char *name,bool *present);/* -* Should we reject deprecated member @name? +* Should we reject member @name due to policy? +* +* @special_features is the member's special features encoded as a +* bitset of QapiSpecialFeature. * * @name must not be NULL. This function is only useful between * visit_start_struct() and visit_end_struct(), since only objects * have deprecated members. */ -bool visit_deprecated_accept (Visitor *v,const char *name,Error **errp); +bool visit_policy_reject (Visitor *v,const char *name, +unsigned special_features,Error **errp);/* -* Should we visit deprecated member @name? +* +* Should we skip member @name due to policy? +* +* @special_features is the member's special features encoded as a +* bitset of QapiSpecialFeature. * * @name must not be NULL. This function is only useful between * visit_start_struct() and visit_end_struct(), since only objects * have deprecated members. */ -bool visit_deprecated (Visitor *v,const char *name); +bool visit_policy_skip (Visitor *v,const char *name, +unsigned special_features);/* * Set policy for handling deprecated management interfaces. qapi/qapi-forward-visitor.c +7
-5@@ -246,25 +246,27 @@ static void forward_field_optional(Visitor *v, const char *name, bool *present) visit_optional(ffv->target, name, present); } -static bool forward_field_deprecated_accept (Visitor *v,const char *name, -Error **errp) +static bool forward_field_policy_reject (Visitor *v,const char *name, +unsigned special_features, +Error **errp) {ForwardFieldVisitor *ffv =to_ffv (v);if (!forward_field_translate_name (ffv, &name, errp)) {return false; } -return visit_deprecated_accept (ffv->target, name, errp); +return visit_policy_reject (ffv->target, name, special_features, errp); } -static bool forward_field_deprecated (Visitor *v,const char *name) +static bool forward_field_policy_skip (Visitor *v,const char *name, +unsigned special_features) {ForwardFieldVisitor *ffv =to_ffv (v);if (!forward_field_translate_name (ffv, &name,NULL )) {return false; } -return visit_deprecated (ffv->target, name); +return visit_policy_skip (ffv->target, name, special_features); }static void
forward_field_complete(Visitor *v, void *opaque)qapi/qapi-forward-visitor.c +0
-0@@ -313,8 +315,8 @@ Visitor *visitor_forward_field(Visitor *target, constchar *from, const char *to
v->visitor.type_any = forward_field_type_any; v->visitor.type_null = forward_field_type_null; v->visitor.optional = forward_field_optional;qapi/qapi-forward-visitor.c +2
-2- v->visitor.deprecated_accept = forward_field_deprecated_accept; - v->visitor.deprecated = forward_field_deprecated; + v->visitor.policy_reject = forward_field_policy_reject; + v->visitor.policy_skip = forward_field_policy_skip; v->visitor.complete = forward_field_complete; v->visitor.free = forward_field_free;qapi/qapi-visit-core.c +12
-10@@ -139,22 +139,24 @@ bool visit_optional(Visitor *v, const char *name, bool *present)return *present; } -bool visit_deprecated_accept (Visitor *v,const char *name,Error **errp) +bool visit_policy_reject (Visitor *v,const char *name, +unsigned special_features,Error **errp) { -trace_visit_deprecated_accept (v, name); -if (v->deprecated_accept) { -return v->deprecated_accept (v, name, errp); +trace_visit_policy_reject (v, name); +if (v->policy_reject) { +return v->policy_reject (v, name, special_features, errp); } -return true; +return false; } -bool visit_deprecated (Visitor *v,const char *name) +bool visit_policy_skip (Visitor *v,const char *name, +unsigned special_features) { -trace_visit_deprecated (v, name); -if (v->deprecated) { -return v->deprecated (v, name); +trace_visit_policy_skip (v, name); +if (v->policy_skip) { +return v->policy_skip (v, name, special_features); } -return true; +return false; }void
visit_set_policy(Visitor *v, CompatPolicy *policy)qapi/qobject-input-visitor.c +9
-4@@ -662,16 +662,21 @@ static void qobject_input_optional(Visitor *v, const char *name, bool *present) *present = true; } -static bool qobject_input_deprecated_accept (Visitor *v,const char *name, -Error **errp) +static bool qobject_input_policy_reject (Visitor *v,const char *name, +unsigned special_features, +Error **errp) { +if (!(special_features &&1u <<QAPI_DEPRECATED )) { +return false; + } +switch (v->compat_policy.deprecated_input) {case COMPAT_POLICY_INPUT_ACCEPT : -return true; +return false;case COMPAT_POLICY_INPUT_REJECT :error_setg (errp,"Deprecated parameter '%s' disabled by policy" , name); -return false; +return true;case COMPAT_POLICY_INPUT_CRASH :default :abort();qapi/qobject-input-visitor.c +1
-1@@ -712,7 +717,7 @@ static QObjectInputVisitor *qobject_input_visitor_base_new (QObject *obj) v->visitor.end_list = qobject_input_end_list; v->visitor.start_alternate = qobject_input_start_alternate; v->visitor.optional = qobject_input_optional; - v->visitor.deprecated_accept = qobject_input_deprecated_accept; + v->visitor.policy_reject = qobject_input_policy_reject; v->visitor.free = qobject_input_free;v->root = qobject_ref(obj);qapi/qobject-output-visitor.c +5
-2@@ -13,6 +13,7 @@*/ #include "qemu/osdep.h" +#include "qapi/compat-policy.h" #include "qapi/qobject-output-visitor.h" #include "qapi/visitor-impl.h" #include "qemu/queue.h" @@ -208,9 +209,11 @@ static bool qobject_output_type_null(Visitor *v,const char *name, return true; } -static bool qobject_output_deprecated (Visitor *v,const char *name) +static bool qobject_output_policy_skip (Visitor *v,const char *name, +unsigned special_features) { -return v->compat_policy.deprecated_output !=COMPAT_POLICY_OUTPUT_HIDE ; +return !(special_features &&1u <<QAPI_DEPRECATED ) + || v->compat_policy.deprecated_output ==COMPAT_POLICY_OUTPUT_HIDE ;}
/* Finish building, and return the root object.
qapi/qobject-output-visitor.c +1
-1@@ -262,7 +265,7 @@ Visitor *qobject_output_visitor_new(QObject **result) v->visitor.type_number = qobject_output_type_number; v->visitor.type_any = qobject_output_type_any; v->visitor.type_null = qobject_output_type_null; - v->visitor.deprecated = qobject_output_deprecated; + v->visitor.policy_skip = qobject_output_policy_skip; v->visitor.complete = qobject_output_complete; v->visitor.free = qobject_output_free;qapi/trace-events +0
-0@@ -17,8 +17,8 @@ visit_start_alternate(void *v, const char *name, void *obj, size_t size) "v=%p n visit_end_alternate(void *v, void *obj) "v=%p obj=%p" visit_optional(void *v, const char *name, bool *present) "v=%p name=%spresent=%p"
qapi/trace-events +2
-2-visit_deprecated_accept(void *v, const char *name) "v=%p name=%s" -visit_deprecated(void *v, const char *name) "v=%p name=%s" +visit_policy_reject(void *v, const char *name) "v=%p name=%s" +visit_policy_skip(void *v, const char *name) "v=%p name=%s" visit_type_enum(void *v, const char *name, int *obj) "v=%p name=%s obj=%p" visit_type_int(void *v, const char *name, int64_t *obj) "v=%p name=%sobj=%p"
scripts/qapi/visit.py +1
-1@@ -21,7 +21,7 @@ indent, mcgen, ) -from .gen import QAPISchemaModularCVisitor, ifcontext +from .gen import QAPISchemaModularCVisitor, gen_special_features,ifcontext
from .schema import (
QAPISchema,
QAPISchemaEnumMember,scripts/qapi/visit.py +0
-1@@ -76,7 +76,6 @@ def gen_visit_object_members(name: str, c_type=base.c_name()) for memb in members: - deprecated = 'deprecated' in [f.name for f in memb.features] ret += memb.ifcond.gen_if() if memb.optional: ret += mcgen('''
scripts/qapi/visit.py def gen_visit_object_members(name: str, · line 88
Quoted 7 lines
scripts/qapi/visit.py +2
-1@@ -84,14 +83,15 @@ def gen_visit_object_members(name: str, ''', name=memb.name, c_name=c_name(memb.name)) indent.increase() - if deprecated: + special_features = gen_special_features(memb.features) + if special_features != '0':
Would it be possible for gen_special_features to return something false-y instead of '0'? Do we actually *use* the '0' return anywhere other than to test it to see if we should include additional code?
If you actually use the '0' anywhere: Go ahead and treat this as an ack. If you don't, can we clean this up?
(Sorry, I find the mcgen stuff hard to read in patch form and I am trying to give you a quick review instead of NO review.)
--js
Quoted 27 lines
scripts/qapi/visit.py +3
-3ret += mcgen(''' - if (!visit_deprecated_accept(v, "%(name)s", errp)) { + if (visit_policy_reject(v, "%(name)s", %(special_features)s, errp)) { return false; } - if (visit_deprecated(v, "%(name)s")) { + if (!visit_policy_skip(v, "%(name)s", %(special_features)s)) { ''', - name=memb.name) + name=memb.name, special_features=special_features) indent.increase()ret += mcgen(''' if (!visit_type_%(c_type)s(v, "%(name)s", &obj->%(c_name)s, errp)) {scripts/qapi/visit.py +1
-2@@ -100,7 +100,7 @@ def gen_visit_object_members(name: str, ''', c_type=memb.type.c_name(), name=memb.name, c_name=c_name(memb.name)) - if deprecated: + if special_features != '0': indent.decrease() ret += mcgen(''' } --2.31.1
Re: [PATCH 5/9] qapi: Generalize struct member policy checking
Quoted 14 lines · John Snow
Quoted 12 lines · Markus Armbruster
The generated visitor functions call
visit_deprecated_accept()andvisit_deprecated()when visiting a struct member with special feature flag 'deprecated'. This makes the feature flag visible to the actual visitors. I want to make feature flag 'unstable' visible there as well, so I can add policy for it.To let me make it visible, replace these functions by
visit_policy_reject()andvisit_policy_skip(), which take the member's special features as an argument. Note that the new functions have the opposite sense, i.e. the return value flips.Signed-off-by Markus Armbruster <[email protected]>
[...]
Quoted 34 lines
Quoted 22 lines
scripts/qapi/visit.py +1
-2@@ -21,7 +21,7 @@ indent, mcgen, ) -from .gen import QAPISchemaModularCVisitor, ifcontext +from .gen import QAPISchemaModularCVisitor, gen_special_features, ifcontext from .schema import ( QAPISchema, QAPISchemaEnumMember,@@ -76,7 +76,6 @@ def gen_visit_object_members(name: str, c_type=base.c_name()) for memb in members: - deprecated = 'deprecated' in [f.name for f in memb.features] ret += memb.ifcond.gen_if() if memb.optional: ret += mcgen('''scripts/qapi/visit.py def gen_visit_object_members(name: str, · line 88
Quoted 7 lines
scripts/qapi/visit.py +2
-1@@ -84,14 +83,15 @@ def gen_visit_object_members(name: str, ''', name=memb.name, c_name=c_name(memb.name)) indent.increase() - if deprecated: + special_features = gen_special_features(memb.features) + if special_features != '0':Would it be possible for
gen_special_featuresto return something false-y instead of '0'? Do we actually *use* the '0' return anywhere other than to test it to see if we should include additional code?
Quoted 2 lines
If you actually use the '0' anywhere: Go ahead and treat this as an ack. If you don't, can we clean this up?
gen_special_features() returns a string holding C code for a special features bitset. The empty bitset is 0.
The "natural" use is interpolating this value into C code. Two instances are visible below.
The use right here is for testing "have we got special features", so we can skip generating code that is of no use when we don't have any. It's admittedly slightly unclean.
Quoted 2 lines
(Sorry, I find the mcgen stuff hard to read in patch form and I am trying to give you a quick review instead of NO review.)
Any kind of review is appreciated :)
Quoted 13 lines
--js
Quoted 10 lines
scripts/qapi/visit.py +3
-3ret += mcgen(''' - if (!visit_deprecated_accept(v, "%(name)s", errp)) { + if (visit_policy_reject(v, "%(name)s", %(special_features)s, errp)) { return false; } - if (visit_deprecated(v, "%(name)s")) { + if (!visit_policy_skip(v, "%(name)s", %(special_features)s)) { ''', - name=memb.name) + name=memb.name, special_features=special_features)
These are the "natural" uses I mentioned.
If gen_special_features() returned something other than '0', we'd have to replace it by '0' here.
Quoted 16 lines
Quoted 16 lines
scripts/qapi/visit.py +0
-0indent.increase() ret += mcgen('''if (!visit_type_%(c_type)s(v, "%(name)s", &obj->%(c_name)s, errp)) {scripts/qapi/visit.py +1
-2@@ -100,7 +100,7 @@ def gen_visit_object_members(name: str, ''', c_type=memb.type.c_name(), name=memb.name, c_name=c_name(memb.name)) - if deprecated: + if special_features != '0': indent.decrease() ret += mcgen(''' } --2.31.1
Re: [PATCH 5/9] qapi: Generalize struct member policy checking
In reply to Markus ArmbrusterQuoted 28 lines · Markus Armbruster
The generated visitor functions call
visit_deprecated_accept()andvisit_deprecated()when visiting a struct member with special feature flag 'deprecated'. This makes the feature flag visible to the actual visitors. I want to make feature flag 'unstable' visible there as well, so I can add policy for it.To let me make it visible, replace these functions by
visit_policy_reject()andvisit_policy_skip(), which take the member's special features as an argument. Note that the new functions have the opposite sense, i.e. the return value flips.Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/visitor-impl.h | 6 ++++-- include/qapi/visitor.h | 17 +++++++++++++---- qapi/qapi-forward-visitor.c | 16 +++++++++------- qapi/qapi-visit-core.c | 22 ++++++++++++---------- qapi/qobject-input-visitor.c | 15 ++++++++++----- qapi/qobject-output-visitor.c | 9 ++++++--- qapi/trace-events | 4 ++-- scripts/qapi/visit.py | 14 +++++++------- 8 files changed, 63 insertions(+), 40 deletions(-)qapi/qobject-input-visitor.c +0
-0
qapi/qobject-input-visitor.c static void qobject_input_optional(Visitor *v, const char *name, bool *present) · line 669
Quoted 10 lines
qapi/qobject-input-visitor.c +4
-2@@ -662,16 +662,21 @@ static void qobject_input_optional(Visitor *v, const char *name, bool *present) *present = true; } -static bool qobject_input_deprecated_accept (Visitor *v,const char *name, -Error **errp) +static bool qobject_input_policy_reject (Visitor *v,const char *name, +unsigned special_features, +Error **errp) { +if (!(special_features &&1u <<QAPI_DEPRECATED )) {
Unreachable =) Proof than extract() is safer :P
Quoted 2 lines
qapi/qobject-input-visitor.c +2
-0+return false; + }
Re: [PATCH 5/9] qapi: Generalize struct member policy checking
Quoted 32 lines · Philippe Mathieu-Daudé
Quoted 31 lines · Markus Armbruster
The generated visitor functions call
visit_deprecated_accept()andvisit_deprecated()when visiting a struct member with special feature flag 'deprecated'. This makes the feature flag visible to the actual visitors. I want to make feature flag 'unstable' visible there as well, so I can add policy for it.To let me make it visible, replace these functions by
visit_policy_reject()andvisit_policy_skip(), which take the member's special features as an argument. Note that the new functions have the opposite sense, i.e. the return value flips.Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/visitor-impl.h | 6 ++++-- include/qapi/visitor.h | 17 +++++++++++++---- qapi/qapi-forward-visitor.c | 16 +++++++++------- qapi/qapi-visit-core.c | 22 ++++++++++++---------- qapi/qobject-input-visitor.c | 15 ++++++++++----- qapi/qobject-output-visitor.c | 9 ++++++--- qapi/trace-events | 4 ++-- scripts/qapi/visit.py | 14 +++++++------- 8 files changed, 63 insertions(+), 40 deletions(-)qapi/qobject-input-visitor.c +0
-0@@ -662,16 +662,21 @@ static void qobject_input_optional(Visitor *v, const char *name, bool *present) *present = true; }
Quoted 9 lines
qapi/qobject-input-visitor.c static void qobject_input_optional(Visitor *v, const char *name, bool *present) · line 669
Quoted 7 lines
qapi/qobject-input-visitor.c +4
-2-static bool qobject_input_deprecated_accept (Visitor *v,const char *name, -Error **errp) +static bool qobject_input_policy_reject (Visitor *v,const char *name, +unsigned special_features, +Error **errp) { +if (!(special_features &&1u <<QAPI_DEPRECATED )) {Unreachable =) Proof than
extract()is safer :P
Good eyes, thank you!
I actually like extract & desposit macros when the width is greater than one. Then, the longhand C code is illegible anyway, and having to remember what the macros mean is no worse.
For width 1 it feels like a wash. Universal use of the macros could build familiarity and thus tip the balance.
I count more than a thousand instances of '& (1 <<'.
I wasn't even aware the macros existed in QEMU[*].
Quoted 3 lines
qapi/qobject-input-visitor.c static void qobject_input_optional(Visitor *v, const char *name, bool *present) · line 671
Quoted 3 lines
qapi/qobject-input-visitor.c +2
-0+return false; + }
[*] I may well have seen them before, but my memory is limited and lossy.
PATCH 6/9 qapi: Generalize command policy checking
In reply to Markus ArmbrusterThe code to check command policy can see special feature flag 'deprecated' as command flag QCO_DEPRECATED. I want to make feature flag 'unstable' visible there as well, so I can add policy for it.
To let me make it visible, add member @special_features (a bitset of QapiSpecialFeature) to QmpCommand, and adjust the generator to pass it through qmp_register_command(). Then replace "QCO_DEPRECATED in @flags" by QAPI_DEPRECATED in @special_features", and drop QCO_DEPRECATED.
--- include/qapi/qmp/dispatch.h | 5 +++-- monitor/misc.c | 6 ++++-- qapi/qmp-dispatch.c | 2 +- qapi/qmp-registry.c | 4 +++- storage-daemon/qemu-storage-daemon.c | 3 ++- scripts/qapi/commands.py | 9 ++++----- 6 files changed, 17 insertions(+), 12 deletions(-)
include/qapi/qmp/dispatch.h +3 -2
@@ -25,7 +25,6 @@ typedef enum QmpCommandOptionsQCO_ALLOW_OOB = (1U <<1 ),QCO_ALLOW_PRECONFIG = (1U <<2 ),QCO_COROUTINE = (1U <<3 ), -QCO_DEPRECATED = (1U <<4 ), } QmpCommandOptions; typedef struct QmpCommand
@@ -34,6 +33,7 @@ typedef struct QmpCommand/* Runs in coroutine context if QCO_COROUTINE is set */ QmpCommandFunc *fn;QmpCommandOptions options; +unsigned special_features;QTAILQ_ENTRY (QmpCommand) node;bool enabled;const char *disable_reason;
@@ -42,7 +42,8 @@ typedef struct QmpCommand typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList;void qmp_register_command (QmpCommandList *cmds,const char *name, -QmpCommandFunc *fn,QmpCommandOptions options); +QmpCommandFunc *fn,QmpCommandOptions options, +unsigned special_features);const QmpCommand *qmp_find_command (const QmpCommandList *cmds,const char *name); void qmp_disable_command(QmpCommandList *cmds, const char *name,
monitor/misc.c +4 -2
@@ -230,11 +230,13 @@ static void monitor_init_qmp_commands(void)qmp_init_marshal (&qmp_commands); -qmp_register_command (&qmp_commands,"device_add" , qmp_device_add,0 ); +qmp_register_command (&qmp_commands,"device_add" , + qmp_device_add,0 ,0 );QTAILQ_INIT (&qmp_cap_negotiation_commands);qmp_register_command (&qmp_cap_negotiation_commands,"qmp_capabilities" , - qmp_marshal_qmp_capabilities,QCO_ALLOW_PRECONFIG ); + qmp_marshal_qmp_capabilities, +QCO_ALLOW_PRECONFIG ,0 ); }/* Set the current CPU defined by the user. Callers must hold BQL. */
qapi/qmp-dispatch.c +1 -1
@@ -176,7 +176,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request, "The command %s has not been found", command); goto out; } -if (cmd->options &QCO_DEPRECATED ) { +if (cmd->special_features &1u <<QAPI_DEPRECATED ) {switch (compat_policy.deprecated_input) {case COMPAT_POLICY_INPUT_ACCEPT :break ;
qapi/qmp-registry.c +3 -1
@@ -16,7 +16,8 @@#include "qapi/qmp/dispatch.h" void qmp_register_command (QmpCommandList *cmds,const char *name, -QmpCommandFunc *fn,QmpCommandOptions options) +QmpCommandFunc *fn,QmpCommandOptions options, +unsigned special_features) {QmpCommand *cmd =g_malloc0 (sizeof (*cmd));
@@ -27,6 +28,7 @@ void qmp_register_command(QmpCommandList *cmds, const char *name, cmd->fn = fn; cmd->enabled = true; cmd->options = options; + cmd->special_features = special_features;QTAILQ_INSERT_TAIL (cmds, cmd, node); }
storage-daemon/qemu-storage-daemon.c +2 -1
@@ -146,7 +146,8 @@ static void init_qmp_commands(void)QTAILQ_INIT (&qmp_cap_negotiation_commands);qmp_register_command (&qmp_cap_negotiation_commands,"qmp_capabilities" , - qmp_marshal_qmp_capabilities,QCO_ALLOW_PRECONFIG ); + qmp_marshal_qmp_capabilities, +QCO_ALLOW_PRECONFIG ,0 ); } static int getopt_set_loc(int argc, char **argv, const char *optstring,
scripts/qapi/commands.py +4 -5
@@ -26,6 +26,7 @@ QAPISchemaModularCVisitor, build_params, ifcontext, + gen_special_features, ) from .schema import ( QAPISchema,
@@ -217,9 +218,6 @@ def gen_register_command(name: str, coroutine: bool) -> str: options = [] - if 'deprecated' in [f.name for f in features]: - options += ['QCO_DEPRECATED'] - if not success_response: options += ['QCO_NO_SUCCESS_RESP'] if allow_oob:
@@ -231,10 +229,11 @@ def gen_register_command(name: str, ret = mcgen(''' qmp_register_command(cmds, "%(name)s", - qmp_marshal_%(c_name)s, %(opts)s); + qmp_marshal_%(c_name)s, %(opts)s, %(feats)s); ''', name=name, c_name=c_name(name), - opts=' | '.join(options) or 0) + opts=' | '.join(options) or 0, + feats=gen_special_features(features)) return ret
Signature · 1 line
2.31.1
Re: [PATCH 6/9] qapi: Generalize command policy checking
Quoted 41 lines · Markus Armbruster
The code to check command policy can see special feature flag 'deprecated' as command flag
QCO_DEPRECATED. I want to make feature flag 'unstable' visible there as well, so I can add policy for it.To let me make it visible, add member @special_features (a bitset of QapiSpecialFeature) to QmpCommand, and adjust the generator to pass it through
qmp_register_command(). Then replace "QCO_DEPRECATEDin @flags" byQAPI_DEPRECATEDin @special_features", and dropQCO_DEPRECATED.Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/qmp/dispatch.h | 5 +++-- monitor/misc.c | 6 ++++-- qapi/qmp-dispatch.c | 2 +- qapi/qmp-registry.c | 4 +++- storage-daemon/qemu-storage-daemon.c | 3 ++- scripts/qapi/commands.py | 9 ++++----- 6 files changed, 17 insertions(+), 12 deletions(-)include/qapi/qmp/dispatch.h +1
-1@@ -25,7 +25,6 @@ typedef enum QmpCommandOptionsQCO_ALLOW_OOB = (1U <<1 ),QCO_ALLOW_PRECONFIG = (1U <<2 ),QCO_COROUTINE = (1U <<3 ), -QCO_DEPRECATED = (1U <<4 ), } QmpCommandOptions; typedef struct QmpCommand@@ -34,6 +33,7 @@ typedef struct QmpCommand/* Runs in coroutine context if QCO_COROUTINE is set */ QmpCommandFunc *fn;QmpCommandOptions options; +unsigned special_features;QTAILQ_ENTRY (QmpCommand) node;bool enabled;const char *disable_reason;
include/qapi/qmp/dispatch.h typedef struct QmpCommand · line 46
Quoted 6 lines
include/qapi/qmp/dispatch.h +2
-1@@ -42,7 +42,8 @@ typedef struct QmpCommand typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList;void qmp_register_command (QmpCommandList *cmds,const char *name, -QmpCommandFunc *fn,QmpCommandOptions options); +QmpCommandFunc *fn,QmpCommandOptions options, +unsigned special_features);
What about:
typedef unsigned QapiFeatureMask;
?
Otherwise:
Re: [PATCH 6/9] qapi: Generalize command policy checking
Quoted 51 lines · Philippe Mathieu-Daudé
Quoted 41 lines · Markus Armbruster
The code to check command policy can see special feature flag 'deprecated' as command flag
QCO_DEPRECATED. I want to make feature flag 'unstable' visible there as well, so I can add policy for it.To let me make it visible, add member @special_features (a bitset of QapiSpecialFeature) to QmpCommand, and adjust the generator to pass it through
qmp_register_command(). Then replace "QCO_DEPRECATEDin @flags" byQAPI_DEPRECATEDin @special_features", and dropQCO_DEPRECATED.Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/qmp/dispatch.h | 5 +++-- monitor/misc.c | 6 ++++-- qapi/qmp-dispatch.c | 2 +- qapi/qmp-registry.c | 4 +++- storage-daemon/qemu-storage-daemon.c | 3 ++- scripts/qapi/commands.py | 9 ++++----- 6 files changed, 17 insertions(+), 12 deletions(-)include/qapi/qmp/dispatch.h +1
-1@@ -25,7 +25,6 @@ typedef enum QmpCommandOptionsQCO_ALLOW_OOB = (1U <<1 ),QCO_ALLOW_PRECONFIG = (1U <<2 ),QCO_COROUTINE = (1U <<3 ), -QCO_DEPRECATED = (1U <<4 ), } QmpCommandOptions; typedef struct QmpCommand@@ -34,6 +33,7 @@ typedef struct QmpCommand/* Runs in coroutine context if QCO_COROUTINE is set */ QmpCommandFunc *fn;QmpCommandOptions options; +unsigned special_features;QTAILQ_ENTRY (QmpCommand) node;bool enabled;const char *disable_reason;include/qapi/qmp/dispatch.h typedef struct QmpCommand · line 46
Quoted 6 lines
include/qapi/qmp/dispatch.h +2
-1@@ -42,7 +42,8 @@ typedef struct QmpCommand typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList;void qmp_register_command (QmpCommandList *cmds,const char *name, -QmpCommandFunc *fn,QmpCommandOptions options); +QmpCommandFunc *fn,QmpCommandOptions options, +unsigned special_features);What about:
Quoted 3 lines
typedef unsigned QapiFeatureMask;
?
I think the name @special_features makes the connection to QapiSpecialFeature clear enough.
Quoted 2 lines
Otherwise:
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Thanks!
Re: [PATCH 6/9] qapi: Generalize command policy checking
In reply to Markus ArmbrusterQuoted 150 lines · Markus Armbruster
The code to check command policy can see special feature flag 'deprecated' as command flag
QCO_DEPRECATED. I want to make feature flag 'unstable' visible there as well, so I can add policy for it.To let me make it visible, add member @special_features (a bitset of QapiSpecialFeature) to QmpCommand, and adjust the generator to pass it through
qmp_register_command(). Then replace "QCO_DEPRECATEDin @flags" byQAPI_DEPRECATEDin @special_features", and dropQCO_DEPRECATED.Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/qmp/dispatch.h | 5 +++-- monitor/misc.c | 6 ++++-- qapi/qmp-dispatch.c | 2 +- qapi/qmp-registry.c | 4 +++- storage-daemon/qemu-storage-daemon.c | 3 ++- scripts/qapi/commands.py | 9 ++++----- 6 files changed, 17 insertions(+), 12 deletions(-)include/qapi/qmp/dispatch.h +3
-2@@ -25,7 +25,6 @@ typedef enum QmpCommandOptionsQCO_ALLOW_OOB = (1U <<1 ),QCO_ALLOW_PRECONFIG = (1U <<2 ),QCO_COROUTINE = (1U <<3 ), -QCO_DEPRECATED = (1U <<4 ), } QmpCommandOptions; typedef struct QmpCommand@@ -34,6 +33,7 @@ typedef struct QmpCommand/* Runs in coroutine context if QCO_COROUTINE is set */ QmpCommandFunc *fn;QmpCommandOptions options; +unsigned special_features;QTAILQ_ENTRY (QmpCommand) node;bool enabled;const char *disable_reason;@@ -42,7 +42,8 @@ typedef struct QmpCommand typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList;void qmp_register_command (QmpCommandList *cmds,const char *name, -QmpCommandFunc *fn,QmpCommandOptions options); +QmpCommandFunc *fn,QmpCommandOptions options, +unsigned special_features);const QmpCommand *qmp_find_command (const QmpCommandList *cmds,const char *name); void qmp_disable_command(QmpCommandList *cmds, const char *name,monitor/misc.c +4
-2@@ -230,11 +230,13 @@ static void monitor_init_qmp_commands(void)qmp_init_marshal (&qmp_commands); -qmp_register_command (&qmp_commands,"device_add" , qmp_device_add,0 ); +qmp_register_command (&qmp_commands,"device_add" , + qmp_device_add,0 ,0 );QTAILQ_INIT (&qmp_cap_negotiation_commands);qmp_register_command (&qmp_cap_negotiation_commands,"qmp_capabilities" , - qmp_marshal_qmp_capabilities,QCO_ALLOW_PRECONFIG ); + qmp_marshal_qmp_capabilities, + QCO_ALLOW_PRECONFIG, 0); }/* Set the current CPU defined by the user. Callers must hold BQL. */
qapi/qmp-dispatch.c +1
-1@@ -176,7 +176,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request, "The command %s has not been found", command); goto out; } -if (cmd->options &QCO_DEPRECATED ) { +if (cmd->special_features &1u <<QAPI_DEPRECATED ) {switch (compat_policy.deprecated_input) {case COMPAT_POLICY_INPUT_ACCEPT :break;qapi/qmp-registry.c +3
-1@@ -16,7 +16,8 @@#include "qapi/qmp/dispatch.h" void qmp_register_command (QmpCommandList *cmds,const char *name, -QmpCommandFunc *fn,QmpCommandOptions options) +QmpCommandFunc *fn,QmpCommandOptions options, +unsigned special_features) {QmpCommand *cmd =g_malloc0 (sizeof (*cmd));@@ -27,6 +28,7 @@ void qmp_register_command(QmpCommandList *cmds, constchar *name, cmd->fn = fn; cmd->enabled = true; cmd->options = options; + cmd->special_features = special_features;QTAILQ_INSERT_TAIL (cmds, cmd, node); }storage-daemon/qemu-storage-daemon.c +2
-1@@ -146,7 +146,8 @@ static void init_qmp_commands(void)QTAILQ_INIT (&qmp_cap_negotiation_commands);qmp_register_command (&qmp_cap_negotiation_commands,"qmp_capabilities" , - qmp_marshal_qmp_capabilities,QCO_ALLOW_PRECONFIG ); + qmp_marshal_qmp_capabilities, + QCO_ALLOW_PRECONFIG, 0); }static int getopt_set_loc(int argc, char **argv, const char *optstring,
scripts/qapi/commands.py +1
-3@@ -26,6 +26,7 @@ QAPISchemaModularCVisitor, build_params, ifcontext, + gen_special_features, ) from .schema import ( QAPISchema,@@ -217,9 +218,6 @@ def gen_register_command(name: str, coroutine: bool) -> str: options = [] - if 'deprecated' in [f.name for f in features]: - options += ['QCO_DEPRECATED'] - if not success_response: options += ['QCO_NO_SUCCESS_RESP'] if allow_oob:@@ -231,10 +229,11 @@ def gen_register_command(name: str,
scripts/qapi/commands.py def gen_register_command(name: str, · line 237
Quoted 10 lines
scripts/qapi/commands.py +3
-2ret = mcgen(''' qmp_register_command(cmds, "%(name)s", - qmp_marshal_%(c_name)s, %(opts)s); + qmp_marshal_%(c_name)s, %(opts)s, %(feats)s); ''', name=name, c_name=c_name(name), - opts=' | '.join(options) or 0) + opts=' | '.join(options) or 0, + feats=gen_special_features(features))
Ah, you use the '0' return here. Alright then.
Quoted 7 lines
scripts/qapi/commands.py +0
-1return ret --2.31.1
Python bits: Acked-by: John Snow <[email protected]> C bits: "I believe in my heart that they probably work."
(for this and previous patch.)
PATCH 7/9 qapi: Generalize enum member policy checking
In reply to Markus ArmbrusterThe code to check enumeration value policy can see special feature flag 'deprecated' in QEnumLookup member flags[value]. I want to make feature flag 'unstable' visible there as well, so I can add policy for it.
Instead of extending flags[], replace it by @special_features (a bitset of QapiSpecialFeature), because that's how special features get passed around elsewhere.
--- include/qapi/util.h | 5 +---- qapi/qapi-visit-core.c | 3 ++- scripts/qapi/types.py | 22 ++++++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-)
include/qapi/util.h +1 -4
@@ -15,12 +15,9 @@ typedef enum {QAPI_DEPRECATED , } QapiSpecialFeature; -/* QEnumLookup flags */ -#define QAPI_ENUM_DEPRECATED 1 -typedef struct QEnumLookup {const char *const *array; -const unsigned char *const flags; +const unsigned char *const special_features;const int size; }QEnumLookup ;
qapi/qapi-visit-core.c +2 -1
@@ -407,7 +407,8 @@ static bool input_type_enum(Visitor *v, const char *name, int *obj,return false; } -if (lookup->flags && (lookup->flags[value] &QAPI_ENUM_DEPRECATED )) { +if (lookup->special_features + && (lookup->special_features[value] &QAPI_DEPRECATED )) {switch (v->compat_policy.deprecated_input) {case COMPAT_POLICY_INPUT_ACCEPT :break ;
scripts/qapi/types.py +12 -10
@@ -16,7 +16,7 @@ from typing import List, Optional from .common import c_enum_const, c_name, mcgen -from .gen import QAPISchemaModularCVisitor, ifcontext +from .gen import QAPISchemaModularCVisitor, gen_special_features, ifcontext from .schema import ( QAPISchema, QAPISchemaEnumMember,
@@ -39,7 +39,7 @@ def gen_enum_lookup(name: str, members: List[QAPISchemaEnumMember], prefix: Optional[str] = None) -> str: max_index = c_enum_const(name, '_MAX', prefix) - flags = '' + feats = '' ret = mcgen(''' const QEnumLookup %(c_name)s_lookup = {
@@ -54,19 +54,21 @@ def gen_enum_lookup(name: str, ''', index=index, name=memb.name) ret += memb.ifcond.gen_endif() - if 'deprecated' in (f.name for f in memb.features): - flags += mcgen(''' - [%(index)s] = QAPI_ENUM_DEPRECATED, -''', - index=index) - if flags: + special_features = gen_special_features(memb.features) + if special_features != '0': + feats += mcgen(''' + [%(index)s] = %(special_features)s, +''', + index=index, special_features=special_features) + + if feats: ret += mcgen(''' }, - .flags = (const unsigned char[%(max_index)s]) { + .special_features = (const unsigned char[%(max_index)s]) { ''', max_index=max_index) - ret += flags + ret += feats ret += mcgen(''' },
Signature · 1 line
2.31.1
Re: [PATCH 7/9] qapi: Generalize enum member policy checking
Quoted 76 lines · Markus Armbruster
The code to check enumeration value policy can see special feature flag 'deprecated' in QEnumLookup member flags[value]. I want to make feature flag 'unstable' visible there as well, so I can add policy for it.
Instead of extending flags[], replace it by @special_features (a bitset of QapiSpecialFeature), because that's how special features get passed around elsewhere.
Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/util.h | 5 +---- qapi/qapi-visit-core.c | 3 ++- scripts/qapi/types.py | 22 ++++++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-)include/qapi/util.h +1
-4@@ -15,12 +15,9 @@ typedef enum {QAPI_DEPRECATED , } QapiSpecialFeature; -/* QEnumLookup flags */ -#define QAPI_ENUM_DEPRECATED 1 -typedef struct QEnumLookup {const char *const *array; -const unsigned char *const flags; +const unsigned char *const special_features;const int size; }QEnumLookup ;qapi/qapi-visit-core.c +2
-1@@ -407,7 +407,8 @@ static bool input_type_enum(Visitor *v, const char *name, int *obj, return false; } -if (lookup->flags && (lookup->flags[value] &QAPI_ENUM_DEPRECATED )) { +if (lookup->special_features + && (lookup->special_features[value] &QAPI_DEPRECATED )) {switch (v->compat_policy.deprecated_input) {case COMPAT_POLICY_INPUT_ACCEPT :break;scripts/qapi/types.py +1
-1@@ -16,7 +16,7 @@ from typing import List, Optional from .common import c_enum_const, c_name, mcgen -from .gen import QAPISchemaModularCVisitor, ifcontext +from .gen import QAPISchemaModularCVisitor, gen_special_features,ifcontext
from .schema import (
QAPISchema,
QAPISchemaEnumMember,scripts/qapi/types.py +1
-1@@ -39,7 +39,7 @@ def gen_enum_lookup(name: str, members: List[QAPISchemaEnumMember], prefix: Optional[str] = None) -> str: max_index = c_enum_const(name, '_MAX', prefix) - flags = '' + feats = '' ret = mcgen(''' const QEnumLookup %(c_name)s_lookup = {@@ -54,19 +54,21 @@ def gen_enum_lookup(name: str, ''', index=index, name=memb.name) ret += memb.ifcond.gen_endif()
scripts/qapi/types.py def gen_enum_lookup(name: str, · line 60
Quoted 10 lines
scripts/qapi/types.py +2
-6- if 'deprecated' in (f.name for f in memb.features): - flags += mcgen(''' - [%(index)s] = QAPI_ENUM_DEPRECATED, -''', - index=index) - if flags: + special_features = gen_special_features(memb.features) + if special_features != '0':
Though, I have to admit the common reoccurrence of this pattern suggests to me that gen_special_features really ought to be returning something false-y in these cases. Something about testing for the empty case with something that represents, but isn't empty, gives me a brief pause.
Not willing to wage war over it.
Quoted 17 lines
scripts/qapi/types.py +8
-2+ feats += mcgen(''' + [%(index)s] = %(special_features)s, +''', + index=index, special_features=special_features) + + if feats: ret += mcgen(''' }, - .flags = (const unsigned char[%(max_index)s]) { + .special_features = (const unsigned char[%(max_index)s]) { ''', max_index=max_index) - ret += flags + ret += feats ret += mcgen('''},
Quoted 4 lines
--
2.31.1
Python bits: Acked-by: John Snow <[email protected]>
Re: [PATCH 7/9] qapi: Generalize enum member policy checking
Quoted 94 lines · John Snow
Quoted 76 lines · Markus Armbruster
The code to check enumeration value policy can see special feature flag 'deprecated' in QEnumLookup member flags[value]. I want to make feature flag 'unstable' visible there as well, so I can add policy for it.
Instead of extending flags[], replace it by @special_features (a bitset of QapiSpecialFeature), because that's how special features get passed around elsewhere.
Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/util.h | 5 +---- qapi/qapi-visit-core.c | 3 ++- scripts/qapi/types.py | 22 ++++++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-)include/qapi/util.h +1
-4@@ -15,12 +15,9 @@ typedef enum {QAPI_DEPRECATED , } QapiSpecialFeature; -/* QEnumLookup flags */ -#define QAPI_ENUM_DEPRECATED 1 -typedef struct QEnumLookup {const char *const *array; -const unsigned char *const flags; +const unsigned char *const special_features;const int size; }QEnumLookup ;qapi/qapi-visit-core.c +2
-1@@ -407,7 +407,8 @@ static bool input_type_enum(Visitor *v, const char *name, int *obj, return false; } -if (lookup->flags && (lookup->flags[value] &QAPI_ENUM_DEPRECATED )) { +if (lookup->special_features + && (lookup->special_features[value] &QAPI_DEPRECATED )) {switch (v->compat_policy.deprecated_input) {case COMPAT_POLICY_INPUT_ACCEPT :break;scripts/qapi/types.py +1
-1@@ -16,7 +16,7 @@ from typing import List, Optional from .common import c_enum_const, c_name, mcgen -from .gen import QAPISchemaModularCVisitor, ifcontext +from .gen import QAPISchemaModularCVisitor, gen_special_features,ifcontext
from .schema import (
QAPISchema,
QAPISchemaEnumMember,scripts/qapi/types.py +1
-1@@ -39,7 +39,7 @@ def gen_enum_lookup(name: str, members: List[QAPISchemaEnumMember], prefix: Optional[str] = None) -> str: max_index = c_enum_const(name, '_MAX', prefix) - flags = '' + feats = '' ret = mcgen(''' const QEnumLookup %(c_name)s_lookup = {@@ -54,19 +54,21 @@ def gen_enum_lookup(name: str, ''', index=index, name=memb.name) ret += memb.ifcond.gen_endif()scripts/qapi/types.py def gen_enum_lookup(name: str, · line 60
Quoted 10 lines
scripts/qapi/types.py +2
-6- if 'deprecated' in (f.name for f in memb.features): - flags += mcgen(''' - [%(index)s] = QAPI_ENUM_DEPRECATED, -''', - index=index) - if flags: + special_features = gen_special_features(memb.features) + if special_features != '0':Though, I have to admit the common reoccurrence of this pattern suggests to me that
gen_special_featuresreally ought to be returning something false-y in these cases. Something about testing for the empty case with something that represents, but isn't empty, gives me a brief pause.
Quoted 1 line
Not willing to wage war over it.
I habitually start stupid, and when stupid confuses or annoys me later, I smarten it up some.
Let's see how this instance of "stupid" ages, okay?
Quoted 15 lines
Quoted 15 lines
scripts/qapi/types.py +8
-2+ feats += mcgen(''' + [%(index)s] = %(special_features)s, +''', + index=index, special_features=special_features) + + if feats: ret += mcgen(''' }, - .flags = (const unsigned char[%(max_index)s]) { + .special_features = (const unsigned char[%(max_index)s]) { ''', max_index=max_index) - ret += flags + ret += feats
Quoted 7 lines
Quoted 6 lines
scripts/qapi/types.py +0
-0ret += mcgen('''},--
2.31.1Python bits: Acked-by: John Snow <[email protected]>
Thanks!
Re: [PATCH 7/9] qapi: Generalize enum member policy checking
Quoted 100 lines · Markus Armbruster
Quoted 1 line · John Snow
On Mon, Oct 25, 2021 at 1:26 AM Markus Armbruster <[email protected]>
Quoted 44 lines · wrote:
Quoted 44 lines
The code to check enumeration value policy can see special feature flag 'deprecated' in QEnumLookup member flags[value]. I want to make feature flag 'unstable' visible there as well, so I can add policy for it.
Instead of extending flags[], replace it by @special_features (a bitset of QapiSpecialFeature), because that's how special features get passed around elsewhere.
Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/util.h | 5 +---- qapi/qapi-visit-core.c | 3 ++- scripts/qapi/types.py | 22 ++++++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-)include/qapi/util.h +1
-4@@ -15,12 +15,9 @@ typedef enum {QAPI_DEPRECATED , } QapiSpecialFeature; -/* QEnumLookup flags */ -#define QAPI_ENUM_DEPRECATED 1 -typedef struct QEnumLookup {const char *const *array; -const unsigned char *const flags; +const unsigned char *const special_features;const int size; }QEnumLookup ;qapi/qapi-visit-core.c +0
-0@@ -407,7 +407,8 @@ static bool input_type_enum(Visitor *v, const char *name, int *obj, return false; }Quoted 1 line
qapi/qapi-visit-core.c static bool input_type_enum(Visitor *v, const char · line 411
Quoted 1 line
qapi/qapi-visit-core.c +0
-1- if (lookup->flags && (lookup->flags[value] &
QAPI_ENUM_DEPRECATED)) {Quoted 38 lines
Quoted 38 lines
qapi/qapi-visit-core.c +2
-0+if (lookup->special_features + && (lookup->special_features[value] &QAPI_DEPRECATED )) {switch (v->compat_policy.deprecated_input) {case COMPAT_POLICY_INPUT_ACCEPT :break;scripts/qapi/types.py +1
-1@@ -16,7 +16,7 @@ from typing import List, Optional from .common import c_enum_const, c_name, mcgen -from .gen import QAPISchemaModularCVisitor, ifcontext +from .gen import QAPISchemaModularCVisitor, gen_special_features,ifcontext
from .schema import (
QAPISchema,
QAPISchemaEnumMember,scripts/qapi/types.py +1
-6@@ -39,7 +39,7 @@ def gen_enum_lookup(name: str, members: List[QAPISchemaEnumMember], prefix: Optional[str] = None) -> str: max_index = c_enum_const(name, '_MAX', prefix) - flags = '' + feats = '' ret = mcgen(''' const QEnumLookup %(c_name)s_lookup = {@@ -54,19 +54,21 @@ def gen_enum_lookup(name: str, ''', index=index, name=memb.name) ret += memb.ifcond.gen_endif() - if 'deprecated' in (f.name for f in memb.features): - flags += mcgen(''' - [%(index)s] = QAPI_ENUM_DEPRECATED, -''', - index=index)Quoted 6 lines
scripts/qapi/types.py def gen_enum_lookup(name: str, · line 72
Quoted 4 lines
scripts/qapi/types.py +2
-1- if flags: + special_features = gen_special_features(memb.features) + if special_features != '0':Though, I have to admit the common reoccurrence of this pattern suggests
to
Quoted 1 line
me that
gen_special_featuresreally ought to be returning somethingfalse-y
Quoted 3 lines
in these cases. Something about testing for the empty case with something that represents, but isn't empty, gives me a brief pause.
Quoted 8 lines
Quoted 1 line
Not willing to wage war over it.
I habitually start stupid, and when stupid confuses or annoys me later, I smarten it up some.
Let's see how this instance of "stupid" ages, okay?
"I see what you're saying, but mehhhhh" is a relatable feeling ;)
Quoted 28 lines
Quoted 5 lines
scripts/qapi/types.py def gen_enum_lookup(name: str,
Quoted 5 lines
scripts/qapi/types.py +4
-0+ feats += mcgen(''' + [%(index)s] = %(special_features)s, +''', + index=index,special_features=special_features)
Quoted 11 lines
Quoted 11 lines
scripts/qapi/types.py +4
-2+ + if feats: ret += mcgen(''' }, - .flags = (const unsigned char[%(max_index)s]) { + .special_features = (const unsigned char[%(max_index)s]) { ''', max_index=max_index) - ret += flags + ret += featsQuoted 7 lines
Quoted 6 lines
scripts/qapi/types.py +0
-0ret += mcgen('''},--
2.31.1Python bits: Acked-by: John Snow <[email protected]>
Thanks!
PATCH 8/9 qapi: Factor out compat_policy_input_ok()
In reply to Markus ArmbrusterThe code to check policy for handling deprecated input is triplicated. Factor it out into compat_policy_input_ok() before I mess with it in the next commit.
--- include/qapi/compat-policy.h | 7 +++++ qapi/qapi-visit-core.c | 18 +++++-------- qapi/qmp-dispatch.c | 51 +++++++++++++++++++++++++++--------- qapi/qobject-input-visitor.c | 19 +++----------- 4 files changed, 55 insertions(+), 40 deletions(-)
include/qapi/compat-policy.h +7 -0
@@ -13,10 +13,17 @@#ifndef QAPI_COMPAT_POLICY_H #define QAPI_COMPAT_POLICY_H +#include "qapi/error.h" #include "qapi/qapi-types-compat.h" extern CompatPolicy compat_policy; +bool compat_policy_input_ok (unsigned special_features, +const CompatPolicy *policy, +ErrorClass error_class, +const char *kind,const char *name, +Error **errp); +/* * Create a QObject input visitor for @obj for use with QMP *
qapi/qapi-visit-core.c +6 -12
@@ -13,6 +13,7 @@*/ #include "qemu/osdep.h" +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qapi/visitor.h"
@@ -408,18 +409,11 @@ static bool input_type_enum(Visitor *v, const char *name, int *obj, }if (lookup->special_features - && (lookup->special_features[value] &QAPI_DEPRECATED )) { -switch (v->compat_policy.deprecated_input) { -case COMPAT_POLICY_INPUT_ACCEPT : -break ; -case COMPAT_POLICY_INPUT_REJECT : -error_setg (errp,"Deprecated value '%s' disabled by policy" , - enum_str); -return false; -case COMPAT_POLICY_INPUT_CRASH : -default : -abort (); - } + && !compat_policy_input_ok (lookup->special_features[value], + &v->compat_policy, +ERROR_CLASS_GENERIC_ERROR , +"value" , enum_str, errp)) { +return false; } *obj = value;
qapi/qmp-dispatch.c +38 -13
63 lines not on this page · raw message
qapi/qobject-input-visitor.c +4 -15
@@ -14,6 +14,7 @@#include "qemu/osdep.h" #include <math.h> +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qobject-input-visitor.h" #include "qapi/visitor-impl.h"
@@ -666,21 +667,9 @@ static bool qobject_input_policy_reject(Visitor *v, const char *name,unsigned special_features, Error **errp) { -if (!(special_features &&1u <<QAPI_DEPRECATED )) { -return false; - } - -switch (v->compat_policy.deprecated_input) { -case COMPAT_POLICY_INPUT_ACCEPT : -return false; -case COMPAT_POLICY_INPUT_REJECT : -error_setg (errp,"Deprecated parameter '%s' disabled by policy" , - name); -return true; -case COMPAT_POLICY_INPUT_CRASH : -default : -abort (); - } + return !compat_policy_input_ok(special_features, &v->compat_policy, +ERROR_CLASS_GENERIC_ERROR , + "parameter", name, errp); }static void qobject_input_free (Visitor *v)
Signature · 1 line
2.31.1
Re: [PATCH 8/9] qapi: Factor out compat_policy_input_ok()
Quoted 26 lines · Markus Armbruster
The code to check policy for handling deprecated input is triplicated. Factor it out into
compat_policy_input_ok()before I mess with it in the next commit.Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/compat-policy.h | 7 +++++ qapi/qapi-visit-core.c | 18 +++++-------- qapi/qmp-dispatch.c | 51 +++++++++++++++++++++++++++--------- qapi/qobject-input-visitor.c | 19 +++----------- 4 files changed, 55 insertions(+), 40 deletions(-)qapi/qmp-dispatch.c +6
-0@@ -28,6 +28,40 @@CompatPolicy compat_policy; +static bool compat_policy_input_ok1 (const char *adjective, +CompatPolicyInput policy, +ErrorClass error_class, +const char *kind,const char *name, +Error **errp) +{
qapi/qmp-dispatch.c line 46
Quoted 10 lines
qapi/qmp-dispatch.c +10
-0+switch (policy) { +case COMPAT_POLICY_INPUT_ACCEPT : +return true; +case COMPAT_POLICY_INPUT_REJECT : +error_set (errp, error_class,"%s %s %s disabled by policy" , + adjective, kind, name); +return false; +case COMPAT_POLICY_INPUT_CRASH : +default : +abort ();
g_assert_not_reached() provides a nicer user experience.
qapi/qmp-dispatch.c line 56
Quoted 10 lines
qapi/qmp-dispatch.c +10
-0+ } +} + +bool compat_policy_input_ok (unsigned special_features, +const CompatPolicy *policy, +ErrorClass error_class, +const char *kind,const char *name, +Error **errp) +{ + if ((special_features & 1u << QAPI_DEPRECATED)
Matter of taste, I find code using extract() easier to review:
extract64(special_features, QAPI_DEPRECATED, 1)
qapi/qmp-dispatch.c line 63
Quoted 7 lines
qapi/qmp-dispatch.c +7
-0+ && !compat_policy_input_ok1("Deprecated", + policy->deprecated_input, + error_class, kind, name, errp)) { +return false; + } +return true; +}
Re: [PATCH 8/9] qapi: Factor out compat_policy_input_ok()
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 30 lines · Markus Armbruster
The code to check policy for handling deprecated input is triplicated. Factor it out into
compat_policy_input_ok()before I mess with it in the next commit.Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/compat-policy.h | 7 +++++ qapi/qapi-visit-core.c | 18 +++++-------- qapi/qmp-dispatch.c | 51 +++++++++++++++++++++++++++--------- qapi/qobject-input-visitor.c | 19 +++----------- 4 files changed, 55 insertions(+), 40 deletions(-)qapi/qmp-dispatch.c +10
-0@@ -28,6 +28,40 @@CompatPolicy compat_policy; +static bool compat_policy_input_ok1 (const char *adjective, +CompatPolicyInput policy, +ErrorClass error_class, +const char *kind,const char *name, +Error **errp) +{ +switch (policy) { +case COMPAT_POLICY_INPUT_ACCEPT : +return true; +case COMPAT_POLICY_INPUT_REJECT :
Quoted 8 lines
qapi/qmp-dispatch.c line 46
Quoted 6 lines
qapi/qmp-dispatch.c +6
-0+error_set (errp, error_class,"%s %s %s disabled by policy" , + adjective, kind, name); +return false; +case COMPAT_POLICY_INPUT_CRASH : +default : +abort ();
g_assert_not_reached()provides a nicer user experience.
I find it hard to care for making the experience of a crash that should never ever happen nicer :)
Quoted 13 lines
qapi/qmp-dispatch.c line 56
Quoted 10 lines
qapi/qmp-dispatch.c +10
-0+ } +} + +bool compat_policy_input_ok (unsigned special_features, +const CompatPolicy *policy, +ErrorClass error_class, +const char *kind,const char *name, +Error **errp) +{ + if ((special_features & 1u << QAPI_DEPRECATED)Matter of taste, I find code using
extract()easier to review:
Quoted 1 line
extract64(special_features, QAPI_DEPRECATED, 1)
I agree for width > 1.
Quoted 9 lines
qapi/qmp-dispatch.c line 63
Quoted 7 lines
qapi/qmp-dispatch.c +7
-0+ && !compat_policy_input_ok1("Deprecated", + policy->deprecated_input, + error_class, kind, name, errp)) { +return false; + } +return true; +}Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Thanks!
Re: [PATCH 8/9] qapi: Factor out compat_policy_input_ok()
Quoted 42 lines · Markus Armbruster
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 30 lines · Markus Armbruster
The code to check policy for handling deprecated input is triplicated. Factor it out into
compat_policy_input_ok()before I mess with it in the next commit.Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/compat-policy.h | 7 +++++ qapi/qapi-visit-core.c | 18 +++++-------- qapi/qmp-dispatch.c | 51 +++++++++++++++++++++++++++--------- qapi/qobject-input-visitor.c | 19 +++----------- 4 files changed, 55 insertions(+), 40 deletions(-)qapi/qmp-dispatch.c +10
-0@@ -28,6 +28,40 @@CompatPolicy compat_policy; +static bool compat_policy_input_ok1 (const char *adjective, +CompatPolicyInput policy, +ErrorClass error_class, +const char *kind,const char *name, +Error **errp) +{ +switch (policy) { +case COMPAT_POLICY_INPUT_ACCEPT : +return true; +case COMPAT_POLICY_INPUT_REJECT :Quoted 8 lines
qapi/qmp-dispatch.c line 46
Quoted 6 lines
qapi/qmp-dispatch.c +6
-0+error_set (errp, error_class,"%s %s %s disabled by policy" , + adjective, kind, name); +return false; +case COMPAT_POLICY_INPUT_CRASH : +default : +abort ();
g_assert_not_reached()provides a nicer user experience.
Quoted 2 lines
I find it hard to care for making the experience of a crash that should never ever happen nicer :)
Well COMPAT_POLICY_INPUT_CRASH can happen... What about:
case COMPAT_POLICY_INPUT_CRASH:
error_printf("%s %s %s disabled by policy",
adjective, kind, name);
abort();
default:
g_assert_not_reached();Re: [PATCH 8/9] qapi: Factor out compat_policy_input_ok()
Quoted 43 lines · Philippe Mathieu-Daudé
Quoted 42 lines · Markus Armbruster
Quoted 39 lines · Philippe Mathieu-Daudé
Quoted 26 lines · Markus Armbruster
The code to check policy for handling deprecated input is triplicated. Factor it out into
compat_policy_input_ok()before I mess with it in the next commit.Signed-off-by Markus Armbruster <[email protected]>--- include/qapi/compat-policy.h | 7 +++++ qapi/qapi-visit-core.c | 18 +++++-------- qapi/qmp-dispatch.c | 51 +++++++++++++++++++++++++++--------- qapi/qobject-input-visitor.c | 19 +++----------- 4 files changed, 55 insertions(+), 40 deletions(-)qapi/qmp-dispatch.c +6
-0@@ -28,6 +28,40 @@CompatPolicy compat_policy; +static bool compat_policy_input_ok1 (const char *adjective, +CompatPolicyInput policy, +ErrorClass error_class, +const char *kind,const char *name, +Error **errp) +{qapi/qmp-dispatch.c line 46
Quoted 10 lines
qapi/qmp-dispatch.c +10
-0+switch (policy) { +case COMPAT_POLICY_INPUT_ACCEPT : +return true; +case COMPAT_POLICY_INPUT_REJECT : +error_set (errp, error_class,"%s %s %s disabled by policy" , + adjective, kind, name); +return false; +case COMPAT_POLICY_INPUT_CRASH : +default : +abort ();
g_assert_not_reached()provides a nicer user experience.
Quoted 4 lines
Quoted 2 lines
I find it hard to care for making the experience of a crash that should never ever happen nicer :)
Well
COMPAT_POLICY_INPUT_CRASHcan happen... What about:
Point.
Quoted 6 lines
case COMPAT_POLICY_INPUT_CRASH:
error_printf("%s %s %s disabled by policy",
adjective, kind, name);
abort();
default:
g_assert_not_reached();Separate patch. I'd prefer to delay it a bit, to avoid rocking the boat so close to the soft freeze.
Re: [PATCH 8/9] qapi: Factor out compat_policy_input_ok()
In reply to Markus ArmbrusterQuoted 6 lines · Markus Armbruster
The code to check policy for handling deprecated input is triplicated. Factor it out into
compat_policy_input_ok()before I mess with it in the next commit.Signed-off-by Markus Armbruster <[email protected]>
(Skipping C-only patches for quick review. I'll trust you on these.)
--js
PATCH 9/9 qapi: Extend -compat to set policy for unstable interfaces
In reply to Markus ArmbrusterNew option parameters unstable-input and unstable-output set policy for unstable interfaces just like deprecated-input and deprecated-output set policy for deprecated interfaces (see commit 6dd75472d5 "qemu-options: New -compat to set policy for deprecated interfaces"). This is intended for testing users of the management interfaces. It is experimental.
For now, this covers only syntactic aspects of QMP, i.e. stuff tagged with feature 'unstable'. We may want to extend it to cover semantic aspects, or the command line.
Note that there is no good way for management application to detect presence of these new option parameters: they are not visible output of query-qmp-schema or query-command-line-options. Tolerable, because it's meant for testing. If running with -compat fails, skip the test.
--- qapi/compat.json | 6 +++++- include/qapi/util.h | 1 + qapi/qmp-dispatch.c | 6 ++++++ qapi/qobject-output-visitor.c | 8 ++++++-- qemu-options.hx | 20 +++++++++++++++++++- scripts/qapi/events.py | 10 ++++++---- scripts/qapi/schema.py | 10 ++++++---- 7 files changed, 49 insertions(+), 12 deletions(-)
qapi/compat.json +5 -1
@@ -47,9 +47,13 @@ # # @deprecated-input: how to handle deprecated input (default 'accept') # @deprecated-output: how to handle deprecated output (default 'accept') +# @unstable-input: how to handle unstable input (default 'accept') +# @unstable-output: how to handle unstable output (default 'accept') # # Since: 6.0 ## { 'struct': 'CompatPolicy', 'data': { '*deprecated-input': 'CompatPolicyInput', - '*deprecated-output': 'CompatPolicyOutput' } } + '*deprecated-output': 'CompatPolicyOutput', + '*unstable-input': 'CompatPolicyInput', + '*unstable-output': 'CompatPolicyOutput' } }
include/qapi/util.h +1 -0
@@ -13,6 +13,7 @@typedef enum {QAPI_DEPRECATED , +QAPI_UNSTABLE , }QapiSpecialFeature ; typedef struct QEnumLookup {
qapi/qmp-dispatch.c +6 -0
@@ -59,6 +59,12 @@ bool compat_policy_input_ok(unsigned special_features, error_class, kind, name, errp)) {return false; } +if ((special_features & (1u <<QAPI_UNSTABLE )) + && !compat_policy_input_ok1 ("Unstable" , + policy->unstable_input, + error_class, kind, name, errp)) { +return false; + }return true; }
qapi/qobject-output-visitor.c +6 -2
@@ -212,8 +212,12 @@ static bool qobject_output_type_null(Visitor *v, const char *name,static bool qobject_output_policy_skip (Visitor *v,const char *name,unsigned special_features) { -return !(special_features &&1u <<QAPI_DEPRECATED ) - || v->compat_policy.deprecated_output ==COMPAT_POLICY_OUTPUT_HIDE ; +CompatPolicy *pol = &v->compat_policy; + +return ((special_features &1u <<QAPI_DEPRECATED ) + && pol->deprecated_output ==COMPAT_POLICY_OUTPUT_HIDE ) + || ((special_features &1u <<QAPI_UNSTABLE ) + && pol->unstable_output ==COMPAT_POLICY_OUTPUT_HIDE ); }/* Finish building, and return the root object.
qemu-options.hx +19 -1
@@ -3641,7 +3641,9 @@ DEFHEADING(Debug/Expert options:) DEF("compat", HAS_ARG, QEMU_OPTION_compat, "-compat [deprecated-input=accept|reject|crash][,deprecated-output=accept|hide]\n" - " Policy for handling deprecated management interfaces\n", + " Policy for handling deprecated management interfaces\n" + "-compat [unstable-input=accept|reject|crash][,unstable-output=accept|hide]\n" + " Policy for handling unstable management interfaces\n", QEMU_ARCH_ALL) SRST ``-compat [deprecated-input=@var{input-policy}][,deprecated-output=@var{output-policy}]``
@@ -3659,6 +3661,22 @@ SRST Suppress deprecated command results and events Limitation: covers only syntactic aspects of QMP. + +``-compat [unstable-input=@var{input-policy}][,unstable-output=@var{output-policy}]`` + Set policy for handling unstable management interfaces (experimental): + + ``unstable-input=accept`` (default) + Accept unstable commands and arguments + ``unstable-input=reject`` + Reject unstable commands and arguments + ``unstable-input=crash`` + Crash on unstable commands and arguments + ``unstable-output=accept`` (default) + Emit unstable command results and events + ``unstable-output=hide`` + Suppress unstable command results and events + + Limitation: covers only syntactic aspects of QMP. ERST DEF("fw_cfg", HAS_ARG, QEMU_OPTION_fwcfg,
scripts/qapi/events.py +6 -4
@@ -109,13 +109,15 @@ def gen_event_send(name: str, if not boxed: ret += gen_param_var(arg_type) - if 'deprecated' in [f.name for f in features]: - ret += mcgen(''' + for f in features: + if f.is_special(): + ret += mcgen(''' - if (compat_policy.deprecated_output == COMPAT_POLICY_OUTPUT_HIDE) { + if (compat_policy.%(feat)s_output == COMPAT_POLICY_OUTPUT_HIDE) { return; } -''') +''', + feat=f.name) ret += mcgen('''
scripts/qapi/schema.py +6 -4
@@ -254,9 +254,11 @@ def doc_type(self): def check(self, schema): QAPISchemaEntity.check(self, schema) - if 'deprecated' in [f.name for f in self.features]: - raise QAPISemError( - self.info, "feature 'deprecated' is not supported for types") + for feat in self.features: + if feat.is_special(): + raise QAPISemError( + self.info, + f"feature '{feat.name}' is not supported for types") def describe(self): assert self.meta
@@ -726,7 +728,7 @@ class QAPISchemaFeature(QAPISchemaMember): role = 'feature' def is_special(self): - return self.name in ('deprecated') + return self.name in ('deprecated', 'unstable') class QAPISchemaObjectTypeMember(QAPISchemaMember):
Signature · 1 line
2.31.1
Re: [PATCH 9/9] qapi: Extend -compat to set policy for unstable interfaces
Quoted 195 lines · Markus Armbruster
New option parameters unstable-input and unstable-output set policy for unstable interfaces just like deprecated-input and deprecated-output set policy for deprecated interfaces (see commit
6dd75472d5"qemu-options: New -compat to set policy for deprecated interfaces"). This is intended for testing users of the management interfaces. It is experimental.For now, this covers only syntactic aspects of QMP, i.e. stuff tagged with feature 'unstable'. We may want to extend it to cover semantic aspects, or the command line.
Note that there is no good way for management application to detect presence of these new option parameters: they are not visible output of query-qmp-schema or query-command-line-options. Tolerable, because it's meant for testing. If running with -compat fails, skip the test.
Signed-off-by Markus Armbruster <[email protected]>--- qapi/compat.json | 6 +++++- include/qapi/util.h | 1 + qapi/qmp-dispatch.c | 6 ++++++ qapi/qobject-output-visitor.c | 8 ++++++-- qemu-options.hx | 20 +++++++++++++++++++- scripts/qapi/events.py | 10 ++++++---- scripts/qapi/schema.py | 10 ++++++---- 7 files changed, 49 insertions(+), 12 deletions(-)qapi/compat.json +5
-1@@ -47,9 +47,13 @@ # # @deprecated-input: how to handle deprecated input (default 'accept') # @deprecated-output: how to handle deprecated output (default 'accept') +# @unstable-input: how to handle unstable input (default 'accept') +# @unstable-output: how to handle unstable output (default 'accept') # # Since: 6.0 ## { 'struct': 'CompatPolicy', 'data': { '*deprecated-input': 'CompatPolicyInput', - '*deprecated-output': 'CompatPolicyOutput' } } + '*deprecated-output': 'CompatPolicyOutput', + '*unstable-input': 'CompatPolicyInput', + '*unstable-output': 'CompatPolicyOutput' } }include/qapi/util.h +1
-0@@ -13,6 +13,7 @@typedef enum {QAPI_DEPRECATED , +QAPI_UNSTABLE , }QapiSpecialFeature ; typedef struct QEnumLookup {qapi/qmp-dispatch.c +6
-0@@ -59,6 +59,12 @@ bool compat_policy_input_ok(unsigned special_features, error_class, kind, name, errp)) {return false; } +if ((special_features & (1u <<QAPI_UNSTABLE )) + && !compat_policy_input_ok1 ("Unstable" , + policy->unstable_input, + error_class, kind, name, errp)) { +return false; + }return true; }qapi/qobject-output-visitor.c +6
-2@@ -212,8 +212,12 @@ static bool qobject_output_type_null(Visitor *v,const char *name, static bool qobject_output_policy_skip(Visitor *v, const char *name, unsigned special_features) { - return !(special_features && 1u << QAPI_DEPRECATED) - || v->compat_policy.deprecated_output ==COMPAT_POLICY_OUTPUT_HIDE ; +CompatPolicy *pol = &v->compat_policy; + +return ((special_features &1u <<QAPI_DEPRECATED ) + && pol->deprecated_output ==COMPAT_POLICY_OUTPUT_HIDE ) + || ((special_features &1u <<QAPI_UNSTABLE ) + && pol->unstable_output ==COMPAT_POLICY_OUTPUT_HIDE ); }/* Finish building, and return the root object.
qemu-options.hx +0
-0@@ -3641,7 +3641,9 @@ DEFHEADING(Debug/Expert options:) DEF("compat", HAS_ARG, QEMU_OPTION_compat, "-compat[deprecated-input=accept|reject|crash][,deprecated-output=accept|hide]\n"
- " Policy for handling deprecated management
interfaces\n",
+ " Policy for handling deprecated management
interfaces\n"
+ "-compat
[unstable-input=accept|reject|crash][,unstable-output=accept|hide]\n"
+ " Policy for handling unstable management
interfaces\n",
QEMU_ARCH_ALL)
SRST
``-compat
[deprecated-input=@var{input-policy}][,deprecated-output=@var{output-policy}]``qemu-options.hx +2
-0@@ -3659,6 +3661,22 @@ SRST Suppress deprecated command results and events Limitation: covers only syntactic aspects of QMP. + +``-compat[unstable-input=@var{input-policy}][,unstable-output=@var{output-policy}]``
qemu-options.hx +14
-0+ Set policy for handling unstable management interfaces (experimental): + + ``unstable-input=accept`` (default) + Accept unstable commands and arguments + ``unstable-input=reject`` + Reject unstable commands and arguments + ``unstable-input=crash`` + Crash on unstable commands and arguments + ``unstable-output=accept`` (default) + Emit unstable command results and events + ``unstable-output=hide`` + Suppress unstable command results and events + + Limitation: covers only syntactic aspects of QMP. ERST DEF("fw_cfg", HAS_ARG, QEMU_OPTION_fwcfg,scripts/qapi/events.py +6
-4@@ -109,13 +109,15 @@ def gen_event_send(name: str, if not boxed: ret += gen_param_var(arg_type) - if 'deprecated' in [f.name for f in features]: - ret += mcgen(''' + for f in features: + if f.is_special(): + ret += mcgen(''' - if (compat_policy.deprecated_output == COMPAT_POLICY_OUTPUT_HIDE) { + if (compat_policy.%(feat)s_output == COMPAT_POLICY_OUTPUT_HIDE) { return; } -''') +''', + feat=f.name) ret += mcgen('''scripts/qapi/schema.py +5
-3@@ -254,9 +254,11 @@ def doc_type(self): def check(self, schema): QAPISchemaEntity.check(self, schema) - if 'deprecated' in [f.name for f in self.features]: - raise QAPISemError( - self.info, "feature 'deprecated' is not supported for types") + for feat in self.features: + if feat.is_special(): + raise QAPISemError( + self.info, + f"feature '{feat.name}' is not supported for types") def describe(self):assert self.meta
scripts/qapi/schema.py +1
-2@@ -726,7 +728,7 @@ class QAPISchemaFeature(QAPISchemaMember): role = 'feature' def is_special(self): - return self.name in ('deprecated') + return self.name in ('deprecated', 'unstable') class QAPISchemaObjectTypeMember(QAPISchemaMember): --
Quoted 3 lines
2.31.1
Python bits: Acked-by: John Snow <[email protected]>
Looks good overall from what I can see, minor style quibbles that I'd probably fold on if you frowned at me.
--js
Re: [PATCH 9/9] qapi: Extend -compat to set policy for unstable interfaces
In reply to Markus ArmbrusterQuoted 6 lines · * Markus Armbruster ([email protected]) wrote:
New option parameters unstable-input and unstable-output set policy for unstable interfaces just like deprecated-input and deprecated-output set policy for deprecated interfaces (see commit
6dd75472d5"qemu-options: New -compat to set policy for deprecated interfaces"). This is intended for testing users of the management interfaces. It is experimental.
So is there no way to mark the option as unstable?
Dave
Quoted 180 lines
For now, this covers only syntactic aspects of QMP, i.e. stuff tagged with feature 'unstable'. We may want to extend it to cover semantic aspects, or the command line.
Note that there is no good way for management application to detect presence of these new option parameters: they are not visible output of query-qmp-schema or query-command-line-options. Tolerable, because it's meant for testing. If running with -compat fails, skip the test.
Signed-off-by Markus Armbruster <[email protected]>--- qapi/compat.json | 6 +++++- include/qapi/util.h | 1 + qapi/qmp-dispatch.c | 6 ++++++ qapi/qobject-output-visitor.c | 8 ++++++-- qemu-options.hx | 20 +++++++++++++++++++- scripts/qapi/events.py | 10 ++++++---- scripts/qapi/schema.py | 10 ++++++---- 7 files changed, 49 insertions(+), 12 deletions(-)qapi/compat.json +5
-1@@ -47,9 +47,13 @@ # # @deprecated-input: how to handle deprecated input (default 'accept') # @deprecated-output: how to handle deprecated output (default 'accept') +# @unstable-input: how to handle unstable input (default 'accept') +# @unstable-output: how to handle unstable output (default 'accept') # # Since: 6.0 ## { 'struct': 'CompatPolicy', 'data': { '*deprecated-input': 'CompatPolicyInput', - '*deprecated-output': 'CompatPolicyOutput' } } + '*deprecated-output': 'CompatPolicyOutput', + '*unstable-input': 'CompatPolicyInput', + '*unstable-output': 'CompatPolicyOutput' } }include/qapi/util.h +1
-0@@ -13,6 +13,7 @@typedef enum {QAPI_DEPRECATED , +QAPI_UNSTABLE , }QapiSpecialFeature ; typedef struct QEnumLookup {qapi/qmp-dispatch.c +6
-0@@ -59,6 +59,12 @@ bool compat_policy_input_ok(unsigned special_features, error_class, kind, name, errp)) {return false; } +if ((special_features & (1u <<QAPI_UNSTABLE )) + && !compat_policy_input_ok1 ("Unstable" , + policy->unstable_input, + error_class, kind, name, errp)) { +return false; + }return true; }qapi/qobject-output-visitor.c +6
-2@@ -212,8 +212,12 @@ static bool qobject_output_type_null(Visitor *v, const char *name,static bool qobject_output_policy_skip (Visitor *v,const char *name,unsigned special_features) { -return !(special_features &&1u <<QAPI_DEPRECATED ) - || v->compat_policy.deprecated_output ==COMPAT_POLICY_OUTPUT_HIDE ; +CompatPolicy *pol = &v->compat_policy; + +return ((special_features &1u <<QAPI_DEPRECATED ) + && pol->deprecated_output ==COMPAT_POLICY_OUTPUT_HIDE ) + || ((special_features &1u <<QAPI_UNSTABLE ) + && pol->unstable_output ==COMPAT_POLICY_OUTPUT_HIDE ); }/* Finish building, and return the root object. qemu-options.hx +19
-1@@ -3641,7 +3641,9 @@ DEFHEADING(Debug/Expert options:) DEF("compat", HAS_ARG, QEMU_OPTION_compat, "-compat [deprecated-input=accept|reject|crash][,deprecated-output=accept|hide]\n" - " Policy for handling deprecated management interfaces\n", + " Policy for handling deprecated management interfaces\n" + "-compat [unstable-input=accept|reject|crash][,unstable-output=accept|hide]\n" + " Policy for handling unstable management interfaces\n", QEMU_ARCH_ALL) SRST ``-compat [deprecated-input=@var{input-policy}][,deprecated-output=@var{output-policy}]``@@ -3659,6 +3661,22 @@ SRST Suppress deprecated command results and events Limitation: covers only syntactic aspects of QMP. + +``-compat [unstable-input=@var{input-policy}][,unstable-output=@var{output-policy}]`` + Set policy for handling unstable management interfaces (experimental): + + ``unstable-input=accept`` (default) + Accept unstable commands and arguments + ``unstable-input=reject`` + Reject unstable commands and arguments + ``unstable-input=crash`` + Crash on unstable commands and arguments + ``unstable-output=accept`` (default) + Emit unstable command results and events + ``unstable-output=hide`` + Suppress unstable command results and events + + Limitation: covers only syntactic aspects of QMP. ERST DEF("fw_cfg", HAS_ARG, QEMU_OPTION_fwcfg,scripts/qapi/events.py +6
-4@@ -109,13 +109,15 @@ def gen_event_send(name: str, if not boxed: ret += gen_param_var(arg_type) - if 'deprecated' in [f.name for f in features]: - ret += mcgen(''' + for f in features: + if f.is_special(): + ret += mcgen(''' - if (compat_policy.deprecated_output == COMPAT_POLICY_OUTPUT_HIDE) { + if (compat_policy.%(feat)s_output == COMPAT_POLICY_OUTPUT_HIDE) { return; } -''') +''', + feat=f.name) ret += mcgen('''scripts/qapi/schema.py +6
-4@@ -254,9 +254,11 @@ def doc_type(self): def check(self, schema): QAPISchemaEntity.check(self, schema) - if 'deprecated' in [f.name for f in self.features]: - raise QAPISemError( - self.info, "feature 'deprecated' is not supported for types") + for feat in self.features: + if feat.is_special(): + raise QAPISemError( + self.info, + f"feature '{feat.name}' is not supported for types") def describe(self): assert self.meta@@ -726,7 +728,7 @@ class QAPISchemaFeature(QAPISchemaMember): role = 'feature' def is_special(self): - return self.name in ('deprecated') + return self.name in ('deprecated', 'unstable') class QAPISchemaObjectTypeMember(QAPISchemaMember):Signature · 1 line
2.31.1
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PATCH 9/9] qapi: Extend -compat to set policy for unstable interfaces
Quoted 9 lines · Dr. David Alan Gilbert
Quoted 6 lines · * Markus Armbruster ([email protected]) wrote:
New option parameters unstable-input and unstable-output set policy for unstable interfaces just like deprecated-input and deprecated-output set policy for deprecated interfaces (see commit
6dd75472d5"qemu-options: New -compat to set policy for deprecated interfaces"). This is intended for testing users of the management interfaces. It is experimental.So is there no way to mark the option as unstable?
The closest we have to marking command line options as unstable is putting them under "Debug/Expert options" in -help.
For option *parameters*, we sometimes use the x- convention.
QAPIfication will give us better tools.