qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, tomoki.sekiyama@hds.com
Subject: [Qemu-devel] [PATCH 3/3] qga: Disable unsupported commands by default
Date: Thu,  7 Aug 2014 17:10:28 -0500	[thread overview]
Message-ID: <1407449428-474-4-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1407449428-474-1-git-send-email-mdroth@linux.vnet.ibm.com>

From: Tomoki Sekiyama <tomoki.sekiyama@hds.com>

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 <tomoki.sekiyama@hds.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 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

  parent reply	other threads:[~2014-08-07 22:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-07 22:10 [Qemu-devel] [PULL 0/3] qga: support fsfreeze'ing specific mounts Michael Roth
2014-08-07 22:10 ` [Qemu-devel] [PATCH 1/3] qga: Add guest-fsfreeze-freeze-list command Michael Roth
2014-08-07 22:10 ` [Qemu-devel] [PATCH 2/3] qga: Add guest-get-fsinfo command Michael Roth
2014-08-07 22:10 ` Michael Roth [this message]
2014-08-07 22:18 ` [Qemu-devel] [PULL 0/3] qga: support fsfreeze'ing specific mounts Eric Blake
2014-08-08 11:12   ` Peter Maydell
2014-08-08 12:59     ` Michael Roth
  -- strict thread matches above, loose matches on Subject: below --
2014-08-08 13:02 [Qemu-devel] [PULL v2 " Michael Roth
2014-08-08 13:02 ` [Qemu-devel] [PATCH 3/3] qga: Disable unsupported commands by default Michael Roth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1407449428-474-4-git-send-email-mdroth@linux.vnet.ibm.com \
    --to=mdroth@linux.vnet.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=tomoki.sekiyama@hds.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).