From 400e92b25a84cd0357ac1ddbfd8636ac5937fd85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 3 Nov 2016 21:41:48 +0100 Subject: [PATCH] storage/lvm: misc fixes - add missing lvm remove call when commiting changes - delay creating volatile image until domain startup (it will be created then anyway) - reset cache only when really changed anything - attach VM to the volume (snapshot) created for its runtime - to not expose changes (for example in root volume) to child VMs until shutdown QubesOS/qubes-issues#2412 QubesOS/qubes-issues#2256 --- qubes/storage/lvm.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/qubes/storage/lvm.py b/qubes/storage/lvm.py index fd0cbdc2..42c0d9e5 100644 --- a/qubes/storage/lvm.py +++ b/qubes/storage/lvm.py @@ -69,6 +69,7 @@ class ThinPool(qubes.storage.Pool): cmd = ['clone', volume._vid_snap, volume.vid] qubes_lvm(cmd, self.log) cmd = ['remove', volume._vid_snap] + qubes_lvm(cmd, self.log) @property def config(self): @@ -83,8 +84,9 @@ class ThinPool(qubes.storage.Pool): assert volume.vid assert volume.size if volume.source: - return self.clone(volume.source, volume) - else: + # will clone in start() + return volume + elif not volume._is_volatile: cmd = [ 'create', self._pool_id, @@ -92,7 +94,7 @@ class ThinPool(qubes.storage.Pool): str(volume.size) ] qubes_lvm(cmd, self.log) - reset_cache() + reset_cache() return volume def destroy(self): @@ -398,6 +400,16 @@ class ThinVolume(qubes.storage.Volume): raise qubes.storage.StoragePoolException( "You shouldn't use lvm size setter") + def block_device(self): + ''' Return :py:class:`qubes.devices.BlockDevice` for serialization in + the libvirt XML template as . + ''' + if not self._is_volatile: + return qubes.devices.BlockDevice( + '/dev/' + self._vid_snap, self.name, self.script, + self.rw, self.domain, self.devtype) + else: + return super(ThinVolume, self).block_device() @property def usage(self): # lvm thin usage always returns at least the same usage as