[PATCH 02/14] qapi: add helper for checking if a command feature is set

Daniel P. Berrangé posted 14 patches 5 months, 3 weeks ago
[PATCH 02/14] qapi: add helper for checking if a command feature is set
Posted by Daniel P. Berrangé 5 months, 3 weeks ago
The 'qmp_command_has_feature' method returns true if the
requested feature has been set.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 include/qapi/qmp/dispatch.h | 1 +
 qapi/qmp-registry.c         | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h
index f2e956813a..0dfcb549b6 100644
--- a/include/qapi/qmp/dispatch.h
+++ b/include/qapi/qmp/dispatch.h
@@ -51,6 +51,7 @@ void qmp_disable_command(QmpCommandList *cmds, const char *name,
 void qmp_enable_command(QmpCommandList *cmds, const char *name);
 
 bool qmp_command_is_enabled(const QmpCommand *cmd);
+bool qmp_command_has_feature(const QmpCommand *cmd, unsigned feature);
 bool qmp_command_available(const QmpCommand *cmd, Error **errp);
 const char *qmp_command_name(const QmpCommand *cmd);
 bool qmp_has_success_response(const QmpCommand *cmd);
diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c
index 485bc5e6fc..392f0e5c5a 100644
--- a/qapi/qmp-registry.c
+++ b/qapi/qmp-registry.c
@@ -74,6 +74,11 @@ bool qmp_command_is_enabled(const QmpCommand *cmd)
     return cmd->enabled;
 }
 
+bool qmp_command_has_feature(const QmpCommand *cmd, unsigned feature)
+{
+    return cmd->special_features & feature;
+}
+
 const char *qmp_command_name(const QmpCommand *cmd)
 {
     return cmd->name;
-- 
2.45.1