qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC][PATCH v7 14/16] virtagent: add virtagent chardev


From: Michael Roth
Subject: [Qemu-devel] [RFC][PATCH v7 14/16] virtagent: add virtagent chardev
Date: Mon, 7 Mar 2011 14:10:40 -0600

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

diff --git a/qemu-char.c b/qemu-char.c
index bd4e944..ffdcadb 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2458,6 +2458,49 @@ fail:
     return NULL;
 }
 
+#include "virtagent-common.h"
+
+static CharDriverState *qemu_chr_open_virtagent(QemuOpts *opts)
+{
+    CharDriverState *chr;
+    const char *path;
+    VAContext ctx;
+    int ret;
+
+    /* revert to/enforce default socket chardev options for virtagent */
+    path = qemu_opt_get(opts, "path");
+    if (path == NULL) {
+        path = VA_HOST_PATH_DEFAULT;
+    }
+    qemu_opt_set(opts, "path", path);
+    qemu_opt_set(opts, "server", "on");
+    qemu_opt_set(opts, "wait", "off");
+    qemu_opt_set(opts, "telnet", "off");
+
+    chr = qemu_chr_open_socket(opts);
+    if (chr == NULL) {
+        goto err;
+    }
+
+    /* initialize virtagent using the socket we just set up */
+    ctx.channel_method = "unix-connect";
+    ctx.channel_path = path;
+    ctx.is_host = true;
+    ret = va_init(ctx);
+    ret = 0;
+    if (ret != 0) {
+        fprintf(stderr, "error initializing virtagent");
+        goto err;
+    }
+
+    return chr;
+err:
+    if (chr) {
+        qemu_free(chr);
+    }
+    return NULL;
+}
+
 static const struct {
     const char *name;
     CharDriverState *(*open)(QemuOpts *opts);
@@ -2467,6 +2510,7 @@ static const struct {
     { .name = "udp",       .open = qemu_chr_open_udp },
     { .name = "msmouse",   .open = qemu_chr_open_msmouse },
     { .name = "vc",        .open = text_console_init },
+    { .name = "virtagent", .open = qemu_chr_open_virtagent },
 #ifdef _WIN32
     { .name = "file",      .open = qemu_chr_open_win_file_out },
     { .name = "pipe",      .open = qemu_chr_open_win_pipe },
-- 
1.7.0.4




reply via email to

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