From patchwork Wed Aug 27 08:08:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tang Chen X-Patchwork-Id: 383367 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 3787A140093 for ; Wed, 27 Aug 2014 18:09:15 +1000 (EST) Received: from localhost ([::1]:58092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMYI5-0003DG-89 for incoming@patchwork.ozlabs.org; Wed, 27 Aug 2014 04:09:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMYH1-0001Hs-1X for qemu-devel@nongnu.org; Wed, 27 Aug 2014 04:08:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMYGv-0002sQ-Lf for qemu-devel@nongnu.org; Wed, 27 Aug 2014 04:08:06 -0400 Received: from [59.151.112.132] (port=6472 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMYGv-0002p8-8I for qemu-devel@nongnu.org; Wed, 27 Aug 2014 04:08:01 -0400 X-IronPort-AV: E=Sophos;i="5.04,409,1406563200"; d="scan'208";a="35133054" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 27 Aug 2014 16:05:06 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s7R87voL000408; Wed, 27 Aug 2014 16:07:57 +0800 Received: from tangchen.fnst.cn.fujitsu.com (10.167.226.71) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 27 Aug 2014 16:08:04 +0800 From: Tang Chen To: , , , Date: Wed, 27 Aug 2014 16:08:35 +0800 Message-ID: <1409126919-22233-5-git-send-email-tangchen@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1409126919-22233-1-git-send-email-tangchen@cn.fujitsu.com> References: <1409126919-22233-1-git-send-email-tangchen@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.71] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: hutao@cn.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com, zhugh.fnst@cn.fujitsu.com, tangchen@cn.fujitsu.com Subject: [Qemu-devel] [RESEND PATCH v3 4/8] qdev: Add memory hot unplug support for bus-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 From: Hu Tao Implement bus-less device hot-remove in qdev_unplug(). It will call PCMachine callback introduced in previous patch. 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 da1ba48..e365a74 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 (*errp == NULL) { + 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 */