From 228ae0754374e4171995219f502d1cd942ff206d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 17 Sep 2014 14:31:20 +0200 Subject: [PATCH] backups: improve errors handling Report nice error message (not a traceback), interrupt the process on non-recoverable error (when extraction process is already dead). --- core/backup.py | 17 ++++++++++++++++- qvm-tools/qvm-backup-restore | 7 +++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/core/backup.py b/core/backup.py index fc0c5e96..976925f1 100644 --- a/core/backup.py +++ b/core/backup.py @@ -742,7 +742,13 @@ def wait_backup_feedback(progress_callback, in_stream, streamproc, if len(buffer) <= 0: return "" - backup_target.write(buffer) + try: + backup_target.write(buffer) + except IOError as e: + if e.errno == errno.EPIPE: + run_error = "target" + else: + raise if hmac: hmac.stdin.write(buffer) @@ -1145,6 +1151,15 @@ def restore_vm_dirs (backup_source, restore_tmpdir, passphrase, vms_dirs, vms, while True: if running_backup_operation and running_backup_operation.canceled: break + if not extract_proc.is_alive(): + command.terminate() + command.wait() + expect_tar_error = True + if vmproc: + vmproc.terminate() + vmproc.wait() + vmproc = None + break if nextfile is not None: filename = nextfile else: diff --git a/qvm-tools/qvm-backup-restore b/qvm-tools/qvm-backup-restore index 17d20a82..76578dda 100755 --- a/qvm-tools/qvm-backup-restore +++ b/qvm-tools/qvm-backup-restore @@ -227,8 +227,11 @@ def main(): exit (0) - backup_restore_do(restore_info, - host_collection=host_collection) + try: + backup_restore_do(restore_info, + host_collection=host_collection) + except QubesException as e: + print >> sys.stderr, "ERROR: %s" % str(e) host_collection.unlock_db()