Skip to contentSkip to conversation

tests/functional/ppc64: Fixes and improvements for hypervisor tests

PATCH In review Aniket Sahu 4 participants 11 messages Nov 20 – Nov 23 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover tests/functional/ppc64: Fixes and improvements for hypervisor tests

This series fixes several issues in the PPC64 hypervisor functional tests and improves their robustness and reliability.

Changes in this series:
-----------------------

1. Replace deprecated datetime.utcnow() with datetime.now(timezone.utc) to avoid deprecation warnings in Python 3.12+.

2. Pin machine types to avoid CPU compatibility issues between the L0 QEMU (which now defaults to power11) and the L1 Alpine guest's packaged QEMU (which doesn't recognize power11). This fixes "Register sync failed" errors in L2.

3. Add kernel command line parameters (console=hvc0 usbcore.nousb) and early panic detection to fail fast when L2 encounters issues, plus retry logic for apk update to handle transient network failures.

4. Dynamically resolve the NVMe device path in L1 instead of hardcoding it, as the device name varies by machine type (nvme0n1 vs nvme1n1). Also adds comprehensive debug logging throughout the test flow and writes the L2 launch command to a script to avoid terminal line-wrap issues.

5. Increase the test timeout from 1000 to 6000 seconds to accommodate the longer runtime due to apk update retries and additional testing.

Testing:
--------
All tests pass on our PPC64 test machines running Ubuntu 26.04 in an LPAR.

Aniket Sahu (3):
tests/functional/ppc64: replace deprecated datetime.utcnow() tests/functional/ppc64: add kernel params and early panic detection tests/functional/ppc64: dynamically resolve NVMe device path

Misbah Anjum N (2):
tests/functional/ppc64: pin machine types for hypervisor tests tests/functional/ppc64: increase timeout for hypervisor tests

 tests/functional/ppc64/meson.build |   2 +-
 tests/functional/ppc64/test_hv.py  | 140 +++++++++++++++++++++++++----
 2 files changed, 117 insertions(+), 25 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/5 tests/functional/ppc64: replace deprecated datetime.utcnow()

Replace datetime.utcnow() with datetime.now(timezone.utc) to avoid deprecation warnings in Python 3.12+.

Also add debug logging when setting the system clock in the L1 guest.

---
 tests/functional/ppc64/test_hv.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tests/functional/ppc64/test_hv.py +3 -2
index beec1dbbea..8a1fca2cb1 100755
@@ -12,7 +12,7 @@
 import os
 import subprocess
 
-from datetime import datetime
+from datetime import datetime, timezone
 from qemu_test import QemuSystemTest, Asset
 from qemu_test import wait_for_console_pattern, exec_command
 from qemu_test import skipIfMissingCommands, skipBigDataTest
@@ -74,8 +74,9 @@ def do_start_alpine(self):
         ps1='localhost:~#'
         wait_for_console_pattern(self, 'localhost login:')
         exec_command_and_wait_for_pattern(self, 'root', ps1)
+        self.log.debug("do_start_alpine: logged in, setting system clock")
         # If the time is wrong, SSL certificates can fail.
-        cmd='date -s "' + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S' + '"')
+        cmd='date -s "' + datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M:%S' + '"')
         exec_command_and_wait_for_pattern(self, cmd, ps1)
         ps1='alpine:~#'
         exec_command_and_wait_for_pattern(self, 'setup-alpine -qe', ps1)
Signature · 1 line
2.52.0
#2 lore raw

PATCH 2/5 tests/functional/ppc64: pin machine types for hypervisor tests

In reply to Aniket Sahu

Pin machine types to avoid CPU compatibility issues:
- Use pseries-8.2 (POWER9) for pseries tests instead of generic 'pseries' alias which resolves to pseries-11.2 (power11_v2.0)
- Use powernv9 for powernv test to ensure consistent PCIe topology
- Fix test_hv_pseries_kvm to use TCG accelerator (L1 runs under TCG, L2 uses KVM inside L1)

The generic 'pseries' alias now resolves to a machine whose default CPU (power11) is not known to the qemu-system-ppc64 packaged by Alpine, causing the L2 guest to fail with "Register sync failed" error.

---
 tests/functional/ppc64/test_hv.py | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
tests/functional/ppc64/test_hv.py +15 -5
index 8a1fca2cb1..d977038271 100755
@@ -125,7 +125,12 @@ def do_test_kvm(self, hpt=False):
     def test_hv_pseries(self):
         self.require_accelerator("tcg")
         self.require_netdev('user')
-        self.set_machine('pseries')
+        # Pin to pseries-8.2 (default CPU power9_v2.2) so that kvm-hv.ko inside
+        # the L1 Alpine guest sees a POWER9 register set.  The generic 'pseries'
+        # alias resolves to pseries-11.2 (power11_v2.0) which Alpine's packaged
+        # qemu-system-ppc64 does not recognise, causing the L2 "Register sync
+        # failed" error.  The L2 script passes '-cpu POWER9' to match.
+        self.set_machine('pseries-8.2')
         self.vm.add_args("-accel", "tcg,thread=multi")
         self.vm.add_args('-device', 'nvme,serial=1234,drive=drive0')
         self.vm.add_args("-machine", "x-vof=on,cap-nested-hv=on")
@@ -135,10 +140,13 @@ def test_hv_pseries(self):
         self.do_stop_alpine()
 
     def test_hv_pseries_kvm(self):
-        self.require_accelerator("kvm")
+        # L1 runs under TCG; L2 is launched with accel=kvm inside L1
+        # (see do_test_kvm).
+        self.require_accelerator("tcg")
         self.require_netdev('user')
-        self.set_machine('pseries')
-        self.vm.add_args("-accel", "kvm")
+        # Same CPU pinning rationale as test_hv_pseries above.
+        self.set_machine('pseries-8.2')
+        self.vm.add_args("-accel", "tcg,thread=multi")
         self.vm.add_args('-device', 'nvme,serial=1234,drive=drive0')
         self.vm.add_args("-machine", "x-vof=on,cap-nested-hv=on,cap-ccf-assist=off")
         self.do_start_alpine()
@@ -149,7 +157,9 @@ def test_hv_pseries_kvm(self):
     def test_hv_powernv(self):
         self.require_accelerator("tcg")
         self.require_netdev('user')
-        self.set_machine('powernv')
+        # Pin to powernv9 so the PCIe topology matches (pcie.0, pcie.2) and
+        # kvm-hv.ko runs with the POWER9 CPU model.
+        self.set_machine('powernv9')
         self.vm.add_args("-accel", "tcg,thread=multi")
         self.vm.add_args('-device', 'nvme,bus=pcie.2,addr=0x0,serial=1234,drive=drive0',
                          '-device', 'e1000e,netdev=net0,mac=C0:FF:EE:00:00:02,bus=pcie.0,addr=0x0',
Signature · 1 line
2.52.0
#3 lore raw

Re: [PATCH 2/5] tests/functional/ppc64: pin machine types for hypervisor tests

Quoted 22 lines · Aniket Sahu

Pin machine types to avoid CPU compatibility issues:
- Use pseries-8.2 (POWER9) for pseries tests instead of generic 'pseries' alias which resolves to pseries-11.2 (power11_v2.0)
- Use powernv9 for powernv test to ensure consistent PCIe topology
- Fix test_hv_pseries_kvm to use TCG accelerator (L1 runs under TCG, L2 uses KVM inside L1)

The generic 'pseries' alias now resolves to a machine whose default CPU (power11) is not known to the qemu-system-ppc64 packaged by Alpine, causing the L2 guest to fail with "Register sync failed" error.

---
 tests/functional/ppc64/test_hv.py | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
tests/functional/ppc64/test_hv.py +0 -0
index 8a1fca2cb1..d977038271 100755

tests/functional/ppc64/test_hv.py def do_test_kvm(self, hpt=False): · line 133

Quoted 10 lines
tests/functional/ppc64/test_hv.py +6 -1
@@ -125,7 +125,12 @@ def do_test_kvm(self, hpt=False):
     def test_hv_pseries(self):
         self.require_accelerator("tcg")
         self.require_netdev('user')
-        self.set_machine('pseries')
+        # Pin to pseries-8.2 (default CPU power9_v2.2) so that kvm-hv.ko inside
+        # the L1 Alpine guest sees a POWER9 register set.  The generic 'pseries'
+        # alias resolves to pseries-11.2 (power11_v2.0) which Alpine's packaged
+        # qemu-system-ppc64 does not recognise, causing the L2 "Register sync
+        # failed" error.  The L2 script passes '-cpu POWER9' to match.
+        self.set_machine('pseries-8.2')

If the guest needs POWER9, why not add a "-cpu POWER9" flag to the L1 QEMU here, instead of making assumptions about what the machine type exposes.

Using old versioned machine types in functional tests is undesirable as we automatically delete versioned machines after 6 years, at which point we'll need to address the CPU model choice anyway.

Quoted 35 lines
tests/functional/ppc64/test_hv.py +9 -4
         self.vm.add_args("-accel", "tcg,thread=multi")
         self.vm.add_args('-device', 'nvme,serial=1234,drive=drive0')
         self.vm.add_args("-machine", "x-vof=on,cap-nested-hv=on")
@@ -135,10 +140,13 @@ def test_hv_pseries(self):
         self.do_stop_alpine()
 
     def test_hv_pseries_kvm(self):
-        self.require_accelerator("kvm")
+        # L1 runs under TCG; L2 is launched with accel=kvm inside L1
+        # (see do_test_kvm).
+        self.require_accelerator("tcg")
         self.require_netdev('user')
-        self.set_machine('pseries')
-        self.vm.add_args("-accel", "kvm")
+        # Same CPU pinning rationale as test_hv_pseries above.
+        self.set_machine('pseries-8.2')
+        self.vm.add_args("-accel", "tcg,thread=multi")
         self.vm.add_args('-device', 'nvme,serial=1234,drive=drive0')
         self.vm.add_args("-machine", "x-vof=on,cap-nested-hv=on,cap-ccf-assist=off")
         self.do_start_alpine()
@@ -149,7 +157,9 @@ def test_hv_pseries_kvm(self):
     def test_hv_powernv(self):
         self.require_accelerator("tcg")
         self.require_netdev('user')
-        self.set_machine('powernv')
+        # Pin to powernv9 so the PCIe topology matches (pcie.0, pcie.2) and
+        # kvm-hv.ko runs with the POWER9 CPU model.
+        self.set_machine('powernv9')
         self.vm.add_args("-accel", "tcg,thread=multi")
         self.vm.add_args('-device', 'nvme,bus=pcie.2,addr=0x0,serial=1234,drive=drive0',
                          '-device', 'e1000e,netdev=net0,mac=C0:FF:EE:00:00:02,bus=pcie.0,addr=0x0',
Signature · 1 line
2.52.0

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
#4 lore raw

Re: [PATCH 2/5] tests/functional/ppc64: pin machine types for hypervisor tests

Hi Daniel,

Thanks for the review!

Quoted 37 lines · Daniel P. Berrangé
Quoted 22 lines · Aniket Sahu

Pin machine types to avoid CPU compatibility issues:
- Use pseries-8.2 (POWER9) for pseries tests instead of generic 'pseries' alias which resolves to pseries-11.2 (power11_v2.0)
- Use powernv9 for powernv test to ensure consistent PCIe topology
- Fix test_hv_pseries_kvm to use TCG accelerator (L1 runs under TCG, L2 uses KVM inside L1)

The generic 'pseries' alias now resolves to a machine whose default CPU (power11) is not known to the qemu-system-ppc64 packaged by Alpine, causing the L2 guest to fail with "Register sync failed" error.

---
  tests/functional/ppc64/test_hv.py | 20 +++++++++++++++-----
  1 file changed, 15 insertions(+), 5 deletions(-)
tests/functional/ppc64/test_hv.py +0 -0
index 8a1fca2cb1..d977038271 100755

tests/functional/ppc64/test_hv.py def do_test_kvm(self, hpt=False): · line 133

Quoted 10 lines
tests/functional/ppc64/test_hv.py +6 -1
@@ -125,7 +125,12 @@ def do_test_kvm(self, hpt=False):
      def test_hv_pseries(self):
          self.require_accelerator("tcg")
          self.require_netdev('user')
-        self.set_machine('pseries')
+        # Pin to pseries-8.2 (default CPU power9_v2.2) so that kvm-hv.ko inside
+        # the L1 Alpine guest sees a POWER9 register set.  The generic 'pseries'
+        # alias resolves to pseries-11.2 (power11_v2.0) which Alpine's packaged
+        # qemu-system-ppc64 does not recognise, causing the L2 "Register sync
+        # failed" error.  The L2 script passes '-cpu POWER9' to match.
+        self.set_machine('pseries-8.2')

If the guest needs POWER9, why not add a "-cpu POWER9" flag to the L1 QEMU here, instead of making assumptions about what the machine type exposes.

Quoted 3 lines

Using old versioned machine types in functional tests is undesirable as we automatically delete versioned machines after 6 years, at which point we'll need to address the CPU model choice anyway.

Noted - will take care of this in V2.

Quoted 30 lines
Quoted 30 lines
tests/functional/ppc64/test_hv.py +9 -4
          self.vm.add_args("-accel", "tcg,thread=multi")
          self.vm.add_args('-device', 'nvme,serial=1234,drive=drive0')
          self.vm.add_args("-machine", "x-vof=on,cap-nested-hv=on")
@@ -135,10 +140,13 @@ def test_hv_pseries(self):
          self.do_stop_alpine()
 
      def test_hv_pseries_kvm(self):
-        self.require_accelerator("kvm")
+        # L1 runs under TCG; L2 is launched with accel=kvm inside L1
+        # (see do_test_kvm).
+        self.require_accelerator("tcg")
          self.require_netdev('user')
-        self.set_machine('pseries')
-        self.vm.add_args("-accel", "kvm")
+        # Same CPU pinning rationale as test_hv_pseries above.
+        self.set_machine('pseries-8.2')
+        self.vm.add_args("-accel", "tcg,thread=multi")
          self.vm.add_args('-device', 'nvme,serial=1234,drive=drive0')
          self.vm.add_args("-machine", "x-vof=on,cap-nested-hv=on,cap-ccf-assist=off")
          self.do_start_alpine()
@@ -149,7 +157,9 @@ def test_hv_pseries_kvm(self):
      def test_hv_powernv(self):
          self.require_accelerator("tcg")
          self.require_netdev('user')
-        self.set_machine('powernv')
+        # Pin to powernv9 so the PCIe topology matches (pcie.0, pcie.2) and
+        # kvm-hv.ko runs with the POWER9 CPU model.
+        self.set_machine('powernv9')
          self.vm.add_args("-accel", "tcg,thread=multi")
Quoted 8 lines
Quoted 6 lines
tests/functional/ppc64/test_hv.py +0 -0
          self.vm.add_args('-device', 'nvme,bus=pcie.2,addr=0x0,serial=1234,drive=drive0',
                           '-device', 'e1000e,netdev=net0,mac=C0:FF:EE:00:00:02,bus=pcie.0,addr=0x0',
Signature · 1 line
2.52.0

With regards,
Daniel

Regards,
Aniket.

#5 lore raw

PATCH 3/5 tests/functional/ppc64: add kernel params and early panic detection

In reply to Aniket Sahu

Add kernel command line parameters and improve error handling:
- Pass "console=hvc0 usbcore.nousb" on the L1 kernel command line
- Add early panic detection in do_test_kvm() with failure_message
- Retry apk update up to 5 times with 10 second delays
- Add debug logging at key steps (VM launch, login, apk update)

This allows the test to fail early if L2 panics instead of waiting for the login prompt until timeout, and makes the Alpine setup more robust against transient network issues.

---
 tests/functional/ppc64/test_hv.py | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)
tests/functional/ppc64/test_hv.py +20 -10
index d977038271..d983e5229c 100755
@@ -63,16 +63,20 @@ def setUp(self):
         self.initramfs = self.extract_from_iso(self.iso_path, '/boot/initramfs-lts')
 
     def do_start_alpine(self):
+        self.log.debug("do_start_alpine: launching L1 VM")
         self.vm.set_console()
-        self.vm.add_args("-kernel", self.vmlinuz)
-        self.vm.add_args("-initrd", self.initramfs)
-        self.vm.add_args("-smp", "4", "-m", "2g")
-        self.vm.add_args("-drive", f"file={self.iso_path},format=raw,if=none,"
-                                    "id=drive0,read-only=true")
-
+        self.vm.add_args(
+            "-kernel", self.vmlinuz,
+            "-initrd", self.initramfs,
+            "-smp", "4", "-m", "2g",
+            "-drive", f"file={self.iso_path},format=raw,if=none,id=drive0,read-only=true",
+            "-append", "console=hvc0 usbcore.nousb",
+        )
         self.vm.launch()
+        self.log.debug("do_start_alpine: VM launched, waiting for login prompt")
         ps1='localhost:~#'
         wait_for_console_pattern(self, 'localhost login:')
+        self.log.debug("do_start_alpine: got login prompt, logging in as root")
         exec_command_and_wait_for_pattern(self, 'root', ps1)
         self.log.debug("do_start_alpine: logged in, setting system clock")
         # If the time is wrong, SSL certificates can fail.
@@ -80,8 +84,11 @@ def do_start_alpine(self):
         exec_command_and_wait_for_pattern(self, cmd, ps1)
         ps1='alpine:~#'
         exec_command_and_wait_for_pattern(self, 'setup-alpine -qe', ps1)
-        exec_command_and_wait_for_pattern(self, 'setup-apkrepos -c1', ps1)
-        exec_command_and_wait_for_pattern(self, 'apk update', ps1)
+        exec_command_and_wait_for_pattern(
+            self,
+            'for i in 1 2 3 4 5; do apk update && break; sleep 10; done',
+            ps1)
+        self.log.debug("do_start_alpine: apk update complete, Alpine L1 is ready")
         # Could upgrade here but it usually should not be necessary
         # exec_command_and_wait_for_pattern(self, 'apk upgrade --available', ps1)
 
@@ -114,9 +121,12 @@ def do_test_kvm(self, hpt=False):
                            '-kernel /media/nvme0n1/boot/vmlinuz-lts '
                            '-append \'usbcore.nousb ' + append + '\'')
         # Alpine 3.21 kernel seems to crash in XHCI USB driver.
-        ps1='localhost:~#'
-        wait_for_console_pattern(self, 'localhost login:')
+        ps1 = 'localhost:~#'
+        wait_for_console_pattern(self, 'localhost login:',
+                                 failure_message=self.panic_message)
+        self.log.debug("do_test_kvm: L2 login prompt seen, logging in")
         exec_command_and_wait_for_pattern(self, 'root', ps1)
+        self.log.debug("do_test_kvm: logged into L2, issuing poweroff")
         exec_command(self, 'poweroff')
         wait_for_console_pattern(self, 'reboot: Power down')
         # Now wait for the host's prompt to come back
Signature · 1 line
2.52.0
#6 lore raw

PATCH 4/5 tests/functional/ppc64: dynamically resolve NVMe device path

In reply to Aniket Sahu

Do not hardcode the NVMe device name in L1 as it depends on the PCIe topology of the machine type (e.g., pseries may enumerate it as nvme0n1 or nvme1n1).

Add _resolve_nvme_dev() method to query the kernel for the actual device path, and write the L2 launch command to a script (/tmp/run-l2.sh) to avoid terminal line-wrap breaking shell argument parsing.

Also add '-cpu POWER9' to the L2 QEMU command line to match what kvm-hv.ko in L1 sees, and add comprehensive debug logging throughout do_test_kvm() and do_setup_kvm().

---
 tests/functional/ppc64/test_hv.py | 87 +++++++++++++++++++++++++++----
 1 file changed, 78 insertions(+), 9 deletions(-)
tests/functional/ppc64/test_hv.py +78 -9
index d983e5229c..567313fb6c 100755
@@ -10,6 +10,7 @@
 # later.  See the COPYING file in the top-level directory.
 
 import os
+import re
 import subprocess
 
 from datetime import datetime, timezone
@@ -100,9 +101,51 @@ def do_stop_alpine(self):
         self.vm.wait()
 
     def do_setup_kvm(self):
-        ps1='alpine:~#'
+        self.log.debug("do_setup_kvm: installing qemu-system-ppc64 in L1")
+        ps1 = 'alpine:~#'
         exec_command_and_wait_for_pattern(self, 'apk add qemu-system-ppc64', ps1)
+        self.log.debug("do_setup_kvm: qemu-system-ppc64 installed, loading kvm-hv")
         exec_command_and_wait_for_pattern(self, 'modprobe kvm-hv', ps1)
+        self.log.debug("do_setup_kvm: kvm-hv module loaded")
+
+    def _resolve_nvme_dev(self):
+        """
+        Determine the NVMe block device path that the ISO is attached as
+        inside the L1 Alpine guest.  The device name is not stable across
+        machine types (e.g. pseries may enumerate it as nvme0n1 or nvme1n1
+        depending on the PCIe bus topology), so we ask the kernel directly.
+
+        Returns the literal device path string, e.g. '/dev/nvme0n1', so
+        callers can bake it directly into shell scripts without any shell
+        variable scoping issues.
+        """
+        self.log.debug("_resolve_nvme_dev: probing NVMe device path in L1")
+        ps1 = 'alpine:~#'
+        # Print a clearly delimited marker and wait for the shell prompt so
+        # we accumulate all console bytes in one call — including any bytes
+        # that the terminal wraps across line boundaries.
+        out = exec_command_and_wait_for_pattern(
+            self,
+            'echo "NVME_PATH:$(ls /dev/nvme?n1 | head -1)"',
+            ps1,
+        )
+        # Decode, strip ANSI escape sequences and newlines, then extract the
+        # path.  Terminal line-wrap can split the token mid-string so we join
+        # all non-whitespace characters before matching.
+        text = out.decode('utf-8', errors='replace')
+        text = re.sub(r'\x1b\[[0-9;]*[A-Za-z]', '', text)
+        joined = ''.join(text.split())
+        # The joined string looks like: ...NVME_PATH:/dev/nvme0n1alpine:~#
+        m = re.search(r'NVME_PATH:(/dev/nvme\S+?)alpine', joined)
+        if not m:
+            m = re.search(r'NVME_PATH:(/dev/nvme\S+)', joined)
+        if m:
+            dev = m.group(1).rstrip('#~:').strip()
+        else:
+            dev = '/dev/nvme0n1'
+            self.log.debug("_resolve_nvme_dev: marker not found, using fallback")
+        self.log.debug("_resolve_nvme_dev: resolved device=%s", dev)
+        return dev
 
     # This uses the host's block device as the source file for guest block
     # device for install media. This is a bit hacky but allows reuse of the
@@ -110,16 +153,40 @@ def do_setup_kvm(self):
     def do_test_kvm(self, hpt=False):
         if hpt:
             append = 'disable_radix'
+            self.log.debug("do_test_kvm: launching L2 in HPT mode")
         else:
             append = ''
-        exec_command(self, 'qemu-system-ppc64 -nographic -smp 2 -m 1g '
-                           '-machine pseries,x-vof=on,accel=kvm '
-                           '-machine cap-cfpc=broken,cap-sbbc=broken,'
-                                    'cap-ibs=broken,cap-ccf-assist=off '
-                           '-drive file=/dev/nvme0n1,format=raw,readonly=on '
-                           '-initrd /media/nvme0n1/boot/initramfs-lts '
-                           '-kernel /media/nvme0n1/boot/vmlinuz-lts '
-                           '-append \'usbcore.nousb ' + append + '\'')
+            self.log.debug("do_test_kvm: launching L2 in Radix mode (default)")
+
+        # Resolve the NVMe device path inside the L1 guest first so we do
+        # not hardcode a path that may differ by machine type.
+        nvme_dev = self._resolve_nvme_dev()
+
+        # Write the L2 launch command to a script to avoid terminal line-wrap
+        # breaking shell argument parsing, and to keep individual lines short.
+        # nvme_dev is the literal path, e.g. /dev/nvme0n1 — bake it in.
+        mnt = f'/media/$(basename {nvme_dev})'
+        ps1 = 'alpine:~#'
+        l2_script = [
+            ("cat > /tmp/run-l2.sh << 'EOF'", '>'),
+            ('#!/bin/sh', '>'),
+            ('qemu-system-ppc64 -nographic \\', '>'),
+            ('  -smp 2 -m 1g \\', '>'),
+            ('  -cpu POWER9 \\', '>'),
+            ('  -machine pseries,x-vof=on,accel=kvm \\', '>'),
+            ('  -machine cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken,cap-ccf-assist=off \\', '>'),
+            (f'  -drive file={nvme_dev},format=raw,readonly=on \\', '>'),
+            (f'  -initrd {mnt}/boot/initramfs-lts \\', '>'),
+            (f'  -kernel {mnt}/boot/vmlinuz-lts \\', '>'),
+            (f'  -append "usbcore.nousb {append}"', '>'),
+            ('EOF', ps1),
+            ('chmod +x /tmp/run-l2.sh', ps1),
+        ]
+        for cmd, expected_pattern in l2_script:
+            exec_command_and_wait_for_pattern(self, cmd, expected_pattern)
+        self.log.debug("do_test_kvm: L2 launch script written, executing")
+        exec_command(self, '/tmp/run-l2.sh')
+        self.log.debug("do_test_kvm: L2 QEMU launched, waiting for L2 login prompt")
         # Alpine 3.21 kernel seems to crash in XHCI USB driver.
         ps1 = 'localhost:~#'
         wait_for_console_pattern(self, 'localhost login:',
@@ -129,8 +196,10 @@ def do_test_kvm(self, hpt=False):
         self.log.debug("do_test_kvm: logged into L2, issuing poweroff")
         exec_command(self, 'poweroff')
         wait_for_console_pattern(self, 'reboot: Power down')
+        self.log.debug("do_test_kvm: L2 powered down, waiting for L1 prompt")
         # Now wait for the host's prompt to come back
         wait_for_console_pattern(self, 'alpine:~#')
+        self.log.debug("do_test_kvm: L1 prompt restored")
 
     def test_hv_pseries(self):
         self.require_accelerator("tcg")
Signature · 1 line
2.52.0
#7 lore raw

PATCH 5/5 tests/functional/ppc64: increase timeout for hypervisor tests

In reply to Aniket Sahu

Increase the timeout for test_hv.py from 1000 to 6000 seconds.

The test now takes much longer due to:
- Retrying apk update up to 5 times
- More comprehensive testing with additional debug logging

---
 tests/functional/ppc64/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/functional/ppc64/meson.build +1 -1
index cb3c745624..d908786426 100644
@@ -2,7 +2,7 @@
 
 test_ppc64_timeouts = {
   'fadump' : 480,
-  'hv' : 1000,
+  'hv' : 6000,
   'mac99' : 120,
   'openbsd' : 240,
   'powernv' : 480,
Signature · 1 line
2.52.0
#8 lore raw
In reply to Aniket Sahu
Quoted 2 lines · Aniket Sahu

This series fixes several issues in the PPC64 hypervisor functional tests and improves their robustness and reliability.

Just a quick note to say the power hardware we have from OSUL doesn't expose a hypervisor so we can't currently run these tests in the upstream CI. Do you know of any way we could get such hardware added to the CI?

Also I should note it would be nice to get:

https://gitlab.com/qemu-project/qemu/-/work_items/3207

addressed. Let me know if you need access to the system.

Quoted 42 lines

Changes in this series:
-----------------------

1. Replace deprecated datetime.utcnow() with datetime.now(timezone.utc) to avoid deprecation warnings in Python 3.12+.

2. Pin machine types to avoid CPU compatibility issues between the L0 QEMU (which now defaults to power11) and the L1 Alpine guest's packaged QEMU (which doesn't recognize power11). This fixes "Register sync failed" errors in L2.

3. Add kernel command line parameters (console=hvc0 usbcore.nousb) and early panic detection to fail fast when L2 encounters issues, plus retry logic for apk update to handle transient network failures.

4. Dynamically resolve the NVMe device path in L1 instead of hardcoding it, as the device name varies by machine type (nvme0n1 vs nvme1n1). Also adds comprehensive debug logging throughout the test flow and writes the L2 launch command to a script to avoid terminal line-wrap issues.

5. Increase the test timeout from 1000 to 6000 seconds to accommodate the longer runtime due to apk update retries and additional testing.

Testing:
--------
All tests pass on our PPC64 test machines running Ubuntu 26.04 in an LPAR.

Aniket Sahu (3):
tests/functional/ppc64: replace deprecated datetime.utcnow() tests/functional/ppc64: add kernel params and early panic detection tests/functional/ppc64: dynamically resolve NVMe device path

Misbah Anjum N (2):
tests/functional/ppc64: pin machine types for hypervisor tests tests/functional/ppc64: increase timeout for hypervisor tests

 tests/functional/ppc64/meson.build |   2 +-
 tests/functional/ppc64/test_hv.py  | 140 +++++++++++++++++++++++++----
 2 files changed, 117 insertions(+), 25 deletions(-)
Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#9 lore raw
Quoted 8 lines · Alex Bennée
Quoted 2 lines · Aniket Sahu

This series fixes several issues in the PPC64 hypervisor functional tests and improves their robustness and reliability.

Just a quick note to say the power hardware we have from OSUL doesn't expose a hypervisor so we can't currently run these tests in the upstream CI. Do you know of any way we could get such hardware added to the CI?

Hypervisor tests are part of the thorough test run (mentioned as hv in the meson.build file), and if I remember correctly, only quick tests are run as part of the CI on gitlab. While the changes I have made would benefit everyone who wants to run hypervisor tests or the thorough test cycle on their machine for ppc64 systems, this mainly helps us target clean CI runs on our internal CI systems. Regarding hardware availability in OSUL, this is something we need to look at and plan for. Will talk with my team about this!

Quoted 6 lines

Also I should note it would be nice to get:

   https://gitlab.com/qemu-project/qemu/-/work_items/3207

addressed. Let me know if you need access to the system.

Noted, taking a loot at the issue, will correspond via the work item comments if I need a machine.

Quoted 35 lines
Quoted 35 lines

Changes in this series:
-----------------------

1. Replace deprecated datetime.utcnow() with datetime.now(timezone.utc) to avoid deprecation warnings in Python 3.12+.

2. Pin machine types to avoid CPU compatibility issues between the L0 QEMU (which now defaults to power11) and the L1 Alpine guest's packaged QEMU (which doesn't recognize power11). This fixes "Register sync failed" errors in L2.

3. Add kernel command line parameters (console=hvc0 usbcore.nousb) and early panic detection to fail fast when L2 encounters issues, plus retry logic for apk update to handle transient network failures.

4. Dynamically resolve the NVMe device path in L1 instead of hardcoding it, as the device name varies by machine type (nvme0n1 vs nvme1n1). Also adds comprehensive debug logging throughout the test flow and writes the L2 launch command to a script to avoid terminal line-wrap issues.

5. Increase the test timeout from 1000 to 6000 seconds to accommodate the longer runtime due to apk update retries and additional testing.

Testing:
--------
All tests pass on our PPC64 test machines running Ubuntu 26.04 in an LPAR.

Aniket Sahu (3):
tests/functional/ppc64: replace deprecated datetime.utcnow() tests/functional/ppc64: add kernel params and early panic detection tests/functional/ppc64: dynamically resolve NVMe device path

Quoted 7 lines
Quoted 7 lines

Misbah Anjum N (2):
tests/functional/ppc64: pin machine types for hypervisor tests tests/functional/ppc64: increase timeout for hypervisor tests

  tests/functional/ppc64/meson.build |   2 +-
  tests/functional/ppc64/test_hv.py  | 140 +++++++++++++++++++++++++----
  2 files changed, 117 insertions(+), 25 deletions(-)

Regards,
Aniket.

#10 lore raw

Am 22.11.26 um 03:19 schrieb Aniket Sahu:

Quoted 11 lines · Alex Bennée
Quoted 8 lines
Quoted 2 lines · Aniket Sahu

This series fixes several issues in the PPC64 hypervisor functional tests and improves their robustness and reliability.

Just a quick note to say the power hardware we have from OSUL doesn't expose a hypervisor so we can't currently run these tests in the upstream CI. Do you know of any way we could get such hardware added to the CI?

Hypervisor tests are part of the thorough test run (mentioned as hv in the meson.build file), and if I remember correctly, only quick tests are run as part of the CI on gitlab.

Just a FYI, only the quick functional tests are run when you do a "make check". But the whole functional test suite (i.e. the thorough tests) are run when you do a "make check-functional". And that's what we're doing in the various functional-system-* jobs in the CI, see .gitlab-ci.d/buildtest.yml.

Thomas