From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LC0hY-0002sN-GT for qemu-devel@nongnu.org; Sun, 14 Dec 2008 18:48:44 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LC0hW-0002pz-VJ for qemu-devel@nongnu.org; Sun, 14 Dec 2008 18:48:43 -0500 Received: from [199.232.76.173] (port=45471 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LC0hV-0002pl-Sv for qemu-devel@nongnu.org; Sun, 14 Dec 2008 18:48:42 -0500 Received: from hall.aurel32.net ([88.191.82.174]:38552) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LC0hU-0004cq-Pg for qemu-devel@nongnu.org; Sun, 14 Dec 2008 18:48:41 -0500 Date: Mon, 15 Dec 2008 00:48:35 +0100 From: Aurelien Jarno Subject: Re: [Qemu-devel] [PATCH 5/5] Add a -net name=foo parameter Message-ID: <20081214234835.GC8523@volta.aurel32.net> References: <1229093136.4041.25.camel@blaa> <1229093191-20618-1-git-send-email-markmc@redhat.com> <1229093191-20618-2-git-send-email-markmc@redhat.com> <1229093191-20618-3-git-send-email-markmc@redhat.com> <1229093191-20618-4-git-send-email-markmc@redhat.com> <1229093191-20618-5-git-send-email-markmc@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1229093191-20618-5-git-send-email-markmc@redhat.com> 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 Cc: Mark McLoughlin On Fri, Dec 12, 2008 at 02:46:31PM +0000, Mark McLoughlin wrote: > Allow the user to supply a vlan client name on the command line. > > This is probably only useful for management tools so that they can > use their own names rather than parsing the output of 'info network'. > > Signed-off-by: Mark McLoughlin > --- > hw/e1000.c | 2 +- > hw/eepro100.c | 2 +- > hw/etraxfs_eth.c | 2 +- > hw/mcf_fec.c | 2 +- > hw/mipsnet.c | 2 +- > hw/musicpal.c | 2 +- > hw/ne2000.c | 4 +- > hw/pcnet.c | 2 +- > hw/rtl8139.c | 2 +- > hw/smc91c111.c | 2 +- > hw/usb-net.c | 2 +- Looks like you have forget to convert at least hw/stellaris_enet.c, so the code doesn't compile. Otherwise the series looks good. > net.c | 97 +++++++++++++++++++++++++++++++++++------------------ > net.h | 2 + > qemu-doc.texi | 15 ++++---- > sysemu.h | 3 +- > tap-win32.c | 5 ++- > vl.c | 14 ++++---- > 17 files changed, 98 insertions(+), 62 deletions(-) > > diff --git a/hw/e1000.c b/hw/e1000.c > index 9b4dbbd..7c8824d 100644 > --- a/hw/e1000.c > +++ b/hw/e1000.c > @@ -1071,7 +1071,7 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) > d->rxbuf_min_shift = 1; > memset(&d->tx, 0, sizeof d->tx); > > - d->vc = qemu_new_vlan_client(nd->vlan, nd->model, > + d->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, > e1000_receive, e1000_can_receive, d); > > qemu_format_nic_info_str(d->vc, d->nd->macaddr); > diff --git a/hw/eepro100.c b/hw/eepro100.c > index 86a4e6e..5eca105 100644 > --- a/hw/eepro100.c > +++ b/hw/eepro100.c > @@ -1776,7 +1776,7 @@ static void nic_init(PCIBus * bus, NICInfo * nd, > > nic_reset(s); > > - s->vc = qemu_new_vlan_client(nd->vlan, nd->model, > + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, > nic_receive, nic_can_receive, s); > > qemu_format_nic_info_str(s->vc, s->macaddr); > diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c > index 244a23d..4bad3d2 100644 > --- a/hw/etraxfs_eth.c > +++ b/hw/etraxfs_eth.c > @@ -596,7 +596,7 @@ void *etraxfs_eth_init(NICInfo *nd, CPUState *env, > eth->ethregs = cpu_register_io_memory(0, eth_read, eth_write, eth); > cpu_register_physical_memory (base, 0x5c, eth->ethregs); > > - eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, > + eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, > eth_receive, eth_can_receive, eth); > > return dma; > diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c > index 7e3afa5..bb9f68f 100644 > --- a/hw/mcf_fec.c > +++ b/hw/mcf_fec.c > @@ -452,7 +452,7 @@ void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq) > mcf_fec_writefn, s); > cpu_register_physical_memory(base, 0x400, iomemtype); > > - s->vc = qemu_new_vlan_client(nd->vlan, nd->model, > + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, > mcf_fec_receive, mcf_fec_can_receive, s); > memcpy(s->macaddr, nd->macaddr, 6); > } > diff --git a/hw/mipsnet.c b/hw/mipsnet.c > index 4b3e8e9..0eb4c1e 100644 > --- a/hw/mipsnet.c > +++ b/hw/mipsnet.c > @@ -250,7 +250,7 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) > s->irq = irq; > s->nd = nd; > if (nd && nd->vlan) { > - s->vc = qemu_new_vlan_client(nd->vlan, nd->model, > + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, > mipsnet_receive, mipsnet_can_receive, s); > } else { > s->vc = NULL; > diff --git a/hw/musicpal.c b/hw/musicpal.c > index d172a11..1c932ec 100644 > --- a/hw/musicpal.c > +++ b/hw/musicpal.c > @@ -718,7 +718,7 @@ static void mv88w8618_eth_init(NICInfo *nd, uint32_t base, qemu_irq irq) > if (!s) > return; > s->irq = irq; > - s->vc = qemu_new_vlan_client(nd->vlan, nd->model, > + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, > eth_receive, eth_can_receive, s); > iomemtype = cpu_register_io_memory(0, mv88w8618_eth_readfn, > mv88w8618_eth_writefn, s); > diff --git a/hw/ne2000.c b/hw/ne2000.c > index ad97bc5..200db90 100644 > --- a/hw/ne2000.c > +++ b/hw/ne2000.c > @@ -741,7 +741,7 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd) > > ne2000_reset(s); > > - s->vc = qemu_new_vlan_client(nd->vlan, nd->model, > + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, > ne2000_receive, ne2000_can_receive, s); > > qemu_format_nic_info_str(s->vc, s->macaddr); > @@ -804,7 +804,7 @@ void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn) > s->pci_dev = (PCIDevice *)d; > memcpy(s->macaddr, nd->macaddr, 6); > ne2000_reset(s); > - s->vc = qemu_new_vlan_client(nd->vlan, nd->model, > + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, > ne2000_receive, ne2000_can_receive, s); > > qemu_format_nic_info_str(s->vc, s->macaddr); > diff --git a/hw/pcnet.c b/hw/pcnet.c > index 5b45956..102166e 100644 > --- a/hw/pcnet.c > +++ b/hw/pcnet.c > @@ -1936,7 +1936,7 @@ static void pcnet_common_init(PCNetState *d, NICInfo *nd, const char *info_str) > d->nd = nd; > > if (nd && nd->vlan) { > - d->vc = qemu_new_vlan_client(nd->vlan, nd->model, > + d->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, > pcnet_receive, pcnet_can_receive, d); > > qemu_format_nic_info_str(d->vc, d->nd->macaddr); > diff --git a/hw/rtl8139.c b/hw/rtl8139.c > index 4449fd2..5805795 100644 > --- a/hw/rtl8139.c > +++ b/hw/rtl8139.c > @@ -3438,7 +3438,7 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn) > s->pci_dev = (PCIDevice *)d; > memcpy(s->macaddr, nd->macaddr, 6); > rtl8139_reset(s); > - s->vc = qemu_new_vlan_client(nd->vlan, nd->model, > + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, > rtl8139_receive, rtl8139_can_receive, s); > > qemu_format_nic_info_str(s->vc, s->macaddr); > diff --git a/hw/smc91c111.c b/hw/smc91c111.c > index fadd151..2ee6701 100644 > --- a/hw/smc91c111.c > +++ b/hw/smc91c111.c > @@ -704,7 +704,7 @@ void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq) > > smc91c111_reset(s); > > - s->vc = qemu_new_vlan_client(nd->vlan, nd->model, > + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, > smc91c111_receive, smc91c111_can_receive, s); > /* ??? Save/restore. */ > } > diff --git a/hw/usb-net.c b/hw/usb-net.c > index 95ebac8..947461c 100644 > --- a/hw/usb-net.c > +++ b/hw/usb-net.c > @@ -1454,7 +1454,7 @@ USBDevice *usb_net_init(NICInfo *nd) > > pstrcpy(s->dev.devname, sizeof(s->dev.devname), > "QEMU USB Network Interface"); > - s->vc = qemu_new_vlan_client(nd->vlan, nd->model, > + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, > usbnet_receive, usbnet_can_receive, s); > > qemu_format_nic_info_str(s->vc, s->mac); > diff --git a/net.c b/net.c > index 69f6546..414affb 100644 > --- a/net.c > +++ b/net.c > @@ -333,6 +333,7 @@ static char *assign_name(VLANClientState *vc1, const char *model) > > VLANClientState *qemu_new_vlan_client(VLANState *vlan, > const char *model, > + const char *name, > IOReadHandler *fd_read, > IOCanRWHandler *fd_can_read, > void *opaque) > @@ -342,7 +343,10 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan, > if (!vc) > return NULL; > vc->model = strdup(model); > - vc->name = assign_name(vc, model); > + if (name) > + vc->name = strdup(name); > + else > + vc->name = assign_name(vc, model); > vc->fd_read = fd_read; > vc->fd_can_read = fd_can_read; > vc->opaque = opaque; > @@ -438,13 +442,13 @@ static void slirp_receive(void *opaque, const uint8_t *buf, int size) > slirp_input(buf, size); > } > > -static int net_slirp_init(VLANState *vlan, const char *model) > +static int net_slirp_init(VLANState *vlan, const char *model, const char *name) > { > if (!slirp_inited) { > slirp_inited = 1; > slirp_init(); > } > - slirp_vc = qemu_new_vlan_client(vlan, model, > + slirp_vc = qemu_new_vlan_client(vlan, model, name, > slirp_receive, NULL, NULL); > slirp_vc->info_str[0] = '\0'; > return 0; > @@ -643,7 +647,10 @@ static void tap_send(void *opaque) > > /* fd support */ > > -static TAPState *net_tap_fd_init(VLANState *vlan, const char *model, int fd) > +static TAPState *net_tap_fd_init(VLANState *vlan, > + const char *model, > + const char *name, > + int fd) > { > TAPState *s; > > @@ -651,7 +658,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan, const char *model, int fd) > if (!s) > return NULL; > s->fd = fd; > - s->vc = qemu_new_vlan_client(vlan, model, tap_receive, NULL, s); > + s->vc = qemu_new_vlan_client(vlan, model, name, tap_receive, NULL, s); > qemu_set_fd_handler(s->fd, tap_send, NULL, s); > snprintf(s->vc->info_str, sizeof(s->vc->info_str), "fd=%d", fd); > return s; > @@ -883,7 +890,8 @@ static int launch_script(const char *setup_script, const char *ifname, int fd) > return 0; > } > > -static int net_tap_init(VLANState *vlan, const char *model, const char *ifname1, > +static int net_tap_init(VLANState *vlan, const char *model, > + const char *name, const char *ifname1, > const char *setup_script, const char *down_script) > { > TAPState *s; > @@ -904,7 +912,7 @@ static int net_tap_init(VLANState *vlan, const char *model, const char *ifname1, > if (launch_script(setup_script, ifname, fd)) > return -1; > } > - s = net_tap_fd_init(vlan, model, fd); > + s = net_tap_fd_init(vlan, model, name, fd); > if (!s) > return -1; > snprintf(s->vc->info_str, sizeof(s->vc->info_str), > @@ -948,7 +956,8 @@ static void vde_from_qemu(void *opaque, const uint8_t *buf, int size) > } > } > > -static int net_vde_init(VLANState *vlan, const char *model, const char *sock, > +static int net_vde_init(VLANState *vlan, const char *model, > + const char *name, const char *sock, > int port, const char *group, int mode) > { > VDEState *s; > @@ -969,7 +978,7 @@ static int net_vde_init(VLANState *vlan, const char *model, const char *sock, > free(s); > return -1; > } > - s->vc = qemu_new_vlan_client(vlan, model, vde_from_qemu, NULL, s); > + s->vc = qemu_new_vlan_client(vlan, model, name, vde_from_qemu, NULL, s); > qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s); > snprintf(s->vc->info_str, sizeof(s->vc->info_str), "sock=%s,fd=%d", > sock, vde_datafd(s->vde)); > @@ -991,6 +1000,7 @@ typedef struct NetSocketState { > typedef struct NetSocketListenState { > VLANState *vlan; > char *model; > + char *name; > int fd; > } NetSocketListenState; > > @@ -1144,7 +1154,9 @@ fail: > return -1; > } > > -static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, const char *model, > +static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, > + const char *model, > + const char *name, > int fd, int is_connected) > { > struct sockaddr_in saddr; > @@ -1188,7 +1200,7 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, const char *mod > return NULL; > s->fd = fd; > > - s->vc = qemu_new_vlan_client(vlan, model, net_socket_receive_dgram, NULL, s); > + s->vc = qemu_new_vlan_client(vlan, model, name, net_socket_receive_dgram, NULL, s); > qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s); > > /* mcast: save bound address as dst */ > @@ -1207,7 +1219,9 @@ static void net_socket_connect(void *opaque) > qemu_set_fd_handler(s->fd, net_socket_send, NULL, s); > } > > -static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, const char *model, > +static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, > + const char *model, > + const char *name, > int fd, int is_connected) > { > NetSocketState *s; > @@ -1215,7 +1229,7 @@ static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, const char *mo > if (!s) > return NULL; > s->fd = fd; > - s->vc = qemu_new_vlan_client(vlan, model, > + s->vc = qemu_new_vlan_client(vlan, model, name, > net_socket_receive, NULL, s); > snprintf(s->vc->info_str, sizeof(s->vc->info_str), > "socket: fd=%d", fd); > @@ -1227,7 +1241,8 @@ static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, const char *mo > return s; > } > > -static NetSocketState *net_socket_fd_init(VLANState *vlan, const char *model, > +static NetSocketState *net_socket_fd_init(VLANState *vlan, > + const char *model, const char *name, > int fd, int is_connected) > { > int so_type=-1, optlen=sizeof(so_type); > @@ -1239,13 +1254,13 @@ static NetSocketState *net_socket_fd_init(VLANState *vlan, const char *model, > } > switch(so_type) { > case SOCK_DGRAM: > - return net_socket_fd_init_dgram(vlan, model, fd, is_connected); > + return net_socket_fd_init_dgram(vlan, model, name, fd, is_connected); > case SOCK_STREAM: > - return net_socket_fd_init_stream(vlan, model, fd, is_connected); > + return net_socket_fd_init_stream(vlan, model, name, fd, is_connected); > default: > /* who knows ... this could be a eg. a pty, do warn and continue as stream */ > fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", so_type, fd); > - return net_socket_fd_init_stream(vlan, model, fd, is_connected); > + return net_socket_fd_init_stream(vlan, model, name, fd, is_connected); > } > return NULL; > } > @@ -1267,7 +1282,7 @@ static void net_socket_accept(void *opaque) > break; > } > } > - s1 = net_socket_fd_init(s->vlan, s->model, fd, 1); > + s1 = net_socket_fd_init(s->vlan, s->model, s->name, fd, 1); > if (!s1) { > closesocket(fd); > } else { > @@ -1277,7 +1292,9 @@ static void net_socket_accept(void *opaque) > } > } > > -static int net_socket_listen_init(VLANState *vlan, const char *model, > +static int net_socket_listen_init(VLANState *vlan, > + const char *model, > + const char *name, > const char *host_str) > { > NetSocketListenState *s; > @@ -1314,12 +1331,15 @@ static int net_socket_listen_init(VLANState *vlan, const char *model, > } > s->vlan = vlan; > s->model = strdup(model); > + s->name = strdup(name); > s->fd = fd; > qemu_set_fd_handler(fd, net_socket_accept, NULL, s); > return 0; > } > > -static int net_socket_connect_init(VLANState *vlan, const char *model, > +static int net_socket_connect_init(VLANState *vlan, > + const char *model, > + const char *name, > const char *host_str) > { > NetSocketState *s; > @@ -1358,7 +1378,7 @@ static int net_socket_connect_init(VLANState *vlan, const char *model, > break; > } > } > - s = net_socket_fd_init(vlan, model, fd, connected); > + s = net_socket_fd_init(vlan, model, name, fd, connected); > if (!s) > return -1; > snprintf(s->vc->info_str, sizeof(s->vc->info_str), > @@ -1367,7 +1387,9 @@ static int net_socket_connect_init(VLANState *vlan, const char *model, > return 0; > } > > -static int net_socket_mcast_init(VLANState *vlan, const char *model, > +static int net_socket_mcast_init(VLANState *vlan, > + const char *model, > + const char *name, > const char *host_str) > { > NetSocketState *s; > @@ -1382,7 +1404,7 @@ static int net_socket_mcast_init(VLANState *vlan, const char *model, > if (fd < 0) > return -1; > > - s = net_socket_fd_init(vlan, model, fd, 0); > + s = net_socket_fd_init(vlan, model, name, fd, 0); > if (!s) > return -1; > > @@ -1420,6 +1442,7 @@ int net_client_init(const char *device, const char *p) > char buf[1024]; > int vlan_id, ret; > VLANState *vlan; > + char *name = NULL; > > vlan_id = 0; > if (get_param_value(buf, sizeof(buf), "vlan", p)) { > @@ -1430,6 +1453,9 @@ int net_client_init(const char *device, const char *p) > fprintf(stderr, "Could not create vlan %d\n", vlan_id); > return -1; > } > + if (get_param_value(buf, sizeof(buf), "name", p)) { > + name = strdup(buf); > + } > if (!strcmp(device, "nic")) { > NICInfo *nd; > uint8_t *macaddr; > @@ -1457,6 +1483,8 @@ int net_client_init(const char *device, const char *p) > nd->model = strdup(buf); > } > nd->vlan = vlan; > + nd->name = name; > + name = NULL; > nb_nics++; > vlan->nb_guest_devs++; > ret = 0; > @@ -1472,7 +1500,7 @@ int net_client_init(const char *device, const char *p) > pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf); > } > vlan->nb_host_devs++; > - ret = net_slirp_init(vlan, device); > + ret = net_slirp_init(vlan, device, name); > } else > #endif > #ifdef _WIN32 > @@ -1483,7 +1511,7 @@ int net_client_init(const char *device, const char *p) > return -1; > } > vlan->nb_host_devs++; > - ret = tap_win32_init(vlan, device, ifname); > + ret = tap_win32_init(vlan, device, name, ifname); > } else > #elif defined (_AIX) > #else > @@ -1496,7 +1524,7 @@ int net_client_init(const char *device, const char *p) > fd = strtol(buf, NULL, 0); > fcntl(fd, F_SETFL, O_NONBLOCK); > ret = -1; > - if (net_tap_fd_init(vlan, device, fd)) > + if (net_tap_fd_init(vlan, device, name, fd)) > ret = 0; > } else { > if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { > @@ -1508,7 +1536,7 @@ int net_client_init(const char *device, const char *p) > if (get_param_value(down_script, sizeof(down_script), "downscript", p) == 0) { > pstrcpy(down_script, sizeof(down_script), DEFAULT_NETWORK_DOWN_SCRIPT); > } > - ret = net_tap_init(vlan, device, ifname, setup_script, down_script); > + ret = net_tap_init(vlan, device, name, ifname, setup_script, down_script); > } > } else > #endif > @@ -1517,14 +1545,14 @@ int net_client_init(const char *device, const char *p) > int fd; > fd = strtol(buf, NULL, 0); > ret = -1; > - if (net_socket_fd_init(vlan, device, fd, 1)) > + if (net_socket_fd_init(vlan, device, name, fd, 1)) > ret = 0; > } else if (get_param_value(buf, sizeof(buf), "listen", p) > 0) { > - ret = net_socket_listen_init(vlan, device, buf); > + ret = net_socket_listen_init(vlan, device, name, buf); > } else if (get_param_value(buf, sizeof(buf), "connect", p) > 0) { > - ret = net_socket_connect_init(vlan, device, buf); > + ret = net_socket_connect_init(vlan, device, name, buf); > } else if (get_param_value(buf, sizeof(buf), "mcast", p) > 0) { > - ret = net_socket_mcast_init(vlan, device, buf); > + ret = net_socket_mcast_init(vlan, device, name, buf); > } else { > fprintf(stderr, "Unknown socket options: %s\n", p); > return -1; > @@ -1552,17 +1580,20 @@ int net_client_init(const char *device, const char *p) > } else { > vde_mode = 0700; > } > - ret = net_vde_init(vlan, device, vde_sock, vde_port, vde_group, vde_mode); > + ret = net_vde_init(vlan, device, name, vde_sock, vde_port, vde_group, vde_mode); > } else > #endif > { > fprintf(stderr, "Unknown network device: %s\n", device); > + if (name) > + free(name); > return -1; > } > if (ret < 0) { > fprintf(stderr, "Could not initialize device '%s'\n", device); > } > - > + if (name) > + free(name); > return ret; > } > > diff --git a/net.h b/net.h > index 244f80b..bb4dce3 100644 > --- a/net.h > +++ b/net.h > @@ -28,6 +28,7 @@ struct VLANState { > VLANState *qemu_find_vlan(int id); > VLANClientState *qemu_new_vlan_client(VLANState *vlan, > const char *model, > + const char *name, > IOReadHandler *fd_read, > IOCanRWHandler *fd_can_read, > void *opaque); > @@ -46,6 +47,7 @@ void do_info_network(void); > struct NICInfo { > uint8_t macaddr[6]; > const char *model; > + const char *name; > VLANState *vlan; > }; > > diff --git a/qemu-doc.texi b/qemu-doc.texi > index 377e384..bb36fe7 100644 > --- a/qemu-doc.texi > +++ b/qemu-doc.texi > @@ -604,10 +604,11 @@ Network options: > > @table @option > > -@item -net nic[,vlan=@var{n}][,macaddr=@var{addr}][,model=@var{type}] > +@item -net nic[,vlan=@var{n}][,macaddr=@var{addr}][,model=@var{type}][,name=@var{name}] > Create a new Network Interface Card and connect it to VLAN @var{n} (@var{n} > = 0 is the default). The NIC is an ne2k_pci by default on the PC > -target. Optionally, the MAC address can be changed. If no > +target. Optionally, the MAC address can be changed to @var{addr} > +and a @var{name} can be assigned for use in monitor commands. If no > @option{-net} option is specified, a single NIC is created. > Qemu can emulate several different models of network card. > Valid values for @var{type} are > @@ -617,12 +618,12 @@ Valid values for @var{type} are > Not all devices are supported on all targets. Use -net nic,model=? > for a list of available devices for your target. > > -@item -net user[,vlan=@var{n}][,hostname=@var{name}] > +@item -net user[,vlan=@var{n}][,hostname=@var{name}][,name=@var{name}] > 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 tap[,vlan=@var{n}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}] > +@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 > @var{dfile} to deconfigure it. If @var{name} is not provided, the OS > @@ -643,7 +644,7 @@ qemu linux.img -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \ > @end example > > > -@item -net socket[,vlan=@var{n}][,fd=@var{h}][,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}] > +@item -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}] > > Connect the VLAN @var{n} to a remote VLAN in another QEMU virtual > machine using a TCP socket connection. If @option{listen} is > @@ -663,7 +664,7 @@ qemu linux.img -net nic,macaddr=52:54:00:12:34:57 \ > -net socket,connect=127.0.0.1:1234 > @end example > > -@item -net socket[,vlan=@var{n}][,fd=@var{h}][,mcast=@var{maddr}:@var{port}] > +@item -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,mcast=@var{maddr}:@var{port}] > > Create a VLAN @var{n} shared with another QEMU virtual > machines using a UDP multicast socket, effectively making a bus for > @@ -703,7 +704,7 @@ qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \ > /path/to/linux ubd0=/path/to/root_fs eth0=mcast > @end example > > -@item -net vde[,vlan=@var{n}][,sock=@var{socketpath}][,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}] > +@item -net vde[,vlan=@var{n}][,name=@var{name}][,sock=@var{socketpath}][,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}] > Connect VLAN @var{n} to PORT @var{n} of a vde switch running on host and > listening for incoming connections on @var{socketpath}. Use GROUP @var{groupname} > and MODE @var{octalmode} to change default ownership and permissions for > diff --git a/sysemu.h b/sysemu.h > index 8ce3900..cac9a95 100644 > --- a/sysemu.h > +++ b/sysemu.h > @@ -75,7 +75,8 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); > #endif > > /* TAP win32 */ > -int tap_win32_init(VLANState *vlan, const char *model, const char *ifname); > +int tap_win32_init(VLANState *vlan, const char *model, > + const char *name, const char *ifname); > > /* SLIRP */ > void do_info_slirp(void); > diff --git a/tap-win32.c b/tap-win32.c > index ee9e23f..da3283e 100644 > --- a/tap-win32.c > +++ b/tap-win32.c > @@ -660,7 +660,8 @@ static void tap_win32_send(void *opaque) > } > } > > -int tap_win32_init(VLANState *vlan, const char *model, const char *ifname) > +int tap_win32_init(VLANState *vlan, const char *model, > + const char *name, const char *ifname) > { > TAPState *s; > > @@ -672,7 +673,7 @@ int tap_win32_init(VLANState *vlan, const char *model, const char *ifname) > return -1; > } > > - s->vc = qemu_new_vlan_client(vlan, model, tap_receive, NULL, s); > + s->vc = qemu_new_vlan_client(vlan, model, name, tap_receive, NULL, s); > > snprintf(s->vc->info_str, sizeof(s->vc->info_str), > "tap: ifname=%s", ifname); > diff --git a/vl.c b/vl.c > index c3a8d8f..bf7d78c 100644 > --- a/vl.c > +++ b/vl.c > @@ -3878,30 +3878,30 @@ static void help(int exitcode) > "-uuid %%08x-%%04x-%%04x-%%04x-%%012x specify machine UUID\n" > "\n" > "Network options:\n" > - "-net nic[,vlan=n][,macaddr=addr][,model=type]\n" > + "-net nic[,vlan=n][,macaddr=addr][,model=type][,name=str]\n" > " create a new Network Interface Card and connect it to VLAN 'n'\n" > #ifdef CONFIG_SLIRP > - "-net user[,vlan=n][,hostname=host]\n" > + "-net user[,vlan=n][,name=str][,hostname=host]\n" > " connect the user mode network stack to VLAN 'n' and send\n" > " hostname 'host' to DHCP clients\n" > #endif > #ifdef _WIN32 > - "-net tap[,vlan=n],ifname=name\n" > + "-net tap[,vlan=n][,name=str],ifname=name\n" > " connect the host TAP network interface to VLAN 'n'\n" > #else > - "-net tap[,vlan=n][,fd=h][,ifname=name][,script=file][,downscript=dfile]\n" > + "-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile]\n" > " connect the host TAP network interface to VLAN 'n' and use the\n" > " network scripts 'file' (default=%s)\n" > " and 'dfile' (default=%s);\n" > " use '[down]script=no' to disable script execution;\n" > " use 'fd=h' to connect to an already opened TAP interface\n" > #endif > - "-net socket[,vlan=n][,fd=h][,listen=[host]:port][,connect=host:port]\n" > + "-net socket[,vlan=n][,name=str][,fd=h][,listen=[host]:port][,connect=host:port]\n" > " connect the vlan 'n' to another VLAN using a socket connection\n" > - "-net socket[,vlan=n][,fd=h][,mcast=maddr:port]\n" > + "-net socket[,vlan=n][,name=str][,fd=h][,mcast=maddr:port]\n" > " connect the vlan 'n' to multicast maddr and port\n" > #ifdef CONFIG_VDE > - "-net vde[,vlan=n][,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]\n" > + "-net vde[,vlan=n][,name=str][,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]\n" > " connect the vlan 'n' to port 'n' of a vde switch running\n" > " on host and listening for incoming connections on 'socketpath'.\n" > " Use group 'groupname' and mode 'octalmode' to change default\n" > -- > 1.5.4.3 > > > > -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net