diff mbox

[RFC,v3,10/11] virtagent: qemu integration, add va invocation via virtproxy chardev

Message ID 1289439450-23556-11-git-send-email-mdroth@linux.vnet.ibm.com
State New
Headers show

Commit Message

Michael Roth Nov. 11, 2010, 1:37 a.m. UTC
From: root <root@arsenal.linuxperf9025.net>

With these modifications we can now start virtagent via a bool option to
the virtproxy chardev. For example:

qemu -chardev virtproxy,id=va_id,virtagent=on

and then passing the chardev id to whatever device we're using for the
transport (virtio/isa serial)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 qemu-char.c   |   24 ++++++++++++++++++++++++
 qemu-config.c |    3 +++
 2 files changed, 27 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/qemu-char.c b/qemu-char.c
index e318acb..9f5efac 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1905,6 +1905,8 @@  return_err:
 /* Virtproxy chardev driver */
 
 #include "virtproxy.h"
+#include "virtagent.h"
+#include "virtagent-daemon.h"
 
 static int vp_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
 {
@@ -1925,6 +1927,8 @@  static CharDriverState *qemu_chr_open_virtproxy(QemuOpts *opts)
 {
     CharDriverState *chr = qemu_mallocz(sizeof(CharDriverState));
     VPDriver *drv = vp_new(VP_CTX_CHARDEV, chr, 0, 0);
+    int ret;
+    bool enable_virtagent;
 
     chr->opaque = drv;
     chr->chr_write = vp_chr_write;
@@ -1937,10 +1941,30 @@  static CharDriverState *qemu_chr_open_virtproxy(QemuOpts *opts)
      * client/server, which will add it's oforwards/iforwards
      * using using virtproxy API calls directly
      */
+    enable_virtagent = qemu_opt_get_bool(opts, "virtagent", 0);
+    if (enable_virtagent) {
+        /* outbound RPCs */
+        ret = va_client_init(drv, true);
+        if (ret) {
+            fprintf(stderr, "error enabling virtagent client");
+            goto fail;
+        }
+        /* inbound RPCs */
+        ret = va_server_init(drv, true);
+        if (ret) {
+            fprintf(stderr, "error enabling virtagent server");
+            goto fail;
+        }
+    }
 
     /* for "info chardev" monitor command */
     chr->filename = NULL;
     return chr;
+
+fail:
+    qemu_free(drv);
+    qemu_free(chr);
+    return NULL;
 }
 
 /***********************************************************/
diff --git a/qemu-config.c b/qemu-config.c
index 52f18be..374182b 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -146,6 +146,9 @@  static QemuOptsList qemu_chardev_opts = {
         },{
             .name = "signal",
             .type = QEMU_OPT_BOOL,
+        },{
+            .name = "virtagent",
+            .type = QEMU_OPT_BOOL,
         },
         { /* end of list */ }
     },