From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFVuC-0002PJ-OV for qemu-devel@nongnu.org; Thu, 07 Aug 2014 18:11:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XFVu2-0006zj-Ia for qemu-devel@nongnu.org; Thu, 07 Aug 2014 18:11:28 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:50025) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFVu2-0006zd-BW for qemu-devel@nongnu.org; Thu, 07 Aug 2014 18:11:18 -0400 Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 7 Aug 2014 16:11:18 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id B88793E4003D for ; Thu, 7 Aug 2014 16:11:14 -0600 (MDT) Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by b03cxnp08026.gho.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s77M9tRe65601784 for ; Fri, 8 Aug 2014 00:09:55 +0200 Received: from d03av05.boulder.ibm.com (localhost [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s77MBEiZ003107 for ; Thu, 7 Aug 2014 16:11:14 -0600 From: Michael Roth Date: Thu, 7 Aug 2014 17:10:28 -0500 Message-Id: <1407449428-474-4-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1407449428-474-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1407449428-474-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 3/3] qga: Disable unsupported commands by default List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, tomoki.sekiyama@hds.com From: Tomoki Sekiyama Currently management softwares cannot know whether a qemu-ga command is supported or not on the running platform until they actually execute it. This patch disables unsupported commands at launch time of qemu-ga, so that management softwares can check whether they are supported from 'enabled' property of the result from 'guest-info' command. Signed-off-by: Tomoki Sekiyama Signed-off-by: Michael Roth --- qga/commands-posix.c | 38 ++++++++++++++++++++++++++++++++++++++ qga/commands-win32.c | 32 +++++++++++++++++++++++++++++++- qga/guest-agent-core.h | 1 + qga/main.c | 1 + 4 files changed, 71 insertions(+), 1 deletion(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 6b8e9c4..7eed7f4 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1955,6 +1955,44 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp) } #endif +/* add unsupported commands to the blacklist */ +GList *ga_command_blacklist_init(GList *blacklist) +{ +#if !defined(__linux__) + { + const char *list[] = { + "guest-suspend-disk", "guest-suspend-ram", + "guest-suspend-hybrid", "guest-network-get-interfaces", + "guest-get-vcpus", "guest-set-vcpus", NULL}; + char **p = (char **)list; + + while (*p) { + blacklist = g_list_append(blacklist, *p++); + } + } +#endif + +#if !defined(CONFIG_FSFREEZE) + { + const char *list[] = { + "guest-get-fsinfo", "guest-fsfreeze-status", + "guest-fsfreeze-freeze", "guest-fsfreeze-freeze-list", + "guest-fsfreeze-thaw", "guest-get-fsinfo", NULL}; + char **p = (char **)list; + + while (*p) { + blacklist = g_list_append(blacklist, *p++); + } + } +#endif + +#if !defined(CONFIG_FSTRIM) + blacklist = g_list_append(blacklist, (char *)"guest-fstrim"); +#endif + + return blacklist; +} + /* register init/cleanup routines for stateful command groups */ void ga_command_state_init(GAState *s, GACommandState *cs) { diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 3b667f5..3bcbeae 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -446,10 +446,40 @@ int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp) return -1; } +/* add unsupported commands to the blacklist */ +GList *ga_command_blacklist_init(GList *blacklist) +{ + const char *list_unsupported[] = { + "guest-file-open", "guest-file-close", "guest-file-read", + "guest-file-write", "guest-file-seek", "guest-file-flush", + "guest-suspend-hybrid", "guest-network-get-interfaces", + "guest-get-vcpus", "guest-set-vcpus", + "guest-fsfreeze-freeze-list", "guest-get-fsinfo", + "guest-fstrim", NULL}; + char **p = (char **)list_unsupported; + + while (*p) { + blacklist = g_list_append(blacklist, *p++); + } + + if (!vss_init(true)) { + const char *list[] = { + "guest-get-fsinfo", "guest-fsfreeze-status", + "guest-fsfreeze-freeze", "guest-fsfreeze-thaw", NULL}; + p = (char **)list; + + while (*p) { + blacklist = g_list_append(blacklist, *p++); + } + } + + return blacklist; +} + /* register init/cleanup routines for stateful command groups */ void ga_command_state_init(GAState *s, GACommandState *cs) { - if (vss_init(true)) { + if (!vss_initialized()) { ga_command_state_add(cs, NULL, guest_fsfreeze_cleanup); } } diff --git a/qga/guest-agent-core.h b/qga/guest-agent-core.h index e422208..e92c6ab 100644 --- a/qga/guest-agent-core.h +++ b/qga/guest-agent-core.h @@ -19,6 +19,7 @@ typedef struct GAState GAState; typedef struct GACommandState GACommandState; extern GAState *ga_state; +GList *ga_command_blacklist_init(GList *blacklist); void ga_command_state_init(GAState *s, GACommandState *cs); void ga_command_state_add(GACommandState *cs, void (*init)(void), diff --git a/qga/main.c b/qga/main.c index 8b927c9..227f2bd 100644 --- a/qga/main.c +++ b/qga/main.c @@ -1144,6 +1144,7 @@ int main(int argc, char **argv) goto out_bad; } + blacklist = ga_command_blacklist_init(blacklist); if (blacklist) { s->blacklist = blacklist; do { -- 1.9.1