Signed-off-by: Zhu Guihua <zhugh.f...@cn.fujitsu.com> Signed-off-by: Gu Zheng <guz.f...@cn.fujitsu.com> --- cpus.c | 7 +++++++ hw/acpi/cpu_hotplug.c | 8 ++++++++ include/hw/acpi/cpu_hotplug.h | 3 +++ include/qom/cpu.h | 9 +++++++++ 4 files changed, 27 insertions(+)
diff --git a/cpus.c b/cpus.c index d5e35c0..1c25054 100644 --- a/cpus.c +++ b/cpus.c @@ -1205,6 +1205,13 @@ void resume_all_vcpus(void) } } +void cpu_remove(CPUState *cpu) +{ + cpu->stop = true; + cpu->exit = true; + qemu_cpu_kick(cpu); +} + /* For temporary buffers for forming a name */ #define VCPU_THREAD_NAME_SIZE 16 diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c index f8a10d2..36feb6a 100644 --- a/hw/acpi/cpu_hotplug.c +++ b/hw/acpi/cpu_hotplug.c @@ -94,6 +94,14 @@ void acpi_cpu_unplug_request_cb(ACPIREGS *ar, qemu_irq irq, acpi_update_sci(ar, irq); } +void acpi_cpu_unplug_cb(ACPIREGS *ar, qemu_irq irq, AcpiCpuHotplug *g, + DeviceState *dev, Error **errp) +{ + CPUState *cpu = CPU(dev); + + cpu_remove(cpu); +} + void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, AcpiCpuHotplug *gpe_cpu, uint16_t base) { diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h index 8b15a3d..0f84adb 100644 --- a/include/hw/acpi/cpu_hotplug.h +++ b/include/hw/acpi/cpu_hotplug.h @@ -27,6 +27,9 @@ void acpi_cpu_unplug_request_cb(ACPIREGS *ar, qemu_irq irq, AcpiCpuHotplug *g, DeviceState *dev, Error **errp); +void acpi_cpu_unplug_cb(ACPIREGS *ar, qemu_irq irq, + AcpiCpuHotplug *g, DeviceState *dev, Error **errp); + void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, AcpiCpuHotplug *gpe_cpu, uint16_t base); #endif diff --git a/include/qom/cpu.h b/include/qom/cpu.h index f663199..0592b4d 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -249,6 +249,7 @@ struct CPUState { bool created; bool stop; bool stopped; + bool exit; volatile sig_atomic_t exit_request; uint32_t interrupt_request; int singlestep_enabled; @@ -613,6 +614,14 @@ void cpu_exit(CPUState *cpu); void cpu_resume(CPUState *cpu); /** + * cpu_remove: + * @cpu: The vCPU to remove. + * + * Requests the CPU @cpu to be removed. + */ +void cpu_remove(CPUState *cpu); + +/** * qemu_init_vcpu: * @cpu: The vCPU to initialize. * -- 1.9.3