@@ -1063,6 +1063,9 @@ out:
return cpu;
}
+static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev,
+ DeviceState *dev, Error **errp);
+
void pc_hot_add_cpu(const int64_t id, Error **errp)
{
X86CPU *cpu;
@@ -1076,6 +1079,11 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
}
if (cpu_exists(apic_id)) {
+ DeviceState *dev = DEVICE(cpu_exists(apic_id));
+ pc_machine_device_unplug_request_cb(
+ qdev_get_hotplug_handler(dev),
+ dev,
+ &local_err);
error_setg(errp, "Unable to add CPU: %" PRIi64
", it already exists", id);
return;
@@ -629,7 +629,7 @@ CPUState *qemu_get_cpu(int index);
*
* Returns: %true - CPU is found, %false - CPU isn't found.
*/
-bool cpu_exists(int64_t id);
+CPUState *cpu_exists(int64_t id);
/**
* cpu_throttle_set:
@@ -29,7 +29,7 @@
#include "qemu/error-report.h"
#include "sysemu/sysemu.h"
-bool cpu_exists(int64_t id)
+CPUState *cpu_exists(int64_t id)
{
CPUState *cpu;
@@ -37,10 +37,10 @@ bool cpu_exists(int64_t id)
CPUClass *cc = CPU_GET_CLASS(cpu);
if (cc->get_arch_id(cpu) == id) {
- return true;
+ return cpu;
}
}
- return false;
+ return NULL;
}
CPUState *cpu_generic_init(const char *typename, const char *cpu_model)
Signed-off-by: Igor Mammedov <imammedo@redhat.com> --- hw/i386/pc.c | 8 ++++++++ include/qom/cpu.h | 2 +- qom/cpu.c | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-)