From 9a7ac28e2668a12d93b7f81485a4eacc612e2109 Mon Sep 17 00:00:00 2001 From: Yingshun Cui Date: Fri, 27 Dec 2024 17:20:40 +0800 Subject: [PATCH] guest_os_booting: Fix the nonexist_template case error 1. nvram file should be cleared before the testing 2. error message changed Signed-off-by: Yingshun Cui --- .../cfg/guest_os_booting/ovmf_firmware/ovmf_nvram.cfg | 2 +- .../src/guest_os_booting/ovmf_firmware/ovmf_nvram.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libvirt/tests/cfg/guest_os_booting/ovmf_firmware/ovmf_nvram.cfg b/libvirt/tests/cfg/guest_os_booting/ovmf_firmware/ovmf_nvram.cfg index 4a1fd4a15f..0b041ddc82 100644 --- a/libvirt/tests/cfg/guest_os_booting/ovmf_firmware/ovmf_nvram.cfg +++ b/libvirt/tests/cfg/guest_os_booting/ovmf_firmware/ovmf_nvram.cfg @@ -28,4 +28,4 @@ variants: - nonexist_template: template_path = "nonexist" - error_msg = "error: Failed to open file.+: No such file or directory" + error_msg = "error: Failed to open file.+: No such file or directory|conversion of the nvram template to another target format" diff --git a/libvirt/tests/src/guest_os_booting/ovmf_firmware/ovmf_nvram.py b/libvirt/tests/src/guest_os_booting/ovmf_firmware/ovmf_nvram.py index 4139fdae2e..5d745be9e2 100644 --- a/libvirt/tests/src/guest_os_booting/ovmf_firmware/ovmf_nvram.py +++ b/libvirt/tests/src/guest_os_booting/ovmf_firmware/ovmf_nvram.py @@ -22,16 +22,18 @@ def run(test, params, env): smm_state = params.get("smm_state") error_msg = params.get("error_msg", "") template_path = params.get("template_path", "") - if template_path: - nvram_dict = eval(params.get("nvram_dict", "{}") % template_path) - else: - nvram_dict = eval(params.get("nvram_dict")) vm = env.get_vm(vm_name) vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name) bkxml = vmxml.copy() try: + if template_path: + nvram_dict = eval(params.get("nvram_dict", "{}") % template_path) + if template_path == "nonexist": + vmxml.sync("--nvram") + else: + nvram_dict = eval(params.get("nvram_dict")) if smm_state: guest_os.prepare_smm_xml(vm_name, smm_state, smm_size=None) guest_os.prepare_os_xml(vm_name, nvram_dict, firmware_type)