From patchwork Wed Feb 23 08:40:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 84110 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0C7D5B70DA for ; Wed, 23 Feb 2011 19:43:00 +1100 (EST) Received: from localhost ([127.0.0.1]:53199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PsAJE-0005dK-Qj for incoming@patchwork.ozlabs.org; Wed, 23 Feb 2011 03:42:56 -0500 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 Received: from [10.167.225.226] ([10.167.225.226]) by mailserver.fnst.cn.fujitus.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2011022316405057-203425 ; Wed, 23 Feb 2011 16:40:50 +0800 Message-ID: <4D64C7F2.2070909@cn.fujitsu.com> Date: Wed, 23 Feb 2011 16:40:18 +0800 From: Wen Congyang User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100413 Fedora/3.0.4-2.fc13 Thunderbird/3.0.4 MIME-Version: 1.0 To: qemu-devel X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-02-23 16:40:50, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-02-23 16:40:53, Serialize complete at 2011-02-23 16:40:53 X-detected-operating-system: by eggs.gnu.org: FreeBSD 6.x (1) X-Received-From: 222.73.24.84 Subject: [Qemu-devel] [PATCH] reset nic when we init it X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; }