@@ -635,11 +635,6 @@ static const MemoryRegionOps cpu_hotplug_ops = {
},
};
-typedef enum {
- PLUG,
- UNPLUG,
-} HotplugEventType;
-
static void piix4_cpu_hotplug_req(PIIX4PMState *s, CPUState *cpu,
HotplugEventType action)
{
@@ -663,8 +658,9 @@ static void piix4_cpu_hotplug_req(PIIX4PMState *s, CPUState *cpu,
static void piix4_cpu_hotplug(Notifier *n, void *opaque)
{
PIIX4PMState *s = container_of(n, PIIX4PMState, cpu_hotplug_notifier);
+ CPUNotifier *notifier = opaque;
- piix4_cpu_hotplug_req(s, CPU(opaque), PLUG);
+ piix4_cpu_hotplug_req(s, CPU(notifier->dev), notifier->type);
}
static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,
@@ -507,6 +507,16 @@ void qemu_init_vcpu(CPUState *cpu);
*/
void cpu_single_step(CPUState *cpu, int enabled);
+typedef enum {
+ PLUG,
+ UNPLUG,
+} HotplugEventType;
+
+typedef struct CPUNotifier {
+ DeviceState *dev;
+ HotplugEventType type;
+} CPUNotifier;
+
#ifdef CONFIG_SOFTMMU
extern const struct VMStateDescription vmstate_cpu_common;
#else
@@ -215,10 +215,14 @@ static ObjectClass *cpu_common_class_by_name(const char *cpu_model)
static void cpu_common_realizefn(DeviceState *dev, Error **errp)
{
CPUState *cpu = CPU(dev);
+ CPUNotifier notifier;
+
+ notifier.dev = dev;
+ notifier.type = PLUG;
if (dev->hotplugged) {
cpu_synchronize_post_init(cpu);
- notifier_list_notify(&cpu_hotplug_notifiers, dev);
+ notifier_list_notify(&cpu_hotplug_notifiers, ¬ifier);
cpu_resume(cpu);
}
}
Move struct HotplugEventType from file piix4.c to file qom/cpu.c, and add struct CPUNotifier for supporting UNPLUG cpu notifier. Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com> --- hw/acpi/piix4.c | 8 ++------ include/qom/cpu.h | 10 ++++++++++ qom/cpu.c | 6 +++++- 3 files changed, 17 insertions(+), 7 deletions(-)