From: Gu Zheng <guz.f...@cn.fujitsu.com> Signed-off-by: Gu Zheng <guz.f...@cn.fujitsu.com> Signed-off-by: Zhu Guihua <zhugh.f...@cn.fujitsu.com> --- hw/acpi/ich9.c | 8 ++++++-- hw/acpi/piix4.c | 10 ++++++++-- hw/i386/pc.c | 26 ++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 7600e88..f095999 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -412,8 +412,12 @@ void ich9_pm_device_unplug_request_cb(ICH9LPCPMRegs *pm, DeviceState *dev, void ich9_pm_device_unplug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp) { - error_setg(errp, "acpi: device unplug for not supported device" - " type: %s", object_get_typename(OBJECT(dev))); + if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + acpi_cpu_unplug_cb(&pm->acpi_regs, pm->irq, &pm->gpe_cpu, dev, errp); + } else { + error_setg(errp, "acpi: device unplug for not supported device" + " type: %s", object_get_typename(OBJECT(dev))); + } } void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 23595b6..4ca9153 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -375,8 +375,14 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev, static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - error_setg(errp, "acpi: device unplug for not supported device" - " type: %s", object_get_typename(OBJECT(dev))); + PIIX4PMState *s = PIIX4_PM(hotplug_dev); + + if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + acpi_cpu_unplug_cb(&s->ar, s->irq, &s->gpe_cpu, dev, errp); + } else { + error_setg(errp, "acpi: device unplug for not supported device" + " type: %s", object_get_typename(OBJECT(dev))); + } } static void piix4_update_bus_hotplug(PCIBus *pci_bus, void *opaque) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 80dac20..d0d289b 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1687,6 +1687,24 @@ out: error_propagate(errp, local_err); } +static void pc_cpu_unplug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + HotplugHandlerClass *hhc; + Error *local_err = NULL; + PCMachineState *pcms = PC_MACHINE(hotplug_dev); + + hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); + hhc->unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + /* decrement the number of CPUs */ + rtc_set_memory(pcms->rtc, 0x5f, rtc_get_memory(pcms->rtc, 0x5f) - 1); +} + static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -1711,8 +1729,12 @@ static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev, static void pc_machine_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - error_setg(errp, "acpi: device unplug for not supported device" - " type: %s", object_get_typename(OBJECT(dev))); + if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + pc_cpu_unplug(hotplug_dev, dev, errp); + } else { + error_setg(errp, "acpi: device unplug for not supported device" + " type: %s", object_get_typename(OBJECT(dev))); + } } static HotplugHandler *pc_get_hotpug_handler(MachineState *machine, -- 1.9.3