diff options
author | Markus Armbruster <armbru@redhat.com> | 2021-10-28 12:25:17 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2021-10-29 18:24:46 +0200 |
commit | 6604e4757a1fc5832f87b5f9244efccabb49be8e (patch) | |
tree | 93e1498cf110a81714c4e05161341ad84e6ef8e4 /qapi | |
parent | a130728554d0cc19ef0ed4c1c824305c1682e64b (diff) | |
download | qemu-6604e4757a1fc5832f87b5f9244efccabb49be8e.zip qemu-6604e4757a1fc5832f87b5f9244efccabb49be8e.tar.gz qemu-6604e4757a1fc5832f87b5f9244efccabb49be8e.tar.bz2 |
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>
Diffstat (limited to 'qapi')
-rw-r--r-- | qapi/qmp-dispatch.c | 2 | ||||
-rw-r--r-- | qapi/qmp-registry.c | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 7e943a0..8cca18c 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -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; diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c index f78c064..485bc5e 100644 --- a/qapi/qmp-registry.c +++ b/qapi/qmp-registry.c @@ -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); } |