aboutsummaryrefslogtreecommitdiff
path: root/target/s390x/kvm.c
diff options
context:
space:
mode:
authorJanosch Frank <frankja@linux.ibm.com>2020-03-31 07:01:23 -0400
committerCornelia Huck <cohuck@redhat.com>2020-04-02 11:44:17 +0200
commitedd075ae2baebf64b74e089457af6201362c9343 (patch)
treef2bf9c99e76254b9d4f15399bf7cd8418e098a5e /target/s390x/kvm.c
parent2833ad487cfff7dc33703e4731b75facde1c561e (diff)
s390x: kvm: Fix number of cpu reports for stsi 3.2.2
The cpu number reporting is handled by KVM and QEMU only fills in the VM name, uuid and other values. Unfortunately KVM doesn't report reserved cpus and doesn't even know they exist until the are created via the ioctl. So let's fix up the cpu values after KVM has written its values to the 3.2.2 sysib. To be consistent, we use the same code to retrieve the cpu numbers as the STSI TCG code in target/s390x/misc_helper.c:HELPER(stsi). Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: David Hildenbrand <david@redhat.com> Message-Id: <20200331110123.3774-1-frankja@linux.ibm.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Diffstat (limited to 'target/s390x/kvm.c')
-rw-r--r--target/s390x/kvm.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index 1d6fd6a27b..7f7ebab842 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -1768,8 +1768,10 @@ static int handle_tsch(S390CPU *cpu)
static void insert_stsi_3_2_2(S390CPU *cpu, __u64 addr, uint8_t ar)
{
+ const MachineState *ms = MACHINE(qdev_get_machine());
+ uint16_t conf_cpus = 0, reserved_cpus = 0;
SysIB_322 sysib;
- int del;
+ int del, i;
if (s390_cpu_virt_mem_read(cpu, addr, ar, &sysib, sizeof(sysib))) {
return;
@@ -1789,6 +1791,19 @@ static void insert_stsi_3_2_2(S390CPU *cpu, __u64 addr, uint8_t ar)
memset(sysib.ext_names[del], 0,
sizeof(sysib.ext_names[0]) * (sysib.count - del));
}
+
+ /* count the cpus and split them into configured and reserved ones */
+ for (i = 0; i < ms->possible_cpus->len; i++) {
+ if (ms->possible_cpus->cpus[i].cpu) {
+ conf_cpus++;
+ } else {
+ reserved_cpus++;
+ }
+ }
+ sysib.vm[0].total_cpus = conf_cpus + reserved_cpus;
+ sysib.vm[0].conf_cpus = conf_cpus;
+ sysib.vm[0].reserved_cpus = reserved_cpus;
+
/* Insert short machine name in EBCDIC, padded with blanks */
if (qemu_name) {
memset(sysib.vm[0].name, 0x40, sizeof(sysib.vm[0].name));