From patchwork Tue Aug 3 16:19:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 60778 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 55B77B70CB for ; Wed, 4 Aug 2010 02:26:17 +1000 (EST) Received: from localhost ([127.0.0.1]:40397 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OgKJi-0004NS-Uo for incoming@patchwork.ozlabs.org; Tue, 03 Aug 2010 12:26:14 -0400 Received: from [140.186.70.92] (port=37062 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OgKDX-000862-Up for qemu-devel@nongnu.org; Tue, 03 Aug 2010 12:19:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OgKDW-0004Qy-Un for qemu-devel@nongnu.org; Tue, 03 Aug 2010 12:19:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27050) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OgKDW-0004Qp-N9 for qemu-devel@nongnu.org; Tue, 03 Aug 2010 12:19:50 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o73GJnqO011070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 3 Aug 2010 12:19:49 -0400 Received: from localhost6.localdomain6 (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o73GJlVH019534; Tue, 3 Aug 2010 12:19:48 -0400 From: Alex Williamson To: qemu-devel@nongnu.org Date: Tue, 03 Aug 2010 10:19:47 -0600 Message-ID: <20100803161914.15514.59304.stgit@localhost6.localdomain6> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: glommer@redhat.com, alex.williamson@redhat.com Subject: [Qemu-devel] [PATCH] qdev: Reset hotplugged devices 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 Several devices rely on their reset() function being called to initialize device state, e1000 and rtl8139 in particular. When the device is hot added, the reset doesn't occur, often leaving the device in an unusable state. Adding a call to reset() after init() for hotplugged devices puts the device in the expected state for the guest. Signed-off-by: Alex Williamson --- 0.13 candidate? hw/qdev.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index e99c73f..b156272 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -278,6 +278,9 @@ int qdev_init(DeviceState *dev) qdev_free(dev); return rc; } + if (dev->hotplugged) { + qdev_reset(dev); + } qemu_register_reset(qdev_reset, dev); if (dev->info->vmsd) { vmstate_register_with_alias_id(dev, -1, dev->info->vmsd, dev,