tests/functional/ppc64: add pseries hotplug and caps tests
Subsystems (2)
v3 cover tests/functional/ppc64: add pseries hotplug and caps tests
Hi all,
This series adds three new functional tests for the pseries (sPAPR/PAPR) machine type and registers them in MAINTAINERS.
Patch 1 adds test_hotplug_cpu.py. It boots a buildroot guest with one core (-smp 2,threads=2,cores=1,maxcpus=4), hot-adds a second core with QMP device_add and waits until /sys/devices/system/cpu/online changes from 0-1 to 0-3. It then hot-removes the core with device_del, waits for the QMP DEVICE_DELETED event and for the guest to be back at 0-1. It runs with TCG and, if available, with KVM.
Patch 2 adds test_pseries_caps.py, a quick test that does not boot a guest. QEMU is started halted (-S) and QMP is used to check that pseries starts with the security capability options (cap-cfpc, cap-sbbc, cap-ibs, cap-ccf-assist, cap-nested-hv) and that qom-get returns the values that were set, that pseries-7.2, 9.2 and 10.0 can be instantiated, and that cap-hpt-max-page-size is visible under /machine in the QOM tree.
Patch 3 adds test_hotplug_blk.py. It boots a similar guest with a second PCI host bridge (phb1), hot-adds a virtio-blk-pci disk backed by a null-co node with QMP device_add and waits for /dev/vda to appear in the guest. It then hot-removes the disk with device_del and waits for the DEVICE_DELETED event and for /dev/vda to disappear. The guest needs rtas_errd and drmgr to enumerate the new device, so the test uses a rootfs that includes them. I raised the patch that adds this image (rootfs-hotplug.ext2) to qemu-ppc-boot, see
https://github.com/raphael502/qemu-ppc-boot/pull/1. It has been merged, so the test downloads the image from that repository. The test runs with TCG, and also with KVM if KVM is enabled.
Patch 4 adds the MAINTAINERS entries for the three tests.
Testing
-------
The three tests were run on a ppc64le POWER host with both TCG and KVM and pass. checkpatch.pl reports no errors or warnings on any patch (apart from the expected "MAINTAINERS needs updating" notices on patches 1-3, resolved by patch 4), and pylint with tests/functional/pylintrc reports nothing for the new files.
Links to previous versions:
- v2:
https://lore.kernel.org/qemu-devel/[email protected]/
- v1 for CPU hotplug and caps tests:
https://lore.kernel.org/qemu-devel/[email protected]/
- RFC v1 for virtio-blk hotplug test:
https://lore.kernel.org/qemu-devel/[email protected]/
Changes in v3 (review comments from Utkarsh Verma on v2):
- Patch 1: put the -smp option on its own line and replaced the arrow characters with ASCII; added snapshot=on to the rootfs drive; bounded the guest wait loops to 45 seconds with a failure message; wait for the QMP DEVICE_DELETED event after device_del.
- Patch 2: the caps tests now check the values with qom-get instead of only checking that QEMU starts; dropped the redundant "pseries" from the -machine arguments; the compat machine check now uses is-default, as is-current is not a query-machines field and the old assertion could never fail.
- Patch 3: the rtas_errd start and the initial /dev/vda checks matched the echoed command and always passed, so they now use the shell variable sentinel and rtas_errd is verified with pidof; bounded the wait loops to 60 seconds with a failure message; assert that DEVICE_DELETED was received.
- Patch 4: no changes.
Changes in v2:
- Combined the two v1 postings above into one series.
- Patch 1: buildroot kernel and rootfs assets now point to raphael502/qemu-ppc-boot instead of legoater/qemu-ppc-boot. They are the same files; the sha256 values are unchanged and were re-verified. Wrapped the long URL lines to keep checkpatch quiet.
- Patch 2: reworded the commit message to say what is actually checked (the options are accepted and the machine starts), fixed docstrings that did not match the code, and dropped the skipped query-cpu-model-expansion placeholder test.
- Patch 3: no longer an RFC. v1 was an RFC because rootfs-hotplug.ext2 was not available yet; it is now merged in qemu-ppc-boot and the asset URLs point to it (the sha256 is unchanged). The vmlinux asset also points to qemu-ppc-boot, and the test file is now executable like the other functional tests.
- Patch 4: a single MAINTAINERS patch covering all three tests (previously a separate patch for the CPU and caps tests, and an entry inside the virtio-blk patch).
- Rebased on current master (6883fb508c).
Anushree Mathur (4):
tests/functional/ppc64: add pseries CPU hotplug test tests/functional/ppc64: add pseries security caps test tests/functional/ppc64: add pseries virtio-blk hotplug test
MAINTAINERS: add pseries hotplug and caps functional tests
MAINTAINERS | 3 + tests/functional/ppc64/meson.build | 5 + tests/functional/ppc64/test_hotplug_blk.py | 206 +++++++++++++++++++ tests/functional/ppc64/test_hotplug_cpu.py | 207 ++++++++++++++++++++ tests/functional/ppc64/test_pseries_caps.py | 169 ++++++++++++++++ 5 files changed, 590 insertions(+) create mode 100755 tests/functional/ppc64/test_hotplug_blk.py create mode 100755 tests/functional/ppc64/test_hotplug_cpu.py create mode 100755 tests/functional/ppc64/test_pseries_caps.py
base-commit: 6883fb508cb7a93e2e7b44c0582bfd9fc2196d4d
Signature · 1 line
2.55.0
PATCH v3 1/4 tests/functional/ppc64: add pseries CPU hotplug test
Add a functional test that exercises DLPAR (Dynamic Logical Partitioning) CPU hotplug and unplug on the pseries machine type.
The pseries machine supports adding and removing CPU cores at runtime via RTAS calls made by the guest. This test boots a minimal Linux kernel with a single core (-smp 2,threads=2,cores=1,maxcpus=4), then uses QMP device_add to attach a second core, verifies the guest sees it via /sys/devices/system/cpu/online, and then removes it again.
The CPU driver name is detected dynamically via query-hotpluggable-cpus so the test remains correct when the default pseries CPU changes in a future QEMU release (e.g. power10 -> power11).
Two variants are provided:
- test_pseries_cpu_hotplug_tcg: runs under TCG on any host arch.
- test_pseries_cpu_hotplug_kvm: runs under KVM on ppc64le hosts with kvm-hv loaded; skipped automatically elsewhere. An explicit /proc/modules check for kvm_hv is added because on ppc64le the base kvm module can create /dev/kvm without kvm-hv, which would cause the test to error rather than skip.
x-vof=on is intentionally NOT used: VOF skips the SLOF firmware path that sets up the RTAS event interrupt, causing CPU hotplug events to be silently dropped by the guest kernel.
---
v3: put the -smp option on its own line in the comments and use plain ASCII instead of arrows; added snapshot=on to the rootfs drive; bounded the wait loops (45 seconds) and report a failure message on timeout; wait for the QMP DEVICE_DELETED event after device_del.
tests/functional/ppc64/meson.build | 2 + tests/functional/ppc64/test_hotplug_cpu.py | 207 +++++++++++++++++++++ 2 files changed, 209 insertions(+) create mode 100755 tests/functional/ppc64/test_hotplug_cpu.py
tests/functional/ppc64/meson.build +2 -0
@@ -2,6 +2,7 @@ test_ppc64_timeouts = { 'fadump' : 480, + 'hotplug_cpu' : 480, 'hv' : 1000, 'mac99' : 120, 'openbsd' : 240,
@@ -19,6 +20,7 @@ tests_ppc64_system_quick = [ tests_ppc64_system_thorough = [ 'e500', 'fadump', + 'hotplug_cpu', 'hv', 'mac99', 'openbsd',
tests/functional/ppc64/test_hotplug_cpu.py new file +207 -0
207 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH v3 2/4 tests/functional/ppc64: add pseries security caps test
In reply to Anushree MathurAdd a quick functional test (no Linux boot required) that checks that the pseries machine type accepts its security capability options and reports them back with the configured values, and that backward-compatible versioned machine types can be instantiated, using the QMP interface.
Each test starts QEMU with -S (halted) so no firmware or kernel is needed. The tests cover:
* test_pseries_in_query_machines: pseries appears in query-machines and is marked is-default=true.
* test_pseries_security_caps_override: cap-cfpc, cap-sbbc, cap-ibs and cap-ccf-assist overrides are accepted, the machine starts and qom-get on /machine returns the values that were set.
* test_pseries_nested_hv_cap: cap-nested-hv=on is accepted and qom-get reports it as on.
* test_pseries_compat_7_2/9_2/10_0: versioned compat machines can be instantiated and are not marked is-default.
* test_pseries_cap_hpt_max_page_size: cap-hpt-max-page-size is reachable via the QOM tree at /machine.
All tests complete in under 5 seconds each and are registered in the tests_ppc64_system_quick list.
---
v3: check the cap-cfpc, cap-sbbc, cap-ibs, cap-ccf-assist and cap-nested-hv values with qom-get instead of only checking that QEMU starts; dropped the redundant "pseries" from the -machine arguments; the compat machine check now looks at is-default (is-current is not a query-machines field, so the old assertion could never fail).
tests/functional/ppc64/meson.build | 1 + tests/functional/ppc64/test_pseries_caps.py | 169 ++++++++++++++++++++ 2 files changed, 170 insertions(+) create mode 100755 tests/functional/ppc64/test_pseries_caps.py
tests/functional/ppc64/meson.build +1 -0
@@ -14,6 +14,7 @@ test_ppc64_timeouts = { tests_ppc64_system_quick = [ 'migration', + 'pseries_caps', 'vmstate', ]
tests/functional/ppc64/test_pseries_caps.py new file +169 -0
169 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH v3 3/4 tests/functional/ppc64: add pseries virtio-blk hotplug test
In reply to Anushree MathurAdd a functional test that hot-plugs and hot-unplugs a virtio-blk-pci disk on the pseries machine. It runs with TCG, and also with KVM if KVM is enabled.
On pseries a PCI device added through QMP is only enumerated by the guest once rtas_errd (ppc64-diag) handles the RTAS hotplug event and runs drmgr (powerpc-utils). Neither is in the buildroot image used by the other pseries tests, so the test uses rootfs-hotplug.ext2: the same image with those two tools added.
The test boots with a second PHB (phb1) present so that the guest registers its slots, adds a null-co backend, hot-plugs virtio-blk-pci into phb1.0 and waits for /dev/vda, then unplugs it and waits for both the QMP DEVICE_DELETED event and /dev/vda to go away. The root drive is used with snapshot=on so the cached asset is not modified by the guest.
---
v3: the rtas_errd start and the initial /dev/vda checks used patterns that also matched the echoed command, so they always passed; they now use the shell variable sentinel, and rtas_errd is verified with pidof. Bounded the wait loops (60 seconds) with a failure message on timeout, and the test now asserts that DEVICE_DELETED was received.
tests/functional/ppc64/meson.build | 2 + tests/functional/ppc64/test_hotplug_blk.py | 206 +++++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100755 tests/functional/ppc64/test_hotplug_blk.py
tests/functional/ppc64/meson.build +2 -0
@@ -2,6 +2,7 @@ test_ppc64_timeouts = { 'fadump' : 480, + 'hotplug_blk' : 600, 'hotplug_cpu' : 480, 'hv' : 1000, 'mac99' : 120,
@@ -21,6 +22,7 @@ tests_ppc64_system_quick = [ tests_ppc64_system_thorough = [ 'e500', 'fadump', + 'hotplug_blk', 'hotplug_cpu', 'hv', 'mac99',
tests/functional/ppc64/test_hotplug_blk.py new file +206 -0
206 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH v3 4/4 MAINTAINERS: add pseries hotplug and caps functional tests
In reply to Anushree MathurAdd entries for the three new pseries functional tests introduced in the preceding commits:
- tests/functional/ppc64/test_hotplug_blk.py
- tests/functional/ppc64/test_hotplug_cpu.py
- tests/functional/ppc64/test_pseries_caps.py
All of them belong under the sPAPR (pseries) section.
---
v3: no changes.
MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+)
MAINTAINERS +3 -0
@@ -1705,6 +1705,9 @@ F: tests/qtest/libqos/rtas* F: tests/functional/ppc64/test_pseries.py F: tests/functional/ppc64/test_hv.py F: tests/functional/ppc64/test_tuxrun.py +F: tests/functional/ppc64/test_hotplug_blk.py +F: tests/functional/ppc64/test_hotplug_cpu.py +F: tests/functional/ppc64/test_pseries_caps.py PowerNV (Non-Virtualized) M: Nicholas Piggin <[email protected]>
Signature · 1 line
2.55.0