From a75a21a106631aeac5a95f9bec7c6c79b6c65528 Mon Sep 17 00:00:00 2001 From: chunfuwen Date: Mon, 21 Oct 2024 22:41:39 -0400 Subject: [PATCH] workaround VM first start failure due to swtpm Signed-off-by: chunfuwen --- libvirt/tests/src/virtual_device/tpm_device.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libvirt/tests/src/virtual_device/tpm_device.py b/libvirt/tests/src/virtual_device/tpm_device.py index 24b5a4f40f..971a824e98 100644 --- a/libvirt/tests/src/virtual_device/tpm_device.py +++ b/libvirt/tests/src/virtual_device/tpm_device.py @@ -713,8 +713,14 @@ def reuse_by_vm2(tpm_dev): return test.fail("Reuse a passthroughed tpm should not succeed.") elif ret.exit_status: - # emulator backend - test.fail("Vtpm for each guest should not interfere with each other") + # workaround VM first start failure due to swtpm + swtpm_error_msg = "internal error: Could not run '/usr/bin/swtpm_setup'" + output = ret.stdout_text + ret.stderr_text + if re.search(r'%s' % swtpm_error_msg, output): + virsh.start(vm2_name, ignore_status=True, debug=True) + else: + # emulator backend + test.fail("Vtpm for each guest should not interfere with each other") def save_modify_pcrbank(vm_name, active_pcr_banks, pcrbank_change): """ @@ -843,7 +849,12 @@ def check_swtpmpidfile(vm_name, test_stage): logging.debug("Expected failure: %s", detail) return else: - test.fail(detail) + # workaround VM first start failure due to swtpm + swtpm_error_msg = "internal error: Could not run '/usr/bin/swtpm_setup'" + if re.search(r'%s' % swtpm_error_msg, str(detail)): + vm.start() + else: + test.fail(detail) if undefine_flag: time.sleep(5) vm.destroy()