From 49f2c1b78d6b91a75981d7ade3e50a28d2470728 Mon Sep 17 00:00:00 2001 From: Pawel Marczewski Date: Thu, 23 Jan 2020 10:39:47 +0100 Subject: [PATCH 1/2] Fix ThinVolume.size initialization from string The size config parameter might be a string coming from XML. The Volume base class handles the conversion to integer already. Fixes QubesOS/qubes-issues#5219. --- qubes/storage/lvm.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/qubes/storage/lvm.py b/qubes/storage/lvm.py index b0a3b52d..7c7f7e09 100644 --- a/qubes/storage/lvm.py +++ b/qubes/storage/lvm.py @@ -314,9 +314,9 @@ class ThinVolume(qubes.storage.Volume): ''' # pylint: disable=too-few-public-methods - def __init__(self, volume_group, size=0, **kwargs): + def __init__(self, volume_group, **kwargs): self.volume_group = volume_group - super(ThinVolume, self).__init__(size=size, **kwargs) + super(ThinVolume, self).__init__(**kwargs) self.log = logging.getLogger('qubes.storage.lvm.%s' % str(self.pool)) if self.snap_on_start or self.save_on_stop: @@ -324,7 +324,6 @@ class ThinVolume(qubes.storage.Volume): if self.save_on_stop: self._vid_import = self.vid + '-import' - self._size = size self._lock = asyncio.Lock() @property From 66abc69a332f8d9c6a9fe39cae5ebfeb6f22114f Mon Sep 17 00:00:00 2001 From: Pawel Marczewski Date: Thu, 23 Jan 2020 10:42:26 +0100 Subject: [PATCH 2/2] Add a test for loading volume config from XML --- qubes/tests/vm/appvm.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/qubes/tests/vm/appvm.py b/qubes/tests/vm/appvm.py index f3bc0979..88634fa8 100644 --- a/qubes/tests/vm/appvm.py +++ b/qubes/tests/vm/appvm.py @@ -1,4 +1,4 @@ -# -*- encoding: utf8 -*- +# -*- encoding: utf-8 -*- # # The Qubes OS Project, http://www.qubes-os.org # @@ -157,3 +157,25 @@ class TC_90_AppVM(qubes.tests.vm.qubesvm.QubesVMTestsMixin, self.assertEqual(vm.template_for_dispvms, False) with self.assertRaises(AttributeError): vm.dispvm_allowed + + def test_600_load_volume_config(self): + xml_template = ''' + + + 1 + testvm + + + + + + + ''' + xml = lxml.etree.XML(xml_template) + vm = qubes.vm.appvm.AppVM(self.app, xml) + self.assertEqual(vm.volume_config['root']['revisions_to_keep'], '3') + self.assertEqual(vm.volume_config['root']['rw'], True) + self.assertEqual(vm.volume_config['root']['size'], '1234') + self.assertEqual(vm.volume_config['root']['vid'], + 'qubes_dom0/vm-testvm-root')