From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmloY-0007ff-N5 for qemu-devel@nongnu.org; Tue, 20 May 2014 11:18:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmloM-0000ox-W3 for qemu-devel@nongnu.org; Tue, 20 May 2014 11:18:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmloM-0000of-OP for qemu-devel@nongnu.org; Tue, 20 May 2014 11:18:38 -0400 From: Igor Mammedov Date: Tue, 20 May 2014 17:15:10 +0200 Message-Id: <1400598934-31921-8-git-send-email-imammedo@redhat.com> In-Reply-To: <1400598934-31921-1-git-send-email-imammedo@redhat.com> References: <1400598934-31921-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH v2 07/31] qdev: hotplug for buss-less devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, alex@alex.org.uk, mst@redhat.com, aik@ozlabs.ru, hutao@cn.fujitsu.com, mjt@tls.msk.ru, tangchen@cn.fujitsu.com, kraxel@redhat.com, pasteka@kabsi.at, s.priebe@profihost.ag, agarcia@igalia.com, armbru@redhat.com, aliguori@amazon.com, david@gibson.dropbear.id.au, lersek@redhat.com, ehabkost@redhat.com, marcel.a@redhat.com, stefanha@redhat.com, cornelia.huck@de.ibm.com, rth@twiddle.net, agraf@suse.de, andrey@xdel.ru, vasilis.liaskovitis@profitbricks.com, pbonzini@redhat.com, afaerber@suse.de, aurelien@aurel32.net Adds get_hotplug_handler() method to machine, and makes bus-less device to use it during hotplug as a means to discover hotplug handler controller. Returned controller is used to permorm a hotplug action. Signed-off-by: Igor Mammedov --- hw/core/qdev.c | 13 +++++++++++++ include/hw/boards.h | 8 ++++++++ 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 936eae6..b4585f2 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -34,6 +34,7 @@ #include "qapi/qmp/qjson.h" #include "monitor/monitor.h" #include "hw/hotplug.h" +#include "hw/boards.h" int qdev_hotplug = 0; static bool qdev_hot_added = false; @@ -761,6 +762,18 @@ static void device_set_realized(Object *obj, bool value, Error **errp) local_err == NULL) { hotplug_handler_plug(dev->parent_bus->hotplug_handler, dev, &local_err); + } else if (local_err == NULL && + object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) { + HotplugHandler *hotplug_ctrl; + MachineState *machine = MACHINE(qdev_get_machine()); + MachineClass *mc = MACHINE_GET_CLASS(machine); + + if (mc->get_hotplug_handler) { + hotplug_ctrl = mc->get_hotplug_handler(machine, dev); + if (hotplug_ctrl) { + hotplug_handler_plug(hotplug_ctrl, dev, &local_err); + } + } } if (qdev_get_vmsd(dev) && local_err == NULL) { diff --git a/include/hw/boards.h b/include/hw/boards.h index f6fbbe1..e4cce46 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -60,6 +60,11 @@ extern MachineState *current_machine; /** * MachineClass: * @qemu_machine: #QEMUMachine + * @get_hotplug_handler: this function is called during bus-less + * device hotplug. If defined it returns pointer to an instance + * of HotplugHandler object, which handles hotplug operation + * for a given @dev. It may return NULL if @dev doesn't require + * any actions to be performed by hotplug handler. */ struct MachineClass { /*< private >*/ @@ -89,6 +94,9 @@ struct MachineClass { const char *default_boot_order; GlobalProperty *compat_props; const char *hw_version; + + HotplugHandler *(*get_hotplug_handler)(MachineState *machine, + DeviceState *dev); }; /** -- 1.7.1