From ef128156a33e82ffdf0495ddb736fbd1d945bf04 Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Sat, 15 Jun 2019 16:03:46 +0000 Subject: [PATCH] storage/reflink: volume.resize(): succeed without image Successfully resize volumes without any currently existing image file, e.g. cleanly stopped volatile volumes: Just update the nominal size in this case. --- qubes/storage/reflink.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/qubes/storage/reflink.py b/qubes/storage/reflink.py index 687f74ea..e9269392 100644 --- a/qubes/storage/reflink.py +++ b/qubes/storage/reflink.py @@ -263,15 +263,13 @@ class ReflinkVolume(qubes.storage.Volume): raise qubes.storage.StoragePoolException( 'Cannot resize: {} is read-only'.format(self.vid)) - try: # assume volume is not (cleanly) stopped ... - _resize_file(self._path_dirty, size) - update = True - except FileNotFoundError: # ... but it actually is. - _resize_file(self._path_clean, size) - update = False + for path in (self._path_dirty, self._path_clean): + with suppress(FileNotFoundError): + _resize_file(path, size) + break self.size = size - if update: + if path == self._path_dirty: _update_loopdev_sizes(self._path_dirty) return self