diff options
author | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-02-16 15:34:18 +0000 |
---|---|---|
committer | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-02-16 15:34:18 +0000 |
commit | 8ca9217d04c070572a747e87288a0d36e44d5424 (patch) | |
tree | 99def423df2ece5f13e5cf7ce933fb2d4b778f24 | |
parent | d85d0d3883f5a567fa2969a0396e42e0a662b3fa (diff) | |
download | hqemu-8ca9217d04c070572a747e87288a0d36e44d5424.zip hqemu-8ca9217d04c070572a747e87288a0d36e44d5424.tar.gz |
specify vmchannel as a net option (Gleb Natapov)
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6623 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r-- | net.c | 41 | ||||
-rw-r--r-- | qemu-doc.texi | 3 |
2 files changed, 44 insertions, 0 deletions
@@ -670,6 +670,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) @@ -1630,6 +1647,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, 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 diff --git a/qemu-doc.texi b/qemu-doc.texi index efb88d2..8322a08 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -643,6 +643,9 @@ Use the user mode network stack which requires no administrator 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 |