@samitouri / QOSamiQemu / commits / 721c189cb6

hw/cpu: Extract cpu_exec_realize() out of cpu_common_realizefn()

cpu_common_realizefn() contains code only used by system mode emulation. Extract it to a new cpu_exec_realize() helper. In the next commit this helper will be moved to cpu-system.c where it belongs. Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20260811183410.22428-8-philmd@oss.qualcomm.com>

Philippe Mathieu-Daudé committed Aug 10, 2026 at 16:40 UTC 721c189cb60b08bacff2b9adeb6e595d04a23975
1 file changed +8 -4
hw/core/cpu-common.c
+8 -4
@@ -246,9 +246,8 @@ bool cpu_common_realize(CPUState *cpu, Error **errp)
246 return true;
247 }
248
249 -static void cpu_exec_realize(DeviceState *dev, Error **errp)
249 +static void cpu_exec_realize(CPUState *cpu, Error **errp)
250 {
251 - CPUState *cpu = CPU(dev);
251 Object *machine = qdev_get_machine();
252
253 /* qdev_get_machine() can return something that's not TYPE_MACHINE
@@ -264,10 +263,15 @@ static void cpu_exec_realize(DeviceState *dev, Error **errp)
263 }
264 }
265
267 - if (dev->hotplugged) {
266 + if (DEVICE(cpu)->hotplugged) {
267 cpu_synchronize_post_init(cpu);
268 cpu_resume(cpu);
269 }
270 +}
271 +
272 +static void cpu_common_realizefn(DeviceState *dev, Error **errp)
273 +{
274 + cpu_exec_realize(CPU(dev), errp);
275
276 /* NOTE: latest generic point where the cpu is fully realized */
277 }
@@ -379,7 +383,7 @@ static void cpu_common_class_init(ObjectClass *klass, const void *data)
383 k->gdb_read_register = cpu_common_gdb_read_register;
384 k->gdb_write_register = cpu_common_gdb_write_register;
385 set_bit(DEVICE_CATEGORY_CPU, dc->categories);
382 - dc->realize = cpu_exec_realize;
386 + dc->realize = cpu_common_realizefn;
387 dc->unrealize = cpu_common_unrealizefn;
388 rc->phases.hold = cpu_common_reset_hold;
389 rc->phases.exit = cpu_common_reset_exit;