From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3nkJ-00059v-VM for qemu-devel@nongnu.org; Tue, 21 Aug 2012 08:39:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T3nkF-0002tz-1c for qemu-devel@nongnu.org; Tue, 21 Aug 2012 08:39:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53010) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3nkE-0002tc-Pl for qemu-devel@nongnu.org; Tue, 21 Aug 2012 08:39:42 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7LCdf7H020987 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 21 Aug 2012 08:39:41 -0400 Received: from bart.brq.redhat.com (dhcp-27-226.brq.redhat.com [10.34.27.226]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7LCdeIH025131 for ; Tue, 21 Aug 2012 08:39:40 -0400 From: Michal Privoznik Date: Tue, 21 Aug 2012 14:39:35 +0200 Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH for-1.2 v3] qemu-ga: report success-response field in guest-info List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a useful hint for users (or libvirt) whether a command returns anything success and hence wait for reply or not. --- diff to v2: -fixed typo and field description diff to v1: -changed condition in qmp_command_reports_success per Paolo's advice qapi-schema-guest.json | 6 +++++- qapi/qmp-core.h | 1 + qapi/qmp-registry.c | 12 ++++++++++++ qga/commands.c | 1 + 4 files changed, 19 insertions(+), 1 deletions(-) diff --git a/qapi-schema-guest.json b/qapi-schema-guest.json index d955cf1..60872e5 100644 --- a/qapi-schema-guest.json +++ b/qapi-schema-guest.json @@ -91,10 +91,14 @@ # # @enabled: whether command is currently enabled by guest admin # +# @success-response: true unless the command does not respond on success +# See 'guest-shutdown' command for more detailed info. +# # Since 1.1.0 ## { 'type': 'GuestAgentCommandInfo', - 'data': { 'name': 'str', 'enabled': 'bool' } } + 'data': { 'name': 'str', 'enabled': 'bool', + 'success-response': 'bool'} } ## # @GuestAgentInfo diff --git a/qapi/qmp-core.h b/qapi/qmp-core.h index 00446cf..271c3f2 100644 --- a/qapi/qmp-core.h +++ b/qapi/qmp-core.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 char *name); +bool qmp_command_reports_success(const char *name); char **qmp_get_command_list(void); QObject *qmp_build_error_object(Error *errp); diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c index 5414613..3f7303c 100644 --- a/qapi/qmp-registry.c +++ b/qapi/qmp-registry.c @@ -77,6 +77,18 @@ bool qmp_command_is_enabled(const char *name) return false; } +bool qmp_command_reports_success(const char *name) { + QmpCommand *cmd; + + QTAILQ_FOREACH(cmd, &qmp_commands, node) { + if (strcmp(cmd->name, name) == 0) { + return (cmd->options & QCO_NO_SUCCESS_RESP) == 0; + } + } + + return true; +} + char **qmp_get_command_list(void) { QmpCommand *cmd; diff --git a/qga/commands.c b/qga/commands.c index 46b0b08..9811221 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -63,6 +63,7 @@ struct GuestAgentInfo *qmp_guest_info(Error **err) cmd_info = g_malloc0(sizeof(GuestAgentCommandInfo)); cmd_info->name = strdup(*cmd_list); cmd_info->enabled = qmp_command_is_enabled(cmd_info->name); + cmd_info->success_response = qmp_command_reports_success(cmd_info->name); cmd_info_list = g_malloc0(sizeof(GuestAgentCommandInfoList)); cmd_info_list->value = cmd_info; -- 1.7.8.6