Skip to content

Commit 0b12128

Browse files
authored
Merge pull request #6564 from liang-cong-red-hat/domjobinfo_fix_job_stuck_pipe_error_3
virsh_domjobinfo: fix pipe file read stuck when background virsh cmd failed
2 parents acbf065 + 8b89623 commit 0b12128

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)