core: make modules.img optional even for PV

When using PVGrub it doesn't make sense to attach modules.img, since
modules are already in the VM. Initramfs there will already handle such
situation and will not try to mount it, when VM's root filesystem
already contains appropriate /lib/modules/`uname -r`.

On the other hand, error earlier when initramfs is missing. While also
not used by PV Grub, the file is always specified in libvirt config and
when missing libvirt will throw rather cryptic error message.

QubesOS/qubes-issues#1354
This commit is contained in:
Marek Marczykowski-Górecki 2015-11-10 17:04:50 +01:00
parent c595ac464b
commit ba54792c83
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -347,9 +347,11 @@ class QubesVm(object):
# Initialize VM image storage class
self.storage = defaults["storage_class"](self)
if hasattr(self, 'kernels_dir'):
self.storage.modules_img = os.path.join(self.kernels_dir,
modules_path = os.path.join(self.kernels_dir,
"modules.img")
self.storage.modules_img_rw = self.kernel is None
if os.path.exists(modules_path):
self.storage.modules_img = modules_path
self.storage.modules_img_rw = self.kernel is None
# Some additional checks for template based VM
if self.template is not None:
@ -517,7 +519,7 @@ class QubesVm(object):
if not os.path.exists(os.path.join(system_path[
'qubes_kernels_base_dir'], new_value)):
raise QubesException("Kernel '%s' not installed" % new_value)
for f in ('vmlinuz', 'modules.img'):
for f in ('vmlinuz', 'initramfs'):
if not os.path.exists(os.path.join(
system_path['qubes_kernels_base_dir'], new_value, f)):
raise QubesException(