qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] reset nic when we init it
@ 2011-02-23  8:40 Wen Congyang
  0 siblings, 0 replies; only message in thread
From: Wen Congyang @ 2011-02-23  8:40 UTC (permalink / raw)
  To: qemu-devel

When we hotplug a nic to guest OS, we can see it
but the mac address of nic is wrong.

The reason of this bug is guest OS does not reset
nic, and we init eeprom(rtl8139) only when we reset
nic.

I think we should reset nic when we init it.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>

---
 hw/e1000.c     |   14 ++++++++------
 hw/pcnet-pci.c |   19 +++++++++++--------
 hw/rtl8139.c   |    1 +
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/hw/e1000.c b/hw/e1000.c
index 0a4574c..5bd91a8 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1137,6 +1137,12 @@ static NetClientInfo net_e1000_info = {
     .link_status_changed = e1000_set_link_status,
 };
 
+static void qdev_e1000_reset(DeviceState *dev)
+{
+    E1000State *d = DO_UPCAST(E1000State, dev.qdev, dev);
+    e1000_reset(d);
+}
+
 static int pci_e1000_init(PCIDevice *pci_dev)
 {
     E1000State *d = DO_UPCAST(E1000State, dev, pci_dev);
@@ -1186,13 +1192,9 @@ static int pci_e1000_init(PCIDevice *pci_dev)
 
     add_boot_device_path(d->conf.bootindex, &pci_dev->qdev, "/ethernet-phy@0");
 
-    return 0;
-}
+    qdev_e1000_reset(&pci_dev->qdev);
 
-static void qdev_e1000_reset(DeviceState *dev)
-{
-    E1000State *d = DO_UPCAST(E1000State, dev.qdev, dev);
-    e1000_reset(d);
+    return 0;
 }
 
 static PCIDeviceInfo e1000_info = {
diff --git a/hw/pcnet-pci.c b/hw/pcnet-pci.c
index 339a401..205f2c7 100644
--- a/hw/pcnet-pci.c
+++ b/hw/pcnet-pci.c
@@ -265,11 +265,19 @@ static NetClientInfo net_pci_pcnet_info = {
     .cleanup = pci_pcnet_cleanup,
 };
 
+static void pci_reset(DeviceState *dev)
+{
+    PCIPCNetState *d = DO_UPCAST(PCIPCNetState, pci_dev.qdev, dev);
+
+    pcnet_h_reset(&d->state);
+}
+
 static int pci_pcnet_init(PCIDevice *pci_dev)
 {
     PCIPCNetState *d = DO_UPCAST(PCIPCNetState, pci_dev, pci_dev);
     PCNetState *s = &d->state;
     uint8_t *pci_conf;
+    int ret;
 
 #if 0
     printf("sizeof(RMD)=%d, sizeof(TMD)=%d\n",
@@ -315,14 +323,9 @@ static int pci_pcnet_init(PCIDevice *pci_dev)
         }
     }
 
-    return pcnet_common_init(&pci_dev->qdev, s, &net_pci_pcnet_info);
-}
-
-static void pci_reset(DeviceState *dev)
-{
-    PCIPCNetState *d = DO_UPCAST(PCIPCNetState, pci_dev.qdev, dev);
-
-    pcnet_h_reset(&d->state);
+    ret = pcnet_common_init(&pci_dev->qdev, s, &net_pci_pcnet_info);
+    pci_reset(&pci_dev->qdev);
+    return ret;
 }
 
 static PCIDeviceInfo pcnet_info = {
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index a22530c..15425a8 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -3405,6 +3405,7 @@ static int pci_rtl8139_init(PCIDevice *dev)
     rtl8139_set_next_tctr_time(s, qemu_get_clock(vm_clock));
 
     add_boot_device_path(s->conf.bootindex, &dev->qdev, "/ethernet-phy@0");
+    rtl8139_reset(&dev->qdev);
 
     return 0;
 }
-- 
1.7.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-02-23  8:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-23  8:40 [Qemu-devel] [PATCH] reset nic when we init it Wen Congyang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).