diff --git a/libvirt/tests/cfg/guest_os_booting/ovmf_firmware/ovmf_smm.cfg b/libvirt/tests/cfg/guest_os_booting/ovmf_firmware/ovmf_smm.cfg new file mode 100644 index 0000000000..419e2cf0e1 --- /dev/null +++ b/libvirt/tests/cfg/guest_os_booting/ovmf_firmware/ovmf_smm.cfg @@ -0,0 +1,30 @@ +- guest_os_booting.ovmf_smm: + type = ovmf_smm + start_vm = no + smm_state = "on" + firmware_type = "ovmf" + only q35 + variants: + - positive_test: + variants: + - tseg_48M: + smm_tseg_size = "48" + smm_xpath = [{'element_attrs':[".//tseg[@unit='MiB']"], 'text':'${smm_tseg_size}'}] + - tseg_0M: + smm_tseg_size = "0" + smm_xpath = [{'element_attrs':[".//tseg[@unit='B']"], 'text':'${smm_tseg_size}'}] + - smm_off: + smm_state = "off" + loader_path = "/usr/share/edk2/ovmf/OVMF_CODE.fd" + nvram_path = "/var/lib/libvirt/qemu/nvram/nvram_VARS.fd" + nvram_template = "/usr/share/edk2/ovmf/OVMF_VARS.fd" + loader_dict = {'loader': '${loader_path}', 'nvram': '${nvram_path}', 'nvram_attrs': {'template': '${nvram_template}'}, 'loader_readonly': 'yes', 'loader_type': 'pflash', 'secure': 'no'} + smm_xpath = [{'element_attrs':[".//smm[@state='${smm_state}']"]}] + - negative_test: + variants: + - tseg_12345M: + smm_tseg_size = "12345" + error_msg = "qemu-kvm: invalid extended-tseg-mbytes value: 12345" + - tseg_-2M: + smm_tseg_size = "-2" + error_msg = "Invalid value '-2' for element or attribute" diff --git a/libvirt/tests/src/guest_os_booting/ovmf_firmware/ovmf_smm.py b/libvirt/tests/src/guest_os_booting/ovmf_firmware/ovmf_smm.py new file mode 100644 index 0000000000..45e9a45d15 --- /dev/null +++ b/libvirt/tests/src/guest_os_booting/ovmf_firmware/ovmf_smm.py @@ -0,0 +1,49 @@ +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright Red Hat +# +# SPDX-License-Identifier: GPL-2.0 + +# Author: Meina Li +# +from virttest.libvirt_xml import vm_xml +from virttest.libvirt_xml import xcepts +from virttest.utils_libvirt import libvirt_vmxml + +from provider.guest_os_booting import guest_os_booting_base as guest_os + + +def run(test, params, env): + """ + This case is to verify the ovmf smm elements. + 1) Prepare a guest with related smm elements. + 2) Start and boot the guest. + """ + vm_name = params.get("main_vm") + smm_state = params.get("smm_state") + smm_tseg_size = params.get("smm_tseg_size", "") + smm_xpath = eval(params.get("smm_xpath", "{}")) + error_msg = params.get("error_msg") + firmware_type = params.get("firmware_type") + loader_dict = eval(params.get("loader_dict", "{}")) + + vm = env.get_vm(vm_name) + vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name) + bkxml = vmxml.copy() + + try: + try: + guest_os.prepare_smm_xml(vm_name, smm_state, smm_tseg_size) + except xcepts.LibvirtXMLError as details: + if error_msg and error_msg in str(details): + test.log.info("Get expected error message: %s.", error_msg) + return + else: + test.fail("Failed to define the guest because error:%s", str(details)) + if smm_state == "off": + guest_os.prepare_os_xml(vm_name, loader_dict, firmware_type) + vmxml = guest_os.check_vm_startup(vm, vm_name, error_msg) + libvirt_vmxml.check_guest_xml_by_xpaths(vmxml, smm_xpath) + finally: + bkxml.sync()