qemu: monitor: Add vcpu state information to monitor data

Return whether a vcpu entry is hotpluggable or online so that upper
layers don't have to infer the information from other data.

Advantage is that this code can be tested by unit tests.
This commit is contained in:
Peter Krempa 2016-09-13 17:52:38 +02:00
parent 66da0356cd
commit 2a0e68be91
10 changed files with 279 additions and 0 deletions

View File

@ -1773,6 +1773,7 @@ qemuMonitorGetCPUInfoHotplug(struct qemuMonitorQueryHotpluggableCpusEntry *hotpl
int order = 1;
size_t totalvcpus = 0;
size_t mastervcpu; /* this iterator is used for iterating hotpluggable entities */
size_t slavevcpu; /* this corresponds to subentries of a hotpluggable entry */
size_t anyvcpu; /* this iterator is used for any vcpu entry in the result */
size_t i;
size_t j;
@ -1816,6 +1817,9 @@ qemuMonitorGetCPUInfoHotplug(struct qemuMonitorQueryHotpluggableCpusEntry *hotpl
* logical vcpus in the guest */
mastervcpu = 0;
for (i = 0; i < nhotplugvcpus; i++) {
vcpus[mastervcpu].online = !!hotplugvcpus[i].qom_path;
vcpus[mastervcpu].hotpluggable = !!hotplugvcpus[i].alias ||
!vcpus[mastervcpu].online;
vcpus[mastervcpu].socket_id = hotplugvcpus[i].socket_id;
vcpus[mastervcpu].core_id = hotplugvcpus[i].core_id;
vcpus[mastervcpu].thread_id = hotplugvcpus[i].thread_id;
@ -1825,6 +1829,12 @@ qemuMonitorGetCPUInfoHotplug(struct qemuMonitorQueryHotpluggableCpusEntry *hotpl
VIR_STEAL_PTR(vcpus[mastervcpu].type, hotplugvcpus[i].type);
vcpus[mastervcpu].id = hotplugvcpus[i].enable_id;
/* copy state information to slave vcpus */
for (slavevcpu = mastervcpu + 1; slavevcpu < mastervcpu + hotplugvcpus[i].vcpus; slavevcpu++) {
vcpus[slavevcpu].online = vcpus[mastervcpu].online;
vcpus[slavevcpu].hotpluggable = vcpus[mastervcpu].hotpluggable;
}
/* calculate next master vcpu (hotpluggable unit) entry */
mastervcpu += hotplugvcpus[i].vcpus;
}

View File

@ -422,6 +422,10 @@ struct _qemuMonitorCPUInfo {
pid_t tid;
int id; /* order of enabling of the given cpu */
/* state data */
bool online;
bool hotpluggable;
/* topology info for hotplug purposes. Hotplug of given vcpu impossible if
* all entries are -1 */
int socket_id;

View File

@ -1,40 +1,88 @@
[vcpu libvirt-id='0']
online=yes
hotpluggable=no
thread-id='21925'
qemu-id='1'
type='host-spapr-cpu-core'
qom_path='/machine/unattached/device[1]'
topology: core='0' vcpus='8'
[vcpu libvirt-id='1']
online=yes
hotpluggable=no
thread-id='21926'
[vcpu libvirt-id='2']
online=yes
hotpluggable=no
thread-id='21927'
[vcpu libvirt-id='3']
online=yes
hotpluggable=no
thread-id='21928'
[vcpu libvirt-id='4']
online=yes
hotpluggable=no
thread-id='21930'
[vcpu libvirt-id='5']
online=yes
hotpluggable=no
thread-id='21931'
[vcpu libvirt-id='6']
online=yes
hotpluggable=no
thread-id='21932'
[vcpu libvirt-id='7']
online=yes
hotpluggable=no
thread-id='21933'
[vcpu libvirt-id='8']
online=no
hotpluggable=yes
type='host-spapr-cpu-core'
topology: core='8' vcpus='8'
[vcpu libvirt-id='9']
online=no
hotpluggable=yes
[vcpu libvirt-id='10']
online=no
hotpluggable=yes
[vcpu libvirt-id='11']
online=no
hotpluggable=yes
[vcpu libvirt-id='12']
online=no
hotpluggable=yes
[vcpu libvirt-id='13']
online=no
hotpluggable=yes
[vcpu libvirt-id='14']
online=no
hotpluggable=yes
[vcpu libvirt-id='15']
online=no
hotpluggable=yes
[vcpu libvirt-id='16']
online=no
hotpluggable=yes
type='host-spapr-cpu-core'
topology: core='16' vcpus='8'
[vcpu libvirt-id='17']
online=no
hotpluggable=yes
[vcpu libvirt-id='18']
online=no
hotpluggable=yes
[vcpu libvirt-id='19']
online=no
hotpluggable=yes
[vcpu libvirt-id='20']
online=no
hotpluggable=yes
[vcpu libvirt-id='21']
online=no
hotpluggable=yes
[vcpu libvirt-id='22']
online=no
hotpluggable=yes
[vcpu libvirt-id='23']
online=no
hotpluggable=yes

View File

@ -1,24 +1,42 @@
[vcpu libvirt-id='0']
online=yes
hotpluggable=no
thread-id='21925'
qemu-id='1'
type='host-spapr-cpu-core'
qom_path='/machine/unattached/device[1]'
topology: core='0' vcpus='8'
[vcpu libvirt-id='1']
online=yes
hotpluggable=no
thread-id='21926'
[vcpu libvirt-id='2']
online=yes
hotpluggable=no
thread-id='21927'
[vcpu libvirt-id='3']
online=yes
hotpluggable=no
thread-id='21928'
[vcpu libvirt-id='4']
online=yes
hotpluggable=no
thread-id='21930'
[vcpu libvirt-id='5']
online=yes
hotpluggable=no
thread-id='21931'
[vcpu libvirt-id='6']
online=yes
hotpluggable=no
thread-id='21932'
[vcpu libvirt-id='7']
online=yes
hotpluggable=no
thread-id='21933'
[vcpu libvirt-id='8']
online=yes
hotpluggable=yes
thread-id='22131'
qemu-id='2'
type='host-spapr-cpu-core'
@ -26,26 +44,56 @@
qom_path='/machine/peripheral/vcpu0'
topology: core='8' vcpus='8'
[vcpu libvirt-id='9']
online=yes
hotpluggable=yes
thread-id='22132'
[vcpu libvirt-id='10']
online=yes
hotpluggable=yes
thread-id='22133'
[vcpu libvirt-id='11']
online=yes
hotpluggable=yes
thread-id='22134'
[vcpu libvirt-id='12']
online=yes
hotpluggable=yes
thread-id='22135'
[vcpu libvirt-id='13']
online=yes
hotpluggable=yes
thread-id='22136'
[vcpu libvirt-id='14']
online=yes
hotpluggable=yes
thread-id='22137'
[vcpu libvirt-id='15']
online=yes
hotpluggable=yes
thread-id='22138'
[vcpu libvirt-id='16']
online=no
hotpluggable=yes
type='host-spapr-cpu-core'
topology: core='16' vcpus='8'
[vcpu libvirt-id='17']
online=no
hotpluggable=yes
[vcpu libvirt-id='18']
online=no
hotpluggable=yes
[vcpu libvirt-id='19']
online=no
hotpluggable=yes
[vcpu libvirt-id='20']
online=no
hotpluggable=yes
[vcpu libvirt-id='21']
online=no
hotpluggable=yes
[vcpu libvirt-id='22']
online=no
hotpluggable=yes
[vcpu libvirt-id='23']
online=no
hotpluggable=yes

View File

@ -1,24 +1,42 @@
[vcpu libvirt-id='0']
online=yes
hotpluggable=no
thread-id='21925'
qemu-id='1'
type='host-spapr-cpu-core'
qom_path='/machine/unattached/device[1]'
topology: core='0' vcpus='8'
[vcpu libvirt-id='1']
online=yes
hotpluggable=no
thread-id='21926'
[vcpu libvirt-id='2']
online=yes
hotpluggable=no
thread-id='21927'
[vcpu libvirt-id='3']
online=yes
hotpluggable=no
thread-id='21928'
[vcpu libvirt-id='4']
online=yes
hotpluggable=no
thread-id='21930'
[vcpu libvirt-id='5']
online=yes
hotpluggable=no
thread-id='21931'
[vcpu libvirt-id='6']
online=yes
hotpluggable=no
thread-id='21932'
[vcpu libvirt-id='7']
online=yes
hotpluggable=no
thread-id='21933'
[vcpu libvirt-id='8']
online=yes
hotpluggable=yes
thread-id='22131'
qemu-id='2'
type='host-spapr-cpu-core'
@ -26,20 +44,36 @@
qom_path='/machine/peripheral/vcpu0'
topology: core='8' vcpus='8'
[vcpu libvirt-id='9']
online=yes
hotpluggable=yes
thread-id='22132'
[vcpu libvirt-id='10']
online=yes
hotpluggable=yes
thread-id='22133'
[vcpu libvirt-id='11']
online=yes
hotpluggable=yes
thread-id='22134'
[vcpu libvirt-id='12']
online=yes
hotpluggable=yes
thread-id='22135'
[vcpu libvirt-id='13']
online=yes
hotpluggable=yes
thread-id='22136'
[vcpu libvirt-id='14']
online=yes
hotpluggable=yes
thread-id='22137'
[vcpu libvirt-id='15']
online=yes
hotpluggable=yes
thread-id='22138'
[vcpu libvirt-id='16']
online=yes
hotpluggable=yes
thread-id='22223'
qemu-id='3'
type='host-spapr-cpu-core'
@ -47,16 +81,30 @@
qom_path='/machine/peripheral/vcpu1'
topology: core='16' vcpus='8'
[vcpu libvirt-id='17']
online=yes
hotpluggable=yes
thread-id='22224'
[vcpu libvirt-id='18']
online=yes
hotpluggable=yes
thread-id='22225'
[vcpu libvirt-id='19']
online=yes
hotpluggable=yes
thread-id='22226'
[vcpu libvirt-id='20']
online=yes
hotpluggable=yes
thread-id='22227'
[vcpu libvirt-id='21']
online=yes
hotpluggable=yes
thread-id='22228'
[vcpu libvirt-id='22']
online=yes
hotpluggable=yes
thread-id='22229'
[vcpu libvirt-id='23']
online=yes
hotpluggable=yes
thread-id='22230'

View File

@ -1,24 +1,42 @@
[vcpu libvirt-id='0']
online=yes
hotpluggable=no
thread-id='21925'
qemu-id='1'
type='host-spapr-cpu-core'
qom_path='/machine/unattached/device[1]'
topology: core='0' vcpus='8'
[vcpu libvirt-id='1']
online=yes
hotpluggable=no
thread-id='21926'
[vcpu libvirt-id='2']
online=yes
hotpluggable=no
thread-id='21927'
[vcpu libvirt-id='3']
online=yes
hotpluggable=no
thread-id='21928'
[vcpu libvirt-id='4']
online=yes
hotpluggable=no
thread-id='21930'
[vcpu libvirt-id='5']
online=yes
hotpluggable=no
thread-id='21931'
[vcpu libvirt-id='6']
online=yes
hotpluggable=no
thread-id='21932'
[vcpu libvirt-id='7']
online=yes
hotpluggable=no
thread-id='21933'
[vcpu libvirt-id='8']
online=yes
hotpluggable=yes
thread-id='23170'
qemu-id='3'
type='host-spapr-cpu-core'
@ -26,20 +44,36 @@
qom_path='/machine/peripheral/vcpu0'
topology: core='8' vcpus='8'
[vcpu libvirt-id='9']
online=yes
hotpluggable=yes
thread-id='23171'
[vcpu libvirt-id='10']
online=yes
hotpluggable=yes
thread-id='23172'
[vcpu libvirt-id='11']
online=yes
hotpluggable=yes
thread-id='23173'
[vcpu libvirt-id='12']
online=yes
hotpluggable=yes
thread-id='23174'
[vcpu libvirt-id='13']
online=yes
hotpluggable=yes
thread-id='23175'
[vcpu libvirt-id='14']
online=yes
hotpluggable=yes
thread-id='23176'
[vcpu libvirt-id='15']
online=yes
hotpluggable=yes
thread-id='23177'
[vcpu libvirt-id='16']
online=yes
hotpluggable=yes
thread-id='22741'
qemu-id='2'
type='host-spapr-cpu-core'
@ -47,16 +81,30 @@
qom_path='/machine/peripheral/vcpu1'
topology: core='16' vcpus='8'
[vcpu libvirt-id='17']
online=yes
hotpluggable=yes
thread-id='22742'
[vcpu libvirt-id='18']
online=yes
hotpluggable=yes
thread-id='22743'
[vcpu libvirt-id='19']
online=yes
hotpluggable=yes
thread-id='22744'
[vcpu libvirt-id='20']
online=yes
hotpluggable=yes
thread-id='22745'
[vcpu libvirt-id='21']
online=yes
hotpluggable=yes
thread-id='22746'
[vcpu libvirt-id='22']
online=yes
hotpluggable=yes
thread-id='22747'
[vcpu libvirt-id='23']
online=yes
hotpluggable=yes
thread-id='22748'

View File

@ -1,72 +1,104 @@
[vcpu libvirt-id='0']
online=yes
hotpluggable=no
thread-id='35232'
qemu-id='1'
type='host-spapr-cpu-core'
qom_path='/machine/unattached/device[1]'
topology: core='0' vcpus='1'
[vcpu libvirt-id='1']
online=yes
hotpluggable=no
thread-id='35233'
qemu-id='2'
type='host-spapr-cpu-core'
qom_path='/machine/unattached/device[2]'
topology: core='8' vcpus='1'
[vcpu libvirt-id='2']
online=yes
hotpluggable=no
thread-id='35234'
qemu-id='3'
type='host-spapr-cpu-core'
qom_path='/machine/unattached/device[3]'
topology: core='16' vcpus='1'
[vcpu libvirt-id='3']
online=yes
hotpluggable=no
thread-id='35235'
qemu-id='4'
type='host-spapr-cpu-core'
qom_path='/machine/unattached/device[4]'
topology: core='24' vcpus='1'
[vcpu libvirt-id='4']
online=yes
hotpluggable=no
thread-id='35236'
qemu-id='5'
type='host-spapr-cpu-core'
qom_path='/machine/unattached/device[5]'
topology: core='32' vcpus='1'
[vcpu libvirt-id='5']
online=yes
hotpluggable=no
thread-id='35237'
qemu-id='6'
type='host-spapr-cpu-core'
qom_path='/machine/unattached/device[6]'
topology: core='40' vcpus='1'
[vcpu libvirt-id='6']
online=yes
hotpluggable=no
thread-id='35238'
qemu-id='7'
type='host-spapr-cpu-core'
qom_path='/machine/unattached/device[7]'
topology: core='48' vcpus='1'
[vcpu libvirt-id='7']
online=yes
hotpluggable=no
thread-id='35239'
qemu-id='8'
type='host-spapr-cpu-core'
qom_path='/machine/unattached/device[8]'
topology: core='56' vcpus='1'
[vcpu libvirt-id='8']
online=no
hotpluggable=yes
type='host-spapr-cpu-core'
topology: core='64' vcpus='1'
[vcpu libvirt-id='9']
online=no
hotpluggable=yes
type='host-spapr-cpu-core'
topology: core='72' vcpus='1'
[vcpu libvirt-id='10']
online=no
hotpluggable=yes
type='host-spapr-cpu-core'
topology: core='80' vcpus='1'
[vcpu libvirt-id='11']
online=no
hotpluggable=yes
type='host-spapr-cpu-core'
topology: core='88' vcpus='1'
[vcpu libvirt-id='12']
online=no
hotpluggable=yes
type='host-spapr-cpu-core'
topology: core='96' vcpus='1'
[vcpu libvirt-id='13']
online=no
hotpluggable=yes
type='host-spapr-cpu-core'
topology: core='104' vcpus='1'
[vcpu libvirt-id='14']
online=no
hotpluggable=yes
type='host-spapr-cpu-core'
topology: core='112' vcpus='1'
[vcpu libvirt-id='15']
online=no
hotpluggable=yes
type='host-spapr-cpu-core'
topology: core='120' vcpus='1'

View File

@ -1,39 +1,55 @@
[vcpu libvirt-id='0']
online=yes
hotpluggable=no
thread-id='518291'
qemu-id='1'
type='qemu64-x86_64-cpu'
qom_path='/machine/unattached/device[0]'
topology: socket='0' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='1']
online=yes
hotpluggable=no
thread-id='518292'
qemu-id='2'
type='qemu64-x86_64-cpu'
qom_path='/machine/unattached/device[2]'
topology: socket='0' core='0' thread='1' vcpus='1'
[vcpu libvirt-id='2']
online=yes
hotpluggable=no
thread-id='518294'
qemu-id='3'
type='qemu64-x86_64-cpu'
qom_path='/machine/unattached/device[3]'
topology: socket='0' core='1' thread='0' vcpus='1'
[vcpu libvirt-id='3']
online=yes
hotpluggable=no
thread-id='518295'
qemu-id='4'
type='qemu64-x86_64-cpu'
qom_path='/machine/unattached/device[4]'
topology: socket='0' core='1' thread='1' vcpus='1'
[vcpu libvirt-id='4']
online=yes
hotpluggable=no
thread-id='518296'
qemu-id='5'
type='qemu64-x86_64-cpu'
qom_path='/machine/unattached/device[5]'
topology: socket='1' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='5']
online=no
hotpluggable=yes
type='qemu64-x86_64-cpu'
topology: socket='1' core='0' thread='1' vcpus='1'
[vcpu libvirt-id='6']
online=no
hotpluggable=yes
type='qemu64-x86_64-cpu'
topology: socket='1' core='1' thread='0' vcpus='1'
[vcpu libvirt-id='7']
online=no
hotpluggable=yes
type='qemu64-x86_64-cpu'
topology: socket='1' core='1' thread='1' vcpus='1'

View File

@ -1,10 +1,14 @@
[vcpu libvirt-id='0']
online=yes
hotpluggable=no
thread-id='895040'
qemu-id='1'
type='Broadwell-x86_64-cpu'
qom_path='/machine/unattached/device[0]'
topology: socket='0' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='1']
online=yes
hotpluggable=yes
thread-id='895056'
qemu-id='2'
type='Broadwell-x86_64-cpu'
@ -12,6 +16,8 @@
qom_path='/machine/peripheral/vcpu1'
topology: socket='1' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='2']
online=yes
hotpluggable=yes
thread-id='895057'
qemu-id='3'
type='Broadwell-x86_64-cpu'
@ -19,6 +25,8 @@
qom_path='/machine/peripheral/vcpu2'
topology: socket='2' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='3']
online=yes
hotpluggable=yes
thread-id='895058'
qemu-id='4'
type='Broadwell-x86_64-cpu'
@ -26,6 +34,8 @@
qom_path='/machine/peripheral/vcpu3'
topology: socket='3' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='4']
online=yes
hotpluggable=yes
thread-id='895059'
qemu-id='5'
type='Broadwell-x86_64-cpu'
@ -33,6 +43,8 @@
qom_path='/machine/peripheral/vcpu4'
topology: socket='4' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='5']
online=yes
hotpluggable=yes
thread-id='895060'
qemu-id='6'
type='Broadwell-x86_64-cpu'
@ -40,6 +52,8 @@
qom_path='/machine/peripheral/vcpu5'
topology: socket='5' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='6']
online=yes
hotpluggable=yes
thread-id='895061'
qemu-id='7'
type='Broadwell-x86_64-cpu'
@ -47,6 +61,8 @@
qom_path='/machine/peripheral/vcpu6'
topology: socket='6' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='7']
online=yes
hotpluggable=yes
thread-id='895062'
qemu-id='8'
type='Broadwell-x86_64-cpu'
@ -54,6 +70,8 @@
qom_path='/machine/peripheral/vcpu7'
topology: socket='7' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='8']
online=yes
hotpluggable=yes
thread-id='895063'
qemu-id='9'
type='Broadwell-x86_64-cpu'
@ -61,6 +79,8 @@
qom_path='/machine/peripheral/vcpu8'
topology: socket='8' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='9']
online=yes
hotpluggable=yes
thread-id='895064'
qemu-id='10'
type='Broadwell-x86_64-cpu'
@ -68,6 +88,8 @@
qom_path='/machine/peripheral/vcpu9'
topology: socket='9' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='10']
online=yes
hotpluggable=yes
thread-id='895065'
qemu-id='11'
type='Broadwell-x86_64-cpu'

View File

@ -2357,6 +2357,9 @@ testQemuMonitorCPUInfoFormat(qemuMonitorCPUInfoPtr vcpus,
virBufferAsprintf(&buf, "[vcpu libvirt-id='%zu']\n", i);
virBufferAdjustIndent(&buf, 4);
virBufferAsprintf(&buf, "online=%s\n", vcpu->online ? "yes" : "no");
virBufferAsprintf(&buf, "hotpluggable=%s\n", vcpu->hotpluggable ? "yes" : "no");
if (vcpu->tid)
virBufferAsprintf(&buf, "thread-id='%llu'\n",
(unsigned long long) vcpu->tid);