From cf0f4408b567ed5056415dec56b1111b65236d6c Mon Sep 17 00:00:00 2001 From: Sebastian Mitterle Date: Wed, 30 Oct 2024 11:09:39 -0400 Subject: [PATCH] guest_os_booting: update tests for s390x The following features are not available on s390x: * SMBIOS * ACPI * fw_cfg * USB * * firmware settings For direct kernel boot, don't use hard coded kernel filename. In our setup we'll use kernel.img, so just use the filename from the download url. Don't use ttyS0, it's the line mode console which is not useful. Using no specific setting works well. Cover also s390x-specific parameter @loadparm by allowing generically to run a test command in the booted VM whose output should match an expected regular expression. Signed-off-by: Sebastian Mitterle --- .../boot_with_multiple_boot_dev.cfg | 1 + .../boot_with_multiple_boot_order.cfg | 34 ++++++++++++++++--- .../hotplug_device_with_boot_order.cfg | 2 ++ .../direct_kernel_boot/direct_kernel_boot.cfg | 2 ++ .../firmware_configuration/os_acpi.cfg | 2 +- .../firmware_configuration/smbios_mode.cfg | 1 + .../firmware_configuration/sysinfo_fwcfg.cfg | 1 + .../migration/migration_boot.cfg | 1 + .../boot_with_multiple_boot_order.py | 14 +++++++- .../direct_kernel_boot/direct_kernel_boot.py | 4 +-- .../guest_os_booting/guest_os_booting_base.py | 3 +- 11 files changed, 55 insertions(+), 10 deletions(-) diff --git a/libvirt/tests/cfg/guest_os_booting/boot_order/boot_with_multiple_boot_dev.cfg b/libvirt/tests/cfg/guest_os_booting/boot_order/boot_with_multiple_boot_dev.cfg index ad60e5d8c9..32a76da370 100644 --- a/libvirt/tests/cfg/guest_os_booting/boot_order/boot_with_multiple_boot_dev.cfg +++ b/libvirt/tests/cfg/guest_os_booting/boot_order/boot_with_multiple_boot_dev.cfg @@ -8,6 +8,7 @@ os_dict = {'boots': ['%s', '%s'], 'bootmenu_enable': 'yes'} cdrom_dict = {'source': {'attrs': {'file': '%s'}}, 'type_name': 'file', 'device': 'cdrom', 'driver': {'name': 'qemu', 'type': 'raw'}, 'target': {'dev': 'sda', 'bus': '${target_bus}'}} check_prompt = ["begin the installation process|Install Red Hat Enterprise"] + no s390-virtio variants first_dev: - hd: variants second_dev: diff --git a/libvirt/tests/cfg/guest_os_booting/boot_order/boot_with_multiple_boot_order.cfg b/libvirt/tests/cfg/guest_os_booting/boot_order/boot_with_multiple_boot_order.cfg index 8821b5f6f6..e1f3c2e69c 100644 --- a/libvirt/tests/cfg/guest_os_booting/boot_order/boot_with_multiple_boot_order.cfg +++ b/libvirt/tests/cfg/guest_os_booting/boot_order/boot_with_multiple_boot_order.cfg @@ -6,8 +6,11 @@ aarch64: os_dict = {'bootmenu_enable': 'yes'} target_bus = 'scsi' + s390-virtio: + os_dict = {'bootmenu_enable': 'no'} + target_bus = 'scsi' cdrom_dict = {'source': {'attrs': {'file': '%s'}}, 'type_name': 'file', 'device': 'cdrom', 'driver': {'name': 'qemu', 'type': 'raw'}, 'target': {'dev': 'sda', 'bus': '${target_bus}'}} - check_prompt = ["begin the installation process|Install Red Hat Enterprise"] + check_prompt = ["begin the installation process|Install Red Hat Enterprise|Starting installer"] variants first_dev: - hd: disk_order = {'boot': '1'} @@ -16,13 +19,20 @@ cdrom_order = {'boot': '2'} variants bootable_device: - hd_bootable: + variants: + - @default: + - with_loadparm: + only s390-virtio + disk_order = {'boot': '1', 'loadparm': '1'} + test_cmd = "lsreipl" + expected_output = Loadparm:\s+"1" - cdrom_bootable: - network: network_order = {'boot': '2'} variants bootable_device: - hd_bootable: - network_bootable: - check_prompt = ["iPXE initialising devices|Start PXE over IPv4"] + check_prompt = ["iPXE initialising devices|Start PXE over IPv4|Trying pxelinux.cfg files"] - cdrom: cdrom_order = {'boot': '1'} variants second_dev: @@ -30,13 +40,20 @@ disk_order = {'boot': '2'} variants bootable_device: - hd_bootable: + variants: + - @default: + - with_loadparm: + only s390-virtio + disk_order = {'boot': '2', 'loadparm': '2'} + test_cmd = "lsreipl" + expected_output = Loadparm:\s+"2" - cdrom_bootable: - network: network_order = {'boot': '2'} variants bootable_device: - cdrom_bootable: - network_bootable: - check_prompt = ["iPXE initialising devices|Start PXE over IPv4"] + check_prompt = ["iPXE initialising devices|Start PXE over IPv4|Trying pxelinux.cfg files"] - network: network_order = {'boot': '1'} variants second_dev: @@ -44,11 +61,18 @@ disk_order = {'boot': '2'} variants bootable_device: - hd_bootable: + variants: + - @default: + - with_loadparm: + only s390-virtio + disk_order = {'boot': '2', 'loadparm': '2'} + test_cmd = "lsreipl" + expected_output = Loadparm:\s+"2" - network_bootable: - check_prompt = ["iPXE initialising devices|Start PXE over IPv4"] + check_prompt = ["iPXE initialising devices|Start PXE over IPv4|Trying pxelinux.cfg files"] - cdrom: cdrom_order = {'boot': '2'} variants bootable_device: - cdrom_bootable: - network_bootable: - check_prompt = ["iPXE initialising devices|Start PXE over IPv4"] + check_prompt = ["iPXE initialising devices|Start PXE over IPv4|Trying pxelinux.cfg files"] diff --git a/libvirt/tests/cfg/guest_os_booting/boot_order/hotplug_device_with_boot_order.cfg b/libvirt/tests/cfg/guest_os_booting/boot_order/hotplug_device_with_boot_order.cfg index 2722ca402f..9dfa260751 100644 --- a/libvirt/tests/cfg/guest_os_booting/boot_order/hotplug_device_with_boot_order.cfg +++ b/libvirt/tests/cfg/guest_os_booting/boot_order/hotplug_device_with_boot_order.cfg @@ -13,6 +13,8 @@ bus_type = "usb" target_disk = "sda" device_dict = {"type_name":"file", "target":{"dev": "${target_disk}", "bus": "${bus_type}"}, 'boot': '2'} + s390-virtio: + expected_error = unsupported configuration: This QEMU doesn't support - filesystem_device: target_dir = "mount_tag" source_dir = "/tmp" diff --git a/libvirt/tests/cfg/guest_os_booting/direct_kernel_boot/direct_kernel_boot.cfg b/libvirt/tests/cfg/guest_os_booting/direct_kernel_boot/direct_kernel_boot.cfg index 563c252244..18b91f72a4 100644 --- a/libvirt/tests/cfg/guest_os_booting/direct_kernel_boot/direct_kernel_boot.cfg +++ b/libvirt/tests/cfg/guest_os_booting/direct_kernel_boot/direct_kernel_boot.cfg @@ -6,6 +6,8 @@ initrd_url = "${repo_url}/images/pxeboot/initrd.img" vmlinuz_url = "${repo_url}/images/pxeboot/vmlinuz" direct_kernel_dict = {'cmdline': 'console=ttyS0 inst.repo=${repo_url}', 'initrd': '%s', 'kernel': '%s'} + s390-virtio: + direct_kernel_dict = {'cmdline': 'inst.repo=${repo_url}', 'initrd': '%s', 'kernel': '%s'} variants: - start_guest: check_prompt = "Starting installer" diff --git a/libvirt/tests/cfg/guest_os_booting/firmware_configuration/os_acpi.cfg b/libvirt/tests/cfg/guest_os_booting/firmware_configuration/os_acpi.cfg index 20d6384228..8cf656f467 100644 --- a/libvirt/tests/cfg/guest_os_booting/firmware_configuration/os_acpi.cfg +++ b/libvirt/tests/cfg/guest_os_booting/firmware_configuration/os_acpi.cfg @@ -4,7 +4,7 @@ acpi_url = "EXAMPLE_ACPI_URL" acpi_file = "slic.dat" acpi_dict = {'acpi': {'table_type': 'slic', 'table': '%s'}} - no aarch64 + no aarch64, s390-virtio variants: - start_guest: cmd_in_guest = "acpidump" diff --git a/libvirt/tests/cfg/guest_os_booting/firmware_configuration/smbios_mode.cfg b/libvirt/tests/cfg/guest_os_booting/firmware_configuration/smbios_mode.cfg index 88eda2e886..e0a034ed82 100644 --- a/libvirt/tests/cfg/guest_os_booting/firmware_configuration/smbios_mode.cfg +++ b/libvirt/tests/cfg/guest_os_booting/firmware_configuration/smbios_mode.cfg @@ -1,6 +1,7 @@ - guest_os_booting.smbios_mode: type = smbios_mode start_vm = no + no s390-virtio variants: - positive_test: variants smbios_mode: diff --git a/libvirt/tests/cfg/guest_os_booting/firmware_configuration/sysinfo_fwcfg.cfg b/libvirt/tests/cfg/guest_os_booting/firmware_configuration/sysinfo_fwcfg.cfg index a9d57e5fe1..32970c35e2 100644 --- a/libvirt/tests/cfg/guest_os_booting/firmware_configuration/sysinfo_fwcfg.cfg +++ b/libvirt/tests/cfg/guest_os_booting/firmware_configuration/sysinfo_fwcfg.cfg @@ -2,6 +2,7 @@ type = sysinfo_fwcfg start_vm = no entry_value = "example value" + no s390-virtio variants: - positive_test: variants: diff --git a/libvirt/tests/cfg/guest_os_booting/migration/migration_boot.cfg b/libvirt/tests/cfg/guest_os_booting/migration/migration_boot.cfg index 58e0e2895f..7fd79d42f7 100644 --- a/libvirt/tests/cfg/guest_os_booting/migration/migration_boot.cfg +++ b/libvirt/tests/cfg/guest_os_booting/migration/migration_boot.cfg @@ -25,6 +25,7 @@ virsh_migrate_connect_uri = "qemu:///system" variants: - os_dev: + no s390-virtio os_attrs_boots = ['hd', 'cdrom', 'network'] - boot_order: disk_boot_idx = 1 diff --git a/libvirt/tests/src/guest_os_booting/boot_order/boot_with_multiple_boot_order.py b/libvirt/tests/src/guest_os_booting/boot_order/boot_with_multiple_boot_order.py index b3469f6bdd..ac9f35fa02 100644 --- a/libvirt/tests/src/guest_os_booting/boot_order/boot_with_multiple_boot_order.py +++ b/libvirt/tests/src/guest_os_booting/boot_order/boot_with_multiple_boot_order.py @@ -3,6 +3,7 @@ # Author: Meina Li import os +import re from avocado.utils import process @@ -74,10 +75,13 @@ def run(test, params, env): check_prompt = eval(params.get("check_prompt", "[]")) bootable_device = params.get("bootable_device") os_dict = eval(params.get("os_dict")) + test_cmd = params.get("test_cmd", None) + expected_output = params.get("expected_output", None) vm = env.get_vm(vm_name) vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm.name) bkxml = vmxml.copy() + session = None try: test.log.info("TEST_SETUP: prepare a guest with necessary attributes.") @@ -89,12 +93,20 @@ def run(test, params, env): test.log.debug(f"The current guest xml is: {vmxml}") test.log.info("TEST_STEP2: check the guest boot from expected device.") if bootable_device == "hd_bootable": - vm.wait_for_login(timeout=360).close() + session = vm.wait_for_login(timeout=360) test.log.debug("Succeed to boot %s", vm_name) + if test_cmd is not None: + output = session.cmd(test_cmd) + if not re.search(expected_output, output): + test.fail(f"Couldn't get {expected_output}, got instead {output}") + test.log.debug("Succeed to set %s", expected_output) + session.close() else: vm.serial_console.read_until_output_matches(check_prompt, timeout=300, internal_timeout=0.5) finally: + if session: + session.close() bkxml.sync() for file in file_list: if os.path.exists(file): diff --git a/libvirt/tests/src/guest_os_booting/direct_kernel_boot/direct_kernel_boot.py b/libvirt/tests/src/guest_os_booting/direct_kernel_boot/direct_kernel_boot.py index 90124677cd..77a70401e6 100644 --- a/libvirt/tests/src/guest_os_booting/direct_kernel_boot/direct_kernel_boot.py +++ b/libvirt/tests/src/guest_os_booting/direct_kernel_boot/direct_kernel_boot.py @@ -35,8 +35,8 @@ def run(test, params, env): bkxml = vmxml.copy() try: - boot_initrd = os.path.join(data_dir.get_data_dir(), "initrd.img") - boot_vmlinuz = os.path.join(data_dir.get_data_dir(), "vmlinuz") + boot_initrd = os.path.join(data_dir.get_data_dir(), initrd_url.split("/")[-1]) + boot_vmlinuz = os.path.join(data_dir.get_data_dir(), vmlinuz_url.split("/")[-1]) url_download(initrd_url, boot_initrd) url_download(vmlinuz_url, boot_vmlinuz) direct_kernel_dict = eval(params.get("direct_kernel_dict") diff --git a/provider/guest_os_booting/guest_os_booting_base.py b/provider/guest_os_booting/guest_os_booting_base.py index 90c64d6217..b6f618bfc2 100644 --- a/provider/guest_os_booting/guest_os_booting_base.py +++ b/provider/guest_os_booting/guest_os_booting_base.py @@ -1,4 +1,5 @@ import logging +import platform from avocado.core import exceptions from avocado.utils import distro @@ -38,7 +39,7 @@ def get_vm(params): LOG.debug(f"VMS: {os_type_dict}") if not firmware_type: LOG.debug("Get default vm") - if detected_distro.name == 'rhel': + if detected_distro.name == 'rhel' and platform.machine() != "s390x": if int(detected_distro.version) < 9: firmware_type = 'seabios' else: