From 93162df677406cee8a1769156f66b7908d98121c Mon Sep 17 00:00:00 2001 From: Andrew Sorensen Date: Sat, 22 Jun 2013 19:59:16 -0700 Subject: [PATCH] dom0: use vm.run() instead of subprocess.Popen() directly --- dom0/qvm-core/qubesutils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dom0/qvm-core/qubesutils.py b/dom0/qvm-core/qubesutils.py index 1a155050..a4b9e7c5 100644 --- a/dom0/qvm-core/qubesutils.py +++ b/dom0/qvm-core/qubesutils.py @@ -1030,7 +1030,6 @@ def backup_do_copy(appvm, base_backup_dir, files_to_backup, progress_callback = ''' bytes_backedup = 0 for file in files_to_backup: - # We prefer to use Linux's cp, because it nicely handles sparse files progress = bytes_backedup * 100 / total_backup_sz progress_callback(progress) dest_dir = backup_dir + '/' + file["subdir"] @@ -1040,9 +1039,13 @@ def backup_do_copy(appvm, base_backup_dir, files_to_backup, progress_callback = raise QubesException("Cannot create directory: {0}?!".format(dest_dir)) file["basename"] = os.path.basename(file["path"]) - compressor = subprocess.Popen (["tar", "-PcOz", file["path"]], stdout=subprocess.PIPE) - subprocess.Popen (["qvm-run", "--pass-io", "-p", appvm, "cat > " + dest_dir + file["basename"] + ".tar.gz"], stdin=compressor.stdout) - + vm.run("mkdir -p {0}".format(dest_dir)) + retcode = vm.run(command = "cat > {0}".format(dest_dir + file["basename"] + ".tar.gz"), passio_popen = True) + compressor = subprocess.Popen (["tar", "-PcOz", file["path"]], stdout=retcode.stdin) + compressor.wait() + if compressor.retcode != 0: + raise QubesException("Failed to backup file {0} with error {1}".format(file["basename"])) + bytes_backedup += file["size"] progress = bytes_backedup * 100 / total_backup_sz progress_callback(progress)