Drawers and Books are levels 4 and 3 of the S390 CPU topology. We allow the user to define these levels and we will store the values inside the S390CcwMachineState.
Signed-off-by: Pierre Morel <pmo...@linux.ibm.com> --- hw/s390x/s390-virtio-ccw.c | 22 +++++++++++++++------- include/hw/s390x/s390-virtio-ccw.h | 2 ++ qapi/machine.json | 2 ++ softmmu/vl.c | 6 ++++++ 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 899d3a4137..42d9be7333 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -591,12 +591,17 @@ static void s390_smp_parse(MachineState *ms, QemuOpts *opts) unsigned cpus = qemu_opt_get_number(opts, "cpus", 1); unsigned sockets = qemu_opt_get_number(opts, "sockets", 1); unsigned cores = qemu_opt_get_number(opts, "cores", 1); + unsigned drawers = qemu_opt_get_number(opts, "drawers", 1); + unsigned books = qemu_opt_get_number(opts, "books", 1); + S390CcwMachineState *s390ms = S390_CCW_MACHINE(ms); if (opts) { - if (cpus == 0 || sockets == 0 || cores == 0) { + if (cpus == 0 || drawers == 0 || books == 0 || sockets == 0 || + cores == 0) { error_report("cpu topology: " - "sockets (%u), cores (%u) or number of CPU(%u) " - "can not be zero", sockets, cores, cpus); + "drawers (%u) books (%u) sockets (%u), cores (%u) " + "or number of CPU(%u) can not be zero", drawers, + books, sockets, cores, cpus); exit(1); } } @@ -608,12 +613,13 @@ static void s390_smp_parse(MachineState *ms, QemuOpts *opts) } if (!qemu_opt_find(opts, "cores")) { - cores = ms->smp.max_cpus / sockets; + cores = ms->smp.max_cpus / (drawers * books * sockets); } - if (sockets * cores != ms->smp.max_cpus) { - error_report("Invalid CPU topology: sockets (%u) * cores (%u) " - "!= maxcpus (%u)", sockets, cores, ms->smp.max_cpus); + if (drawers * books * sockets * cores != ms->smp.max_cpus) { + error_report("Invalid CPU topology: drawers (%u) books (%u) " + "sockets (%u) * cores (%u) != maxcpus (%u)", + drawers, books, sockets, cores, ms->smp.max_cpus); exit(1); } @@ -621,6 +627,8 @@ static void s390_smp_parse(MachineState *ms, QemuOpts *opts) ms->smp.cpus = cpus; ms->smp.cores = cores; ms->smp.sockets = sockets; + s390ms->drawers = drawers; + s390ms->books = books; } static void ccw_machine_class_init(ObjectClass *oc, void *data) diff --git a/include/hw/s390x/s390-virtio-ccw.h b/include/hw/s390x/s390-virtio-ccw.h index 3331990e02..fb3c3a50ce 100644 --- a/include/hw/s390x/s390-virtio-ccw.h +++ b/include/hw/s390x/s390-virtio-ccw.h @@ -28,6 +28,8 @@ struct S390CcwMachineState { bool dea_key_wrap; bool pv; uint8_t loadparm[8]; + int drawers; + int books; }; struct S390CcwMachineClass { diff --git a/qapi/machine.json b/qapi/machine.json index c3210ee1fb..98aff804c6 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -883,6 +883,8 @@ 'data': { '*node-id': 'int', '*socket-id': 'int', '*die-id': 'int', + '*drawer-id': 'int', + '*book-id': 'int', '*core-id': 'int', '*thread-id': 'int' } diff --git a/softmmu/vl.c b/softmmu/vl.c index 4df1496101..fc73107b91 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -699,6 +699,12 @@ static QemuOptsList qemu_smp_opts = { }, { .name = "dies", .type = QEMU_OPT_NUMBER, + }, { + .name = "books", + .type = QEMU_OPT_NUMBER, + }, { + .name = "drawers", + .type = QEMU_OPT_NUMBER, }, { .name = "cores", .type = QEMU_OPT_NUMBER, -- 2.25.1