From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47434 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnVha-0003GT-98 for qemu-devel@nongnu.org; Mon, 23 Aug 2010 08:00:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OnVhY-0002iJ-Qc for qemu-devel@nongnu.org; Mon, 23 Aug 2010 08:00:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63010) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnVhY-0002i3-Gi for qemu-devel@nongnu.org; Mon, 23 Aug 2010 08:00:32 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7NC0VIv027263 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 Aug 2010 08:00:31 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7NC0TkS001495 for ; Mon, 23 Aug 2010 08:00:30 -0400 Message-ID: <4C7262DC.3040001@redhat.com> Date: Mon, 23 Aug 2010 15:00:28 +0300 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] qdev: Reset hotplugged devices References: <20100803161914.15514.59304.stgit@localhost6.localdomain6> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Alex Williamson , glommer@redhat.com, qemu-devel@nongnu.org On 08/20/2010 12:00 PM, Markus Armbruster wrote: > Alex Williamson writes: > >> 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, > qdev_reset() isn't necessary when !dev->hotplugged, because then > qemu_system_reset() will run shortly, which will call qdev_reset(). > Correct? Off-topic, but what's the reason for dev->hotplugged's existence? A device is either plugged or not, it is either hotpluggable or not, but is there a way to tell, from looking at a plugged device, whether it has been hotplugged in the past? AFAICT it is redundant state and should be removed. -- error compiling committee.c: too many arguments to function