qapi: Generalize command policy checking

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_DEPRECATED in
@flags" by QAPI_DEPRECATED in @special_features", and drop
QCO_DEPRECATED.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: John Snow <jsnow@redhat.com>
Message-Id: <20211028102520.747396-7-armbru@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Markus Armbruster 2021-10-28 12:25:17 +02:00
parent a130728554
commit 6604e4757a
6 changed files with 17 additions and 12 deletions

View file

@ -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:
@ -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