From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=35769 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PsAIV-0005d2-0R for qemu-devel@nongnu.org; Wed, 23 Feb 2011 03:42:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PsAIT-0000i4-EJ for qemu-devel@nongnu.org; Wed, 23 Feb 2011 03:42:10 -0500 Received: from [222.73.24.84] (port=60621 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PsAIS-0000gy-TH for qemu-devel@nongnu.org; Wed, 23 Feb 2011 03:42:09 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 2DBAD170135 for ; Wed, 23 Feb 2011 16:41:56 +0800 (CST) Received: from mailserver.fnst.cn.fujitus.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id p1N8aBCX010863 for ; Wed, 23 Feb 2011 16:36:12 +0800 Message-ID: <4D64C7F2.2070909@cn.fujitsu.com> Date: Wed, 23 Feb 2011 16:40:18 +0800 From: Wen Congyang MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1 Subject: [Qemu-devel] [PATCH] reset nic when we init it List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 --- 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