Commit 8ca9217d04c070572a747e87288a0d36e44d5424
1 parent
d85d0d38
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
Showing
2 changed files
with
44 additions
and
0 deletions
net.c
... | ... | @@ -670,6 +670,23 @@ void do_info_slirp(void) |
670 | 670 | slirp_stats(); |
671 | 671 | } |
672 | 672 | |
673 | +struct VMChannel { | |
674 | + CharDriverState *hd; | |
675 | + int port; | |
676 | +} *vmchannels; | |
677 | + | |
678 | +static int vmchannel_can_read(void *opaque) | |
679 | +{ | |
680 | + struct VMChannel *vmc = (struct VMChannel*)opaque; | |
681 | + return slirp_socket_can_recv(4, vmc->port); | |
682 | +} | |
683 | + | |
684 | +static void vmchannel_read(void *opaque, const uint8_t *buf, int size) | |
685 | +{ | |
686 | + struct VMChannel *vmc = (struct VMChannel*)opaque; | |
687 | + slirp_socket_recv(4, vmc->port, buf, size); | |
688 | +} | |
689 | + | |
673 | 690 | #endif /* CONFIG_SLIRP */ |
674 | 691 | |
675 | 692 | #if !defined(_WIN32) |
... | ... | @@ -1630,6 +1647,30 @@ int net_client_init(const char *device, const char *p) |
1630 | 1647 | } |
1631 | 1648 | vlan->nb_host_devs++; |
1632 | 1649 | ret = net_slirp_init(vlan, device, name); |
1650 | + } else if (!strcmp(device, "channel")) { | |
1651 | + long port; | |
1652 | + char name[20], *devname; | |
1653 | + struct VMChannel *vmc; | |
1654 | + | |
1655 | + port = strtol(p, &devname, 10); | |
1656 | + devname++; | |
1657 | + if (port < 1 || port > 65535) { | |
1658 | + fprintf(stderr, "vmchannel wrong port number\n"); | |
1659 | + return -1; | |
1660 | + } | |
1661 | + vmc = malloc(sizeof(struct VMChannel)); | |
1662 | + snprintf(name, 20, "vmchannel%ld", port); | |
1663 | + vmc->hd = qemu_chr_open(name, devname, NULL); | |
1664 | + if (!vmc->hd) { | |
1665 | + fprintf(stderr, "qemu: could not open vmchannel device" | |
1666 | + "'%s'\n", devname); | |
1667 | + return -1; | |
1668 | + } | |
1669 | + vmc->port = port; | |
1670 | + slirp_add_exec(3, vmc->hd, 4, port); | |
1671 | + qemu_chr_add_handlers(vmc->hd, vmchannel_can_read, vmchannel_read, | |
1672 | + NULL, vmc); | |
1673 | + ret = 0; | |
1633 | 1674 | } else |
1634 | 1675 | #endif |
1635 | 1676 | #ifdef _WIN32 | ... | ... |
qemu-doc.texi
... | ... | @@ -643,6 +643,9 @@ Use the user mode network stack which requires no administrator |
643 | 643 | privilege to run. @option{hostname=name} can be used to specify the client |
644 | 644 | hostname reported by the builtin DHCP server. |
645 | 645 | |
646 | +@item -net channel,@var{port}:@var{dev} | |
647 | +Forward @option{user} TCP connection to port @var{port} to character device @var{dev} | |
648 | + | |
646 | 649 | @item -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}] |
647 | 650 | Connect the host TAP network interface @var{name} to VLAN @var{n}, use |
648 | 651 | the network script @var{file} to configure it and the network script | ... | ... |