storage/lvm: fix resizing not persistent volumes
Even when volume is not persistent (like TemplateBasedVM:root), it should be resizeable. Just the new size, similarly to the volume content, will be reverted after qube shutdown. Additionally, when VM is running, volume resize should affect _only_ its temporary snapshot. This way resize can be properly reverted together with actual volume changes (which include resize2fs call). Fixes QubesOS/qubes-issues#3519
This commit is contained in:
parent
9b5256f002
commit
7903dc53f9
@ -225,6 +225,8 @@ class ThinVolume(qubes.storage.Volume):
|
|||||||
@property
|
@property
|
||||||
def size(self):
|
def size(self):
|
||||||
try:
|
try:
|
||||||
|
if self.is_dirty():
|
||||||
|
return qubes.storage.lvm.size_cache[self._vid_snap]['size']
|
||||||
return qubes.storage.lvm.size_cache[self.vid]['size']
|
return qubes.storage.lvm.size_cache[self.vid]['size']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return self._size
|
return self._size
|
||||||
@ -430,11 +432,12 @@ class ThinVolume(qubes.storage.Volume):
|
|||||||
if size == self.size:
|
if size == self.size:
|
||||||
return
|
return
|
||||||
|
|
||||||
cmd = ['extend', self.vid, str(size)]
|
|
||||||
qubes_lvm(cmd, self.log)
|
|
||||||
if self.is_dirty():
|
if self.is_dirty():
|
||||||
cmd = ['extend', self._vid_snap, str(size)]
|
cmd = ['extend', self._vid_snap, str(size)]
|
||||||
qubes_lvm(cmd, self.log)
|
qubes_lvm(cmd, self.log)
|
||||||
|
elif self.save_on_stop or not self.snap_on_start:
|
||||||
|
cmd = ['extend', self.vid, str(size)]
|
||||||
|
qubes_lvm(cmd, self.log)
|
||||||
reset_cache()
|
reset_cache()
|
||||||
|
|
||||||
def _snapshot(self):
|
def _snapshot(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user