From bdae560770e3c03d2f3a820ea1ed07b8b36d64c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 18 Feb 2015 21:41:22 +0100 Subject: [PATCH] backup: fix deadlock on error while receiving backup from a VM When qfile-dom0-unpacker detects an error, it sends error report to stdout and terminate (so stdout is closed). That close should be transferred to the VM process (as EOF on its stdin), which will signal it to stop sending the data and handle error report. Also qrexec-client holds the connection until both stdin and stdout are closed. So when that EOF is missing, tar2qfile will not detect error report and still tries to send the data and qrexec-client will hold the connection while receiving process is long dead. To prevent that deadlock from happening, close FD in python code, so qfile-dom0-unpacker will be the last owner of write end of the pipe. When it closes its stdout, qrexec-client will receive EOF at its stdin. --- core/backup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/backup.py b/core/backup.py index 57ffc953..18e1fa48 100644 --- a/core/backup.py +++ b/core/backup.py @@ -1285,6 +1285,10 @@ def restore_vm_dirs (backup_source, restore_tmpdir, passphrase, vms_dirs, vms, # to the VM), while tar output filelist on stdout if appvm: filelist_pipe = command.stderr + # let qfile-dom0-unpacker hold the only open FD to the write end of + # pipe, otherwise qrexec-client will not receive EOF when + # qfile-dom0-unpacker terminates + vmproc.stdin.close() else: filelist_pipe = command.stdout