From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LQ2AH-0003Kr-R2 for qemu-devel@nongnu.org; Thu, 22 Jan 2009 11:12:21 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LQ2AH-0003KT-5M for qemu-devel@nongnu.org; Thu, 22 Jan 2009 11:12:21 -0500 Received: from [199.232.76.173] (port=55424 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LQ2AG-0003KN-Uy for qemu-devel@nongnu.org; Thu, 22 Jan 2009 11:12:21 -0500 Received: from e8.ny.us.ibm.com ([32.97.182.138]:36311) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LQ2AG-0006pV-I6 for qemu-devel@nongnu.org; Thu, 22 Jan 2009 11:12:20 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e8.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n0MG698p026926 for ; Thu, 22 Jan 2009 11:06:09 -0500 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id n0MGCJ3I128520 for ; Thu, 22 Jan 2009 11:12:19 -0500 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n0MGCJKM029951 for ; Thu, 22 Jan 2009 11:12:19 -0500 Received: from squirrel.codemonkey.ws (sig-9-65-90-232.mts.ibm.com [9.65.90.232]) by d01av04.pok.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n0MGCIBU029861 for ; Thu, 22 Jan 2009 11:12:19 -0500 Message-ID: <49789AD7.5040507@us.ibm.com> Date: Thu, 22 Jan 2009 10:12:07 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [RESEND][PATCH] specify vmchannel as a net option References: <20090122142217.GA9389@redhat.com> In-Reply-To: <20090122142217.GA9389@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 Gleb Natapov wrote: > Another version. Try to maintain balance between command > line ugliness and parsing ugliness. > > To configure vmchannel use: > -net channel,666:unix:/tmp/666,server,nowait > > Signed-off-by: Gleb Natapov > Can you add some docs to qemu-doc.texi? Regards, Anthony Liguori > diff --git a/net.c b/net.c > index 86ee7d5..35728dd 100644 > --- a/net.c > +++ b/net.c > @@ -644,6 +644,23 @@ void do_info_slirp(void) > 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) > @@ -1604,6 +1621,30 @@ int net_client_init(const char *device, const char *p) > } > 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); > + 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 > -- > Gleb. > > > >