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.
This commit is contained in:
Marek Marczykowski-Górecki 2019-02-25 04:40:37 +01:00
parent 723b33a2f6
commit e110cbecb3
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -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"
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 '''