backup: check if there is enough disk space available to restore
Avoid failing restore after potentially lengthy processing - check available space first. This will be even more important after adding waiting for free space - then if there won't be enough free space, the process will deadlock. QubesOS/qubes-issues#4791
This commit is contained in:
parent
16ff6d0552
commit
10d4381c14
@ -1871,6 +1871,22 @@ class BackupRestore(object):
|
|||||||
self.log.error('Failed to resize volume %s of VM %s to %d: %s',
|
self.log.error('Failed to resize volume %s of VM %s to %d: %s',
|
||||||
volume.name, vm.name, size, err)
|
volume.name, vm.name, size, err)
|
||||||
|
|
||||||
|
def check_disk_space(self):
|
||||||
|
"""
|
||||||
|
Check if there is enough disk space to restore the backup.
|
||||||
|
|
||||||
|
Currently it checks only for the space in temporary directory,
|
||||||
|
not the target storage pools.
|
||||||
|
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
|
||||||
|
statvfs = os.statvfs(self.tmpdir)
|
||||||
|
# require 1GB in /var/tmp
|
||||||
|
if statvfs.f_frsize * statvfs.f_bavail < 1024 ** 3:
|
||||||
|
raise QubesException("Too little space in {}, needs at least 1GB".
|
||||||
|
format(self.tmpdir))
|
||||||
|
|
||||||
def restore_do(self, restore_info):
|
def restore_do(self, restore_info):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@ -1887,6 +1903,8 @@ class BackupRestore(object):
|
|||||||
if self.header_data.version == 1:
|
if self.header_data.version == 1:
|
||||||
raise NotImplementedError('Backup format version 1 not supported')
|
raise NotImplementedError('Backup format version 1 not supported')
|
||||||
|
|
||||||
|
self.check_disk_space()
|
||||||
|
|
||||||
restore_info = self.restore_info_verify(restore_info)
|
restore_info = self.restore_info_verify(restore_info)
|
||||||
|
|
||||||
self._restore_vms_metadata(restore_info)
|
self._restore_vms_metadata(restore_info)
|
||||||
|
Loading…
Reference in New Issue
Block a user