From 1774be1c6966d6032f7357e52639487f40037408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 26 Feb 2018 22:18:44 +0100 Subject: [PATCH] storage/kernel: skip modules.img block device if kernel dir doesn't have it Some kernels (like pvgrub2) may not provide modules.img and it isn't an error. Don't break VM startup in that case, skip that device instead. Fixes QubesOS/qubes-issues#3563 --- qubes/storage/kernels.py | 11 +++++------ qubes/tests/storage_kernels.py | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/qubes/storage/kernels.py b/qubes/storage/kernels.py index a1a6b18d..b39d8b3d 100644 --- a/qubes/storage/kernels.py +++ b/qubes/storage/kernels.py @@ -105,10 +105,6 @@ class LinuxModules(Volume): return False def start(self): - path = self.path - if path and not os.path.exists(path): - raise StoragePoolException('Missing kernel modules: %s' % path) - return self def stop(self): @@ -116,12 +112,15 @@ class LinuxModules(Volume): def verify(self): if self.vid: - _check_path(self.path) _check_path(self.vmlinuz) _check_path(self.initramfs) def block_device(self): - if self.vid: + path = self.path + # create block device for modules.img only if: + # - there is kernel set for the VM + # - that kernel directory contains modules.img file + if path and os.path.exists(path): return super().block_device() return None diff --git a/qubes/tests/storage_kernels.py b/qubes/tests/storage_kernels.py index 7abcd0fa..9b067ef4 100644 --- a/qubes/tests/storage_kernels.py +++ b/qubes/tests/storage_kernels.py @@ -75,6 +75,8 @@ class TC_01_KernelVolumes(qubes.tests.QubesTestCase): self.app = TestApp() self.app.create_dummy_template() self.app.add_pool(**self.POOL_CONF) + os.makedirs(self.POOL_DIR + '/dummy', exist_ok=True) + open('/tmp/test-pool/dummy/modules.img', 'w').close() def tearDown(self): """ Remove the file based storage pool after testing """