[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 05/11] pc: add cpu hot unplug request callback su
From: |
Zhu Guihua |
Subject: |
[Qemu-devel] [PATCH v2 05/11] pc: add cpu hot unplug request callback support |
Date: |
Wed, 14 Jan 2015 15:44:58 +0800 |
Add cpu hot unplug request callback support, and a pre-check about the
active cpus is added to avoid removing the last cpu.
Signed-off-by: Zhu Guihua <address@hidden>
Signed-off-by: Gu Zheng <address@hidden>
---
hw/i386/pc.c | 36 ++++++++++++++++++++++++++++++++++--
1 file changed, 34 insertions(+), 2 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 9bdec16..dd6e8da 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1694,6 +1694,34 @@ 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;
+
+ if (smp_cpus == 1) {
+ error_setg(&local_err,
+ "This is the last cpu, should not be removed!");
+ 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)
{
@@ -1707,8 +1735,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,
--
1.9.3
- [Qemu-devel] [PATCH v2 00/11] cpu: add i386 cpu hot remove support, Zhu Guihua, 2015/01/14
- [Qemu-devel] [PATCH v2 02/11] acpi/cpu: add cpu hot unplug request callback function, Zhu Guihua, 2015/01/14
- [Qemu-devel] [PATCH v2 01/11] x86: add x86_cpu_unrealizefn() for cpu apic remove, Zhu Guihua, 2015/01/14
- [Qemu-devel] [PATCH v2 03/11] acpi/piix4: add cpu hot unplug request callback support, Zhu Guihua, 2015/01/14
- [Qemu-devel] [PATCH v2 04/11] acpi/ich9: add cpu hot unplug request callback support, Zhu Guihua, 2015/01/14
- [Qemu-devel] [PATCH v2 05/11] pc: add cpu hot unplug request callback support,
Zhu Guihua <=
- [Qemu-devel] [PATCH v2 06/11] acpi/cpu: add cpu hot unplug callback function, Zhu Guihua, 2015/01/14
- [Qemu-devel] [PATCH v2 07/11] acpi/piix4: add cpu hot unplug callback support, Zhu Guihua, 2015/01/14
- [Qemu-devel] [PATCH v2 08/11] acpi/ich9: add cpu hot unplug support, Zhu Guihua, 2015/01/14
- [Qemu-devel] [PATCH v2 09/11] pc: add cpu hot unplug callback support, Zhu Guihua, 2015/01/14
- [Qemu-devel] [PATCH v2 10/11] cpu hotplug: implement function cpu_status_write() for vcpu ejection, Zhu Guihua, 2015/01/14
- [Qemu-devel] [PATCH v2 11/11] cpus: reclaim allocated vCPU objects, Zhu Guihua, 2015/01/14
- Message not available