backup: throttle backup extracting if there is not enough disk space

Instead of failing the restore process, pause data extracting, until
already extracted data gets processed.
This commit implements this for local tar extraction. Extracting data
received from a VM is handled in qfile-(dom0-)unpacker, which also has
similar feature, turned on in 6338b936e2.

Fixes QubesOS/qubes-issues#4791
This commit is contained in:
Marek Marczykowski-Górecki 2021-01-05 04:19:28 +01:00
父節點 10d4381c14
當前提交 93608658a9
沒有發現已知的金鑰在資料庫的簽署中
GPG Key ID: 063938BA42CFA724

查看文件

@ -1005,8 +1005,18 @@ class BackupRestore(object):
else:
backup_stdin = open(self.backup_location, 'rb')
block_size = os.statvfs(self.tmpdir).f_frsize
# slow down the restore if there is too little space in the temp dir
checkpoint_command = \
'while [ $(stat -f --format=%a "{}") -lt {} ]; ' \
'do sleep 1; done' \
.format(self.tmpdir, 500 * 1024 * 1024 // block_size)
tar1_command = ['tar',
'-ixv',
'--checkpoint=10000',
'--checkpoint-action=exec=' + checkpoint_command,
'--occurrence=1',
'-C', self.tmpdir] + filelist