From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LKDQB-0006Zn-RH for qemu-devel@nongnu.org; Tue, 06 Jan 2009 10:00:43 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LKDQ9-0006YE-4o for qemu-devel@nongnu.org; Tue, 06 Jan 2009 10:00:42 -0500 Received: from [199.232.76.173] (port=43493 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LKDQ8-0006Xv-Ns for qemu-devel@nongnu.org; Tue, 06 Jan 2009 10:00:40 -0500 Received: from mail16.svc.cra.dublin.eircom.net ([159.134.118.215]:37166) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1LKDQ7-0003qO-Aw for qemu-devel@nongnu.org; Tue, 06 Jan 2009 10:00:39 -0500 From: Mark McLoughlin Date: Tue, 6 Jan 2009 15:00:33 +0000 Message-Id: <1231254036-29060-3-git-send-email-markmc@redhat.com> In-Reply-To: <1231254036-29060-2-git-send-email-markmc@redhat.com> References: <1231253967.23355.1.camel@localhost.localdomain> <1231254036-29060-1-git-send-email-markmc@redhat.com> <1231254036-29060-2-git-send-email-markmc@redhat.com> Subject: [Qemu-devel] [PATCH 3/6] Fixup info_str formatting Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Mark McLoughlin , qemu-devel@nongnu.org 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. Signed-off-by: Mark McLoughlin --- 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(-) diff --git a/hw/e1000.c b/hw/e1000.c index 03c573b..996260c 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -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]); diff --git a/hw/eepro100.c b/hw/eepro100.c index a7861ca..8ea283c 100644 --- a/hw/eepro100.c +++ b/hw/eepro100.c @@ -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]); diff --git a/hw/mipsnet.c b/hw/mipsnet.c index 549e6f3..8190738 100644 --- a/hw/mipsnet.c +++ b/hw/mipsnet.c @@ -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], diff --git a/hw/ne2000.c b/hw/ne2000.c index dc97989..600cdc3 100644 --- a/hw/ne2000.c +++ b/hw/ne2000.c @@ -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], diff --git a/hw/pcnet.c b/hw/pcnet.c index e961a06..90bf7fd 100644 --- a/hw/pcnet.c +++ b/hw/pcnet.c @@ -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], diff --git a/hw/rtl8139.c b/hw/rtl8139.c index 39f3209..1853ab3 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -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], diff --git a/hw/usb-net.c b/hw/usb-net.c index 40ee41b..1622ef8 100644 --- a/hw/usb-net.c +++ b/hw/usb-net.c @@ -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", diff --git a/net.c b/net.c index c268233..db69c7f 100644 --- a/net.c +++ b/net.c @@ -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); } -- 1.6.0.6