From 8b89623059d879bf65b473f40a16d1e411ebc754 Mon Sep 17 00:00:00 2001 From: Liang Cong Date: Mon, 15 Sep 2025 00:06:09 -0400 Subject: [PATCH] virsh_domjobinfo: fix pipe file read stuck when background virsh cmd failed Since libvirt 11.5.0, the virsh dump --live option has been disabled and now returns an error message. This causes the test to hang while attempting to read the virsh dump pipe file's input. The fix implements subprocess.communicate() to handle the background command interaction: Command failure: the test aborts immediately with the error message. Command success: original logic remains unchanged. Note: If the background command fails after the timeout period, this likely indicates a libvirt issue, so no changes are made for now. Signed-off-by: Liang Cong --- libvirt/tests/src/virsh_cmd/domain/virsh_domjobinfo.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libvirt/tests/src/virsh_cmd/domain/virsh_domjobinfo.py b/libvirt/tests/src/virsh_cmd/domain/virsh_domjobinfo.py index c14135ce66..5fc1b8f0d3 100644 --- a/libvirt/tests/src/virsh_cmd/domain/virsh_domjobinfo.py +++ b/libvirt/tests/src/virsh_cmd/domain/virsh_domjobinfo.py @@ -150,6 +150,14 @@ def cmp_jobinfo(result, info_list, job_type, actions): else: process = get_subprocess(action, vm_name, tmp_pipe, None) + try: + _, stderr = process.communicate(timeout=6) + if process.returncode: + os.unlink(tmp_pipe) + test.error('Background cmd met unexpected failure of %s, abort the test.' % stderr) + except subprocess.TimeoutExpired: + logging.debug("Background cmd is still running.") + f = open(tmp_pipe, 'rb') dummy = f.read(1024 * 1024).decode(locale.getpreferredencoding(), 'ignore')