aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-01-07 17:46:21 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-01-07 17:46:21 +0000
commit7cb7434b1e4aee549b55536208abe56e35159763 (patch)
treea0aa76dfcf83f7575eab561d0cb714e09bd00d4f /hw
parent676cff2940f3d34e2ef7735df0f83cce958b0d77 (diff)
Add qemu_format_nic_info_str() (Mark McLoughlin)
Factor out a simple little function for formatting a NIC's info_str and make all NICs use it. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6218 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw')
-rw-r--r--hw/e1000.c5
-rw-r--r--hw/eepro100.c6
-rw-r--r--hw/mipsnet.c9
-rw-r--r--hw/ne2000.c18
-rw-r--r--hw/pcnet.c9
-rw-r--r--hw/rtl8139.c9
-rw-r--r--hw/usb-net.c6
7 files changed, 9 insertions, 53 deletions
diff --git a/hw/e1000.c b/hw/e1000.c
index 03c573bf1e..5b0b7314d0 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -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),
- "%s macaddr=%02x:%02x:%02x:%02x:%02x:%02x", info_str,
- 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);
}
diff --git a/hw/eepro100.c b/hw/eepro100.c
index a7861ca7c4..86a4e6e511 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -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),
- "eepro100 pci 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);
diff --git a/hw/mipsnet.c b/hw/mipsnet.c
index 549e6f38f1..4b3e8e9347 100644
--- a/hw/mipsnet.c
+++ b/hw/mipsnet.c
@@ -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),
- "mipsnet 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);
diff --git a/hw/ne2000.c b/hw/ne2000.c
index dc9798902e..ad97bc5f60 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -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),
- "ne2000 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),
- "ne2000 pci 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);
}
diff --git a/hw/pcnet.c b/hw/pcnet.c
index e961a06db2..5b45956299 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -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),
- "pcnet 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;
}
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index 39f32094ec..d51722054e 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -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),
- "rtl8139 pci 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;
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 40ee41b693..5539336dc8 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -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),
- "usbnet 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]);