From: Wen Congyang <wency@cn.fujitsu.com>
To: qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] reset nic when we init it
Date: Wed, 23 Feb 2011 16:40:18 +0800 [thread overview]
Message-ID: <4D64C7F2.2070909@cn.fujitsu.com> (raw)
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
reply other threads:[~2011-02-23 8:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D64C7F2.2070909@cn.fujitsu.com \
--to=wency@cn.fujitsu.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.