From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeEy1-0005zn-JZ for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeExu-0004n9-Eb for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:37 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49332 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeExu-0004mK-7g for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:30 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 15 Oct 2014 05:08:56 +0200 Message-Id: <1413342561-4754-23-git-send-email-afaerber@suse.de> In-Reply-To: <1413342561-4754-1-git-send-email-afaerber@suse.de> References: <1413342561-4754-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 22/47] qdev: Add wrapper to set BUS as HotplugHandler List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Igor Mammedov , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Igor Mammedov To be used for conversion of SCSI and USB devices, and would allow to make every HBA/USB host switch to HotplugHandler API without touching each controller explicitly. Signed-off-by: Igor Mammedov Reviewed-by: Paolo Bonzini Signed-off-by: Andreas F=C3=A4rber --- hw/core/qdev.c | 19 +++++++++++++++++++ include/hw/qdev-core.h | 11 ++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 9f18520..b1da409 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -112,6 +112,25 @@ void qdev_set_parent_bus(DeviceState *dev, BusState = *bus) bus_add_child(bus, dev); } =20 +static void qbus_set_hotplug_handler_internal(BusState *bus, Object *han= dler, + Error **errp) +{ + + object_property_set_link(OBJECT(bus), OBJECT(handler), + QDEV_HOTPLUG_HANDLER_PROPERTY, errp); + bus->allow_hotplug =3D 1; +} + +void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, Error= **errp) +{ + qbus_set_hotplug_handler_internal(bus, OBJECT(handler), errp); +} + +void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp) +{ + qbus_set_hotplug_handler_internal(bus, OBJECT(bus), errp); +} + /* Create a new device. This only initializes the device state structur= e and allows properties to be set. qdev_init should be called to initialize the actual device emulation. */ diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index ba812c5..48e9579 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -363,13 +363,10 @@ extern int qdev_hotplug; =20 char *qdev_get_dev_path(DeviceState *dev); =20 -static inline void qbus_set_hotplug_handler(BusState *bus, DeviceState *= handler, - Error **errp) -{ - object_property_set_link(OBJECT(bus), OBJECT(handler), - QDEV_HOTPLUG_HANDLER_PROPERTY, errp); - bus->allow_hotplug =3D 1; -} +void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, + Error **errp); + +void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp); =20 static inline bool qbus_is_hotpluggable(BusState *bus) { --=20 1.8.4.5