From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=44902 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POZza-0002FX-6T for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:04:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POZzX-0003MF-U4 for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:04:21 -0500 Received: from e5.ny.us.ibm.com ([32.97.182.145]:48824) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POZzX-0003M4-Rn for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:04:19 -0500 Received: from d01dlp02.pok.ibm.com (d01dlp02.pok.ibm.com [9.56.224.85]) by e5.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oB3Hg97H003890 for ; Fri, 3 Dec 2010 12:42:16 -0500 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 7D51E4DE8041 for ; Fri, 3 Dec 2010 13:02:36 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oB3I4ILH400084 for ; Fri, 3 Dec 2010 13:04:18 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oB3I4GQW015933 for ; Fri, 3 Dec 2010 13:04:18 -0500 From: Michael Roth Date: Fri, 3 Dec 2010 12:03:21 -0600 Message-Id: <1291399402-20366-21-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1291399402-20366-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1291399402-20366-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC][PATCH v5 20/21] virtagent: integrate virtagent server/client via chardev List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: agl@linux.vnet.ibm.com, stefanha@linux.vnet.ibm.com, Jes.Sorensen@redhat.com, mdroth@linux.vnet.ibm.com, aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com, abeekhof@redhat.com This adds a new chardev, virtagent, which actually just passes back a socket chardev after connecting to it and initializing the agent. Signed-off-by: Michael Roth --- qemu-char.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+), 0 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 88997f9..5e83e09 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2399,6 +2399,54 @@ fail: return NULL; } +#include "virtagent-common.h" + +static CharDriverState *qemu_chr_open_virtagent(QemuOpts *opts) +{ + CharDriverState *chr; + int fd, ret; + + /* revert to/enforce default socket chardev options for virtagent */ + if (qemu_opt_get(opts, "path") == NULL) { + qemu_opt_set(opts, "path", "/tmp/virtagent-client.sock"); + } + //qemu_opt_set(opts, "id", "virtagent"); + 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; + } + + /* connect immediately to the socket we set up. + * TODO: perhaps we should cut out the socket for the virtagent + * chardev case and use a couple pipe pairs for i/o? + */ + fd = unix_connect_opts(opts); + if (fd == -1) { + fprintf(stderr, "error connecting to virtagent socket: %s", + strerror(errno)); + } + socket_set_nonblock(fd); + + /* pass fd to virtagent */ + ret = va_init(VA_CTX_HOST, fd); + 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); @@ -2408,6 +2456,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