Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LZ5UD-0007bS-SR for qemu-devel@nongnu.org; Mon, 16 Feb 2009 10:34:21 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LZ5UC-0007b1-G4 for qemu-devel@nongnu.org; Mon, 16 Feb 2009 10:34:20 -0500 Received: from [199.232.76.173] (port=47471 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LZ5UC-0007ay-5E for qemu-devel@nongnu.org; Mon, 16 Feb 2009 10:34:20 -0500 Received: from savannah.gnu.org ([199.232.41.3]:42644 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LZ5UB-00056A-U8 for qemu-devel@nongnu.org; Mon, 16 Feb 2009 10:34:20 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LZ5UB-0006cr-ED for qemu-devel@nongnu.org; Mon, 16 Feb 2009 15:34:19 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LZ5UB-0006cn-56 for qemu-devel@nongnu.org; Mon, 16 Feb 2009 15:34:19 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Mon, 16 Feb 2009 15:34:19 +0000 Subject: [Qemu-devel] [6623] specify vmchannel as a net option (Gleb Natapov) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6623 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6623 Author: aliguori Date: 2009-02-16 15:34:18 +0000 (Mon, 16 Feb 2009) Log Message: ----------- specify vmchannel as a net option (Gleb Natapov) Signed-off-by: Gleb Natapov Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/net.c trunk/qemu-doc.texi Modified: trunk/net.c =================================================================== --- trunk/net.c 2009-02-16 14:59:35 UTC (rev 6622) +++ trunk/net.c 2009-02-16 15:34:18 UTC (rev 6623) @@ -670,6 +670,23 @@ slirp_stats(); } +struct VMChannel { + CharDriverState *hd; + int port; +} *vmchannels; + +static int vmchannel_can_read(void *opaque) +{ + struct VMChannel *vmc = (struct VMChannel*)opaque; + return slirp_socket_can_recv(4, vmc->port); +} + +static void vmchannel_read(void *opaque, const uint8_t *buf, int size) +{ + struct VMChannel *vmc = (struct VMChannel*)opaque; + slirp_socket_recv(4, vmc->port, buf, size); +} + #endif /* CONFIG_SLIRP */ #if !defined(_WIN32) @@ -1630,6 +1647,30 @@ } vlan->nb_host_devs++; ret = net_slirp_init(vlan, device, name); + } else if (!strcmp(device, "channel")) { + long port; + char name[20], *devname; + struct VMChannel *vmc; + + port = strtol(p, &devname, 10); + devname++; + if (port < 1 || port > 65535) { + fprintf(stderr, "vmchannel wrong port number\n"); + return -1; + } + vmc = malloc(sizeof(struct VMChannel)); + snprintf(name, 20, "vmchannel%ld", port); + vmc->hd = qemu_chr_open(name, devname, NULL); + if (!vmc->hd) { + fprintf(stderr, "qemu: could not open vmchannel device" + "'%s'\n", devname); + return -1; + } + vmc->port = port; + slirp_add_exec(3, vmc->hd, 4, port); + qemu_chr_add_handlers(vmc->hd, vmchannel_can_read, vmchannel_read, + NULL, vmc); + ret = 0; } else #endif #ifdef _WIN32 Modified: trunk/qemu-doc.texi =================================================================== --- trunk/qemu-doc.texi 2009-02-16 14:59:35 UTC (rev 6622) +++ trunk/qemu-doc.texi 2009-02-16 15:34:18 UTC (rev 6623) @@ -643,6 +643,9 @@ privilege to run. @option{hostname=name} can be used to specify the client hostname reported by the builtin DHCP server. +@item -net channel,@var{port}:@var{dev} +Forward @option{user} TCP connection to port @var{port} to character device @var{dev} + @item -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}] Connect the host TAP network interface @var{name} to VLAN @var{n}, use the network script @var{file} to configure it and the network script