Skip to contentSkip to conversation

tests/functional/ppc64: add pseries CPU hotplug and security caps tests

PATCH New Anushree Mathur 1 participant 9 messages Oct 30 – Nov 19

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover tests/functional/ppc64: add pseries CPU hotplug and security caps tests

This series adds two new functional tests for the pseries (sPAPR/PAPR) machine type:

Patch 1 adds a DLPAR CPU hotplug/unplug test. It boots a minimal buildroot Linux guest with one active core and uses QMP device_add / device_del to attach and detach a second core at runtime, verifying the guest kernel's view via /sys/devices/system/cpu/online. Two variants are provided: TCG (runs on any host) and KVM (ppc64le only, with an explicit kvm-hv module check).

Patch 2 adds a lightweight no-boot capability test suite. Each test starts QEMU halted (-S) and exercises the QMP interface to verify that security capability properties (cap-cfpc, cap-sbbc, cap-ibs, cap-ccf-assist, cap-nested-hv) are accepted, that versioned compat machines (pseries-7.2, pseries-9.2, pseries-10.0) can be instantiated and are correctly marked non-current, and that cap-hpt-max-page-size is reachable via the QOM tree. All tests complete in under 5 seconds and are registered in the quick suite.

Patch 3 registers both new test files in MAINTAINERS under the sPAPR (pseries) section.

Both tests have been run on a ppc64le Power11 LPAR and pass cleanly under both TCG and KVM.

GitLab CI pipeline (check-dco, check-patch, build-system-* pass):
https://gitlab.com/Anushree-Mathur1/qemu/-/pipelines/3003562135

Anushree Mathur (3):
tests/functional/ppc64: add pseries CPU hotplug test tests/functional/ppc64: add pseries security caps test
MAINTAINERS: add pseries CPU hotplug and caps functional tests

 MAINTAINERS                                 |   2 +
 tests/functional/ppc64/meson.build          |   3 +
 tests/functional/ppc64/test_hotplug_cpu.py  | 183 ++++++++++++++++++++
 tests/functional/ppc64/test_pseries_caps.py | 178 +++++++++++++++++++
 4 files changed, 366 insertions(+)
 create mode 100755 tests/functional/ppc64/test_hotplug_cpu.py
 create mode 100755 tests/functional/ppc64/test_pseries_caps.py

base-commit: b574eaf640f02c4edf28cbee6417378f0d79cda0

Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/3 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.

---
 tests/functional/ppc64/meson.build         |   2 +
 tests/functional/ppc64/test_hotplug_cpu.py | 183 +++++++++++++++++++++
 2 files changed, 185 insertions(+)
 create mode 100755 tests/functional/ppc64/test_hotplug_cpu.py
tests/functional/ppc64/meson.build +2 -0
index cb3c745624..45468087cb 100644
@@ -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 +183 -0

183 lines not on this page · raw message

Signature · 1 line
2.55.0
#2 lore raw

PATCH 2/3 tests/functional/ppc64: add pseries security caps test

In reply to Anushree Mathur

Add a quick functional test (no Linux boot required) that validates pseries machine-type security capabilities and backward-compatible machine-type instantiation via 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 without error.
* test_pseries_nested_hv_cap: cap-nested-hv=on is accepted.
* test_pseries_compat_7_2/9_2/10_0: versioned compat machines can be instantiated and are not marked is-current.
* test_pseries_cpu_model_expansion: skipped (query-cpu-model-expansion is not implemented for ppc64 TCG).
* 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.

---
 tests/functional/ppc64/meson.build          |   1 +
 tests/functional/ppc64/test_pseries_caps.py | 178 ++++++++++++++++++++
 2 files changed, 179 insertions(+)
 create mode 100755 tests/functional/ppc64/test_pseries_caps.py
tests/functional/ppc64/meson.build +1 -0
index 45468087cb..d91209f041 100644
@@ -14,6 +14,7 @@ test_ppc64_timeouts = {
 
 tests_ppc64_system_quick = [
   'migration',
+  'pseries_caps',
   'vmstate',
 ]
 
tests/functional/ppc64/test_pseries_caps.py new file +178 -0

178 lines not on this page · raw message

Signature · 1 line
2.55.0
#3 lore raw

PATCH 3/3 MAINTAINERS: add pseries CPU hotplug and caps functional tests

In reply to Anushree Mathur

Add entries for the two new pseries functional tests introduced in the preceding commits:
- tests/functional/ppc64/test_hotplug_cpu.py
- tests/functional/ppc64/test_pseries_caps.py

Both belong under the sPAPR (pseries) section.

---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index 70e9fed776..a2187c440f 100644
@@ -1702,6 +1702,8 @@ 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_cpu.py
+F: tests/functional/ppc64/test_pseries_caps.py
 
 PowerNV (Non-Virtualized)
 M: Nicholas Piggin <[email protected]>
Signature · 1 line
2.55.0
#4 lore raw

v2 cover tests/functional/ppc64: add pseries hotplug and caps tests

In reply to Anushree Mathur

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 and waits 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), 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
-------
v1 of the CPU hotplug, caps and virtio-blk tests were run on a ppc64le POWER host with both TCG and KVM and passed. The changes below do not touch the test logic. 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.

CI
--
GitLab pipeline: https://gitlab.com/Anushree-Mathur1/qemu/-/pipelines/3084104292
The jobs that fail are all allow_failure: Rust nightly (bitops.rs), tuxrun/armbian asset downloads, and aarch64 timeout/migration tests. None of them involve this series, which only adds ppc64 tests and MAINTAINERS entries.

Links to v1:
- 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 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  | 188 ++++++++++++++++++++
 tests/functional/ppc64/test_hotplug_cpu.py  | 185 +++++++++++++++++++
 tests/functional/ppc64/test_pseries_caps.py | 162 +++++++++++++++++
 5 files changed, 543 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
#5 lore raw

PATCH v2 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.

---
v2: assets now from raphael502/qemu-ppc-boot instead of legoater/qemu-ppc-boot (same files, same sha256); wrapped long URL lines for checkpatch.

 tests/functional/ppc64/meson.build         |   2 +
 tests/functional/ppc64/test_hotplug_cpu.py | 185 +++++++++++++++++++++
 2 files changed, 187 insertions(+)
 create mode 100755 tests/functional/ppc64/test_hotplug_cpu.py
tests/functional/ppc64/meson.build +2 -0
index cb3c745624..45468087cb 100644
@@ -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 +185 -0

185 lines not on this page · raw message

Signature · 1 line
2.55.0
#6 lore raw

PATCH v2 2/4 tests/functional/ppc64: add pseries security caps test

In reply to Anushree Mathur

Add a quick functional test (no Linux boot required) that checks that the pseries machine type accepts its security capability options 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 and the machine starts.
* test_pseries_nested_hv_cap: cap-nested-hv=on is accepted.
* test_pseries_compat_7_2/9_2/10_0: versioned compat machines can be instantiated and are not marked is-current.
* 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.

---
v2: reworded the commit message to say what is actually checked, fixed docstrings that did not match the code and dropped the skipped query-cpu-model-expansion placeholder test.

 tests/functional/ppc64/meson.build          |   1 +
 tests/functional/ppc64/test_pseries_caps.py | 162 ++++++++++++++++++++
 2 files changed, 163 insertions(+)
 create mode 100755 tests/functional/ppc64/test_pseries_caps.py
tests/functional/ppc64/meson.build +1 -0
index 45468087cb..d91209f041 100644
@@ -14,6 +14,7 @@ test_ppc64_timeouts = {
 
 tests_ppc64_system_quick = [
   'migration',
+  'pseries_caps',
   'vmstate',
 ]
 
tests/functional/ppc64/test_pseries_caps.py new file +162 -0

162 lines not on this page · raw message

Signature · 1 line
2.55.0
#7 lore raw

PATCH v2 3/4 tests/functional/ppc64: add pseries virtio-blk hotplug test

In reply to Anushree Mathur

Add 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.

---
v2: no longer RFC. I raised the patch adding rootfs-hotplug.ext2 to qemu-ppc-boot (https://github.com/raphael502/qemu-ppc-boot/pull/1) and it has been merged, so the asset URLs now point to that repository (sha256 unchanged). The vmlinux asset also points to qemu-ppc-boot, and the test file is now executable like the other functional tests.

 tests/functional/ppc64/meson.build         |   2 +
 tests/functional/ppc64/test_hotplug_blk.py | 188 +++++++++++++++++++++
 2 files changed, 190 insertions(+)
 create mode 100755 tests/functional/ppc64/test_hotplug_blk.py
tests/functional/ppc64/meson.build +2 -0
index d91209f041..f483ce4d76 100644
@@ -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 +188 -0

188 lines not on this page · raw message

Signature · 1 line
2.55.0
#8 lore raw

PATCH v2 4/4 MAINTAINERS: add pseries hotplug and caps functional tests

In reply to Anushree Mathur

Add 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.

---
v2: now a single patch covering all three tests (previously a separate patch plus an entry in the virtio-blk patch).

 MAINTAINERS | 3 +++
 1 file changed, 3 insertions(+)
MAINTAINERS +3 -0
index 15942aaba3..8456c5fbec 100644
@@ -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