Move kernel file checks to LinuxKernel pool
This commit is contained in:
parent
ef485ca32a
commit
fe6a35155e
@ -23,7 +23,6 @@
|
||||
#
|
||||
import os
|
||||
|
||||
from qubes.exc import QubesVMError
|
||||
from qubes.storage import Pool, StoragePoolException, Volume
|
||||
|
||||
|
||||
@ -35,6 +34,8 @@ class LinuxModules(Volume):
|
||||
self.kernels_dir = os.path.join(target_dir, kernel_version)
|
||||
self.path = os.path.join(self.kernels_dir, 'modules.img')
|
||||
self.vid = self.path
|
||||
self.vmlinuz = os.path.join(self.kernels_dir, 'vmlinuz')
|
||||
self.initramfs = os.path.join(self.kernels_dir, 'initramfs')
|
||||
|
||||
|
||||
class LinuxKernel(Pool):
|
||||
@ -45,14 +46,20 @@ class LinuxKernel(Pool):
|
||||
super(LinuxKernel, self).__init__(name=name)
|
||||
self.dir_path = dir_path
|
||||
|
||||
def init_volume(self, volume_config):
|
||||
def init_volume(self, vm, volume_config):
|
||||
assert 'volume_type' in volume_config, "Volume type missing " \
|
||||
+ str(volume_config)
|
||||
volume_type = volume_config['volume_type']
|
||||
if volume_type != 'read-only':
|
||||
raise StoragePoolException("Unknown volume type " + volume_type)
|
||||
|
||||
return LinuxModules(self.dir_path, self.vm.kernel, **volume_config)
|
||||
volume = LinuxModules(self.dir_path, vm.kernel, **volume_config)
|
||||
|
||||
_check_path(volume.path)
|
||||
_check_path(volume.vmlinuz)
|
||||
_check_path(volume.initramfs)
|
||||
|
||||
return volume
|
||||
|
||||
def clone(self, source, target):
|
||||
return target
|
||||
@ -86,9 +93,17 @@ class LinuxKernel(Pool):
|
||||
def start(self, volume):
|
||||
path = volume.path
|
||||
if not os.path.exists(path):
|
||||
msg = 'VM %s is missing modules: %s' % (self.vm.name, path)
|
||||
raise QubesVMError(self.vm, msg)
|
||||
raise StoragePoolException('Missing kernel modules: %s' % path)
|
||||
|
||||
return volume
|
||||
|
||||
def stop(self, volume):
|
||||
pass
|
||||
|
||||
|
||||
def _check_path(path):
|
||||
''' Raise an :py:class:`qubes.storage.StoragePoolException` if ``path`` does
|
||||
not exist.
|
||||
'''
|
||||
if not os.path.exists(path):
|
||||
raise StoragePoolException('Missing file: %s' % path)
|
||||
|
@ -1532,18 +1532,6 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
||||
|
||||
self.storage.verify_files()
|
||||
|
||||
if not os.path.exists(
|
||||
os.path.join(self.storage.kernels_dir, 'vmlinuz')):
|
||||
raise qubes.exc.QubesException(
|
||||
'VM kernel does not exist: {0}'.format(
|
||||
os.path.join(self.storage.kernels_dir, 'vmlinuz')))
|
||||
|
||||
if not os.path.exists(
|
||||
os.path.join(self.storage.kernels_dir, 'initramfs')):
|
||||
raise qubes.exc.QubesException(
|
||||
'VM initramfs does not exist: {0}'.format(
|
||||
os.path.join(self.storage.kernels_dir, 'initramfs')))
|
||||
|
||||
self.fire_event('domain-verify-files')
|
||||
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user