aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2021-10-29 19:42:36 -0700
committerRichard Henderson <richard.henderson@linaro.org>2021-10-29 19:42:36 -0700
commitdd61b91c080cdfba1360a5ea1e4693fffb3445b0 (patch)
treef5b3cec0b0af415826cdf979ba49fe7e6fc0f8dc /scripts
parenta856cce31b48ef1b04ea80893458766ec16e7194 (diff)
parent57df0dff1a1f4c846aa74a082bfd595a8a990015 (diff)
downloadqemu-dd61b91c080cdfba1360a5ea1e4693fffb3445b0.zip
qemu-dd61b91c080cdfba1360a5ea1e4693fffb3445b0.tar.gz
qemu-dd61b91c080cdfba1360a5ea1e4693fffb3445b0.tar.bz2
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-10-29' into staging
QAPI patches patches for 2021-10-29 # gpg: Signature made Fri 29 Oct 2021 12:28:53 PM PDT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] * remotes/armbru/tags/pull-qapi-2021-10-29: qapi: Extend -compat to set policy for unstable interfaces qapi: Factor out compat_policy_input_ok() qapi: Generalize enum member policy checking qapi: Generalize command policy checking qapi: Generalize struct member policy checking qapi: Tools for sets of special feature flags in generated code qapi: Eliminate QCO_NO_OPTIONS for a slight simplification qapi: Mark unstable QMP parts with feature 'unstable' qapi: New special feature flag "unstable" Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi/commands.py12
-rw-r--r--scripts/qapi/events.py10
-rw-r--r--scripts/qapi/gen.py8
-rw-r--r--scripts/qapi/schema.py11
-rw-r--r--scripts/qapi/types.py20
-rw-r--r--scripts/qapi/visit.py14
6 files changed, 44 insertions, 31 deletions
diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py
index 3654825..21001bb 100644
--- a/scripts/qapi/commands.py
+++ b/scripts/qapi/commands.py
@@ -26,6 +26,7 @@ from .gen import (
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:
@@ -229,15 +227,13 @@ 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);
+ qmp_marshal_%(c_name)s, %(opts)s, %(feats)s);
''',
name=name, c_name=c_name(name),
- opts=" | ".join(options))
+ opts=' | '.join(options) or 0,
+ feats=gen_special_features(features))
return ret
diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py
index 82475e8..27b44c4 100644
--- a/scripts/qapi/events.py
+++ b/scripts/qapi/events.py
@@ -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('''
diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py
index 2ec1e7b..995a97d 100644
--- a/scripts/qapi/gen.py
+++ b/scripts/qapi/gen.py
@@ -18,6 +18,7 @@ from typing import (
Dict,
Iterator,
Optional,
+ Sequence,
Tuple,
)
@@ -29,6 +30,7 @@ from .common import (
mcgen,
)
from .schema import (
+ QAPISchemaFeature,
QAPISchemaIfCond,
QAPISchemaModule,
QAPISchemaObjectType,
@@ -37,6 +39,12 @@ from .schema import (
from .source import QAPISourceInfo
+def gen_special_features(features: Sequence[QAPISchemaFeature]) -> str:
+ special_features = [f"1u << QAPI_{feat.name.upper()}"
+ for feat in features if feat.is_special()]
+ return ' | '.join(special_features) or '0'
+
+
class QAPIGen:
def __init__(self, fname: str):
self.fname = fname
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 6d5f465..b7b3fc0 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -254,9 +254,11 @@ class QAPISchemaType(QAPISchemaEntity):
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
@@ -725,6 +727,9 @@ class QAPISchemaEnumMember(QAPISchemaMember):
class QAPISchemaFeature(QAPISchemaMember):
role = 'feature'
+ def is_special(self):
+ return self.name in ('deprecated', 'unstable')
+
class QAPISchemaObjectTypeMember(QAPISchemaMember):
def __init__(self, name, info, typ, optional, ifcond=None, features=None):
diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py
index ab2441a..3013329 100644
--- a/scripts/qapi/types.py
+++ b/scripts/qapi/types.py
@@ -16,7 +16,7 @@ This work is licensed under the terms of the GNU GPL, version 2.
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 @@ const QEnumLookup %(c_name)s_lookup = {
''',
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,
+
+ special_features = gen_special_features(memb.features)
+ if special_features != '0':
+ feats += mcgen('''
+ [%(index)s] = %(special_features)s,
''',
- index=index)
+ index=index, special_features=special_features)
- if flags:
+ 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('''
},
diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py
index 9d9196a..e13bbe4 100644
--- a/scripts/qapi/visit.py
+++ b/scripts/qapi/visit.py
@@ -21,7 +21,7 @@ from .common import (
indent,
mcgen,
)
-from .gen import QAPISchemaModularCVisitor, ifcontext
+from .gen import QAPISchemaModularCVisitor, gen_special_features, ifcontext
from .schema import (
QAPISchema,
QAPISchemaEnumMember,
@@ -76,7 +76,6 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
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 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
''',
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 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
''',
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('''
}