From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWyS9-0002Fg-5S for qemu-devel@nongnu.org; Wed, 24 Sep 2014 22:06:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XWyS2-0002PJ-UZ for qemu-devel@nongnu.org; Wed, 24 Sep 2014 22:06:41 -0400 Received: from [59.151.112.132] (port=14921 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWyS1-0002Of-T1 for qemu-devel@nongnu.org; Wed, 24 Sep 2014 22:06:34 -0400 Message-ID: <54237895.9030009@cn.fujitsu.com> Date: Thu, 25 Sep 2014 10:06:13 +0800 From: Tang Chen MIME-Version: 1.0 References: <1411559299-19042-1-git-send-email-imammedo@redhat.com> <1411559299-19042-14-git-send-email-imammedo@redhat.com> In-Reply-To: <1411559299-19042-14-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 13/30] qdev: hotplug: set handler only if HOTPLUG_HANDLER interface is supported List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov , qemu-devel@nongnu.org Cc: cornelia.huck@de.ibm.com, mst@redhat.com, amit.shah@redhat.com, agraf@suse.de, borntraeger@de.ibm.com, kraxel@redhat.com, dmitry@daynix.com, pbonzini@redhat.com, rth@twiddle.net On 09/24/2014 07:48 PM, Igor Mammedov wrote: > Check if 'handler' implements HOTPLUG_HANDLER interface > before setting it, if it's not then do nothing and leave > bus not hotpluggable. > > That would allow to reuse the same code for creating bus > for example 'scsi_bus_new()' for both hotpluggable and not > hotpluggable controllers. > > Signed-off-by: Igor Mammedov > --- > PS: > Keep allow_hotplug = 1 before check to preserve legacy > behaviour for incremental conversion without breaking > bisect-ability. I will be removed later in series. > --- > include/hw/qdev-core.h | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h > index ba812c5..653ff4a 100644 > --- a/include/hw/qdev-core.h > +++ b/include/hw/qdev-core.h > @@ -366,9 +366,14 @@ char *qdev_get_dev_path(DeviceState *dev); > static inline void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, > Error **errp) > { > + bus->allow_hotplug = 1; BTW, why not make allow_hotplug a bool ? Thanks. > + > + if (!object_dynamic_cast(OBJECT(handler), TYPE_HOTPLUG_HANDLER)) { > + return; > + } > + > object_property_set_link(OBJECT(bus), OBJECT(handler), > QDEV_HOTPLUG_HANDLER_PROPERTY, errp); > - bus->allow_hotplug = 1; > } > > static inline bool qbus_is_hotpluggable(BusState *bus)