qapi: Add feature flags to commands

Similarly to features for struct types introduce the feature flags also
for commands. This will allow notifying management layers of fixes and
compatible changes in the behaviour of a command which may not be
detectable any other way.

The changes were heavily inspired by commit 6a8c0b5102.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20191018081454.21369-3-armbru@redhat.com>
This commit is contained in:
Peter Krempa 2019-10-18 10:14:51 +02:00 committed by Markus Armbruster
parent 758f272b6d
commit 23394b4c39
8 changed files with 62 additions and 28 deletions

View file

@ -110,7 +110,8 @@ class QAPISchemaVisitor(object):
pass
def visit_command(self, name, info, ifcond, arg_type, ret_type, gen,
success_response, boxed, allow_oob, allow_preconfig):
success_response, boxed, allow_oob, allow_preconfig,
features):
pass
def visit_event(self, name, info, ifcond, arg_type, boxed):
@ -659,10 +660,14 @@ class QAPISchemaCommand(QAPISchemaEntity):
meta = 'command'
def __init__(self, name, info, doc, ifcond, arg_type, ret_type,
gen, success_response, boxed, allow_oob, allow_preconfig):
gen, success_response, boxed, allow_oob, allow_preconfig,
features):
QAPISchemaEntity.__init__(self, name, info, doc, ifcond)
assert not arg_type or isinstance(arg_type, str)
assert not ret_type or isinstance(ret_type, str)
for f in features:
assert isinstance(f, QAPISchemaFeature)
f.set_defined_in(name)
self._arg_type_name = arg_type
self.arg_type = None
self._ret_type_name = ret_type
@ -672,6 +677,7 @@ class QAPISchemaCommand(QAPISchemaEntity):
self.boxed = boxed
self.allow_oob = allow_oob
self.allow_preconfig = allow_preconfig
self.features = features
def check(self, schema):
QAPISchemaEntity.check(self, schema)
@ -701,13 +707,19 @@ class QAPISchemaCommand(QAPISchemaEntity):
"command's 'returns' cannot take %s"
% self.ret_type.describe())
# Features are in a name space separate from members
seen = {}
for f in self.features:
f.check_clash(self.info, seen)
def visit(self, visitor):
QAPISchemaEntity.visit(self, visitor)
visitor.visit_command(self.name, self.info, self.ifcond,
self.arg_type, self.ret_type,
self.gen, self.success_response,
self.boxed, self.allow_oob,
self.allow_preconfig)
self.allow_preconfig,
self.features)
class QAPISchemaEvent(QAPISchemaEntity):
@ -984,6 +996,7 @@ class QAPISchema(object):
allow_oob = expr.get('allow-oob', False)
allow_preconfig = expr.get('allow-preconfig', False)
ifcond = expr.get('if')
features = expr.get('features', [])
if isinstance(data, OrderedDict):
data = self._make_implicit_object_type(
name, info, doc, ifcond, 'arg', self._make_members(data, info))
@ -992,7 +1005,8 @@ class QAPISchema(object):
rets = self._make_array_type(rets[0], info)
self._def_entity(QAPISchemaCommand(name, info, doc, ifcond, data, rets,
gen, success_response,
boxed, allow_oob, allow_preconfig))
boxed, allow_oob, allow_preconfig,
self._make_features(features, info)))
def _def_event(self, expr, info, doc):
name = expr['event']