diff mbox

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

Message ID 1381213399-11487-1-git-send-email-wudxw@linux.vnet.ibm.com
State New
Headers show

Commit Message

Mark Wu Oct. 8, 2013, 6:23 a.m. UTC
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.

Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
---
Changes:
v4: 
    Add signature of qmp_has_success_response per Michael.
v3: 
	1. treat cmd->options as a bitmask instead of single option (per Eric) 
	2. rebase on the patch " Add interface to traverse the qmp command list
    by QmpCommand" to avoid the O(n2) problem (per Eric and Michael)
v2: 
    add the notation 'since 1.7' to the option 'success-response'
    (per Eric Blake's comments)

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

Comments

Eric Blake Oct. 8, 2013, 1:16 p.m. UTC | #1
On 10/08/2013 12:23 AM, Mark Wu 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.
> 
> Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
> ---
> Changes:
> v4: 
>     Add signature of qmp_has_success_response per Michael.
> v3: 
> 	1. treat cmd->options as a bitmask instead of single option (per Eric) 
> 	2. rebase on the patch " Add interface to traverse the qmp command list
>     by QmpCommand" to avoid the O(n2) problem (per Eric and Michael)
> v2: 
>     add the notation 'since 1.7' to the option 'success-response'
>     (per Eric Blake's comments)
> 
>  include/qapi/qmp/dispatch.h | 1 +
>  qapi/qmp-registry.c         | 5 +++++
>  qga/commands.c              | 1 +
>  qga/qapi-schema.json        | 5 ++++-
>  4 files changed, 11 insertions(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>
Michael Roth Oct. 8, 2013, 8:50 p.m. UTC | #2
Quoting Mark Wu (2013-10-08 01:23:19)
> 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.
> 
> Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

Will apply on top of 'Add interface to traverse ...' patch once that goes
in.

> ---
> Changes:
> v4: 
>     Add signature of qmp_has_success_response per Michael.
> v3: 
>         1. treat cmd->options as a bitmask instead of single option (per Eric) 
>         2. rebase on the patch " Add interface to traverse the qmp command list
>     by QmpCommand" to avoid the O(n2) problem (per Eric and Michael)
> v2: 
>     add the notation 'since 1.7' to the option 'success-response'
>     (per Eric Blake's comments)
> 
>  include/qapi/qmp/dispatch.h | 1 +
>  qapi/qmp-registry.c         | 5 +++++
>  qga/commands.c              | 1 +
>  qga/qapi-schema.json        | 5 ++++-
>  4 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h
> index b6eb49e..cebf6aa 100644
> --- a/include/qapi/qmp/dispatch.h
> +++ b/include/qapi/qmp/dispatch.h
> @@ -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 QmpCommand *cmd);
> +bool qmp_has_success_response(const QmpCommand *cmd);
>  QObject *qmp_build_error_object(Error *errp);
>  typedef void (*qmp_cmd_callback_fn)(QmpCommand *cmd, void *opaque);
>  void qmp_for_each_command(qmp_cmd_callback_fn fn, void *opaque);
> diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c
> index 3fcf10e..c75c2e8 100644
> --- a/qapi/qmp-registry.c
> +++ b/qapi/qmp-registry.c
> @@ -71,6 +71,11 @@ bool qmp_command_is_enabled(const QmpCommand *cmd)
>      return cmd->enabled;
>  }
> 
> +bool qmp_has_success_response(const QmpCommand *cmd)
> +{
> +       return !(cmd->options & QCO_NO_SUCCESS_RESP);
> +}
> +
>  void qmp_for_each_command(qmp_cmd_callback_fn fn, void *opaque)
>  {
>      QmpCommand *cmd;
> diff --git a/qga/commands.c b/qga/commands.c
> index 063b22b..7f089ba 100644
> --- a/qga/commands.c
> +++ b/qga/commands.c
> @@ -54,6 +54,7 @@ static void qmp_command_info(QmpCommand *cmd, void *opaque)
>      cmd_info = g_malloc0(sizeof(GuestAgentCommandInfo));
>      cmd_info->name = g_strdup(cmd->name);
>      cmd_info->enabled = qmp_command_is_enabled(cmd);
> +    cmd_info->success_response = qmp_has_success_response(cmd);
> 
>      cmd_info_list = g_malloc0(sizeof(GuestAgentCommandInfoList));
>      cmd_info_list->value = cmd_info;
> diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
> index 7155b7a..245f968 100644
> --- a/qga/qapi-schema.json
> +++ b/qga/qapi-schema.json
> @@ -141,10 +141,13 @@
>  #
>  # @enabled: whether command is currently enabled by guest admin
>  #
> +# @success-response: whether command returns a response on success
> +#                    (since 1.7)
> +#
>  # Since 1.1.0
>  ##
>  { 'type': 'GuestAgentCommandInfo',
> -  'data': { 'name': 'str', 'enabled': 'bool' } }
> +  'data': { 'name': 'str', 'enabled': 'bool', 'success-response': 'bool' } }
> 
>  ##
>  # @GuestAgentInfo
> -- 
> 1.8.3.1
diff mbox

Patch

diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h
index b6eb49e..cebf6aa 100644
--- a/include/qapi/qmp/dispatch.h
+++ b/include/qapi/qmp/dispatch.h
@@ -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 QmpCommand *cmd);
+bool qmp_has_success_response(const QmpCommand *cmd);
 QObject *qmp_build_error_object(Error *errp);
 typedef void (*qmp_cmd_callback_fn)(QmpCommand *cmd, void *opaque);
 void qmp_for_each_command(qmp_cmd_callback_fn fn, void *opaque);
diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c
index 3fcf10e..c75c2e8 100644
--- a/qapi/qmp-registry.c
+++ b/qapi/qmp-registry.c
@@ -71,6 +71,11 @@  bool qmp_command_is_enabled(const QmpCommand *cmd)
     return cmd->enabled;
 }
 
+bool qmp_has_success_response(const QmpCommand *cmd)
+{
+	return !(cmd->options & QCO_NO_SUCCESS_RESP);
+}
+
 void qmp_for_each_command(qmp_cmd_callback_fn fn, void *opaque)
 {
     QmpCommand *cmd;
diff --git a/qga/commands.c b/qga/commands.c
index 063b22b..7f089ba 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -54,6 +54,7 @@  static void qmp_command_info(QmpCommand *cmd, void *opaque)
     cmd_info = g_malloc0(sizeof(GuestAgentCommandInfo));
     cmd_info->name = g_strdup(cmd->name);
     cmd_info->enabled = qmp_command_is_enabled(cmd);
+    cmd_info->success_response = qmp_has_success_response(cmd);
 
     cmd_info_list = g_malloc0(sizeof(GuestAgentCommandInfoList));
     cmd_info_list->value = cmd_info;
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index 7155b7a..245f968 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -141,10 +141,13 @@ 
 #
 # @enabled: whether command is currently enabled by guest admin
 #
+# @success-response: whether command returns a response on success
+#                    (since 1.7)
+#
 # Since 1.1.0
 ##
 { 'type': 'GuestAgentCommandInfo',
-  'data': { 'name': 'str', 'enabled': 'bool' } }
+  'data': { 'name': 'str', 'enabled': 'bool', 'success-response': 'bool' } }
 
 ##
 # @GuestAgentInfo