diff mbox series

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

Message ID 20240604153242.251334-3-berrange@redhat.com
State New
Headers show
Series Improve mechanism for configuring allowed commands | expand

Commit Message

Daniel P. Berrangé June 4, 2024, 3:32 p.m. UTC
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 mbox series

Patch

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;