Skip to content

Commit 8b89623

Browse files
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 <[email protected]>
1 parent e924cd0 commit 8b89623

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

libvirt/tests/src/virsh_cmd/domain/virsh_domjobinfo.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ def cmp_jobinfo(result, info_list, job_type, actions):
150150
else:
151151
process = get_subprocess(action, vm_name, tmp_pipe, None)
152152

153+
try:
154+
_, stderr = process.communicate(timeout=6)
155+
if process.returncode:
156+
os.unlink(tmp_pipe)
157+
test.error('Background cmd met unexpected failure of %s, abort the test.' % stderr)
158+
except subprocess.TimeoutExpired:
159+
logging.debug("Background cmd is still running.")
160+
153161
f = open(tmp_pipe, 'rb')
154162
dummy = f.read(1024 * 1024).decode(locale.getpreferredencoding(), 'ignore')
155163

0 commit comments

Comments
 (0)