tests: Verify handling of CPU clusters in QMP data

Since aarch64 doesn't support CPU hotplug at the moment, we have
to get a bit creative.

While the 'query-cpus-fast' output is taken directly from a VM
configured as

  <vcpu current='7'>16</vcpu>
  <cpu mode='host-passthrough'>
    <topology sockets='2' dies='1' clusters='2' cores='2' threads='2'/>
  </cpu>

the 'query-hotpluggable-cpus' output is constructed by hand
starting from the former and using the 'x86-dies' test data as
a model.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Andrea Bolognani 2024-01-08 18:44:25 +01:00
parent 763381df53
commit cb7abb0703
4 changed files with 375 additions and 1 deletions

View File

@ -0,0 +1,88 @@
{
"return": [
{
"thread-id": 284700,
"props": {
"core-id": 0,
"thread-id": 0,
"socket-id": 0,
"cluster-id": 0
},
"qom-path": "/machine/unattached/device[0]",
"cpu-index": 0,
"target": "aarch64"
},
{
"thread-id": 284701,
"props": {
"core-id": 0,
"thread-id": 1,
"socket-id": 0,
"cluster-id": 0
},
"qom-path": "/machine/unattached/device[1]",
"cpu-index": 1,
"target": "aarch64"
},
{
"thread-id": 284702,
"props": {
"core-id": 1,
"thread-id": 0,
"socket-id": 0,
"cluster-id": 0
},
"qom-path": "/machine/unattached/device[2]",
"cpu-index": 2,
"target": "aarch64"
},
{
"thread-id": 284703,
"props": {
"core-id": 1,
"thread-id": 1,
"socket-id": 0,
"cluster-id": 0
},
"qom-path": "/machine/unattached/device[3]",
"cpu-index": 3,
"target": "aarch64"
},
{
"thread-id": 284704,
"props": {
"core-id": 0,
"thread-id": 0,
"socket-id": 0,
"cluster-id": 1
},
"qom-path": "/machine/unattached/device[4]",
"cpu-index": 4,
"target": "aarch64"
},
{
"thread-id": 284705,
"props": {
"core-id": 0,
"thread-id": 1,
"socket-id": 0,
"cluster-id": 1
},
"qom-path": "/machine/unattached/device[5]",
"cpu-index": 5,
"target": "aarch64"
},
{
"thread-id": 284706,
"props": {
"core-id": 1,
"thread-id": 0,
"socket-id": 0,
"cluster-id": 1
},
"qom-path": "/machine/unattached/device[6]",
"cpu-index": 6,
"target": "aarch64"
}
]
}

View File

@ -0,0 +1,171 @@
{
"return": [
{
"props": {
"core-id": 1,
"thread-id": 1,
"socket-id": 1,
"cluster-id": 1
},
"vcpus-count": 1,
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 1,
"thread-id": 0,
"socket-id": 1,
"cluster-id": 1
},
"vcpus-count": 1,
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 0,
"thread-id": 1,
"socket-id": 1,
"cluster-id": 1
},
"vcpus-count": 1,
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 0,
"thread-id": 0,
"socket-id": 1,
"cluster-id": 1
},
"vcpus-count": 1,
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 1,
"thread-id": 1,
"socket-id": 1,
"cluster-id": 0
},
"vcpus-count": 1,
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 1,
"thread-id": 0,
"socket-id": 1,
"cluster-id": 0
},
"vcpus-count": 1,
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 0,
"thread-id": 1,
"socket-id": 1,
"cluster-id": 0
},
"vcpus-count": 1,
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 0,
"thread-id": 0,
"socket-id": 1,
"cluster-id": 0
},
"vcpus-count": 1,
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 1,
"thread-id": 1,
"socket-id": 0,
"cluster-id": 1
},
"vcpus-count": 1,
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 1,
"thread-id": 0,
"socket-id": 0,
"cluster-id": 1
},
"vcpus-count": 1,
"qom-path": "/machine/unattached/device[6]",
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 0,
"thread-id": 1,
"socket-id": 0,
"cluster-id": 1
},
"vcpus-count": 1,
"qom-path": "/machine/unattached/device[5]",
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 0,
"thread-id": 0,
"socket-id": 0,
"cluster-id": 1
},
"vcpus-count": 1,
"qom-path": "/machine/unattached/device[4]",
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 1,
"thread-id": 1,
"socket-id": 0,
"cluster-id": 0
},
"vcpus-count": 1,
"qom-path": "/machine/unattached/device[3]",
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 1,
"thread-id": 0,
"socket-id": 0,
"cluster-id": 0
},
"vcpus-count": 1,
"qom-path": "/machine/unattached/device[2]",
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 0,
"thread-id": 1,
"socket-id": 0,
"cluster-id": 0
},
"vcpus-count": 1,
"qom-path": "/machine/unattached/device[1]",
"type": "host-arm-cpu"
},
{
"props": {
"core-id": 0,
"thread-id": 0,
"socket-id": 0,
"cluster-id": 0
},
"vcpus-count": 1,
"qom-path": "/machine/unattached/device[0]",
"type": "host-arm-cpu"
}
]
}

View File

@ -0,0 +1,108 @@
[vcpu libvirt-id='0']
online=yes
hotpluggable=no
thread-id='284700'
enable-id='1'
query-cpus-id='0'
type='host-arm-cpu'
qom_path='/machine/unattached/device[0]'
topology: socket='0' cluster_id='0' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='1']
online=yes
hotpluggable=no
thread-id='284701'
enable-id='2'
query-cpus-id='1'
type='host-arm-cpu'
qom_path='/machine/unattached/device[1]'
topology: socket='0' cluster_id='0' core='0' thread='1' vcpus='1'
[vcpu libvirt-id='2']
online=yes
hotpluggable=no
thread-id='284702'
enable-id='3'
query-cpus-id='2'
type='host-arm-cpu'
qom_path='/machine/unattached/device[2]'
topology: socket='0' cluster_id='0' core='1' thread='0' vcpus='1'
[vcpu libvirt-id='3']
online=yes
hotpluggable=no
thread-id='284703'
enable-id='4'
query-cpus-id='3'
type='host-arm-cpu'
qom_path='/machine/unattached/device[3]'
topology: socket='0' cluster_id='0' core='1' thread='1' vcpus='1'
[vcpu libvirt-id='4']
online=yes
hotpluggable=no
thread-id='284704'
enable-id='5'
query-cpus-id='4'
type='host-arm-cpu'
qom_path='/machine/unattached/device[4]'
topology: socket='0' cluster_id='1' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='5']
online=yes
hotpluggable=no
thread-id='284705'
enable-id='6'
query-cpus-id='5'
type='host-arm-cpu'
qom_path='/machine/unattached/device[5]'
topology: socket='0' cluster_id='1' core='0' thread='1' vcpus='1'
[vcpu libvirt-id='6']
online=yes
hotpluggable=no
thread-id='284706'
enable-id='7'
query-cpus-id='6'
type='host-arm-cpu'
qom_path='/machine/unattached/device[6]'
topology: socket='0' cluster_id='1' core='1' thread='0' vcpus='1'
[vcpu libvirt-id='7']
online=no
hotpluggable=yes
type='host-arm-cpu'
topology: socket='0' cluster_id='1' core='1' thread='1' vcpus='1'
[vcpu libvirt-id='8']
online=no
hotpluggable=yes
type='host-arm-cpu'
topology: socket='1' cluster_id='0' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='9']
online=no
hotpluggable=yes
type='host-arm-cpu'
topology: socket='1' cluster_id='0' core='0' thread='1' vcpus='1'
[vcpu libvirt-id='10']
online=no
hotpluggable=yes
type='host-arm-cpu'
topology: socket='1' cluster_id='0' core='1' thread='0' vcpus='1'
[vcpu libvirt-id='11']
online=no
hotpluggable=yes
type='host-arm-cpu'
topology: socket='1' cluster_id='0' core='1' thread='1' vcpus='1'
[vcpu libvirt-id='12']
online=no
hotpluggable=yes
type='host-arm-cpu'
topology: socket='1' cluster_id='1' core='0' thread='0' vcpus='1'
[vcpu libvirt-id='13']
online=no
hotpluggable=yes
type='host-arm-cpu'
topology: socket='1' cluster_id='1' core='0' thread='1' vcpus='1'
[vcpu libvirt-id='14']
online=no
hotpluggable=yes
type='host-arm-cpu'
topology: socket='1' cluster_id='1' core='1' thread='0' vcpus='1'
[vcpu libvirt-id='15']
online=no
hotpluggable=yes
type='host-arm-cpu'
topology: socket='1' cluster_id='1' core='1' thread='1' vcpus='1'

View File

@ -2262,13 +2262,16 @@ testQemuMonitorCPUInfoFormat(qemuMonitorCPUInfo *vcpus,
if (vcpu->qom_path) if (vcpu->qom_path)
virBufferAsprintf(&buf, "qom_path='%s'\n", vcpu->qom_path); virBufferAsprintf(&buf, "qom_path='%s'\n", vcpu->qom_path);
if (vcpu->socket_id != -1 || vcpu->core_id != -1 || if (vcpu->socket_id != -1 || vcpu->die_id != -1 ||
vcpu->cluster_id != -1 || vcpu->core_id != -1 ||
vcpu->thread_id != -1 || vcpu->vcpus != 0) { vcpu->thread_id != -1 || vcpu->vcpus != 0) {
virBufferAddLit(&buf, "topology:"); virBufferAddLit(&buf, "topology:");
if (vcpu->socket_id != -1) if (vcpu->socket_id != -1)
virBufferAsprintf(&buf, " socket='%d'", vcpu->socket_id); virBufferAsprintf(&buf, " socket='%d'", vcpu->socket_id);
if (vcpu->die_id != -1) if (vcpu->die_id != -1)
virBufferAsprintf(&buf, " die='%d'", vcpu->die_id); virBufferAsprintf(&buf, " die='%d'", vcpu->die_id);
if (vcpu->cluster_id != -1)
virBufferAsprintf(&buf, " cluster_id='%d'", vcpu->cluster_id);
if (vcpu->core_id != -1) if (vcpu->core_id != -1)
virBufferAsprintf(&buf, " core='%d'", vcpu->core_id); virBufferAsprintf(&buf, " core='%d'", vcpu->core_id);
if (vcpu->thread_id != -1) if (vcpu->thread_id != -1)
@ -2919,6 +2922,10 @@ mymain(void)
DO_TEST_CPU_INFO("ppc64-hotplug-4", 24); DO_TEST_CPU_INFO("ppc64-hotplug-4", 24);
DO_TEST_CPU_INFO("ppc64-no-threads", 16); DO_TEST_CPU_INFO("ppc64-no-threads", 16);
/* aarch64 doesn't support CPU hotplug yet, so the data used in
* this test is partially synthetic */
DO_TEST_CPU_INFO("aarch64-clusters", 16);
DO_TEST_CPU_INFO("s390", 2); DO_TEST_CPU_INFO("s390", 2);