Skip to contentSkip to conversation

Extend qemu-ga's 'guest-info' command to expose flag 'success-response'

PATCH In review Mark Wu 3 participants 3 messages Sep 18, 2013

lore
Share & tools
lore

Mark Wu

author
#0 lore raw

PATCH 1/1 Extend qemu-ga's 'guest-info' command to expose flag 'success-response'

Now we have several qemu-ga commands not returning response on success. It has been documented in qga/qapi-schema.json already. This patch exposes the 'success-response' flag by extending 'guest-info' command. With this change, the clients can handle the command response more flexibly.

---
 include/qapi/qmp/dispatch.h |  1 +
 qapi/qmp-registry.c         | 13 +++++++++++++
 qga/commands.c              |  2 ++
 qga/qapi-schema.json        |  4 +++-
 4 files changed, 19 insertions(+), 1 deletion(-)
include/qapi/qmp/dispatch.h +1 -0
index 1ce11f5..f08c1dd 100644
@@ -48,6 +48,7 @@ QObject *qmp_dispatch(QObject *request);
 void qmp_disable_command(const char *name);
 void qmp_enable_command(const char *name);
 bool qmp_command_is_enabled(const char *name);
+bool qmp_command_has_success_response(const char *name);
 char **qmp_get_command_list(void);
 QObject *qmp_build_error_object(Error *errp);
 
qapi/qmp-registry.c +13 -0
index 28bbbe8..f86c3a5 100644
@@ -79,6 +79,19 @@ bool qmp_command_is_enabled(const char *name)
     return false;
 }
 
+bool qmp_command_has_success_response(const char *name)
+{
+    QmpCommand *cmd;
+
+    QTAILQ_FOREACH(cmd, &qmp_commands, node) {
+        if (strcmp(cmd->name, name) == 0) {
+            return cmd->options != QCO_NO_SUCCESS_RESP;
+        }
+    }
+
+    return false;
+}
+
 char **qmp_get_command_list(void)
 {
     QmpCommand *cmd;
qga/commands.c +2 -0
index 528b082..0df910b 100644
@@ -63,6 +63,8 @@ struct GuestAgentInfo *qmp_guest_info(Error **err)
         cmd_info = g_malloc0(sizeof(GuestAgentCommandInfo));
         cmd_info->name = g_strdup(*cmd_list);
         cmd_info->enabled = qmp_command_is_enabled(cmd_info->name);
+        cmd_info->success_response =
+            qmp_command_has_success_response(cmd_info->name);
 
         cmd_info_list = g_malloc0(sizeof(GuestAgentCommandInfoList));
         cmd_info_list->value = cmd_info;
qga/qapi-schema.json +3 -1
index 7155b7a..6caf019 100644
@@ -141,10 +141,12 @@
 #
 # @enabled: whether command is currently enabled by guest admin
 #
+# @success-response: whether command returns a response on success
+#
 # Since 1.1.0
 ##
 { 'type': 'GuestAgentCommandInfo',
-  'data': { 'name': 'str', 'enabled': 'bool' } }
+  'data': { 'name': 'str', 'enabled': 'bool', 'success-response': 'bool' } }
 
 ##
 # @GuestAgentInfo
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · On Wed, 18 Sep 2013 15:23:58 +0800 Mark Wu <[email protected]> wrote:

Now we have several qemu-ga commands not returning response on success. It has been documented in qga/qapi-schema.json already. This patch exposes the 'success-response' flag by extending 'guest-info' command. With this change, the clients can handle the command response more flexibly.

Looks good:

Quoted 74 lines
---
 include/qapi/qmp/dispatch.h |  1 +
 qapi/qmp-registry.c         | 13 +++++++++++++
 qga/commands.c              |  2 ++
 qga/qapi-schema.json        |  4 +++-
 4 files changed, 19 insertions(+), 1 deletion(-)
include/qapi/qmp/dispatch.h +1 -0
index 1ce11f5..f08c1dd 100644
@@ -48,6 +48,7 @@ QObject *qmp_dispatch(QObject *request);
 void qmp_disable_command(const char *name);
 void qmp_enable_command(const char *name);
 bool qmp_command_is_enabled(const char *name);
+bool qmp_command_has_success_response(const char *name);
 char **qmp_get_command_list(void);
 QObject *qmp_build_error_object(Error *errp);
 
qapi/qmp-registry.c +13 -0
index 28bbbe8..f86c3a5 100644
@@ -79,6 +79,19 @@ bool qmp_command_is_enabled(const char *name)
     return false;
 }
 
+bool qmp_command_has_success_response(const char *name)
+{
+    QmpCommand *cmd;
+
+    QTAILQ_FOREACH(cmd, &qmp_commands, node) {
+        if (strcmp(cmd->name, name) == 0) {
+            return cmd->options != QCO_NO_SUCCESS_RESP;
+        }
+    }
+
+    return false;
+}
+
 char **qmp_get_command_list(void)
 {
     QmpCommand *cmd;
qga/commands.c +2 -0
index 528b082..0df910b 100644
@@ -63,6 +63,8 @@ struct GuestAgentInfo *qmp_guest_info(Error **err)
         cmd_info = g_malloc0(sizeof(GuestAgentCommandInfo));
         cmd_info->name = g_strdup(*cmd_list);
         cmd_info->enabled = qmp_command_is_enabled(cmd_info->name);
+        cmd_info->success_response =
+            qmp_command_has_success_response(cmd_info->name);
 
         cmd_info_list = g_malloc0(sizeof(GuestAgentCommandInfoList));
         cmd_info_list->value = cmd_info;
qga/qapi-schema.json +3 -1
index 7155b7a..6caf019 100644
@@ -141,10 +141,12 @@
 #
 # @enabled: whether command is currently enabled by guest admin
 #
+# @success-response: whether command returns a response on success
+#
 # Since 1.1.0
 ##
 { 'type': 'GuestAgentCommandInfo',
-  'data': { 'name': 'str', 'enabled': 'bool' } }
+  'data': { 'name': 'str', 'enabled': 'bool', 'success-response': 'bool' } }
 
 ##
 # @GuestAgentInfo
#2 lore raw
In reply to Mark Wu
Quoted 16 lines · Mark Wu

Now we have several qemu-ga commands not returning response on success. It has been documented in qga/qapi-schema.json already. This patch exposes the 'success-response' flag by extending 'guest-info' command. With this change, the clients can handle the command response more flexibly.

---
 include/qapi/qmp/dispatch.h |  1 +
 qapi/qmp-registry.c         | 13 +++++++++++++
 qga/commands.c              |  2 ++
 qga/qapi-schema.json        |  4 +++-
 4 files changed, 19 insertions(+), 1 deletion(-)

+++ b/qga/qapi-schema.json

qga/qapi-schema.json line 144

Quoted 4 lines
qga/qapi-schema.json +1 -0
@@ -141,10 +141,12 @@
 #
 # @enabled: whether command is currently enabled by guest admin
 #
+# @success-response: whether command returns a response on success

Please add the notation (since 1.7) to this option, to document that it was not present in 1.1.0.

Other than that, looks okay to me.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org