From: Anushree Mathur <anushree.mathur@linux.ibm.com>
To: "Harsh Prateek Bora" <harshpb@linux.ibm.com>,
"Cédric Le Goater" <clg@redhat.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Cc: Anushree Mathur <anushree.mathur@linux.ibm.com>,
Thomas Huth <thuth@redhat.com>,
Amit Machhiwal <amachhiw@linux.ibm.com>,
Miles Glenn <milesg@linux.ibm.com>,
Aditya Gupta <adityag@linux.ibm.com>,
misanjum@linux.ibm.com, Chinmay Rath <rathc@linux.ibm.com>,
Utkarsh Verma <uverma@linux.ibm.com>
Subject: [PATCH v3 2/4] tests/functional/ppc64: add pseries security caps test
Date: Tue, 24 Nov 2026 16:30:28 +0530 [thread overview]
Message-ID: <20261124110030.30097-3-anushree.mathur@linux.ibm.com> (raw)
In-Reply-To: <20261124110030.30097-1-anushree.mathur@linux.ibm.com>
Add 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.
Signed-off-by: Anushree Mathur <anushree.mathur@linux.ibm.com>
---
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
diff --git a/tests/functional/ppc64/meson.build b/tests/functional/ppc64/meson.build
index 45468087cb..d91209f041 100644
--- a/tests/functional/ppc64/meson.build
+++ b/tests/functional/ppc64/meson.build
@@ -14,6 +14,7 @@ test_ppc64_timeouts = {
tests_ppc64_system_quick = [
'migration',
+ 'pseries_caps',
'vmstate',
]
diff --git a/tests/functional/ppc64/test_pseries_caps.py b/tests/functional/ppc64/test_pseries_caps.py
new file mode 100755
index 0000000000..2b2d33229f
--- /dev/null
+++ b/tests/functional/ppc64/test_pseries_caps.py
@@ -0,0 +1,169 @@
+#!/usr/bin/env python3
+# Copyright (c) 2025 IBM Corporation
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import QemuSystemTest
+
+
+class PseriesCapsTest(QemuSystemTest):
+ """
+ Quick (no-boot) tests for pseries machine capabilities.
+
+ Each test starts QEMU with -S (halted) so no firmware or kernel is
+ needed. The tests exercise the QMP interface to verify that:
+
+ * The machine type is visible in 'query-machines' output.
+ * Known security capability properties (cap-cfpc, cap-sbbc,
+ cap-ibs, cap-ccf-assist, cap-nested-hv) are accepted and read
+ back with the values that were set.
+ * Versioned compat machines (pseries-7.2, pseries-9.2 and
+ pseries-10.0) can be instantiated and are not marked
+ is-default.
+ * cap-hpt-max-page-size is reachable via the QOM tree.
+ """
+
+ timeout = 30
+
+ # ------------------------------------------------------------------ #
+ # Helpers
+ # ------------------------------------------------------------------ #
+
+ def _launch_stopped(self, machine='pseries', extra_args=None):
+ """Launch QEMU paused (-S) for the named machine and return."""
+ self.set_machine(machine)
+ self.vm.add_args('-S', '-nodefaults')
+ if extra_args:
+ self.vm.add_args(*extra_args)
+ self.vm.launch()
+
+ def _query_machine_info(self, name):
+ """Return the entry from query-machines that matches *name* or alias."""
+ machines = self.vm.cmd('query-machines')
+ for m in machines:
+ if m['name'] == name or m.get('alias') == name:
+ return m
+ return None
+
+ # ------------------------------------------------------------------ #
+ # Test: basic pseries machine is visible in query-machines
+ # ------------------------------------------------------------------ #
+
+ def test_pseries_in_query_machines(self):
+ """pseries (latest) must appear in query-machines output."""
+ self._launch_stopped('pseries')
+ info = self._query_machine_info('pseries')
+ self.assertIsNotNone(info,
+ 'pseries not found in query-machines output')
+ # The default/latest versioned machine carries is-default=True.
+ self.assertTrue(
+ info.get('is-default', False),
+ 'pseries alias should be marked is-default=true',
+ )
+
+ # ------------------------------------------------------------------ #
+ # Test: security cap overrides are accepted without error
+ # ------------------------------------------------------------------ #
+
+ def test_pseries_security_caps_override(self):
+ """
+ Verify pseries accepts all well-known security cap overrides.
+
+ These are the options used by the KVM nested-HV path in
+ test_hv.py. Check that QEMU starts cleanly and that each
+ capability reads back through qom-get with the value that was
+ set on the command line.
+ """
+ caps = (
+ 'cap-cfpc=broken,'
+ 'cap-sbbc=broken,'
+ 'cap-ibs=broken,'
+ 'cap-ccf-assist=off'
+ )
+ self._launch_stopped('pseries', extra_args=['-machine', caps])
+ for name in ('cap-cfpc', 'cap-sbbc', 'cap-ibs'):
+ self.assertEqual(
+ self.vm.cmd('qom-get', path='/machine', property=name),
+ 'broken',
+ f'{name} should read back as broken',
+ )
+ self.assertFalse(
+ self.vm.cmd('qom-get', path='/machine',
+ property='cap-ccf-assist'),
+ 'cap-ccf-assist should read back as off',
+ )
+
+ # ------------------------------------------------------------------ #
+ # Test: nested-HV cap is accepted
+ # ------------------------------------------------------------------ #
+
+ def test_pseries_nested_hv_cap(self):
+ """pseries must accept cap-nested-hv=on and report it as on."""
+ self._launch_stopped(
+ 'pseries',
+ extra_args=['-machine', 'x-vof=on,cap-nested-hv=on'],
+ )
+ self.assertTrue(
+ self.vm.cmd('qom-get', path='/machine',
+ property='cap-nested-hv'),
+ 'cap-nested-hv should read back as on',
+ )
+
+ # ------------------------------------------------------------------ #
+ # Test: versioned compat machines can be instantiated
+ # ------------------------------------------------------------------ #
+
+ def _test_compat_machine(self, version_str):
+ """
+ Helper: launch a versioned compat machine and verify that the
+ name appears in query-machines and that it is not marked
+ is-default (the default is always the latest version).
+ """
+ self._launch_stopped(version_str)
+ info = self._query_machine_info(version_str)
+ self.assertIsNotNone(
+ info,
+ f'compat machine {version_str!r} not found in query-machines',
+ )
+ # query-machines only reports is-default for the default (latest)
+ # machine, so it must be absent or False for a compat machine.
+ self.assertFalse(
+ info.get('is-default', False),
+ f'{version_str} should not be marked is-default=true',
+ )
+
+ def test_pseries_compat_7_2(self):
+ """pseries-7.2 (vmstate reference version) can be instantiated."""
+ self._test_compat_machine('pseries-7.2')
+
+ def test_pseries_compat_9_2(self):
+ """pseries-9.2 can be instantiated."""
+ self._test_compat_machine('pseries-9.2')
+
+ def test_pseries_compat_10_0(self):
+ """pseries-10.0 can be instantiated."""
+ self._test_compat_machine('pseries-10.0')
+
+ # ------------------------------------------------------------------ #
+ # Test: cap-hpt-max-page-size is reachable via the QOM tree
+ # ------------------------------------------------------------------ #
+
+ def test_pseries_cap_hpt_max_page_size(self):
+ """
+ Verify that pseries exposes cap-hpt-max-page-size in its
+ machine properties (it is used by migration compat checks).
+ """
+ self._launch_stopped('pseries')
+ # query-machine-props is not a real QMP command; we use the
+ # object model instead.
+ props = self.vm.cmd('qom-list', path='/machine')
+ prop_names = [p['name'] for p in props]
+ # The property should be reachable via the QOM tree.
+ self.assertIn(
+ 'cap-hpt-max-page-size', prop_names,
+ 'pseries /machine must expose cap-hpt-max-page-size via QOM',
+ )
+
+
+if __name__ == '__main__':
+ PseriesCapsTest.main()
--
2.55.0
next prev parent reply other threads:[~2026-11-24 11:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 11:00 [PATCH v3 0/4] tests/functional/ppc64: add pseries hotplug and caps tests Anushree Mathur
2026-11-24 11:00 ` [PATCH v3 1/4] tests/functional/ppc64: add pseries CPU hotplug test Anushree Mathur
2026-11-27 1:57 ` Utkarsh Verma
2026-11-24 11:00 ` Anushree Mathur [this message]
2026-11-27 12:15 ` [PATCH v3 2/4] tests/functional/ppc64: add pseries security caps test Utkarsh Verma
2026-11-24 11:00 ` [PATCH v3 3/4] tests/functional/ppc64: add pseries virtio-blk hotplug test Anushree Mathur
2026-11-27 12:51 ` Utkarsh Verma
2026-11-24 11:00 ` [PATCH v3 4/4] MAINTAINERS: add pseries hotplug and caps functional tests Anushree Mathur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261124110030.30097-3-anushree.mathur@linux.ibm.com \
--to=anushree.mathur@linux.ibm.com \
--cc=adityag@linux.ibm.com \
--cc=amachhiw@linux.ibm.com \
--cc=clg@redhat.com \
--cc=harshpb@linux.ibm.com \
--cc=milesg@linux.ibm.com \
--cc=misanjum@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rathc@linux.ibm.com \
--cc=thuth@redhat.com \
--cc=uverma@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.