Hi, This is an attempt to implement David Gibson's RFC that was posted at https://lists.gnu.org/archive/html/qemu-ppc/2016-02/msg00000.html I am not sure if I have followed all the aspects of the RFC fully, but we can make changes going forward.
An example cpu-package implementation is done for sPAPR in this patchset. Hot removal is not yet done in this patchset. For the command line, -smp 8,sockets=1,cores=1,threads=8,maxcpus=16 -numa node,nodeid=0,cpus=0-7 -numa node,nodeid=1,cpus=8-15 the HMP query looks like this: (qemu) info cpu-packages CPU Package: "" type: "spapr-cpu-package" qom_path: "/machine/cpu-package[0]" realized: true nr_cpus: 8 CPU: 0 Type: "host-powerpc64-cpu" Arch ID: 0 Thread: 0 Core: 0 Socket: 0 Node: 0 CPU: 1 Type: "host-powerpc64-cpu" Arch ID: 1 Thread: 1 Core: 0 Socket: 0 Node: 0 CPU: 2 Type: "host-powerpc64-cpu" Arch ID: 2 Thread: 2 Core: 0 Socket: 0 Node: 0 CPU: 3 Type: "host-powerpc64-cpu" Arch ID: 3 Thread: 3 Core: 0 Socket: 0 Node: 0 CPU: 4 Type: "host-powerpc64-cpu" Arch ID: 4 Thread: 4 Core: 0 Socket: 0 Node: 0 CPU: 5 Type: "host-powerpc64-cpu" Arch ID: 5 Thread: 5 Core: 0 Socket: 0 Node: 0 CPU: 6 Type: "host-powerpc64-cpu" Arch ID: 6 Thread: 6 Core: 0 Socket: 0 Node: 0 CPU: 7 Type: "host-powerpc64-cpu" Arch ID: 7 Thread: 7 Core: 0 Socket: 0 Node: 0 CPU Package: "" type: "spapr-cpu-package" qom_path: "/machine/cpu-package[1]" realized: false nr_cpus: 8 As can be seen from above, all the cores upto max_cpus are created upfront here and hot plug is done in the following manner: (qemu) qom-set /machine/cpu-package[1] realized true This will result in the 2nd cpu-package consisting of a core with 8 threads to become available. I am not fully sure if the QMP emumeration here works for all archs, but just wanted to share what I currently. Bharata B Rao (8): cpu: Store CPU typename in MachineState cpu: Don't realize CPU from cpu_generic_init() cpu: CPU package abstract device spapr: Introduce CPU core device spapr: Convert boot CPUs into CPU core device initialization spapr: CPU hotplug support qmp: Implement query cpu-packages hmp: Implement 'info cpu-slots' hmp-commands-info.hx | 14 +++ hmp.c | 50 ++++++++ hmp.h | 1 + hw/cpu/Makefile.objs | 1 + hw/cpu/package.c | 85 +++++++++++++ hw/ppc/Makefile.objs | 1 + hw/ppc/spapr.c | 246 +++++++++++++++++++++++++++++++++++-- hw/ppc/spapr_cpu_package.c | 50 ++++++++ hw/ppc/spapr_events.c | 3 + hw/ppc/spapr_rtas.c | 24 ++++ include/hw/boards.h | 2 + include/hw/cpu/package.h | 27 ++++ include/hw/ppc/spapr.h | 1 + include/hw/ppc/spapr_cpu_package.h | 27 ++++ qapi-schema.json | 48 ++++++++ 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 | 16 ++- target-sh4/cpu.c | 16 ++- target-tricore/helper.c | 16 ++- target-unicore32/helper.c | 16 ++- 25 files changed, 707 insertions(+), 23 deletions(-) create mode 100644 hw/cpu/package.c create mode 100644 hw/ppc/spapr_cpu_package.c create mode 100644 include/hw/cpu/package.h create mode 100644 include/hw/ppc/spapr_cpu_package.h -- 2.1.0