Moving code related to CPU creation and initialization internal parts from board level into apic and cpu objects will allow X86CPU to better model QOM object life-cycle. It will allow to create X86CPU as any other object by creating it with object_new() then setting properties and then calling x86_cpu_realize() to make it running. Later x86_cpu_realize() should become realize property.
git tree for testing: https://github.com/imammedo/qemu/tree/x86-cpu-realize-v3 Compile & Run tested: target-i386: tcg and kvm mode i386-linux-user: running of /bin/ls and /usr/bin/make on qemu tree (12): store prev_debug_excp_handler globaly and not per target target-xtensa: use global prev_debug_excp_handler instead of local one target-i386: use global prev_debug_excp_handler instead of local one target-i386: move tcg initialization into x86_cpu_initfn() pc: Add CPU as /machine/cpu[n] apic: Replace cpu_env pointer by X86CPU link taken from Andreas' QOM CPUState part 4 series, to avoid conflict with reintroducing set_ptr replaced by link<X86CPU> in this patches target-i386: move cpu halted decision into x86_cpu_reset target-i386: introduce cpu-model property for x86_cpu target-i386: make cpu a child of /machine right after it's created pc: Enable MSI support at APIC level http://thread.gmane.org/gmane.comp.emulators.kvm.devel/91186 included here to prevent confilict since qom-next doesn't have it but next patch is depending on it. target-i386: initialize APIC at CPU level target-i386: move reset callback to cpu.c and call cpu_reset() in x86_cpu_realize() cpu-defs.h | 2 +- cpu-exec.c | 7 +-- exec-all.h | 3 +- hw/apic.c | 37 +++++++++------ hw/apic.h | 2 +- hw/apic_common.c | 30 +++++++++--- hw/apic_internal.h | 2 +- hw/kvm/apic.c | 9 ++-- hw/pc.c | 92 +++----------------------------------- hw/xen.h | 10 ---- hw/xen_apic.c | 5 ++ target-i386/cpu.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++ target-i386/cpu.h | 2 + target-i386/helper.c | 41 ++++++++++------- target-i386/kvm.c | 5 +- target-xtensa/helper.c | 5 +--