All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tests/functional: Check for nested virtualization to run KVM tests
@ 2026-01-16  7:04 Philippe Mathieu-Daudé
  2026-01-16  9:59 ` Daniel P. Berrangé
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-01-16  7:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, Peter Maydell, Mohamed Mediouni, Thomas Huth,
	Alex Bennée, Philippe Mathieu-Daudé

On Apple Silicon, nested virtualization starts to be usable
with M3 models and later. Check for the CPU model to avoid
failure on pre-M3:

  qemu-system-aarch64: unable to find CPU model 'cortex-a72'

Now tests are correctly skipped, i.e. on M1:

  ok 1 test_kvm.Aarch64VirtKVMTests.test_aarch64_nvhe_selftest # SKIP Nested Virtualization not available on Apple M1 Pro
  ok 2 test_kvm.Aarch64VirtKVMTests.test_aarch64_vhe_selftest # SKIP Nested Virtualization not available on Apple M1 Pro

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 tests/functional/aarch64/test_kvm.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tests/functional/aarch64/test_kvm.py b/tests/functional/aarch64/test_kvm.py
index 7545f5ed554..b26c849ec67 100755
--- a/tests/functional/aarch64/test_kvm.py
+++ b/tests/functional/aarch64/test_kvm.py
@@ -29,8 +29,31 @@ class Aarch64VirtKVMTests(LinuxKernelTest):
     # base of tests
     KUT_BASE = "/usr/share/kvm-unit-tests/"
 
+    def require_nested_virtualization(self):
+        """
+        Requires the accelerator to support nested virtualization for the test
+        to continue
+
+        If the check fails, the test is canceled.
+        """
+        import platform, re, subprocess
+
+        if platform.system() != 'Darwin':
+            return
+        r = subprocess.run(['sysctl', '-n', 'machdep.cpu.brand_string'],
+                           text=True, capture_output=True)
+        if r.returncode != 0:
+            return
+        m = re.match(r"Apple M(\d+)( .*)?", r.stdout)
+        if m:
+            if int(m.group(1)) < 3:
+                self.skipTest("Nested Virtualization not available"
+                              " on %s" % r.stdout.strip())
+
     def _launch_guest(self, kvm_mode="nvhe"):
 
+        self.require_nested_virtualization()
+
         self.set_machine('virt')
         kernel_path = self.ASSET_KVM_TEST_KERNEL.fetch()
 
-- 
2.52.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-01-16 10:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-16  7:04 [PATCH] tests/functional: Check for nested virtualization to run KVM tests Philippe Mathieu-Daudé
2026-01-16  9:59 ` Daniel P. Berrangé

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.