[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/5] Fixup info_str formatting
From: |
Mark McLoughlin |
Subject: |
[Qemu-devel] [PATCH 3/5] Fixup info_str formatting |
Date: |
Fri, 12 Dec 2008 14:46:29 +0000 |
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 <address@hidden>
---
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 45706bb..13fcc1c 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 f3f6564..b16c4cc 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 06ff668..c80b048 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -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",
diff --git a/net.c b/net.c
index fe7c648..100e335 100644
--- a/net.c
+++ b/net.c
@@ -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);
}
--
1.5.4.3
- [Qemu-devel] [PATCH 0/4] Add nic link up/down emulation to e1000, Mark McLoughlin, 2008/12/09
- [Qemu-devel] [PATCH 1/4] Add 'set_link' monitor command, Mark McLoughlin, 2008/12/09
- [Qemu-devel] Re: [PATCH 1/4] Add 'set_link' monitor command, Anthony Liguori, 2008/12/09
- [Qemu-devel] Re: [PATCH 1/4] Add 'set_link' monitor command, Mark McLoughlin, 2008/12/12
- [Qemu-devel] [PATCH 1/5] Add a model string to VLANClientState, Mark McLoughlin, 2008/12/12
- [Qemu-devel] [PATCH 2/5] Assign a name to each VLAN client, Mark McLoughlin, 2008/12/12
- [Qemu-devel] [PATCH 3/5] Fixup info_str formatting,
Mark McLoughlin <=
- [Qemu-devel] [PATCH 4/5] Add qemu_format_nic_info_str(), Mark McLoughlin, 2008/12/12
- [Qemu-devel] [PATCH 5/5] Add a -net name=foo parameter, Mark McLoughlin, 2008/12/12
- Re: [Qemu-devel] [PATCH 5/5] Add a -net name=foo parameter, Aurelien Jarno, 2008/12/14
Re: [Qemu-devel] [PATCH 0/4] Add nic link up/down emulation to e1000, Daniel P. Berrange, 2008/12/09
[Qemu-devel] Re: [PATCH 0/4] Add nic link up/down emulation to e1000, Anthony Liguori, 2008/12/09