Add nic link up/down emulation to e1000
cover Add nic link up/down emulation to e1000
Hi,
Here's a small patch set which adds link up/down
emulation to e1000 via a "set_link" monitor command. This is useful for people who want to e.g. test how applications and/or the guest OS handles this condition.
The command itself takes a VLAN ID and device index
in order to identify which device to modify. That's a bit lame and could clearly by improved if the overall idea was thought to be sound.
Thanks,
Mark.
PATCH 1/4 Add 'set_link' monitor command
Add a monitor command to setting a given network device's link status to 'up' or 'down'.
Allows simulation of network cable disconnect.
--- monitor.c | 1 + net.c | 41 ++++++++++++++++++++++++++++++++++++++++- net.h | 2 ++ 3 files changed, 43 insertions(+), 1 deletions(-)
monitor.c +1 -0
@@ -1497,6 +1497,7 @@ static const term_cmd_t term_cmds[] = { "value", "set maximum speed (in bytes) for migrations" }, {"balloon" ,"i" , do_balloon, "target", "request VM to change it's memory allocation (in MB)" }, + { "set_link", "iis", do_set_link, "vlan_id dev_idx [up|down]" }, { NULL, NULL, }, };
net.c +40 -1
58 lines not on this page · raw message
net.h +2 -0
@@ -10,6 +10,7 @@ struct VLANClientState {/* Packets may still be sent if this returns zero. It's used to rate-limit the slirp code. */ IOCanRWHandler *fd_can_read; +int link_down;void *opaque;struct VLANClientState *next;struct VLANState *vlan;
@@ -34,6 +35,7 @@ void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size);void qemu_handler_true (void *opaque);void do_info_network (void ); +int do_set_link (int vlan_id,int device_idx,const char *up_or_down);/* NIC info */
Signature · 1 line
1.5.4.3
PATCH 2/4 Add device index to 'info network' output
The 'set_link' command requires the user to specify a device index.
--- net.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
net.c +2 -1
@@ -1557,9 +1557,10 @@ void do_info_network(void)VLANClientState *vc;for (vlan = first_vlan; vlan !=NULL ; vlan = vlan->next) { +int i =0 ;term_printf ("VLAN %d devices:\n" , vlan->id);for (vc = vlan->first_client; vc !=NULL ; vc = vc->next) -term_printf (" %s\n" , vc->info_str); +term_printf (" %d %s\n" , i++, vc->info_str); } }
Signature · 1 line
1.5.4.3
PATCH 3/4 Allow devices be notified of link status change
--- net.c | 3 +++ net.h | 3 +++ 2 files changed, 6 insertions(+), 0 deletions(-)
net.c +3 -0
@@ -1597,6 +1597,9 @@ int do_set_link(int vlan_id, int device_idx, const char *up_or_down)term_printf ("invalid link status '%s'; only 'up' or 'down' valid\n" , up_or_down); +if (vc->link_status_changed) + vc->link_status_changed (vc); +return 1 ; }
net.h +3 -0
@@ -5,11 +5,14 @@typedef struct VLANClientState VLANClientState ; +typedef void (LinkStatusChanged )(VLANClientState *); +struct VLANClientState {IOReadHandler *fd_read;/* Packets may still be sent if this returns zero. It's used to rate-limit the slirp code. */ IOCanRWHandler *fd_can_read; +LinkStatusChanged *link_status_changed;int link_down;void *opaque;struct VLANClientState *next;
Signature · 1 line
1.5.4.3
PATCH 4/4 Implement e1000 link status
On link up or down we set the E1000_STATUS_LU ("link up") bit in the status register and set the E1000_ICR_LSC ("link status changed") bit in the interrupt cause register before interrupting the guest.
--- hw/e1000.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
hw/e1000.c +16 -0
@@ -570,6 +570,21 @@ receive_filter(E1000State *s, const uint8_t *buf, int size)return 0 ; } +static void +e1000_set_link_status (VLANClientState *vc) +{ +E1000State *s = vc->opaque; +uint32_t old_status = s->mac_reg[STATUS ]; + +if (vc->link_down) + s->mac_reg[STATUS ] &= ~E1000_STATUS_LU ; +else + s->mac_reg[STATUS ] |=E1000_STATUS_LU ; + +if (s->mac_reg[STATUS ] != old_status) +set_ics (s,0 ,E1000_ICR_LSC ); +} +static int e1000_can_receive (void *opaque) {
@@ -1061,6 +1076,7 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) d->vc =qemu_new_vlan_client (nd->vlan, e1000_receive, e1000_can_receive, d); + d->vc->link_status_changed = e1000_set_link_status; snprintf(d->vc->info_str, sizeof(d->vc->info_str), "%s macaddr=%02x:%02x:%02x:%02x:%02x:%02x", info_str,
Signature · 1 line
1.5.4.3
[Qemu-devel] Re: [PATCH 2/4] Add device index to 'info network' output
In reply to Mark McLoughlinQuoted 12 lines · Mark McLoughlin
The '
set_link' command requires the user to specify a device index.Signed-off-by Mark McLoughlin <[email protected]>--- net.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)net.c +0
-0
net.c void do_info_network(void) · line 1564
Quoted 9 lines
net.c +2
-1@@ -1557,9 +1557,10 @@ void do_info_network(void)VLANClientState *vc;for (vlan = first_vlan; vlan !=NULL ; vlan = vlan->next) { +int i =0 ;term_printf ("VLAN %d devices:\n" , vlan->id);for (vc = vlan->first_client; vc !=NULL ; vc = vc->next) -term_printf (" %s\n" , vc->info_str); +term_printf (" %d %s\n" , i++, vc->info_str);
This info command is unfortunately not very well formed, but I still think you should do " id=%d %s\n", i++, vc->info_str.
Regards,
Anthony Liguori
Quoted 4 lines
net.c +0
-0} }
[Qemu-devel] Re: [PATCH 1/4] Add 'set_link' monitor command
In reply to Mark McLoughlinQuoted 17 lines · Mark McLoughlin
Add a monitor command to setting a given network device's link status to 'up' or 'down'.
Allows simulation of network cable disconnect.
Signed-off-by Mark McLoughlin <[email protected]>--- monitor.c | 1 + net.c | 41 ++++++++++++++++++++++++++++++++++++++++- net.h | 2 ++ 3 files changed, 43 insertions(+), 1 deletions(-)monitor.c +0
-0
monitor.c static const term_cmd_t term_cmds[] = { · line 1503
Quoted 7 lines
monitor.c +1
-0@@ -1497,6 +1497,7 @@ static const term_cmd_t term_cmds[] = { "value", "set maximum speed (in bytes) for migrations" }, {"balloon" ,"i" , do_balloon, "target", "request VM to change it's memory allocation (in MB)" }, + { "set_link", "iis", do_set_link, "vlan_id dev_idx [up|down]" }, { NULL, NULL, }, };
This command seems reasonable to me but the dev_idx thing is a bit too hacky.
monitor.c
Quoted 4 lines
monitor.c +3
-0+for (vc = vlan->first_client; vc !=NULL ; vc = vc->next) +if (i++ == device_idx) +break ;
I think a better way would be to allow a user to specify an id for the nic that gets saved early on. info nics should print the id and a default id should be assigned. I think you could argue either way as to whether the ids should be vlan local or global.
I sort of think that making them global has a number of advantages. You could also use a string to identify the nics globally, it's up to you.
Regards,
Anthony Liguori
[Qemu-devel] Re: [PATCH 1/4] Add 'set_link' monitor command
Quoted 5 lines · Anthony Liguori
net.c void do_info_network(void) · line 1583
Quoted 4 lines
net.c +3
-0+for (vc = vlan->first_client; vc !=NULL ; vc = vc->next) +if (i++ == device_idx) +break ;
Quoted 7 lines
I think a better way would be to allow a user to specify an id for the nic that gets saved early on. info nics should print the id and a default id should be assigned. I think you could argue either way as to whether the ids should be vlan local or global.
I sort of think that making them global has a number of advantages. You could also use a string to identify the nics globally, it's up to you.
Okay, here's a few patches to add a vlan client name.
I'll repost the set_link patches once we agree on this part.
Cheers,
Mark.
PATCH 1/5 Add a model string to VLANClientState
Don't lose track of what type/model a vlan client is so that we can e.g. assign a global per-model id to clients.
The entire patch is basically a tedious excercise in making sure the type/model string gets propagated down to qemu_new_vlan_client().
--- hw/e1000.c | 4 +- hw/eepro100.c | 3 +- hw/etraxfs_eth.c | 2 +- hw/mcf_fec.c | 4 +- hw/mipsnet.c | 4 +- hw/musicpal.c | 3 +- hw/ne2000.c | 8 ++-- hw/pcnet.c | 4 +- hw/rtl8139.c | 4 +- hw/smc91c111.c | 4 +- hw/stellaris_enet.c | 4 +- hw/usb-net.c | 2 +- net.c | 78 ++++++++++++++++++++++++++++----------------------- net.h | 2 + sysemu.h | 2 +- tap-win32.c | 4 +- 16 files changed, 72 insertions(+), 60 deletions(-)
hw/e1000.c +2 -2
@@ -1071,8 +1071,8 @@ 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, e1000_receive, - e1000_can_receive, d); + d->vc =qemu_new_vlan_client (nd->vlan, nd->model, + e1000_receive, e1000_can_receive, d); snprintf(d->vc->info_str, sizeof(d->vc->info_str), "%s macaddr=%02x:%02x:%02x:%02x:%02x:%02x", info_str,
hw/eepro100.c +2 -1
@@ -1776,7 +1776,8 @@ static void nic_init(PCIBus * bus, NICInfo * nd,nic_reset (s); - s->vc =qemu_new_vlan_client (nd->vlan, nic_receive, nic_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + nic_receive, nic_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "eepro100 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
hw/etraxfs_eth.c +1 -1
@@ -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, + eth->vc =qemu_new_vlan_client (nd->vlan, nd->model, eth_receive, eth_can_receive, eth);return dma;
hw/mcf_fec.c +2 -2
@@ -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, mcf_fec_receive, - mcf_fec_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + mcf_fec_receive, mcf_fec_can_receive, s);memcpy (s->macaddr, nd->macaddr,6 ); }
hw/mipsnet.c +2 -2
@@ -250,8 +250,8 @@ 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, mipsnet_receive, - mipsnet_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + mipsnet_receive, mipsnet_can_receive, s); }else { s->vc =NULL ; }
hw/musicpal.c +2 -1
@@ -718,7 +718,8 @@ 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, eth_receive, eth_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + eth_receive, eth_can_receive, s); iomemtype =cpu_register_io_memory (0 , mv88w8618_eth_readfn, mv88w8618_eth_writefn, s);cpu_register_physical_memory (base,MP_ETH_SIZE , iomemtype);
hw/ne2000.c +4 -4
@@ -741,8 +741,8 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)ne2000_reset (s); - s->vc =qemu_new_vlan_client (nd->vlan, ne2000_receive, - ne2000_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + ne2000_receive, ne2000_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "ne2000 macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
@@ -811,8 +811,8 @@ 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, ne2000_receive, - ne2000_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + ne2000_receive, ne2000_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "ne2000 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
hw/pcnet.c +2 -2
@@ -1936,8 +1936,8 @@ 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, pcnet_receive, - pcnet_can_receive, d); + d->vc =qemu_new_vlan_client (nd->vlan, nd->model, + pcnet_receive, pcnet_can_receive, d); snprintf(d->vc->info_str, sizeof(d->vc->info_str), "pcnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
hw/rtl8139.c +2 -2
@@ -3438,8 +3438,8 @@ 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, rtl8139_receive, - rtl8139_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + rtl8139_receive, rtl8139_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "rtl8139 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
hw/smc91c111.c +2 -2
@@ -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, smc91c111_receive, - smc91c111_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + smc91c111_receive, smc91c111_can_receive, s);/* ??? Save/restore. */ }
hw/stellaris_enet.c +2 -2
@@ -397,8 +397,8 @@ void stellaris_enet_init(NICInfo *nd, uint32_t base, qemu_irq irq)memcpy (s->macaddr, nd->macaddr,6 );if (nd->vlan) - s->vc =qemu_new_vlan_client (nd->vlan, stellaris_enet_receive, - stellaris_enet_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + stellaris_enet_receive, stellaris_enet_can_receive, s);stellaris_enet_reset (s); register_savevm("stellaris_enet", -1, 1,
hw/usb-net.c +1 -1
@@ -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, + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, usbnet_receive, usbnet_can_receive, s); snprintf(s->usbstring_mac, sizeof(s->usbstring_mac),
net.c +43 -35
270 lines not on this page · raw message
net.h +2 -0
@@ -13,6 +13,7 @@ struct VLANClientState {void *opaque;struct VLANClientState *next;struct VLANState *vlan; +char *model;char info_str[256 ]; };
@@ -25,6 +26,7 @@ struct VLANState {VLANState *qemu_find_vlan (int id);VLANClientState *qemu_new_vlan_client (VLANState *vlan, +const char *model,IOReadHandler *fd_read,IOCanRWHandler *fd_can_read,void *opaque);
sysemu.h +1 -1
@@ -75,7 +75,7 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);#endif /* TAP win32 */ -int tap_win32_init (VLANState *vlan,const char *ifname); +int tap_win32_init (VLANState *vlan,const char *model,const char *ifname);/* SLIRP */ void do_info_slirp (void );
tap-win32.c +2 -2
@@ -660,7 +660,7 @@ static void tap_win32_send(void *opaque) } } -int tap_win32_init (VLANState *vlan,const char *ifname) +int tap_win32_init (VLANState *vlan,const char *model,const char *ifname) {TAPState *s;
@@ -672,7 +672,7 @@ int tap_win32_init(VLANState *vlan, const char *ifname)return -1 ; } - s->vc =qemu_new_vlan_client (vlan, tap_receive,NULL , s); + s->vc =qemu_new_vlan_client (vlan, model, tap_receive,NULL , s);snprintf (s->vc->info_str,sizeof (s->vc->info_str),"tap: ifname=%s" , ifname);
Signature · 1 line
1.5.4.3
PATCH 2/5 Assign a name to each VLAN client
Automatically assign a name to each vlan client based on its model, e.g. e1000.0, tap.3 or vde.1.
This name is intended to be used by the forthcoming 'set_link' monitor command.
--- net.c | 21 +++++++++++++++++++++ net.h | 1 + 2 files changed, 22 insertions(+), 0 deletions(-)
net.c +21 -0
@@ -304,6 +304,25 @@ static int parse_unix_path(struct sockaddr_un *uaddr, const char *str) }#endif +static char *assign_name (VLANClientState *vc1,const char *model) +{ +VLANState *vlan; +char buf[256 ]; +int id =0 ; + +for (vlan = first_vlan; vlan; vlan = vlan->next) { +VLANClientState *vc; + +for (vc = vlan->first_client; vc; vc = vc->next) +if (vc != vc1 &&strcmp (vc->model, model) ==0 ) + id++; + } + +snprintf (buf,sizeof (buf),"%s.%d" , model, id); + +return strdup (buf); +} + VLANClientState *qemu_new_vlan_client(VLANState *vlan, const char *model, IOReadHandler *fd_read,
@@ -315,6 +334,7 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan,if (!vc)return NULL ; vc->model =strdup (model); + vc->name =assign_name (vc, model); vc->fd_read = fd_read; vc->fd_can_read = fd_can_read; vc->opaque = opaque;
@@ -335,6 +355,7 @@ void qemu_del_vlan_client(VLANClientState *vc)while (*pvc !=NULL )if (*pvc == vc) { *pvc = vc->next; +free (vc->name);free (vc->model);free (vc);break ;
net.h +1 -0
@@ -14,6 +14,7 @@ struct VLANClientState {struct VLANClientState *next;struct VLANState *vlan;char *model; +char *name;char info_str[256 ]; };
Signature · 1 line
1.5.4.3
PATCH 3/5 Fixup info_str formatting
The VLANClientState::info_str format isn't terribly consistent and this patch moves towards it just containing the param strings separated by a comma.
The type/model string is removed from info_str, and 'info network' instead displays the vlan client name with the info_str.
There's a horrible little hack in net_cleanup() to parse a tap client's info_str which I've also fixed up. The hack probably shouldn't exist at all, though.
--- hw/e1000.c | 2 +- hw/eepro100.c | 2 +- hw/mipsnet.c | 2 +- hw/ne2000.c | 4 ++-- hw/pcnet.c | 2 +- hw/rtl8139.c | 2 +- hw/usb-net.c | 2 +- net.c | 14 ++++++++------ 8 files changed, 16 insertions(+), 14 deletions(-)
hw/e1000.c +1 -1
@@ -1075,7 +1075,7 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) e1000_receive, e1000_can_receive, d);snprintf (d->vc->info_str,sizeof (d->vc->info_str), -"%s macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , info_str, +"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , d->nd->macaddr[0 ], d->nd->macaddr[1 ], d->nd->macaddr[2 ], d->nd->macaddr[3 ], d->nd->macaddr[4 ], d->nd->macaddr[5 ]);
hw/eepro100.c +1 -1
@@ -1780,7 +1780,7 @@ static void nic_init(PCIBus * bus, NICInfo * nd, nic_receive, nic_can_receive, s);snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"eepro100 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , +"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , s->macaddr[0 ], s->macaddr[1 ], s->macaddr[2 ], s->macaddr[3 ], s->macaddr[4 ], s->macaddr[5 ]);
hw/mipsnet.c +1 -1
@@ -257,7 +257,7 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) } snprintf(s->vc->info_str, sizeof(s->vc->info_str), - "mipsnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x", + "macaddr=%02x:%02x:%02x:%02x:%02x:%02x", s->nd->macaddr[0], s->nd->macaddr[1], s->nd->macaddr[2],
hw/ne2000.c +2 -2
@@ -745,7 +745,7 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd) ne2000_receive, ne2000_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), - "ne2000 macaddr=%02x:%02x:%02x:%02x:%02x:%02x", + "macaddr=%02x:%02x:%02x:%02x:%02x:%02x", s->macaddr[0], s->macaddr[1], s->macaddr[2],
@@ -815,7 +815,7 @@ void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn) ne2000_receive, ne2000_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), - "ne2000 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x", + "macaddr=%02x:%02x:%02x:%02x:%02x:%02x", s->macaddr[0], s->macaddr[1], s->macaddr[2],
hw/pcnet.c +1 -1
@@ -1940,7 +1940,7 @@ static void pcnet_common_init(PCNetState *d, NICInfo *nd, const char *info_str) pcnet_receive, pcnet_can_receive, d); snprintf(d->vc->info_str, sizeof(d->vc->info_str), - "pcnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x", + "macaddr=%02x:%02x:%02x:%02x:%02x:%02x", d->nd->macaddr[0], d->nd->macaddr[1], d->nd->macaddr[2],
hw/rtl8139.c +1 -1
@@ -3442,7 +3442,7 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn) rtl8139_receive, rtl8139_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), - "rtl8139 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x", + "macaddr=%02x:%02x:%02x:%02x:%02x:%02x", s->macaddr[0], s->macaddr[1], s->macaddr[2],
hw/usb-net.c +1 -1
@@ -1462,7 +1462,7 @@ USBDevice *usb_net_init(NICInfo *nd)0x40 , s->mac[1 ], s->mac[2 ], s->mac[3], s->mac[4], s->mac[5]);snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"usbnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , +"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , s->mac[0 ], s->mac[1 ], s->mac[2 ], s->mac[3 ], s->mac[4 ], s->mac[5 ]); fprintf(stderr, "usbnet: initialized mac %02x:%02x:%02x:%02x:%02x:%02x\n",
net.c +8 -6
@@ -438,7 +438,7 @@ static int net_slirp_init(VLANState *vlan, const char *model) } slirp_vc =qemu_new_vlan_client (vlan, model, slirp_receive,NULL ,NULL ); -snprintf (slirp_vc->info_str,sizeof (slirp_vc->info_str),"user redirector" ); + slirp_vc->info_str[0 ] ='\0' ;return 0 ; }
@@ -645,7 +645,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan, const char *model, int fd) s->fd = fd; s->vc =qemu_new_vlan_client (vlan, model, tap_receive,NULL , s);qemu_set_fd_handler (s->fd, tap_send,NULL , s); -snprintf (s->vc->info_str,sizeof (s->vc->info_str),"tap: fd=%d" , fd); +snprintf (s->vc->info_str,sizeof (s->vc->info_str),"fd=%d" , fd);return s; }
@@ -900,7 +900,8 @@ static int net_tap_init(VLANState *vlan, const char *model, const char *ifname1,if (!s)return -1 ;snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"tap: ifname=%s setup_script=%s" , ifname, setup_script); +"ifname=%s,script=%s,downscript=%s" , + ifname, setup_script, down_script);if (down_script &&strcmp (down_script,"no" ))snprintf (s->down_script,sizeof (s->down_script),"%s" , down_script);return 0 ;
@@ -962,7 +963,7 @@ static int net_vde_init(VLANState *vlan, const char *model, const char *sock, } s->vc =qemu_new_vlan_client (vlan, model, 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),"vde: sock=%s fd=%d" , +snprintf (s->vc->info_str,sizeof (s->vc->info_str),"sock=%s,fd=%d" , sock,vde_datafd (s->vde));return 0 ; }
@@ -1585,7 +1586,7 @@ void do_info_network(void)for (vlan = first_vlan; vlan !=NULL ; vlan = vlan->next) {term_printf ("VLAN %d devices:\n" , vlan->id);for (vc = vlan->first_client; vc !=NULL ; vc = vc->next) -term_printf (" %s\n" , vc->info_str); +term_printf (" %s: %s\n" , vc->name, vc->info_str); } }
@@ -1603,7 +1604,8 @@ void net_cleanup(void)char ifname[64 ];TAPState *s = vc->opaque; -if (sscanf (vc->info_str,"tap: ifname=%63s " , ifname) ==1 && +if (strcmp (vc->model,"tap" ) ==0 && +sscanf (vc->info_str,"ifname=%63s " , ifname) ==1 && s->down_script[0 ])launch_script (s->down_script, ifname, s->fd); }
Signature · 1 line
1.5.4.3
PATCH 4/5 Add qemu_format_nic_info_str()
Factor out a simple little function for formatting a NIC's info_str and make all NICs use it.
--- hw/e1000.c | 5 +---- hw/eepro100.c | 6 +----- hw/mipsnet.c | 9 +-------- hw/ne2000.c | 18 ++---------------- hw/pcnet.c | 9 +-------- hw/rtl8139.c | 9 +-------- hw/usb-net.c | 6 ++---- net.c | 8 ++++++++ net.h | 1 + 9 files changed, 18 insertions(+), 53 deletions(-)
hw/e1000.c +1 -4
@@ -1074,10 +1074,7 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) d->vc =qemu_new_vlan_client (nd->vlan, nd->model, e1000_receive, e1000_can_receive, d); -snprintf (d->vc->info_str,sizeof (d->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - d->nd->macaddr[0 ], d->nd->macaddr[1 ], d->nd->macaddr[2 ], - d->nd->macaddr[3 ], d->nd->macaddr[4 ], d->nd->macaddr[5 ]); +qemu_format_nic_info_str (d->vc, d->nd->macaddr);register_savevm (info_str,-1 ,2 , nic_save, nic_load, d); }
hw/eepro100.c +1 -5
@@ -1779,11 +1779,7 @@ static void nic_init(PCIBus * bus, NICInfo * nd, s->vc =qemu_new_vlan_client (nd->vlan, nd->model, nic_receive, nic_can_receive, s); -snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - s->macaddr[0 ], - s->macaddr[1 ], - s->macaddr[2 ], s->macaddr[3 ], s->macaddr[4 ], s->macaddr[5 ]); +qemu_format_nic_info_str (s->vc, s->macaddr);qemu_register_reset (nic_reset, s);
hw/mipsnet.c +1 -8
@@ -256,14 +256,7 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) s->vc =NULL ; } -snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - s->nd->macaddr[0 ], - s->nd->macaddr[1 ], - s->nd->macaddr[2 ], - s->nd->macaddr[3 ], - s->nd->macaddr[4 ], - s->nd->macaddr[5 ]); +qemu_format_nic_info_str (s->vc, s->nd->macaddr);mipsnet_reset (s);register_savevm ("mipsnet" ,0 ,0 , mipsnet_save, mipsnet_load, s);
hw/ne2000.c +2 -16
@@ -744,14 +744,7 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd) s->vc =qemu_new_vlan_client (nd->vlan, nd->model, ne2000_receive, ne2000_can_receive, s); -snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - s->macaddr[0 ], - s->macaddr[1 ], - s->macaddr[2 ], - s->macaddr[3 ], - s->macaddr[4 ], - s->macaddr[5 ]); +qemu_format_nic_info_str (s->vc, s->macaddr);register_savevm ("ne2000" ,-1 ,2 , ne2000_save, ne2000_load, s); }
@@ -814,14 +807,7 @@ void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn) s->vc =qemu_new_vlan_client (nd->vlan, nd->model, ne2000_receive, ne2000_can_receive, s); -snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - s->macaddr[0 ], - s->macaddr[1 ], - s->macaddr[2 ], - s->macaddr[3 ], - s->macaddr[4 ], - s->macaddr[5 ]); +qemu_format_nic_info_str (s->vc, s->macaddr);register_savevm ("ne2000" ,-1 ,3 , ne2000_save, ne2000_load, s); }
hw/pcnet.c +1 -8
@@ -1939,14 +1939,7 @@ static void pcnet_common_init(PCNetState *d, NICInfo *nd, const char *info_str) d->vc =qemu_new_vlan_client (nd->vlan, nd->model, pcnet_receive, pcnet_can_receive, d); -snprintf (d->vc->info_str,sizeof (d->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - d->nd->macaddr[0 ], - d->nd->macaddr[1 ], - d->nd->macaddr[2 ], - d->nd->macaddr[3 ], - d->nd->macaddr[4 ], - d->nd->macaddr[5 ]); +qemu_format_nic_info_str (d->vc, d->nd->macaddr); }else { d->vc =NULL ; }
hw/rtl8139.c +1 -8
@@ -3441,14 +3441,7 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn) s->vc =qemu_new_vlan_client (nd->vlan, nd->model, rtl8139_receive, rtl8139_can_receive, s); -snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - s->macaddr[0 ], - s->macaddr[1 ], - s->macaddr[2 ], - s->macaddr[3 ], - s->macaddr[4 ], - s->macaddr[5 ]); +qemu_format_nic_info_str (s->vc, s->macaddr); s->cplus_txbuffer =NULL ; s->cplus_txbuffer_len =0 ;
hw/usb-net.c +2 -4
@@ -1457,14 +1457,12 @@ USBDevice *usb_net_init(NICInfo *nd) s->vc =qemu_new_vlan_client (nd->vlan, nd->model, usbnet_receive, usbnet_can_receive, s); +qemu_format_nic_info_str (s->vc, s->mac); +snprintf (s->usbstring_mac,sizeof (s->usbstring_mac),"%02x%02x%02x%02x%02x%02x" ,0x40 , s->mac[1 ], s->mac[2 ], s->mac[3 ], s->mac[4 ], s->mac[5 ]); -snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - s->mac[0 ], s->mac[1 ], s->mac[2 ], - s->mac[3 ], s->mac[4 ], s->mac[5 ]);fprintf (stderr,"usbnet: initialized mac %02x:%02x:%02x:%02x:%02x:%02x\n" , s->mac[0 ], s->mac[1 ], s->mac[2 ], s->mac[3 ], s->mac[4 ], s->mac[5 ]);
net.c +8 -0
@@ -304,6 +304,14 @@ static int parse_unix_path(struct sockaddr_un *uaddr, const char *str) }#endif +void qemu_format_nic_info_str (VLANClientState *vc,uint8_t macaddr[6 ]) +{ +snprintf (vc->info_str,sizeof (vc->info_str), +"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , + macaddr[0 ], macaddr[1 ], macaddr[2 ], + macaddr[3 ], macaddr[4 ], macaddr[5 ]); +} +static char *assign_name (VLANClientState *vc1,const char *model) {VLANState *vlan;
net.h +1 -0
@@ -34,6 +34,7 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan,void qemu_del_vlan_client (VLANClientState *vc);int qemu_can_send_packet (VLANClientState *vc);void qemu_send_packet (VLANClientState *vc,const uint8_t *buf,int size); +void qemu_format_nic_info_str (VLANClientState *vc,uint8_t macaddr[6 ]);void qemu_handler_true (void *opaque);void do_info_network (void );
Signature · 1 line
1.5.4.3
PATCH 5/5 Add a -net name=foo parameter
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'.
--- 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 +- 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(-)
hw/e1000.c +1 -1
@@ -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);
hw/eepro100.c +1 -1
@@ -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);
hw/etraxfs_eth.c +1 -1
@@ -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;
hw/mcf_fec.c +1 -1
@@ -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 ); }
hw/mipsnet.c +1 -1
@@ -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 ;
hw/musicpal.c +1 -1
@@ -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);
hw/ne2000.c +2 -2
@@ -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);
hw/pcnet.c +1 -1
@@ -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);
hw/rtl8139.c +1 -1
@@ -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);
hw/smc91c111.c +1 -1
@@ -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. */ }
hw/usb-net.c +1 -1
@@ -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);
net.c +64 -33
310 lines not on this page · raw message
net.h +2 -0
@@ -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; };
qemu-doc.texi +8 -7
@@ -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
sysemu.h +2 -1
@@ -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 );
tap-win32.c +3 -2
@@ -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);
vl.c +7 -7
@@ -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"
Signature · 1 line
1.5.4.3
Re: [Qemu-devel] [PATCH 5/5] Add a -net name=foo parameter
Quoted 6 lines · Mark McLoughlin
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 <[email protected]>
Quoted 12 lines
--- 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.
Quoted 670 lines
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(-)hw/e1000.c +1
-1@@ -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);hw/eepro100.c +1
-1@@ -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);hw/etraxfs_eth.c +1
-1@@ -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;hw/mcf_fec.c +1
-1@@ -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 ); }hw/mipsnet.c +1
-1@@ -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 ;hw/musicpal.c +1
-1@@ -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);hw/ne2000.c +2
-2@@ -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);hw/pcnet.c +1
-1@@ -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);hw/rtl8139.c +1
-1@@ -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);hw/smc91c111.c +1
-1@@ -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. */ }hw/usb-net.c +1
-1@@ -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);net.c +64
-33@@ -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 *modreturn 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 *moif (!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 *moreturn 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; }net.h +2
-0@@ -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; };qemu-doc.texi +8
-7@@ -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 forsysemu.h +2
-1@@ -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 );tap-win32.c +3
-2@@ -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);vl.c +7
-7@@ -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" Signature · 1 line
1.5.4.3
Signature · 4 lines
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' [email protected] | [email protected] `- people.debian.org/~aurel32 | www.aurel32.net
Re: [Qemu-devel] Re: [PATCH 1/4] Add 'set_link' monitor command
In reply to Mark McLoughlinHi Anthony,
Quoted 11 lines · Mark McLoughlin
Quoted 10 lines · Anthony Liguori
net.c void do_info_network(void) · line 1583
Quoted 4 lines
net.c +3
-0+for (vc = vlan->first_client; vc !=NULL ; vc = vc->next) +if (i++ == device_idx) +break ;I think a better way would be to allow a user to specify an id for the nic that gets saved early on. info nics should print the id and a default id should be assigned. I think you could argue either way as to whether the ids should be vlan local or global.
Quoted 6 lines
Quoted 2 lines
I sort of think that making them global has a number of advantages. You could also use a string to identify the nics globally, it's up to you.
Okay, here's a few patches to add a vlan client name.
I'll repost the
set_linkpatches once we agree on this part.
Re-posting a re-based version of these patches; also includes a fix for the build error pointer out by Aurelien Jarno.
Cheers,
Mark.
PATCH 1/6 Add a model string to VLANClientState
Don't lose track of what type/model a vlan client is so that we can e.g. assign a global per-model id to clients.
The entire patch is basically a tedious excercise in making sure the type/model string gets propagated down to qemu_new_vlan_client().
--- hw/e1000.c | 4 +- hw/eepro100.c | 3 +- hw/etraxfs_eth.c | 2 +- hw/mcf_fec.c | 4 +- hw/mipsnet.c | 4 +- hw/musicpal.c | 3 +- hw/ne2000.c | 8 ++-- hw/pcnet.c | 4 +- hw/rtl8139.c | 4 +- hw/smc91c111.c | 4 +- hw/stellaris_enet.c | 4 +- hw/usb-net.c | 2 +- hw/virtio-net.c | 4 +- net.c | 78 ++++++++++++++++++++++++++++----------------------- net.h | 2 + sysemu.h | 2 +- tap-win32.c | 4 +- 17 files changed, 74 insertions(+), 62 deletions(-)
hw/e1000.c +2 -2
@@ -1071,8 +1071,8 @@ 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, e1000_receive, - e1000_can_receive, d); + d->vc =qemu_new_vlan_client (nd->vlan, nd->model, + e1000_receive, e1000_can_receive, d); snprintf(d->vc->info_str, sizeof(d->vc->info_str), "%s macaddr=%02x:%02x:%02x:%02x:%02x:%02x", info_str,
hw/eepro100.c +2 -1
@@ -1776,7 +1776,8 @@ static void nic_init(PCIBus * bus, NICInfo * nd,nic_reset (s); - s->vc =qemu_new_vlan_client (nd->vlan, nic_receive, nic_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + nic_receive, nic_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "eepro100 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
hw/etraxfs_eth.c +1 -1
@@ -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, + eth->vc =qemu_new_vlan_client (nd->vlan, nd->model, eth_receive, eth_can_receive, eth);return dma;
hw/mcf_fec.c +2 -2
@@ -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, mcf_fec_receive, - mcf_fec_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + mcf_fec_receive, mcf_fec_can_receive, s);memcpy (s->macaddr, nd->macaddr,6 ); }
hw/mipsnet.c +2 -2
@@ -250,8 +250,8 @@ 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, mipsnet_receive, - mipsnet_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + mipsnet_receive, mipsnet_can_receive, s); }else { s->vc =NULL ; }
hw/musicpal.c +2 -1
@@ -718,7 +718,8 @@ 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, eth_receive, eth_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + eth_receive, eth_can_receive, s); iomemtype =cpu_register_io_memory (0 , mv88w8618_eth_readfn, mv88w8618_eth_writefn, s);cpu_register_physical_memory (base,MP_ETH_SIZE , iomemtype);
hw/ne2000.c +4 -4
@@ -741,8 +741,8 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)ne2000_reset (s); - s->vc =qemu_new_vlan_client (nd->vlan, ne2000_receive, - ne2000_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + ne2000_receive, ne2000_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "ne2000 macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
@@ -811,8 +811,8 @@ 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, ne2000_receive, - ne2000_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + ne2000_receive, ne2000_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "ne2000 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
hw/pcnet.c +2 -2
@@ -1936,8 +1936,8 @@ 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, pcnet_receive, - pcnet_can_receive, d); + d->vc =qemu_new_vlan_client (nd->vlan, nd->model, + pcnet_receive, pcnet_can_receive, d); snprintf(d->vc->info_str, sizeof(d->vc->info_str), "pcnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
hw/rtl8139.c +2 -2
@@ -3438,8 +3438,8 @@ 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, rtl8139_receive, - rtl8139_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + rtl8139_receive, rtl8139_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "rtl8139 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
hw/smc91c111.c +2 -2
@@ -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, smc91c111_receive, - smc91c111_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + smc91c111_receive, smc91c111_can_receive, s);/* ??? Save/restore. */ }
hw/stellaris_enet.c +2 -2
@@ -397,8 +397,8 @@ void stellaris_enet_init(NICInfo *nd, uint32_t base, qemu_irq irq)memcpy (s->macaddr, nd->macaddr,6 );if (nd->vlan) - s->vc =qemu_new_vlan_client (nd->vlan, stellaris_enet_receive, - stellaris_enet_can_receive, s); + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + stellaris_enet_receive, stellaris_enet_can_receive, s);stellaris_enet_reset (s); register_savevm("stellaris_enet", -1, 1,
hw/usb-net.c +1 -1
@@ -1453,7 +1453,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, + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, usbnet_receive, usbnet_can_receive, s); snprintf(s->usbstring_mac, sizeof(s->usbstring_mac),
hw/virtio-net.c +2 -2
@@ -315,8 +315,8 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) n->rx_vq =virtio_add_queue (&n->vdev,256 , virtio_net_handle_rx); n->tx_vq =virtio_add_queue (&n->vdev,256 , virtio_net_handle_tx);memcpy (n->mac, nd->macaddr,6 ); - n->vc =qemu_new_vlan_client (nd->vlan, virtio_net_receive, - virtio_net_can_receive, n); + n->vc =qemu_new_vlan_client (nd->vlan, nd->model, + virtio_net_receive, virtio_net_can_receive, n); n->tx_timer =qemu_new_timer (vm_clock, virtio_net_tx_timer, n); n->tx_timer_active =0 ;
net.c +43 -35
270 lines not on this page · raw message
net.h +2 -0
@@ -18,6 +18,7 @@ struct VLANClientState {void *opaque;struct VLANClientState *next;struct VLANState *vlan; +char *model;char info_str[256 ]; };
@@ -30,6 +31,7 @@ struct VLANState {VLANState *qemu_find_vlan (int id);VLANClientState *qemu_new_vlan_client (VLANState *vlan, +const char *model,IOReadHandler *fd_read,IOCanRWHandler *fd_can_read,void *opaque);
sysemu.h +1 -1
@@ -75,7 +75,7 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);#endif /* TAP win32 */ -int tap_win32_init (VLANState *vlan,const char *ifname); +int tap_win32_init (VLANState *vlan,const char *model,const char *ifname);/* SLIRP */ void do_info_slirp (void );
tap-win32.c +2 -2
@@ -660,7 +660,7 @@ static void tap_win32_send(void *opaque) } } -int tap_win32_init (VLANState *vlan,const char *ifname) +int tap_win32_init (VLANState *vlan,const char *model,const char *ifname) {TAPState *s;
@@ -672,7 +672,7 @@ int tap_win32_init(VLANState *vlan, const char *ifname)return -1 ; } - s->vc =qemu_new_vlan_client (vlan, tap_receive,NULL , s); + s->vc =qemu_new_vlan_client (vlan, model, tap_receive,NULL , s);snprintf (s->vc->info_str,sizeof (s->vc->info_str),"tap: ifname=%s" , ifname);
Signature · 1 line
1.6.0.6
PATCH 2/6 Assign a name to each VLAN client
Automatically assign a name to each vlan client based on its model, e.g. e1000.0, tap.3 or vde.1.
This name is intended to be used by the forthcoming 'set_link' monitor command.
--- net.c | 21 +++++++++++++++++++++ net.h | 1 + 2 files changed, 22 insertions(+), 0 deletions(-)
net.c +21 -0
@@ -296,6 +296,25 @@ static int parse_unix_path(struct sockaddr_un *uaddr, const char *str) }#endif +static char *assign_name (VLANClientState *vc1,const char *model) +{ +VLANState *vlan; +char buf[256 ]; +int id =0 ; + +for (vlan = first_vlan; vlan; vlan = vlan->next) { +VLANClientState *vc; + +for (vc = vlan->first_client; vc; vc = vc->next) +if (vc != vc1 &&strcmp (vc->model, model) ==0 ) + id++; + } + +snprintf (buf,sizeof (buf),"%s.%d" , model, id); + +return strdup (buf); +} + VLANClientState *qemu_new_vlan_client(VLANState *vlan, const char *model, IOReadHandler *fd_read,
@@ -307,6 +326,7 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan,if (!vc)return NULL ; vc->model =strdup (model); + vc->name =assign_name (vc, model); vc->fd_read = fd_read; vc->fd_can_read = fd_can_read; vc->opaque = opaque;
@@ -327,6 +347,7 @@ void qemu_del_vlan_client(VLANClientState *vc)while (*pvc !=NULL )if (*pvc == vc) { *pvc = vc->next; +free (vc->name);free (vc->model);free (vc);break ;
net.h +1 -0
@@ -19,6 +19,7 @@ struct VLANClientState {struct VLANClientState *next;struct VLANState *vlan;char *model; +char *name;char info_str[256 ]; };
Signature · 1 line
1.6.0.6
PATCH 3/6 Fixup info_str formatting
The VLANClientState::info_str format isn't terribly consistent and this patch moves towards it just containing the param strings separated by a comma.
The type/model string is removed from info_str, and 'info network' instead displays the vlan client name with the info_str.
There's a horrible little hack in net_cleanup() to parse a tap client's info_str which I've also fixed up. The hack probably shouldn't exist at all, though.
--- hw/e1000.c | 2 +- hw/eepro100.c | 2 +- hw/mipsnet.c | 2 +- hw/ne2000.c | 4 ++-- hw/pcnet.c | 2 +- hw/rtl8139.c | 2 +- hw/usb-net.c | 2 +- net.c | 14 ++++++++------ 8 files changed, 16 insertions(+), 14 deletions(-)
hw/e1000.c +1 -1
@@ -1075,7 +1075,7 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) e1000_receive, e1000_can_receive, d);snprintf (d->vc->info_str,sizeof (d->vc->info_str), -"%s macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , info_str, +"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , d->nd->macaddr[0 ], d->nd->macaddr[1 ], d->nd->macaddr[2 ], d->nd->macaddr[3 ], d->nd->macaddr[4 ], d->nd->macaddr[5 ]);
hw/eepro100.c +1 -1
@@ -1780,7 +1780,7 @@ static void nic_init(PCIBus * bus, NICInfo * nd, nic_receive, nic_can_receive, s);snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"eepro100 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , +"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , s->macaddr[0 ], s->macaddr[1 ], s->macaddr[2 ], s->macaddr[3 ], s->macaddr[4 ], s->macaddr[5 ]);
hw/mipsnet.c +1 -1
@@ -257,7 +257,7 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) } snprintf(s->vc->info_str, sizeof(s->vc->info_str), - "mipsnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x", + "macaddr=%02x:%02x:%02x:%02x:%02x:%02x", s->nd->macaddr[0], s->nd->macaddr[1], s->nd->macaddr[2],
hw/ne2000.c +2 -2
@@ -745,7 +745,7 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd) ne2000_receive, ne2000_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), - "ne2000 macaddr=%02x:%02x:%02x:%02x:%02x:%02x", + "macaddr=%02x:%02x:%02x:%02x:%02x:%02x", s->macaddr[0], s->macaddr[1], s->macaddr[2],
@@ -815,7 +815,7 @@ void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn) ne2000_receive, ne2000_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), - "ne2000 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x", + "macaddr=%02x:%02x:%02x:%02x:%02x:%02x", s->macaddr[0], s->macaddr[1], s->macaddr[2],
hw/pcnet.c +1 -1
@@ -1940,7 +1940,7 @@ static void pcnet_common_init(PCNetState *d, NICInfo *nd, const char *info_str) pcnet_receive, pcnet_can_receive, d); snprintf(d->vc->info_str, sizeof(d->vc->info_str), - "pcnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x", + "macaddr=%02x:%02x:%02x:%02x:%02x:%02x", d->nd->macaddr[0], d->nd->macaddr[1], d->nd->macaddr[2],
hw/rtl8139.c +1 -1
@@ -3442,7 +3442,7 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn) rtl8139_receive, rtl8139_can_receive, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), - "rtl8139 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x", + "macaddr=%02x:%02x:%02x:%02x:%02x:%02x", s->macaddr[0], s->macaddr[1], s->macaddr[2],
hw/usb-net.c +1 -1
@@ -1461,7 +1461,7 @@ USBDevice *usb_net_init(NICInfo *nd)0x40 , s->mac[1 ], s->mac[2 ], s->mac[3], s->mac[4], s->mac[5]);snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"usbnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , +"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , s->mac[0 ], s->mac[1 ], s->mac[2 ], s->mac[3 ], s->mac[4 ], s->mac[5 ]); fprintf(stderr, "usbnet: initialized mac %02x:%02x:%02x:%02x:%02x:%02x\n",
net.c +8 -6
@@ -474,7 +474,7 @@ static int net_slirp_init(VLANState *vlan, const char *model) } slirp_vc =qemu_new_vlan_client (vlan, model, slirp_receive,NULL ,NULL ); -snprintf (slirp_vc->info_str,sizeof (slirp_vc->info_str),"user redirector" ); + slirp_vc->info_str[0 ] ='\0' ;return 0 ; }
@@ -699,7 +699,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan, const char *model, int fd) s->vc->fd_readv = tap_receive_iov;#endif qemu_set_fd_handler (s->fd, tap_send,NULL , s); -snprintf (s->vc->info_str,sizeof (s->vc->info_str),"tap: fd=%d" , fd); +snprintf (s->vc->info_str,sizeof (s->vc->info_str),"fd=%d" , fd);return s; }
@@ -954,7 +954,8 @@ static int net_tap_init(VLANState *vlan, const char *model, const char *ifname1,if (!s)return -1 ;snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"tap: ifname=%s setup_script=%s" , ifname, setup_script); +"ifname=%s,script=%s,downscript=%s" , + ifname, setup_script, down_script);if (down_script &&strcmp (down_script,"no" ))snprintf (s->down_script,sizeof (s->down_script),"%s" , down_script);return 0 ;
@@ -1016,7 +1017,7 @@ static int net_vde_init(VLANState *vlan, const char *model, const char *sock, } s->vc =qemu_new_vlan_client (vlan, model, 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),"vde: sock=%s fd=%d" , +snprintf (s->vc->info_str,sizeof (s->vc->info_str),"sock=%s,fd=%d" , sock,vde_datafd (s->vde));return 0 ; }
@@ -1639,7 +1640,7 @@ void do_info_network(void)for (vlan = first_vlan; vlan !=NULL ; vlan = vlan->next) {term_printf ("VLAN %d devices:\n" , vlan->id);for (vc = vlan->first_client; vc !=NULL ; vc = vc->next) -term_printf (" %s\n" , vc->info_str); +term_printf (" %s: %s\n" , vc->name, vc->info_str); } }
@@ -1657,7 +1658,8 @@ void net_cleanup(void)char ifname[64 ];TAPState *s = vc->opaque; -if (sscanf (vc->info_str,"tap: ifname=%63s " , ifname) ==1 && +if (strcmp (vc->model,"tap" ) ==0 && +sscanf (vc->info_str,"ifname=%63s " , ifname) ==1 && s->down_script[0 ])launch_script (s->down_script, ifname, s->fd); }
Signature · 1 line
1.6.0.6
PATCH 4/6 Add qemu_format_nic_info_str()
Factor out a simple little function for formatting a NIC's info_str and make all NICs use it.
--- hw/e1000.c | 5 +---- hw/eepro100.c | 6 +----- hw/mipsnet.c | 9 +-------- hw/ne2000.c | 18 ++---------------- hw/pcnet.c | 9 +-------- hw/rtl8139.c | 9 +-------- hw/usb-net.c | 6 ++---- net.c | 8 ++++++++ net.h | 1 + 9 files changed, 18 insertions(+), 53 deletions(-)
hw/e1000.c +1 -4
@@ -1074,10 +1074,7 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) d->vc =qemu_new_vlan_client (nd->vlan, nd->model, e1000_receive, e1000_can_receive, d); -snprintf (d->vc->info_str,sizeof (d->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - d->nd->macaddr[0 ], d->nd->macaddr[1 ], d->nd->macaddr[2 ], - d->nd->macaddr[3 ], d->nd->macaddr[4 ], d->nd->macaddr[5 ]); +qemu_format_nic_info_str (d->vc, d->nd->macaddr);register_savevm (info_str,-1 ,2 , nic_save, nic_load, d); }
hw/eepro100.c +1 -5
@@ -1779,11 +1779,7 @@ static void nic_init(PCIBus * bus, NICInfo * nd, s->vc =qemu_new_vlan_client (nd->vlan, nd->model, nic_receive, nic_can_receive, s); -snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - s->macaddr[0 ], - s->macaddr[1 ], - s->macaddr[2 ], s->macaddr[3 ], s->macaddr[4 ], s->macaddr[5 ]); +qemu_format_nic_info_str (s->vc, s->macaddr);qemu_register_reset (nic_reset, s);
hw/mipsnet.c +1 -8
@@ -256,14 +256,7 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) s->vc =NULL ; } -snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - s->nd->macaddr[0 ], - s->nd->macaddr[1 ], - s->nd->macaddr[2 ], - s->nd->macaddr[3 ], - s->nd->macaddr[4 ], - s->nd->macaddr[5 ]); +qemu_format_nic_info_str (s->vc, s->nd->macaddr);mipsnet_reset (s);register_savevm ("mipsnet" ,0 ,0 , mipsnet_save, mipsnet_load, s);
hw/ne2000.c +2 -16
@@ -744,14 +744,7 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd) s->vc =qemu_new_vlan_client (nd->vlan, nd->model, ne2000_receive, ne2000_can_receive, s); -snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - s->macaddr[0 ], - s->macaddr[1 ], - s->macaddr[2 ], - s->macaddr[3 ], - s->macaddr[4 ], - s->macaddr[5 ]); +qemu_format_nic_info_str (s->vc, s->macaddr);register_savevm ("ne2000" ,-1 ,2 , ne2000_save, ne2000_load, s); }
@@ -814,14 +807,7 @@ void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn) s->vc =qemu_new_vlan_client (nd->vlan, nd->model, ne2000_receive, ne2000_can_receive, s); -snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - s->macaddr[0 ], - s->macaddr[1 ], - s->macaddr[2 ], - s->macaddr[3 ], - s->macaddr[4 ], - s->macaddr[5 ]); +qemu_format_nic_info_str (s->vc, s->macaddr);register_savevm ("ne2000" ,-1 ,3 , ne2000_save, ne2000_load, s); }
hw/pcnet.c +1 -8
@@ -1939,14 +1939,7 @@ static void pcnet_common_init(PCNetState *d, NICInfo *nd, const char *info_str) d->vc =qemu_new_vlan_client (nd->vlan, nd->model, pcnet_receive, pcnet_can_receive, d); -snprintf (d->vc->info_str,sizeof (d->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - d->nd->macaddr[0 ], - d->nd->macaddr[1 ], - d->nd->macaddr[2 ], - d->nd->macaddr[3 ], - d->nd->macaddr[4 ], - d->nd->macaddr[5 ]); +qemu_format_nic_info_str (d->vc, d->nd->macaddr); }else { d->vc =NULL ; }
hw/rtl8139.c +1 -8
@@ -3441,14 +3441,7 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn) s->vc =qemu_new_vlan_client (nd->vlan, nd->model, rtl8139_receive, rtl8139_can_receive, s); -snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - s->macaddr[0 ], - s->macaddr[1 ], - s->macaddr[2 ], - s->macaddr[3 ], - s->macaddr[4 ], - s->macaddr[5 ]); +qemu_format_nic_info_str (s->vc, s->macaddr); s->cplus_txbuffer =NULL ; s->cplus_txbuffer_len =0 ;
hw/usb-net.c +2 -4
@@ -1456,14 +1456,12 @@ USBDevice *usb_net_init(NICInfo *nd) s->vc =qemu_new_vlan_client (nd->vlan, nd->model, usbnet_receive, usbnet_can_receive, s); +qemu_format_nic_info_str (s->vc, s->mac); +snprintf (s->usbstring_mac,sizeof (s->usbstring_mac),"%02x%02x%02x%02x%02x%02x" ,0x40 , s->mac[1 ], s->mac[2 ], s->mac[3 ], s->mac[4 ], s->mac[5 ]); -snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - s->mac[0 ], s->mac[1 ], s->mac[2 ], - s->mac[3 ], s->mac[4 ], s->mac[5 ]);fprintf (stderr,"usbnet: initialized mac %02x:%02x:%02x:%02x:%02x:%02x\n" , s->mac[0 ], s->mac[1 ], s->mac[2 ], s->mac[3 ], s->mac[4 ], s->mac[5 ]);
net.c +8 -0
@@ -296,6 +296,14 @@ static int parse_unix_path(struct sockaddr_un *uaddr, const char *str) }#endif +void qemu_format_nic_info_str (VLANClientState *vc,uint8_t macaddr[6 ]) +{ +snprintf (vc->info_str,sizeof (vc->info_str), +"macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , + macaddr[0 ], macaddr[1 ], macaddr[2 ], + macaddr[3 ], macaddr[4 ], macaddr[5 ]); +} +static char *assign_name (VLANClientState *vc1,const char *model) {VLANState *vlan;
net.h +1 -0
@@ -41,6 +41,7 @@ int qemu_can_send_packet(VLANClientState *vc);ssize_t qemu_sendv_packet (VLANClientState *vc,const struct iovec *iov,int iovcnt);void qemu_send_packet (VLANClientState *vc,const uint8_t *buf,int size); +void qemu_format_nic_info_str (VLANClientState *vc,uint8_t macaddr[6 ]);void qemu_handler_true (void *opaque);void do_info_network (void );
Signature · 1 line
1.6.0.6
PATCH 5/6 add missing MAC address to info_str for some NICs
--- hw/mcf_fec.c | 1 + hw/smc91c111.c | 1 + hw/stellaris_enet.c | 4 +++- hw/virtio-net.c | 2 ++ 4 files changed, 7 insertions(+), 1 deletions(-)
hw/mcf_fec.c +1 -0
@@ -455,4 +455,5 @@ void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq) s->vc =qemu_new_vlan_client (nd->vlan, nd->model, mcf_fec_receive, mcf_fec_can_receive, s);memcpy (s->macaddr, nd->macaddr,6 ); +qemu_format_nic_info_str (n->vc, s->macaddr); }
hw/smc91c111.c +1 -0
@@ -706,5 +706,6 @@ void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq) s->vc =qemu_new_vlan_client (nd->vlan, nd->model, smc91c111_receive, smc91c111_can_receive, s); +qemu_format_nic_info_str (s->vc, s->macaddr);/* ??? Save/restore. */ }
hw/stellaris_enet.c +3 -1
@@ -396,9 +396,11 @@ void stellaris_enet_init(NICInfo *nd, uint32_t base, qemu_irq irq) s->irq = irq;memcpy (s->macaddr, nd->macaddr,6 ); -if (nd->vlan) +if (nd->vlan) { s->vc =qemu_new_vlan_client (nd->vlan, nd->model, stellaris_enet_receive, stellaris_enet_can_receive, s); +qemu_format_nic_info_str (s->vc, s->macaddr); + }stellaris_enet_reset (s); register_savevm("stellaris_enet", -1, 1,
hw/virtio-net.c +2 -0
@@ -318,6 +318,8 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) n->vc =qemu_new_vlan_client (nd->vlan, nd->model, virtio_net_receive, virtio_net_can_receive, n); +qemu_format_nic_info_str (n->vc, n->mac); + n->tx_timer =qemu_new_timer (vm_clock, virtio_net_tx_timer, n); n->tx_timer_active =0 ; n->mergeable_rx_bufs =0 ;
Signature · 1 line
1.6.0.6
PATCH 6/6 Add a -net name=foo parameter
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'.
--- 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/stellaris_enet.c | 2 +- hw/usb-net.c | 2 +- hw/virtio-net.c | 2 +- net.c | 97 +++++++++++++++++++++++++++++++++----------------- net.h | 2 + qemu-doc.texi | 15 ++++---- sysemu.h | 3 +- tap-win32.c | 5 ++- vl.c | 14 ++++---- 19 files changed, 100 insertions(+), 64 deletions(-)
hw/e1000.c +1 -1
@@ -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);
hw/eepro100.c +1 -1
@@ -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);
hw/etraxfs_eth.c +1 -1
@@ -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;
hw/mcf_fec.c +1 -1
@@ -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 );qemu_format_nic_info_str (n->vc, s->macaddr);
hw/mipsnet.c +1 -1
@@ -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 ;
hw/musicpal.c +1 -1
@@ -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);
hw/ne2000.c +2 -2
@@ -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);
hw/pcnet.c +1 -1
@@ -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);
hw/rtl8139.c +1 -1
@@ -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);
hw/smc91c111.c +1 -1
@@ -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);qemu_format_nic_info_str (s->vc, s->macaddr);/* ??? Save/restore. */
hw/stellaris_enet.c +1 -1
@@ -397,7 +397,7 @@ void stellaris_enet_init(NICInfo *nd, uint32_t base, qemu_irq irq)memcpy (s->macaddr, nd->macaddr,6 );if (nd->vlan) { - s->vc =qemu_new_vlan_client (nd->vlan, nd->model, + s->vc =qemu_new_vlan_client (nd->vlan, nd->model, nd->name, stellaris_enet_receive, stellaris_enet_can_receive, s);qemu_format_nic_info_str (s->vc, s->macaddr); }
hw/usb-net.c +1 -1
@@ -1453,7 +1453,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);
hw/virtio-net.c +1 -1
@@ -315,7 +315,7 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) n->rx_vq =virtio_add_queue (&n->vdev,256 , virtio_net_handle_rx); n->tx_vq =virtio_add_queue (&n->vdev,256 , virtio_net_handle_tx);memcpy (n->mac, nd->macaddr,6 ); - n->vc =qemu_new_vlan_client (nd->vlan, nd->model, + n->vc =qemu_new_vlan_client (nd->vlan, nd->model, nd->name, virtio_net_receive, virtio_net_can_receive, n);qemu_format_nic_info_str (n->vc, n->mac);
net.c +64 -33
310 lines not on this page · raw message
net.h +2 -0
@@ -33,6 +33,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);
@@ -53,6 +54,7 @@ void do_info_network(void);struct NICInfo {uint8_t macaddr[6 ];const char *model; +const char *name;VLANState *vlan; };
qemu-doc.texi +8 -7
@@ -606,10 +606,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
@@ -619,12 +620,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
@@ -645,7 +646,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
@@ -665,7 +666,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
@@ -705,7 +706,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
sysemu.h +2 -1
@@ -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 );
tap-win32.c +3 -2
@@ -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);
vl.c +7 -7
@@ -3871,30 +3871,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"
Signature · 1 line
1.6.0.6
[Qemu-devel] Re: [PATCH 1/6] Add a model string to VLANClientState
In reply to Mark McLoughlinQuoted 8 lines · Mark McLoughlin
Don't lose track of what type/model a vlan client is so that we can e.g. assign a global per-model id to clients.
The entire patch is basically a tedious excercise in making sure the type/model string gets propagated down to
qemu_new_vlan_client().Signed-off-by Mark McLoughlin <[email protected]>
Applied the whole series. Thanks.
Really nice series too.
Regards,
Anthony Liguori
Quoted 5 lines · Mark McLoughlin
Hi,
Here's a small patch set which adds link up/down
emulation to e1000 via a "set_link" monitor command. This is useful for people who want to e.g. test how applications and/or the guest OS handles this condition.
It sounds like it could also be useful for people who use bridging of guests to the LAN on mobile devices. eg, a management tool could monitor for when I unplugged my laptop from the ethernet and set the guest link down. When I then plug it back it, it'd set the link back up, and the guest (if using NetworkManager or equivalent) would be able to correctly DHCP a new address. In current scenario with the guest totally unaware of host link sstatus, they just continue using the original bogus DHCP address at least until the renew time.
Daniel
Signature · 4 lines
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
Quoted 17 lines · Daniel P. Berrange
Quoted 6 lines · Mark McLoughlin
Hi,
Here's a small patch set which adds link up/down
emulation to e1000 via a "set_link" monitor command. This is useful for people who want to e.g. test how applications and/or the guest OS handles this condition.It sounds like it could also be useful for people who use bridging of
guests to the LAN on mobile devices. eg, a management tool could monitor for when I unplugged my laptop from the ethernet and set the guest link down. When I then plug it back it, it'd set the link back
up, and the guest (if using NetworkManager or equivalent) would be
able to correctly DHCP a new address. In current scenario with the
guest totally unaware of host link sstatus, they just continue using
the original bogus DHCP address at least until the renew time.
Quoted 2 lines
Daniel
Indeed.
Besides that its also good for windows virtio network certification. MS has a test that needs to play with the link status.
Quoted 11 lines · Mark McLoughlin
Hi,
Here's a small patch set which adds link up/down
emulation to e1000 via a "set_link" monitor command. This is useful for people who want to e.g. test how applications and/or the guest OS handles this condition.The command itself takes a VLAN ID and device index
in order to identify which device to modify. That's a bit lame and could clearly by improved if the overall idea was thought to be sound.
Yeah, this series looks good (as does the virtio-net one). I plan on merging virtio-net either today or tomorrow and I can merge your virtio-net series into QEMU too.
BTW, I plan on introducing qemu_sendv_packet() to QEMU in the process of this.
Regards,
Anthony Liguori
Quoted 5 lines
Thanks,
Mark.
Quoted 7 lines · Anthony Liguori
Quoted 6 lines · Mark McLoughlin
Hi,
Here's a small patch set which adds link up/down
emulation to e1000 via a "set_link" monitor command. This is useful for people who want to e.g. test how applications and/or the guest OS handles this condition.
Quoted 7 lines
Quoted 5 lines
The command itself takes a VLAN ID and device index
in order to identify which device to modify. That's a bit lame and could clearly by improved if the overall idea was thought to be sound.Yeah, this series looks good (as does the virtio-net one). I plan on merging virtio-net either today or tomorrow and I can merge your virtio-net series into QEMU too.
Excellent. Mark, I'll get your patches from the next qemu merge.
Signature · 1 line
error compiling committee.c: too many arguments to function