[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 3/7] acpi, pc: add cpu hot unplug request callbac
From: |
Zhu Guihua |
Subject: |
[Qemu-devel] [PATCH v3 3/7] acpi, pc: add cpu hot unplug request callback support |
Date: |
Fri, 13 Feb 2015 18:40:18 +0800 |
Signed-off-by: Zhu Guihua <address@hidden>
Signed-off-by: Gu Zheng <address@hidden>
---
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,
--
1.9.3
- [Qemu-devel] [PATCH v3 0/7] cpu: add i386 cpu hot remove support, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v3 2/7] acpi/cpu: add cpu hot unplug request callback function, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v3 1/7] x86: add x86_cpu_unrealizefn() for cpu apic remove, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v3 3/7] acpi, pc: add cpu hot unplug request callback support,
Zhu Guihua <=
- [Qemu-devel] [PATCH v3 4/7] acpi/cpu: add cpu hot unplug callback function, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v3 5/7] acpi, pc: add cpu hot unplug callback support, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v3 6/7] cpu hotplug: implement function cpu_status_write() for vcpu ejection, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v3 7/7] cpus: reclaim allocated vCPU objects, Zhu Guihua, 2015/02/13
- Re: [Qemu-devel] [PATCH v3 0/7] cpu: add i386 cpu hot remove support, Gu Zheng, 2015/02/23