From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xecvf-0001Br-7U for qemu-devel@nongnu.org; Thu, 16 Oct 2014 00:44:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xecva-0002Lk-JL for qemu-devel@nongnu.org; Thu, 16 Oct 2014 00:44:47 -0400 Received: from [59.151.112.132] (port=62945 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XecvZ-0002KO-S8 for qemu-devel@nongnu.org; Thu, 16 Oct 2014 00:44:42 -0400 From: Tang Chen Date: Thu, 16 Oct 2014 12:44:22 +0800 Message-ID: <1413434666-22732-9-git-send-email-tangchen@cn.fujitsu.com> In-Reply-To: <1413434666-22732-1-git-send-email-tangchen@cn.fujitsu.com> References: <1413434666-22732-1-git-send-email-tangchen@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v4 08/12] qdev: Add memory hot unplug support for bus-less devices. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, imammedo@redhat.com, mst@redhat.com, pbonzini@redhat.com Cc: hutao@cn.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com, zhugh.fnst@cn.fujitsu.com, tangchen@cn.fujitsu.com From: Hu Tao Implement bus-less device hot-remove in qdev_unplug(). For now, only pc-dimm is bus-less device, but this is generic handling that applies to other devices. Signed-off-by: Hu Tao Signed-off-by: Tang Chen --- hw/core/qdev.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index fcb1638..01d89a8 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -228,6 +228,14 @@ void qdev_unplug(DeviceState *dev, Error **errp) if (dev->parent_bus && dev->parent_bus->hotplug_handler) { hotplug_handler_unplug(dev->parent_bus->hotplug_handler, dev, errp); + } else if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) { + HotplugHandler *hotplug_ctrl; + MachineState *machine = MACHINE(qdev_get_machine()); + MachineClass *mc = MACHINE_GET_CLASS(machine); + + hotplug_ctrl = mc->get_hotplug_handler(machine, dev); + if (hotplug_ctrl) + hotplug_handler_unplug(hotplug_ctrl, dev, errp); } else { assert(dc->unplug != NULL); if (dc->unplug(dev) < 0) { /* legacy handler */ -- 1.8.4.2