From patchwork Fri Apr 4 13:36:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 336995 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 364AD1400E8 for ; Sat, 5 Apr 2014 01:49:09 +1100 (EST) Received: from localhost ([::1]:49923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WW4M0-0003iv-1E for incoming@patchwork.ozlabs.org; Fri, 04 Apr 2014 09:40:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WW4Jw-00012F-2C for qemu-devel@nongnu.org; Fri, 04 Apr 2014 09:38:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WW4Jo-0005yO-2K for qemu-devel@nongnu.org; Fri, 04 Apr 2014 09:38:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8445) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WW4Jn-0005y8-Ps for qemu-devel@nongnu.org; Fri, 04 Apr 2014 09:38:04 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s34DbsRj019693 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 4 Apr 2014 09:37:54 -0400 Received: from thinkpad.redhat.com (vpn-226-165.phx2.redhat.com [10.3.226.165]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s34Db1fO029770; Fri, 4 Apr 2014 09:37:49 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 4 Apr 2014 15:36:33 +0200 Message-Id: <1396618620-27823-9-git-send-email-imammedo@redhat.com> In-Reply-To: <1396618620-27823-1-git-send-email-imammedo@redhat.com> References: <1396618620-27823-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, mst@redhat.com, aik@ozlabs.ru, hutao@cn.fujitsu.com, mjt@tls.msk.ru, lcapitulino@redhat.com, kraxel@redhat.com, akong@redhat.com, quintela@redhat.com, armbru@redhat.com, aliguori@amazon.com, jan.kiszka@siemens.com, lersek@redhat.com, ehabkost@redhat.com, marcel.a@redhat.com, stefanha@redhat.com, chegu_vinod@hp.com, rth@twiddle.net, kwolf@redhat.com, s.priebe@profihost.ag, mreitz@redhat.com, vasilis.liaskovitis@profitbricks.com, pbonzini@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH 08/35] qdev: hotplug for buss-less devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 60f9df1..50bb8f5 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 **err) 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 3567190..67750b5 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -73,6 +73,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 >*/ @@ -80,6 +85,9 @@ struct MachineClass { /*< public >*/ QEMUMachine *qemu_machine; + + HotplugHandler *(*get_hotplug_handler)(MachineState *machine, + DeviceState *dev); }; /**