master
py 138 lines 5.31 KB
Raw
1 #!/usr/bin/env python3
2 #
3 # SPDX-License-Identifier: GPL-2.0-or-later
4 #
5 # Copyright 2026 Red Hat, Inc.
6 #
7 # Author:
8 # Thomas Huth <thuth@redhat.com>
9 '''
10 Functional test that boots from a (incomplete) disk with 4k sectors
11 (DASD/ECKD geometry) and multiple kernels installed, so we can check
12 the boot menu and various LOADPARM options.
13 '''
14
15 from qemu_test import QemuSystemTest, Asset, skipFlakyTest
16 from qemu_test import wait_for_console_pattern
17
18
19 class S390Boot4k(QemuSystemTest):
20
21 # This disk image has been taken from a DASD with 4k sectors.
22 # Note: It's incomplete (to keep it small), it contains just enough
23 # data for booting the kernels that are installed on the disk image
24 ASSET_DISK = Asset(
25 ('https://github.com/huth/qemu-paddock/raw/refs/heads/main/s390x/'
26 'f32-4k-bootmenu.raw.xz'),
27 'f4e2c91b4ec50a4756e8816b7a7c8ca01cc0d929f7a711cfd8124640c304ea41')
28
29 def wait_for_pattern(self, success_message, vm=None):
30 wait_for_console_pattern(self, success_message, vm=vm,
31 failure_message='panic')
32
33 def basic_machine_setup(self):
34 self.set_machine('s390-ccw-virtio')
35 disk_path = self.uncompress(self.ASSET_DISK, format="xz")
36
37 self.vm.set_console()
38 self.vm.add_args("-nographic", "-no-shutdown", "-blockdev",
39 f"driver=file,filename={disk_path},node-name=d1")
40
41 def test_default(self):
42 '''
43 Check that the default kernel boots up correctly from a ccw device
44 '''
45 self.basic_machine_setup()
46 self.vm.add_args("-device", "virtio-blk-ccw,drive=d1")
47 self.vm.launch()
48 self.wait_for_pattern("Linux version 5.8.15-301.fc33.s390x")
49 self.wait_for_pattern("Trying to unpack rootfs image as initramfs")
50
51 def test_loadparm_machine(self):
52 '''
53 Check that we can select a kernel via "-machine loadparm=..."
54 '''
55 self.basic_machine_setup()
56 self.vm.add_args("-device", "virtio-blk-ccw,drive=d1",
57 "-machine", "loadparm=2")
58 self.vm.launch()
59 self.wait_for_pattern("Linux version 5.6.6-300.fc32.s390x")
60
61 def test_loadparm_device(self):
62 '''
63 Check that we can select a kernel via "-device ...,loadparm=..."
64 '''
65 self.basic_machine_setup()
66 self.vm.add_args("-device",
67 "virtio-blk-ccw,drive=d1,bootindex=1,loadparm=3")
68 self.vm.launch()
69 self.wait_for_pattern("Linux version 5.6.6-300.fc32.s390x")
70
71 @skipFlakyTest("https://gitlab.com/qemu-project/qemu/-/work_items/3350")
72 def test_loadparm_pci(self):
73 '''
74 Check that we can select a kernel via "-device ...-pci,loadparm=..."
75 '''
76 self.require_device('virtio-blk-pci')
77 self.basic_machine_setup()
78 self.vm.add_args("-device",
79 "virtio-blk-pci,drive=d1,bootindex=1,loadparm=2")
80 self.vm.launch()
81 self.wait_for_pattern("Linux version 5.6.6-300.fc32.s390x")
82
83 def test_scsi_default(self):
84 '''
85 Check that we can boot via SCSI, too (need to set logical block size
86 here to avoid that the auto-detection in the bios fails)
87 '''
88 self.basic_machine_setup()
89 self.vm.add_args("-device", "virtio-scsi", "-device",
90 "scsi-hd,drive=d1,physical_block_size=4096,logical_block_size=4096")
91 self.vm.launch()
92 self.wait_for_pattern("Linux version 5.8.15-301.fc33.s390x")
93
94 def test_scsi_loadparm(self):
95 '''
96 Check that we can boot via SCSI with loadparm
97 '''
98 self.basic_machine_setup()
99 self.vm.add_args("-device", "virtio-scsi", "-device",
100 ("scsi-hd,drive=d1,bootindex=1,loadparm=3,"
101 "physical_block_size=4096,logical_block_size=4096"))
102 self.vm.launch()
103 self.wait_for_pattern("Linux version 5.6.6-300.fc32.s390x")
104
105 def test_menu(self):
106 '''
107 Check that boot menu shows up correctly
108 '''
109 self.basic_machine_setup()
110 self.vm.add_args("-device", "virtio-blk-ccw,drive=d1,bootindex=1",
111 "-boot", "menu=on")
112 self.vm.launch()
113 self.wait_for_pattern("1. Fedora (5.8.15-301.fc33.s390x) 33")
114 self.wait_for_pattern("2. Fedora (5.6.6-300.fc32.s390x) 32")
115 self.wait_for_pattern("3. Fedora (0-rescue-b7218f0092704c5a9")
116 self.wait_for_pattern("Please choose:")
117 # For some unknown reason, sending a key to the bios does not work
118 # in the testing framework yet:
119 # exec_command_and_wait_for_pattern(self, '2',
120 # "Linux version 5.6.6-300.fc32.s390x")
121
122 def test_menu_timeout(self):
123 '''
124 Check that boot menu shows up and boot continues automatically
125 when a timeout has been specified
126 '''
127 self.basic_machine_setup()
128 self.vm.add_args("-device", "virtio-blk-ccw,drive=d1,bootindex=1",
129 "-boot", "menu=on,splash-time=1")
130 self.vm.launch()
131 self.wait_for_pattern("s390-ccw zIPL Boot Menu")
132 self.wait_for_pattern("0. default (Fedora (5.8.15-301.fc33.s390x)")
133 self.wait_for_pattern("(default will boot in 0 seconds)")
134 self.wait_for_pattern("Linux version 5.8.15-301.fc33.s390x")
135
136
137 if __name__ == '__main__':
138 QemuSystemTest.main()