From e110cbecb327de991413a1472b53276111d48153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 25 Feb 2019 04:40:37 +0100 Subject: [PATCH] storage: fallback kernels_dir path if there is no 'kernel' volume Return meaningful value for kernels_dir if VM has no 'kernel' volume. Right now it's mostly useful for tests, but could be also used for new VM classes which doesn't have modules.img, but still use dom0-provided kernel. --- qubes/storage/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index 78579000..9079a830 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -468,8 +468,14 @@ class Storage: If :py:attr:`self.vm.kernel` is :py:obj:`None`, the this points inside :py:attr:`self.vm.dir_path` ''' - assert 'kernel' in self.vm.volumes, "VM has no kernel volume" - return self.vm.volumes['kernel'].kernels_dir + if not self.vm.kernel: + return None + if 'kernel' in self.vm.volumes: + return self.vm.volumes['kernel'].kernels_dir + return os.path.join( + qubes.config.qubes_base_dir, + qubes.config.system_path['qubes_kernels_base_dir'], + self.vm.kernel) def get_disk_utilization(self): ''' Returns summed up disk utilization for all domain volumes '''