qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [RFC][PATCH v1 08/12] qemu-char: add qmp_proxy chardev


From: Anthony Liguori
Subject: [Qemu-devel] Re: [RFC][PATCH v1 08/12] qemu-char: add qmp_proxy chardev
Date: Fri, 25 Mar 2011 16:29:01 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8

On 03/25/2011 02:47 PM, Michael Roth wrote:
This allows qemu to be started with guest agent support via:

qemu -chardev qmp_proxy,path=<optional>,id=qmp_proxy \
       -device ...,chardev=qmp_proxy

It is essentially a wrapper for -chardev socket, which takes the extra
step of setting required defaults and initializing the qmp proxy by
passing the path argument along.

Not sure if this is the most elegant approach, but in terms of the
command-line invocation it seems to be the most consistent way to do
it.

Signed-off-by: Michael Roth<address@hidden>
---
  qemu-char.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
  1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index d301925..6ff7698 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2275,6 +2275,51 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts 
*opts)
      return NULL;
  }

+#include "qmp-proxy-core.h"
+
+extern QmpProxy *qmp_proxy_default;
+
+static CharDriverState *qemu_chr_open_qmp_proxy(QemuOpts *opts)
+{
+    CharDriverState *chr;
+    QmpProxy *p;
+    const char *path;
+
+    /* revert to/enforce default socket chardev options for qmp proxy */
+    path = qemu_opt_get(opts, "path");
+    if (path == NULL) {
+        path = QMP_PROXY_PATH_DEFAULT;
+        qemu_opt_set_qerr(opts, "path", path);
+    }
+    /* required options for qmp proxy */
+    qemu_opt_set_qerr(opts, "server", "on");
+    qemu_opt_set_qerr(opts, "wait", "off");
+    qemu_opt_set_qerr(opts, "telnet", "off");

Why are these options required?

Regards,

Anthony Liguori

+
+    chr = qemu_chr_open_socket(opts);
+    if (chr == NULL) {
+        goto err;
+    }
+
+    /* initialize virtagent using the socket we just set up */
+    if (qmp_proxy_default) {
+        fprintf(stderr, "error, multiple qmp guest proxies are not allowed\n");
+    }
+    p = qmp_proxy_new(path);
+    if (p == NULL) {
+        fprintf(stderr, "error initializing qmp guest proxy\n");
+        goto err;
+    }
+    qmp_proxy_default = p;
+
+    return chr;
+err:
+    if (chr) {
+        qemu_free(chr);
+    }
+    return NULL;
+}
+
  /***********************************************************/
  /* Memory chardev */
  typedef struct {
@@ -2495,6 +2540,7 @@ static const struct {
      || defined(__FreeBSD_kernel__)
      { .name = "parport",   .open = qemu_chr_open_pp },
  #endif
+    { .name = "qmp_proxy", .open = qemu_chr_open_qmp_proxy },
  };

  CharDriverState *qemu_chr_open_opts(QemuOpts *opts,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]