From patchwork Fri Feb 13 10:40:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Guihua X-Patchwork-Id: 439484 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 7F4661401F6 for ; Fri, 13 Feb 2015 21:44:22 +1100 (AEDT) Received: from localhost ([::1]:54431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMDjQ-0002gs-O9 for incoming@patchwork.ozlabs.org; Fri, 13 Feb 2015 05:44:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMDh9-0006q7-D2 for qemu-devel@nongnu.org; Fri, 13 Feb 2015 05:42:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMDh5-0003wF-0I for qemu-devel@nongnu.org; Fri, 13 Feb 2015 05:41:58 -0500 Received: from [59.151.112.132] (port=25995 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMDh4-0003b9-CA for qemu-devel@nongnu.org; Fri, 13 Feb 2015 05:41:54 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="57556761" Received: from localhost (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 13 Feb 2015 18:38:19 +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 t1DAf7gK029731; Fri, 13 Feb 2015 18:41:07 +0800 Received: from G08FNSTD140041.g08.fujitsu.local (10.167.226.252) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 13 Feb 2015 18:41:54 +0800 From: Zhu Guihua To: Date: Fri, 13 Feb 2015 18:40:18 +0800 Message-ID: <4a9c9135a3ed1fab6e892347fd9d278f04957da0.1423823368.git.zhugh.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.226.252] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Zhu Guihua , tangchen@cn.fujitsu.com, guz.fnst@cn.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com, anshul.makkar@profitbricks.com, chen.fan.fnst@cn.fujitsu.com, imammedo@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v3 3/7] acpi, pc: add cpu hot unplug request callback support 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 Signed-off-by: Zhu Guihua Signed-off-by: Gu Zheng --- hw/acpi/ich9.c | 9 +++++++-- hw/acpi/piix4.c | 2 ++ hw/i386/pc.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 5352e19..7600e88 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -400,8 +400,13 @@ void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp) void ich9_pm_device_unplug_request_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp) { - error_setg(errp, "acpi: device unplug request for not supported device" - " type: %s", object_get_typename(OBJECT(dev))); + if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + acpi_cpu_unplug_request_cb(&pm->acpi_regs, pm->irq, + &pm->gpe_cpu, dev, errp); + } else { + error_setg(errp, "acpi: device unplug request for not supported device" + " type: %s", object_get_typename(OBJECT(dev))); + } } void ich9_pm_device_unplug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 14d40a0..23595b6 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -364,6 +364,8 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev, if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { acpi_pcihp_device_unplug_cb(&s->ar, s->irq, &s->acpi_pci_hotplug, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + acpi_cpu_unplug_request_cb(&s->ar, s->irq, &s->gpe_cpu, dev, errp); } else { error_setg(errp, "acpi: device unplug request for not supported device" " type: %s", object_get_typename(OBJECT(dev))); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c1ecf08..80dac20 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1653,6 +1653,40 @@ out: error_propagate(errp, local_err); } +static void pc_cpu_unplug_request(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + HotplugHandlerClass *hhc; + Error *local_err = NULL; + PCMachineState *pcms; + CPUState *cpu; + int current_cpus = 0; + + CPU_FOREACH(cpu) { + current_cpus++; + } + + if (current_cpus == 1) { + error_setg(&local_err, + "remove the last cpu is not allowed"); + goto out; + } + + pcms = PC_MACHINE(hotplug_dev); + if (!pcms->acpi_dev) { + if (dev->hotplugged) { + error_setg(&local_err, + "cpu hot unplug is not enabled: missing acpi device"); + } + goto out; + } + + hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); + hhc->unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err); +out: + error_propagate(errp, local_err); +} + static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -1666,8 +1700,12 @@ static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev, static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - error_setg(errp, "acpi: device unplug request for not supported device" - " type: %s", object_get_typename(OBJECT(dev))); + if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + pc_cpu_unplug_request(hotplug_dev, dev, errp); + } else { + error_setg(errp, "acpi: device unplug request for not supported device" + " type: %s", object_get_typename(OBJECT(dev))); + } } static void pc_machine_device_unplug_cb(HotplugHandler *hotplug_dev,