public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
* [PATCH] tests/functional/s390x: Add test for booting from a disk with 4k sectors
@ 2026-03-23 17:14 Thomas Huth
  2026-03-24  2:52 ` Eric Farman
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2026-03-23 17:14 UTC (permalink / raw)
  To: qemu-devel, Cornelia Huck, Eric Farman
  Cc: qemu-s390x, Matthew Rosato, Thomas Huth

From: Thomas Huth <thuth@redhat.com>

The DASD disks on s390x have a different sector size (4k) and use
a different layout of the boot loader data compared to the usual
"SCSI"-style disks with 512 sectors that are used with most modern
guests. To make sure that there are no regressions with 4k disk
booting, add a test case that uses a disk image with these 4k sectors
and check that we can successfully show the boot menu and and load the
right kernel in all supported cases.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/s390x/meson.build     |   1 +
 tests/functional/s390x/test_boot_4k.py | 138 +++++++++++++++++++++++++
 2 files changed, 139 insertions(+)
 create mode 100755 tests/functional/s390x/test_boot_4k.py

diff --git a/tests/functional/s390x/meson.build b/tests/functional/s390x/meson.build
index 0f03e1c9db8..b065b666bc2 100644
--- a/tests/functional/s390x/meson.build
+++ b/tests/functional/s390x/meson.build
@@ -10,6 +10,7 @@ tests_s390x_system_quick = [
 ]
 
 tests_s390x_system_thorough = [
+  'boot_4k',
   'ccw_virtio',
   'pxelinux',
   'replay',
diff --git a/tests/functional/s390x/test_boot_4k.py b/tests/functional/s390x/test_boot_4k.py
new file mode 100755
index 00000000000..965123ebd31
--- /dev/null
+++ b/tests/functional/s390x/test_boot_4k.py
@@ -0,0 +1,138 @@
+#!/usr/bin/env python3
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright 2026 Red Hat, Inc.
+#
+# Author:
+#  Thomas Huth <thuth@redhat.com>
+'''
+Functional test that boots from a (incomplete) disk with 4k sectors
+(DASD/ECKD geometry) and multiple kernels installed, so we can check
+the boot menu and various LOADPARM options.
+'''
+
+from qemu_test import QemuSystemTest, Asset, skipFlakyTest
+from qemu_test import wait_for_console_pattern
+
+
+class S390Boot4k(QemuSystemTest):
+
+    # This disk image has been taken from a DASD with 4k sectors.
+    # Note: It's incomplete (to keep it small), it contains just enough
+    # data for booting the kernels that are installed on the disk image
+    ASSET_DISK = Asset(
+        ('https://github.com/huth/qemu-paddock/raw/refs/heads/main/s390x/'
+         'f32-4k-bootmenu.raw.xz'),
+        'f4e2c91b4ec50a4756e8816b7a7c8ca01cc0d929f7a711cfd8124640c304ea41')
+
+    def wait_for_pattern(self, success_message, vm=None):
+        wait_for_console_pattern(self, success_message, vm=vm,
+                                 failure_message='panic')
+
+    def basic_machine_setup(self):
+        self.set_machine('s390-ccw-virtio')
+        disk_path = self.uncompress(self.ASSET_DISK, format="xz")
+
+        self.vm.set_console()
+        self.vm.add_args("-nographic", "-no-shutdown", "-blockdev",
+                         f"driver=file,filename={disk_path},node-name=d1")
+
+    def test_default(self):
+        '''
+        Check that the default kernel boots up correctly from a ccw device
+        '''
+        self.basic_machine_setup()
+        self.vm.add_args("-device", "virtio-blk-ccw,drive=d1")
+        self.vm.launch()
+        self.wait_for_pattern("Linux version 5.8.15-301.fc33.s390x")
+        self.wait_for_pattern("Trying to unpack rootfs image as initramfs")
+
+    def test_loadparm_machine(self):
+        '''
+        Check that we can select a kernel via "-machine loadparm=..."
+        '''
+        self.basic_machine_setup()
+        self.vm.add_args("-device", "virtio-blk-ccw,drive=d1",
+                         "-machine", "loadparm=2")
+        self.vm.launch()
+        self.wait_for_pattern("Linux version 5.6.6-300.fc32.s390x")
+
+    def test_loadparm_device(self):
+        '''
+        Check that we can select a kernel via  "-device ...,loadparm=..."
+        '''
+        self.basic_machine_setup()
+        self.vm.add_args("-device",
+                         "virtio-blk-ccw,drive=d1,bootindex=1,loadparm=3")
+        self.vm.launch()
+        self.wait_for_pattern("Linux version 5.6.6-300.fc32.s390x")
+
+    @skipFlakyTest("https://gitlab.com/qemu-project/qemu/-/work_items/3350")
+    def test_loadparm_pci(self):
+        '''
+        Check that we can select a kernel via  "-device ...-pci,loadparm=..."
+        '''
+        self.require_device('virtio-blk-pci')
+        self.basic_machine_setup()
+        self.vm.add_args("-device",
+                         "virtio-blk-pci,drive=d1,bootindex=1,loadparm=2")
+        self.vm.launch()
+        self.wait_for_pattern("Linux version 5.6.6-300.fc32.s390x")
+
+    def test_scsi_default(self):
+        '''
+        Check that we can boot via SCSI, too (need to set logical block size
+        here to avoid that the auto-detection in the bios fails)
+        '''
+        self.basic_machine_setup()
+        self.vm.add_args("-device", "virtio-scsi", "-device",
+            "scsi-hd,drive=d1,physical_block_size=4096,logical_block_size=4096")
+        self.vm.launch()
+        self.wait_for_pattern("Linux version 5.8.15-301.fc33.s390x")
+
+    def test_scsi_loadparm(self):
+        '''
+        Check that we can boot via SCSI with loadparm
+        '''
+        self.basic_machine_setup()
+        self.vm.add_args("-device", "virtio-scsi", "-device",
+                         ("scsi-hd,drive=d1,bootindex=1,loadparm=3,"
+                          "physical_block_size=4096,logical_block_size=4096"))
+        self.vm.launch()
+        self.wait_for_pattern("Linux version 5.6.6-300.fc32.s390x")
+
+    def test_menu(self):
+        '''
+        Check that boot menu shows up correctly
+        '''
+        self.basic_machine_setup()
+        self.vm.add_args("-device", "virtio-blk-ccw,drive=d1,bootindex=1",
+                         "-boot", "menu=on")
+        self.vm.launch()
+        self.wait_for_pattern("1. Fedora (5.8.15-301.fc33.s390x) 33")
+        self.wait_for_pattern("2. Fedora (5.6.6-300.fc32.s390x) 32")
+        self.wait_for_pattern("3. Fedora (0-rescue-b7218f0092704c5a9")
+        self.wait_for_pattern("Please choose:")
+        # For some unknown reason, sending a key to the bios does not work
+        # in the testing framework yet:
+        # exec_command_and_wait_for_pattern(self, '2',
+        #                              "Linux version 5.6.6-300.fc32.s390x")
+
+    def test_menu_timeout(self):
+        '''
+        Check that boot menu shows up and boot continues automatically
+        when a timeout has been specified
+        '''
+        self.basic_machine_setup()
+        self.vm.add_args("-device", "virtio-blk-ccw,drive=d1,bootindex=1",
+                         "-boot", "menu=on,splash-time=1")
+        self.vm.launch()
+        self.wait_for_pattern("s390-ccw zIPL Boot Menu")
+        self.wait_for_pattern("0. default (Fedora (5.8.15-301.fc33.s390x)")
+        self.wait_for_pattern("(default will boot in 0 seconds)")
+        self.wait_for_pattern("Linux version 5.8.15-301.fc33.s390x")
+
+
+if __name__ == '__main__':
+    QemuSystemTest.main()
-- 
2.53.0



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

* Re: [PATCH] tests/functional/s390x: Add test for booting from a disk with 4k sectors
  2026-03-23 17:14 [PATCH] tests/functional/s390x: Add test for booting from a disk with 4k sectors Thomas Huth
@ 2026-03-24  2:52 ` Eric Farman
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Farman @ 2026-03-24  2:52 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Cornelia Huck, jrossi; +Cc: qemu-s390x, Matthew Rosato

On Mon, 2026-03-23 at 18:14 +0100, Thomas Huth wrote:
> From: Thomas Huth <thuth@redhat.com>
> 
> The DASD disks on s390x have a different sector size (4k) and use
> a different layout of the boot loader data compared to the usual
> "SCSI"-style disks with 512 sectors that are used with most modern
> guests. To make sure that there are no regressions with 4k disk
> booting, add a test case that uses a disk image with these 4k sectors
> and check that we can successfully show the boot menu and and load the
> right kernel in all supported cases.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  tests/functional/s390x/meson.build     |   1 +
>  tests/functional/s390x/test_boot_4k.py | 138 +++++++++++++++++++++++++
>  2 files changed, 139 insertions(+)
>  create mode 100755 tests/functional/s390x/test_boot_4k.py

Thanks, Thomas!

Reviewed-by: Eric Farman <farman@linux.ibm.com>

> 
> diff --git a/tests/functional/s390x/meson.build b/tests/functional/s390x/meson.build
> index 0f03e1c9db8..b065b666bc2 100644
> --- a/tests/functional/s390x/meson.build
> +++ b/tests/functional/s390x/meson.build
> @@ -10,6 +10,7 @@ tests_s390x_system_quick = [
>  ]
>  
>  tests_s390x_system_thorough = [
> +  'boot_4k',
>    'ccw_virtio',
>    'pxelinux',
>    'replay',
> diff --git a/tests/functional/s390x/test_boot_4k.py b/tests/functional/s390x/test_boot_4k.py
> new file mode 100755
> index 00000000000..965123ebd31
> --- /dev/null
> +++ b/tests/functional/s390x/test_boot_4k.py
> @@ -0,0 +1,138 @@
> +#!/usr/bin/env python3
> +#
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +#
> +# Copyright 2026 Red Hat, Inc.
> +#
> +# Author:
> +#  Thomas Huth <thuth@redhat.com>
> +'''
> +Functional test that boots from a (incomplete) disk with 4k sectors
> +(DASD/ECKD geometry) and multiple kernels installed, so we can check
> +the boot menu and various LOADPARM options.
> +'''
> +
> +from qemu_test import QemuSystemTest, Asset, skipFlakyTest
> +from qemu_test import wait_for_console_pattern
> +
> +
> +class S390Boot4k(QemuSystemTest):
> +
> +    # This disk image has been taken from a DASD with 4k sectors.
> +    # Note: It's incomplete (to keep it small), it contains just enough
> +    # data for booting the kernels that are installed on the disk image
> +    ASSET_DISK = Asset(
> +        ('https://github.com/huth/qemu-paddock/raw/refs/heads/main/s390x/'
> +         'f32-4k-bootmenu.raw.xz'),
> +        'f4e2c91b4ec50a4756e8816b7a7c8ca01cc0d929f7a711cfd8124640c304ea41')
> +
> +    def wait_for_pattern(self, success_message, vm=None):
> +        wait_for_console_pattern(self, success_message, vm=vm,
> +                                 failure_message='panic')
> +
> +    def basic_machine_setup(self):
> +        self.set_machine('s390-ccw-virtio')
> +        disk_path = self.uncompress(self.ASSET_DISK, format="xz")
> +
> +        self.vm.set_console()
> +        self.vm.add_args("-nographic", "-no-shutdown", "-blockdev",
> +                         f"driver=file,filename={disk_path},node-name=d1")
> +
> +    def test_default(self):
> +        '''
> +        Check that the default kernel boots up correctly from a ccw device
> +        '''
> +        self.basic_machine_setup()
> +        self.vm.add_args("-device", "virtio-blk-ccw,drive=d1")
> +        self.vm.launch()
> +        self.wait_for_pattern("Linux version 5.8.15-301.fc33.s390x")
> +        self.wait_for_pattern("Trying to unpack rootfs image as initramfs")
> +
> +    def test_loadparm_machine(self):
> +        '''
> +        Check that we can select a kernel via "-machine loadparm=..."
> +        '''
> +        self.basic_machine_setup()
> +        self.vm.add_args("-device", "virtio-blk-ccw,drive=d1",
> +                         "-machine", "loadparm=2")
> +        self.vm.launch()
> +        self.wait_for_pattern("Linux version 5.6.6-300.fc32.s390x")
> +
> +    def test_loadparm_device(self):
> +        '''
> +        Check that we can select a kernel via  "-device ...,loadparm=..."
> +        '''
> +        self.basic_machine_setup()
> +        self.vm.add_args("-device",
> +                         "virtio-blk-ccw,drive=d1,bootindex=1,loadparm=3")
> +        self.vm.launch()
> +        self.wait_for_pattern("Linux version 5.6.6-300.fc32.s390x")
> +
> +    @skipFlakyTest("https://gitlab.com/qemu-project/qemu/-/work_items/3350")
> +    def test_loadparm_pci(self):
> +        '''
> +        Check that we can select a kernel via  "-device ...-pci,loadparm=..."
> +        '''
> +        self.require_device('virtio-blk-pci')
> +        self.basic_machine_setup()
> +        self.vm.add_args("-device",
> +                         "virtio-blk-pci,drive=d1,bootindex=1,loadparm=2")
> +        self.vm.launch()
> +        self.wait_for_pattern("Linux version 5.6.6-300.fc32.s390x")
> +
> +    def test_scsi_default(self):
> +        '''
> +        Check that we can boot via SCSI, too (need to set logical block size
> +        here to avoid that the auto-detection in the bios fails)
> +        '''
> +        self.basic_machine_setup()
> +        self.vm.add_args("-device", "virtio-scsi", "-device",
> +            "scsi-hd,drive=d1,physical_block_size=4096,logical_block_size=4096")
> +        self.vm.launch()
> +        self.wait_for_pattern("Linux version 5.8.15-301.fc33.s390x")
> +
> +    def test_scsi_loadparm(self):
> +        '''
> +        Check that we can boot via SCSI with loadparm
> +        '''
> +        self.basic_machine_setup()
> +        self.vm.add_args("-device", "virtio-scsi", "-device",
> +                         ("scsi-hd,drive=d1,bootindex=1,loadparm=3,"
> +                          "physical_block_size=4096,logical_block_size=4096"))
> +        self.vm.launch()
> +        self.wait_for_pattern("Linux version 5.6.6-300.fc32.s390x")
> +
> +    def test_menu(self):
> +        '''
> +        Check that boot menu shows up correctly
> +        '''
> +        self.basic_machine_setup()
> +        self.vm.add_args("-device", "virtio-blk-ccw,drive=d1,bootindex=1",
> +                         "-boot", "menu=on")
> +        self.vm.launch()
> +        self.wait_for_pattern("1. Fedora (5.8.15-301.fc33.s390x) 33")
> +        self.wait_for_pattern("2. Fedora (5.6.6-300.fc32.s390x) 32")
> +        self.wait_for_pattern("3. Fedora (0-rescue-b7218f0092704c5a9")
> +        self.wait_for_pattern("Please choose:")
> +        # For some unknown reason, sending a key to the bios does not work
> +        # in the testing framework yet:
> +        # exec_command_and_wait_for_pattern(self, '2',
> +        #                              "Linux version 5.6.6-300.fc32.s390x")
> +
> +    def test_menu_timeout(self):
> +        '''
> +        Check that boot menu shows up and boot continues automatically
> +        when a timeout has been specified
> +        '''
> +        self.basic_machine_setup()
> +        self.vm.add_args("-device", "virtio-blk-ccw,drive=d1,bootindex=1",
> +                         "-boot", "menu=on,splash-time=1")
> +        self.vm.launch()
> +        self.wait_for_pattern("s390-ccw zIPL Boot Menu")
> +        self.wait_for_pattern("0. default (Fedora (5.8.15-301.fc33.s390x)")
> +        self.wait_for_pattern("(default will boot in 0 seconds)")
> +        self.wait_for_pattern("Linux version 5.8.15-301.fc33.s390x")
> +
> +
> +if __name__ == '__main__':
> +    QemuSystemTest.main()


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

end of thread, other threads:[~2026-03-24  2:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 17:14 [PATCH] tests/functional/s390x: Add test for booting from a disk with 4k sectors Thomas Huth
2026-03-24  2:52 ` Eric Farman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox