Hi, This is the 6th iteration of patchset that introduces CPU hotplug for PowerPC sPAPR guests using device_add/device_del commands.
(qemu) device_add powerpc64-cpu-core,id=core1 The first 6 patches are generic changes. 1/11 machine: Don't allow CPU toplogies with partially filled cores 2/11 exec: Remove cpu from cpus list during cpu_exec_exit() 3/11 exec: Do vmstate unregistration from cpu_exec_exit() 4/11 cpu: Don't realize CPU from cpu_generic_init() Above 4 patches can stand on their own and probably can be pushed ahead of actual hotplug patches when found ready. Let me know if I should pursue these in a separate patchset. 5/11 cpu: Reclaim vCPU objects Above patch is needed by x86 as well as s390 and has been posted in their respective CPU hotplug patchsets. 6/11 cpu: Add a sync version of cpu_remove() The remaining patches are ppc/spapr specific. I had posted an RFC on generic cpu-core device in Dec 15. (https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg01526.html) While that was an attempt to define common CPU device semantics that could work for all archs, this patchset continues to pursue the PowerPC specific semantics. One aspect that is still missing from this patchset is to expose this arch sepcific CPU device name in a way that becomes easier for higher level management tool like libvirt. A patchset addressing this aspect would benefit x86 and s390 CPU hotplug platchsets as well. Main changes in v6 ------------------ - Instead of creating and realizing SMT threads from main thread's plug() routine, I have now created a PowerPC specific CPU core device which will create all the threads of the core from its instance_init and realize them separately. (10/11) - The new CPU core device will change the semantics of CPU hotplug. Instead of the earlier semantics which had CPU model and CPU type name like (qemu) device_add POWER8-powerpc64-cpu,id=cpu0 ,we now have the following semantics to add a core: (qemu) device_add powerpc64-cpu-core,id=core1 - Added a patch to remove realization part from cpu_generic_init() and moved the realization bit to the callers. (4/11) - The approach to prevent partially filled cores has been modified based on Eduardo's suggestion. (1/11) - CPUs specified with -smp command line option are created as PowerPC specific CPU core device only if CPU hotplug is enabled (pseries-2.6 and higher). Otherwise they continue to be brought up as individual CPU devices as earlier. This allows us to support partially filled CPU core configuations w/o the associated ugliness I had in v4. (10/11) - CPU unplug patch has been reworked to show the core and thread unplug routines explicit and clear. (11/11) Other changes ------------- - Moved ss->cs handling into xics based on David's review. (7/11) - Use of iothread unlock instead of global mutex in CPU reclaims patch based on David and Alexey's review. (5/11) - No need to use DIV_UP when calculating the numbers of cores as we are already preventing configurations with partially fileed cores as per David's review. (9/11) - Removed spapr_cpu_init() call from boot time cpus initialization as it is now done from ->plug() handler (10/11) - Enabled CPU hotplug for pseries-2.6 instead of 2.5. v5: https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg04655.html Bharata B Rao (10): machine: Don't allow CPU toplogies with partially filled cores exec: Remove cpu from cpus list during cpu_exec_exit() exec: Do vmstate unregistration from cpu_exec_exit() cpu: Don't realize CPU from cpu_generic_init() cpu: Add a sync version of cpu_remove() xics,xics_kvm: Handle CPU unplug correctly target-ppc: Introduce PowerPC specific CPU core device spapr: Enable CPU hotplug for pseries-2.6 and add CPU DRC DT entries spapr: CPU hotplug support spapr: CPU hot unplug support Gu Zheng (1): cpu: Reclaim vCPU objects cpus.c | 50 +++++++ exec.c | 30 ++++ hw/core/machine.c | 20 +++ hw/i386/pc_piix.c | 7 + hw/i386/pc_q35.c | 7 + hw/intc/xics.c | 13 ++ hw/intc/xics_kvm.c | 8 +- hw/ppc/Makefile.objs | 1 + hw/ppc/cpu-core.c | 69 ++++++++++ hw/ppc/spapr.c | 326 +++++++++++++++++++++++++++++++++++++++++++- hw/ppc/spapr_events.c | 3 + hw/ppc/spapr_rtas.c | 24 ++++ include/hw/boards.h | 1 + include/hw/ppc/cpu-core.h | 22 +++ include/hw/ppc/spapr.h | 12 ++ include/hw/ppc/xics.h | 1 + include/qom/cpu.h | 18 +++ include/sysemu/kvm.h | 1 + kvm-all.c | 57 +++++++- kvm-stub.c | 5 + qom/cpu.c | 6 - target-arm/helper.c | 16 ++- target-cris/cpu.c | 16 ++- target-lm32/helper.c | 16 ++- target-moxie/cpu.c | 16 ++- target-openrisc/cpu.c | 16 ++- target-ppc/translate_init.c | 24 +++- target-sh4/cpu.c | 16 ++- target-tricore/helper.c | 16 ++- target-unicore32/helper.c | 16 ++- vl.c | 4 + 31 files changed, 810 insertions(+), 27 deletions(-) create mode 100644 hw/ppc/cpu-core.c create mode 100644 include/hw/ppc/cpu-core.h -- 2.1.0