From: Peter Krempa Date: Fri, 10 Feb 2017 16:14:22 +0000 (+0100) Subject: test: qemuhotplugtest: Add testing of individual vcpu hotplug X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=bd8f10c62aa4d0fa09bf74bc5f337a3a28b0d694;p=libvirt.git test: qemuhotplugtest: Add testing of individual vcpu hotplug Test that the vcpu entity selection code works properly --- diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 8a58d5468c..cdeb3f1bfb 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -493,6 +493,8 @@ testQemuHotplugCpuFinalize(struct testQemuHotplugCpuData *data) struct testQemuHotplugCpuParams { const char *test; int newcpus; + const char *cpumap; + bool state; bool modern; bool fail; }; @@ -533,6 +535,46 @@ testQemuHotplugCpuGroup(const void *opaque) } +static int +testQemuHotplugCpuIndividual(const void *opaque) +{ + const struct testQemuHotplugCpuParams *params = opaque; + struct testQemuHotplugCpuData *data = NULL; + virBitmapPtr map = NULL; + int ret = -1; + int rc; + + if (!(data = testQemuHotplugCpuPrepare(params->test, params->modern))) + return -1; + + if (virBitmapParse(params->cpumap, &map, 128) < 0) + goto cleanup; + + rc = qemuDomainSetVcpuInternal(&driver, data->vm, data->vm->def, + data->vm->newDef, map, params->state); + + if (params->fail) { + if (rc == 0) + fprintf(stderr, "cpu test '%s' should have failed\n", params->test); + else + ret = 0; + + goto cleanup; + } else { + if (rc < 0) + goto cleanup; + } + + ret = testQemuHotplugCpuFinalize(data); + + cleanup: + virBitmapFree(map); + testQemuHotplugCpuDataFree(data); + return ret; +} + + + static int mymain(void) { @@ -789,6 +831,27 @@ mymain(void) DO_TEST_CPU_GROUP("ppc64-modern-bulk", 23, true, true); DO_TEST_CPU_GROUP("ppc64-modern-bulk", 25, true, true); +#define DO_TEST_CPU_INDIVIDUAL(prefix, mapstr, statefl, modernhp, expectfail) \ + do { \ + cpudata.test = prefix; \ + cpudata.cpumap = mapstr; \ + cpudata.state = statefl; \ + cpudata.modern = modernhp; \ + cpudata.fail = expectfail; \ + if (virTestRun("hotplug vcpus group " prefix, \ + testQemuHotplugCpuIndividual, &cpudata) < 0) \ + ret = -1; \ + } while (0) + + DO_TEST_CPU_INDIVIDUAL("x86-modern-individual-add", "7", true, true, false); + DO_TEST_CPU_INDIVIDUAL("x86-modern-individual-add", "6,7", true, true, true); + DO_TEST_CPU_INDIVIDUAL("x86-modern-individual-add", "7", false, true, true); + DO_TEST_CPU_INDIVIDUAL("x86-modern-individual-add", "7", true, false, true); + + DO_TEST_CPU_INDIVIDUAL("ppc64-modern-individual", "16-23", true, true, false); + DO_TEST_CPU_INDIVIDUAL("ppc64-modern-individual", "16-22", true, true, true); + DO_TEST_CPU_INDIVIDUAL("ppc64-modern-individual", "17", true, true, true); + qemuTestDriverFree(&driver); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuhotplugtestcpus/ppc64-modern-individual-domain.xml b/tests/qemuhotplugtestcpus/ppc64-modern-individual-domain.xml new file mode 100644 index 0000000000..eb04e42b6b --- /dev/null +++ b/tests/qemuhotplugtestcpus/ppc64-modern-individual-domain.xml @@ -0,0 +1,20 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 32 + + hvm + + + + + + destroy + restart + destroy + + /usr/bin/qemu + + diff --git a/tests/qemuhotplugtestcpus/ppc64-modern-individual-monitor.json b/tests/qemuhotplugtestcpus/ppc64-modern-individual-monitor.json new file mode 100644 index 0000000000..ad5cc984a8 --- /dev/null +++ b/tests/qemuhotplugtestcpus/ppc64-modern-individual-monitor.json @@ -0,0 +1,318 @@ +{"execute":"query-hotpluggable-cpus","id":"libvirt-1"} + +{ + "return": [ + { + "props": { + "core-id": 24 + }, + "vcpus-count": 8, + "type": "host-spapr-cpu-core" + }, + { + "props": { + "core-id": 16 + }, + "vcpus-count": 8, + "type": "host-spapr-cpu-core" + }, + { + "props": { + "core-id": 8 + }, + "vcpus-count": 8, + "type": "host-spapr-cpu-core" + }, + { + "props": { + "core-id": 0 + }, + "vcpus-count": 8, + "qom-path": "/machine/unattached/device[1]", + "type": "host-spapr-cpu-core" + } + ], + "id": "libvirt-15" +} + +{"execute":"query-cpus","id":"libvirt-2"} + +{ + "return": [ + { + "arch": "ppc", + "current": true, + "CPU": 0, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[0]", + "halted": false, + "thread_id": 21925 + }, + { + "arch": "ppc", + "current": false, + "CPU": 1, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[1]", + "halted": false, + "thread_id": 21926 + }, + { + "arch": "ppc", + "current": false, + "CPU": 2, + "nip": -4611686018422360608, + "qom_path": "/machine/unattached/device[1]/thread[2]", + "halted": false, + "thread_id": 21927 + }, + { + "arch": "ppc", + "current": false, + "CPU": 3, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[3]", + "halted": false, + "thread_id": 21928 + }, + { + "arch": "ppc", + "current": false, + "CPU": 4, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[4]", + "halted": false, + "thread_id": 21930 + }, + { + "arch": "ppc", + "current": false, + "CPU": 5, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[5]", + "halted": false, + "thread_id": 21931 + }, + { + "arch": "ppc", + "current": false, + "CPU": 6, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[6]", + "halted": false, + "thread_id": 21932 + }, + { + "arch": "ppc", + "current": false, + "CPU": 7, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[7]", + "halted": false, + "thread_id": 21933 + } + ], + "id": "libvirt-12" +} + +{ + "execute": "device_add", + "arguments": { + "driver": "host-spapr-cpu-core", + "id": "vcpu16", + "core-id": 16 + }, + "id": "libvirt-3" +} + +{"return": {}} + +{"execute":"query-hotpluggable-cpus","id":"libvirt-4"} + +{ + "return": [ + { + "props": { + "core-id": 24 + }, + "vcpus-count": 8, + "type": "host-spapr-cpu-core" + }, + { + "props": { + "core-id": 16 + }, + "vcpus-count": 8, + "qom-path": "/machine/peripheral/vcpu16", + "type": "host-spapr-cpu-core" + }, + { + "props": { + "core-id": 8 + }, + "vcpus-count": 8, + "type": "host-spapr-cpu-core" + }, + { + "props": { + "core-id": 0 + }, + "vcpus-count": 8, + "qom-path": "/machine/unattached/device[1]", + "type": "host-spapr-cpu-core" + } + ], + "id": "libvirt-15" +} + +{"execute":"query-cpus","id":"libvirt-5"} + +{ + "return": [ + { + "arch": "ppc", + "current": true, + "CPU": 0, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[0]", + "halted": false, + "thread_id": 21925 + }, + { + "arch": "ppc", + "current": false, + "CPU": 1, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[1]", + "halted": false, + "thread_id": 21926 + }, + { + "arch": "ppc", + "current": false, + "CPU": 2, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[2]", + "halted": false, + "thread_id": 21927 + }, + { + "arch": "ppc", + "current": false, + "CPU": 3, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[3]", + "halted": false, + "thread_id": 21928 + }, + { + "arch": "ppc", + "current": false, + "CPU": 4, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[4]", + "halted": false, + "thread_id": 21930 + }, + { + "arch": "ppc", + "current": false, + "CPU": 5, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[5]", + "halted": false, + "thread_id": 21931 + }, + { + "arch": "ppc", + "current": false, + "CPU": 6, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[6]", + "halted": false, + "thread_id": 21932 + }, + { + "arch": "ppc", + "current": false, + "CPU": 7, + "nip": -4611686018426772172, + "qom_path": "/machine/unattached/device[1]/thread[7]", + "halted": false, + "thread_id": 21933 + }, + { + "arch": "ppc", + "current": false, + "CPU": 8, + "nip": -4611686018426772172, + "qom_path": "/machine/peripheral/vcpu16/thread[0]", + "halted": false, + "thread_id": 22131 + }, + { + "arch": "ppc", + "current": false, + "CPU": 9, + "nip": -4611686018426772172, + "qom_path": "/machine/peripheral/vcpu16/thread[1]", + "halted": false, + "thread_id": 22132 + }, + { + "arch": "ppc", + "current": false, + "CPU": 10, + "nip": -4611686018426772172, + "qom_path": "/machine/peripheral/vcpu16/thread[2]", + "halted": false, + "thread_id": 22133 + }, + { + "arch": "ppc", + "current": false, + "CPU": 11, + "nip": -4611686018426772172, + "qom_path": "/machine/peripheral/vcpu16/thread[3]", + "halted": false, + "thread_id": 22134 + }, + { + "arch": "ppc", + "current": false, + "CPU": 12, + "nip": -4611686018426772172, + "qom_path": "/machine/peripheral/vcpu16/thread[4]", + "halted": false, + "thread_id": 22135 + }, + { + "arch": "ppc", + "current": false, + "CPU": 13, + "nip": -4611686018426772172, + "qom_path": "/machine/peripheral/vcpu16/thread[5]", + "halted": false, + "thread_id": 22136 + }, + { + "arch": "ppc", + "current": false, + "CPU": 14, + "nip": -4611686018426772172, + "qom_path": "/machine/peripheral/vcpu16/thread[6]", + "halted": false, + "thread_id": 22137 + }, + { + "arch": "ppc", + "current": false, + "CPU": 15, + "nip": -4611686018426772172, + "qom_path": "/machine/peripheral/vcpu16/thread[7]", + "halted": false, + "thread_id": 22138 + } + ], + "id": "libvirt-14" +} diff --git a/tests/qemuhotplugtestcpus/ppc64-modern-individual-result-conf.xml b/tests/qemuhotplugtestcpus/ppc64-modern-individual-result-conf.xml new file mode 100644 index 0000000000..bda1bc579a --- /dev/null +++ b/tests/qemuhotplugtestcpus/ppc64-modern-individual-result-conf.xml @@ -0,0 +1,64 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu + +
+ + + + + +
+ + + diff --git a/tests/qemuhotplugtestcpus/ppc64-modern-individual-result-live.xml b/tests/qemuhotplugtestcpus/ppc64-modern-individual-result-live.xml new file mode 100644 index 0000000000..8621b62b76 --- /dev/null +++ b/tests/qemuhotplugtestcpus/ppc64-modern-individual-result-live.xml @@ -0,0 +1,72 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu + + +
+ + + + + + + + + + + + +
+ + + diff --git a/tests/qemuhotplugtestcpus/x86-modern-individual-add-domain.xml b/tests/qemuhotplugtestcpus/x86-modern-individual-add-domain.xml new file mode 100644 index 0000000000..1c2a5b1313 --- /dev/null +++ b/tests/qemuhotplugtestcpus/x86-modern-individual-add-domain.xml @@ -0,0 +1,21 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 8 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu + + diff --git a/tests/qemuhotplugtestcpus/x86-modern-individual-add-monitor.json b/tests/qemuhotplugtestcpus/x86-modern-individual-add-monitor.json new file mode 100644 index 0000000000..294198b270 --- /dev/null +++ b/tests/qemuhotplugtestcpus/x86-modern-individual-add-monitor.json @@ -0,0 +1,299 @@ +{"execute":"query-hotpluggable-cpus","id":"libvirt-1"} + +{ + "return": [ + { + "props": { + "core-id": 1, + "thread-id": 1, + "socket-id": 1 + }, + "vcpus-count": 1, + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 1, + "thread-id": 0, + "socket-id": 1 + }, + "vcpus-count": 1, + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 0, + "thread-id": 1, + "socket-id": 1 + }, + "vcpus-count": 1, + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 0, + "thread-id": 0, + "socket-id": 1 + }, + "vcpus-count": 1, + "qom-path": "/machine/unattached/device[5]", + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 1, + "thread-id": 1, + "socket-id": 0 + }, + "vcpus-count": 1, + "qom-path": "/machine/unattached/device[4]", + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 1, + "thread-id": 0, + "socket-id": 0 + }, + "vcpus-count": 1, + "qom-path": "/machine/unattached/device[3]", + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 0, + "thread-id": 1, + "socket-id": 0 + }, + "vcpus-count": 1, + "qom-path": "/machine/unattached/device[2]", + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 0, + "thread-id": 0, + "socket-id": 0 + }, + "vcpus-count": 1, + "qom-path": "/machine/unattached/device[0]", + "type": "qemu64-x86_64-cpu" + } + ], + "id": "libvirt-23" +} + +{"execute":"query-cpus","id":"libvirt-2"} + +{ + "return": [ + { + "arch": "x86", + "current": true, + "CPU": 0, + "qom_path": "/machine/unattached/device[0]", + "pc": -2130415978, + "halted": true, + "thread_id": 518291 + }, + { + "arch": "x86", + "current": false, + "CPU": 1, + "qom_path": "/machine/unattached/device[2]", + "pc": -2130415978, + "halted": true, + "thread_id": 518292 + }, + { + "arch": "x86", + "current": false, + "CPU": 2, + "qom_path": "/machine/unattached/device[3]", + "pc": -2130415978, + "halted": true, + "thread_id": 518294 + }, + { + "arch": "x86", + "current": false, + "CPU": 3, + "qom_path": "/machine/unattached/device[4]", + "pc": -2130415978, + "halted": true, + "thread_id": 518295 + }, + { + "arch": "x86", + "current": false, + "CPU": 4, + "qom_path": "/machine/unattached/device[5]", + "pc": -2130415978, + "halted": true, + "thread_id": 518296 + } + ], + "id": "libvirt-22" +} + +{ + "execute": "device_add", + "arguments": { + "driver": "qemu64-x86_64-cpu", + "id": "vcpu7", + "socket-id": 1, + "core-id": 1, + "thread-id": 1 + }, + "id": "libvirt-3" +} + +{"return": {}} + +{"execute":"query-hotpluggable-cpus","id":"libvirt-4"} + +{ + "return": [ + { + "props": { + "core-id": 1, + "thread-id": 1, + "socket-id": 1 + }, + "vcpus-count": 1, + "qom-path": "/machine/peripheral/vcpu7", + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 1, + "thread-id": 0, + "socket-id": 1 + }, + "vcpus-count": 1, + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 0, + "thread-id": 1, + "socket-id": 1 + }, + "vcpus-count": 1, + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 0, + "thread-id": 0, + "socket-id": 1 + }, + "vcpus-count": 1, + "qom-path": "/machine/unattached/device[5]", + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 1, + "thread-id": 1, + "socket-id": 0 + }, + "vcpus-count": 1, + "qom-path": "/machine/unattached/device[4]", + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 1, + "thread-id": 0, + "socket-id": 0 + }, + "vcpus-count": 1, + "qom-path": "/machine/unattached/device[3]", + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 0, + "thread-id": 1, + "socket-id": 0 + }, + "vcpus-count": 1, + "qom-path": "/machine/unattached/device[2]", + "type": "qemu64-x86_64-cpu" + }, + { + "props": { + "core-id": 0, + "thread-id": 0, + "socket-id": 0 + }, + "vcpus-count": 1, + "qom-path": "/machine/unattached/device[0]", + "type": "qemu64-x86_64-cpu" + } + ], + "id": "libvirt-23" +} + +{"execute":"query-cpus","id":"libvirt-5"} + +{ + "return": [ + { + "arch": "x86", + "current": true, + "CPU": 0, + "qom_path": "/machine/unattached/device[0]", + "pc": -2130415978, + "halted": true, + "thread_id": 518291 + }, + { + "arch": "x86", + "current": false, + "CPU": 1, + "qom_path": "/machine/unattached/device[2]", + "pc": -2130415978, + "halted": true, + "thread_id": 518292 + }, + { + "arch": "x86", + "current": false, + "CPU": 2, + "qom_path": "/machine/unattached/device[3]", + "pc": -2130415978, + "halted": true, + "thread_id": 518294 + }, + { + "arch": "x86", + "current": false, + "CPU": 3, + "qom_path": "/machine/unattached/device[4]", + "pc": -2130415978, + "halted": true, + "thread_id": 518295 + }, + { + "arch": "x86", + "current": false, + "CPU": 4, + "qom_path": "/machine/unattached/device[5]", + "pc": -2130415978, + "halted": true, + "thread_id": 518296 + }, + { + "arch": "x86", + "current": false, + "CPU": 5, + "qom_path": "/machine/peripheral/vcpu7", + "pc": -2130415978, + "halted": true, + "thread_id": 518297 + } + ], + "id": "libvirt-22" +} diff --git a/tests/qemuhotplugtestcpus/x86-modern-individual-add-result-conf.xml b/tests/qemuhotplugtestcpus/x86-modern-individual-add-result-conf.xml new file mode 100644 index 0000000000..75e8335587 --- /dev/null +++ b/tests/qemuhotplugtestcpus/x86-modern-individual-add-result-conf.xml @@ -0,0 +1,40 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 8 + + + + + + + + + + + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu + +
+ + + + + +
+ + + diff --git a/tests/qemuhotplugtestcpus/x86-modern-individual-add-result-live.xml b/tests/qemuhotplugtestcpus/x86-modern-individual-add-result-live.xml new file mode 100644 index 0000000000..a21db6f3b1 --- /dev/null +++ b/tests/qemuhotplugtestcpus/x86-modern-individual-add-result-live.xml @@ -0,0 +1,48 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 8 + + + + + + + + + + + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu + + +
+ + + + + + + + + + + + +
+ + +