core3: fix mounting modules.img
This commit is contained in:
parent
15c59f938c
commit
c9cbf8ffe2
@ -44,8 +44,7 @@ class VMStorage(object):
|
|||||||
in mind.
|
in mind.
|
||||||
''' # pylint: disable=abstract-class-little-used
|
''' # pylint: disable=abstract-class-little-used
|
||||||
|
|
||||||
def __init__(self, vm, private_img_size=None, root_img_size=None,
|
def __init__(self, vm, private_img_size=None, root_img_size=None):
|
||||||
modules_img=None, modules_img_rw=False):
|
|
||||||
|
|
||||||
#: Domain for which we manage storage
|
#: Domain for which we manage storage
|
||||||
self.vm = vm
|
self.vm = vm
|
||||||
@ -60,10 +59,6 @@ class VMStorage(object):
|
|||||||
if root_img_size is not None \
|
if root_img_size is not None \
|
||||||
else qubes.config.defaults['root_img_size']
|
else qubes.config.defaults['root_img_size']
|
||||||
|
|
||||||
# For now compute this path still in QubesVm
|
|
||||||
self.modules_img = modules_img
|
|
||||||
self.modules_img_rw = modules_img_rw
|
|
||||||
|
|
||||||
#: Additional drive (currently used only by HVM)
|
#: Additional drive (currently used only by HVM)
|
||||||
self.drive = None
|
self.drive = None
|
||||||
|
|
||||||
@ -87,6 +82,36 @@ class VMStorage(object):
|
|||||||
return self.abspath(qubes.config.vm_files['volatile_img'])
|
return self.abspath(qubes.config.vm_files['volatile_img'])
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def kernels_dir(self):
|
||||||
|
'''Directory where kernel resides.
|
||||||
|
|
||||||
|
If :py:attr:`self.vm.kernel` is :py:obj:`None`, the this points inside
|
||||||
|
:py:attr:`self.vm.dir_path`
|
||||||
|
'''
|
||||||
|
return os.path.join(qubes.config.system_path['qubes_base_dir'],
|
||||||
|
qubes.config.system_path['qubes_kernels_base_dir'], self.vm.kernel) \
|
||||||
|
if self.vm.kernel is not None \
|
||||||
|
else os.path.join(self.vm.dir_path,
|
||||||
|
qubes.config.vm_files['kernels_subdir'])
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def modules_img(self):
|
||||||
|
'''Path to image with modules.
|
||||||
|
|
||||||
|
Depending on domain, this may be global or inside domain's dir.
|
||||||
|
'''
|
||||||
|
return os.path.join(self.kernels_dir, 'modules.img')
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def modules_img_rw(self):
|
||||||
|
''':py:obj:`True` if module image should be mounted RW, :py:obj:`False`
|
||||||
|
otherwise.'''
|
||||||
|
return self.vm.kernel is None
|
||||||
|
|
||||||
|
|
||||||
def abspath(self, path, rel=None):
|
def abspath(self, path, rel=None):
|
||||||
'''Make absolute path.
|
'''Make absolute path.
|
||||||
|
|
||||||
|
@ -102,6 +102,8 @@ class XenVMStorage(qubes.storage.VMStorage):
|
|||||||
args['volatiledev'] = self._format_disk_dev(self.volatile_img,
|
args['volatiledev'] = self._format_disk_dev(self.volatile_img,
|
||||||
self.volatile_dev)
|
self.volatile_dev)
|
||||||
|
|
||||||
|
args['kerneldir'] = self.kernels_dir
|
||||||
|
|
||||||
if self.modules_img is not None:
|
if self.modules_img is not None:
|
||||||
args['otherdevs'] = self._format_disk_dev(self.modules_img,
|
args['otherdevs'] = self._format_disk_dev(self.modules_img,
|
||||||
self.modules_dev, rw=self.modules_img_rw)
|
self.modules_dev, rw=self.modules_img_rw)
|
||||||
|
@ -354,8 +354,6 @@ class BaseVM(qubes.PropertyHolder):
|
|||||||
|
|
||||||
args = {}
|
args = {}
|
||||||
args['name'] = self.name
|
args['name'] = self.name
|
||||||
if hasattr(self, 'kernels_dir'):
|
|
||||||
args['kerneldir'] = self.kernels_dir
|
|
||||||
args['uuid'] = str(self.uuid)
|
args['uuid'] = str(self.uuid)
|
||||||
args['vmdir'] = self.dir_path
|
args['vmdir'] = self.dir_path
|
||||||
args['pcidevs'] = ''.join(lxml.etree.tostring(self.lvxml_pci_dev(dev))
|
args['pcidevs'] = ''.join(lxml.etree.tostring(self.lvxml_pci_dev(dev))
|
||||||
|
@ -370,20 +370,6 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
return self.storage.volatile_img
|
return self.storage.volatile_img
|
||||||
|
|
||||||
|
|
||||||
@property
|
|
||||||
def kernels_dir(self):
|
|
||||||
'''Directory where kernel resides.
|
|
||||||
|
|
||||||
If :py:attr:`self.kernel` is :py:obj:`None`, the this points inside
|
|
||||||
:py:attr:`self.dir_path`
|
|
||||||
'''
|
|
||||||
return os.path.join(qubes.config.system_path['qubes_base_dir'],
|
|
||||||
qubes.config.system_path['qubes_kernels_base_dir'], self.kernel) \
|
|
||||||
if self.kernel is not None \
|
|
||||||
else os.path.join(self.dir_path,
|
|
||||||
qubes.config.vm_files['kernels_subdir'])
|
|
||||||
|
|
||||||
|
|
||||||
# XXX shouldn't this go elsewhere?
|
# XXX shouldn't this go elsewhere?
|
||||||
@property
|
@property
|
||||||
def updateable(self):
|
def updateable(self):
|
||||||
@ -525,12 +511,6 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
# Initialize VM image storage class
|
# Initialize VM image storage class
|
||||||
self.storage = qubes.storage.get_storage(self)
|
self.storage = qubes.storage.get_storage(self)
|
||||||
|
|
||||||
# XXX should be moved to defaults in storage class
|
|
||||||
# if self.kernels_dir is not None: # it is None for AdminVM
|
|
||||||
# self.storage.modules_img = os.path.join(self.kernels_dir,
|
|
||||||
# 'modules.img')
|
|
||||||
# self.storage.modules_img_rw = self.kernel is None
|
|
||||||
|
|
||||||
# fire hooks
|
# fire hooks
|
||||||
self.fire_event('domain-init')
|
self.fire_event('domain-init')
|
||||||
|
|
||||||
@ -1102,6 +1082,7 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
p.communicate(input=self.default_user)
|
p.communicate(input=self.default_user)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO move to storage
|
||||||
def create_on_disk(self, source_template=None):
|
def create_on_disk(self, source_template=None):
|
||||||
'''Create files needed for VM.
|
'''Create files needed for VM.
|
||||||
|
|
||||||
@ -1117,7 +1098,7 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
self.storage.create_on_disk(source_template)
|
self.storage.create_on_disk(source_template)
|
||||||
|
|
||||||
if self.updateable:
|
if self.updateable:
|
||||||
kernels_dir = source_template.kernels_dir
|
kernels_dir = source_template.storage.kernels_dir
|
||||||
self.log.info(
|
self.log.info(
|
||||||
'Copying the kernel (unset kernel to use it): {0}'.format(
|
'Copying the kernel (unset kernel to use it): {0}'.format(
|
||||||
kernels_dir))
|
kernels_dir))
|
||||||
@ -1125,8 +1106,7 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
os.mkdir(self.dir_path + '/kernels')
|
os.mkdir(self.dir_path + '/kernels')
|
||||||
for filename in ("vmlinuz", "initramfs", "modules.img"):
|
for filename in ("vmlinuz", "initramfs", "modules.img"):
|
||||||
shutil.copy(os.path.join(kernels_dir, filename),
|
shutil.copy(os.path.join(kernels_dir, filename),
|
||||||
os.path.join(self.dir_path,
|
os.path.join(self.storage.kernels_dir, filename))
|
||||||
qubes.config.vm_files["kernels_subdir"], filename))
|
|
||||||
|
|
||||||
self.log.info('Creating icon symlink: {} -> {}'.format(
|
self.log.info('Creating icon symlink: {} -> {}'.format(
|
||||||
self.icon_path, self.label.icon_path))
|
self.icon_path, self.label.icon_path))
|
||||||
@ -1556,6 +1536,7 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
return qubes.utils.get_disk_usage(self.dir_path)
|
return qubes.utils.get_disk_usage(self.dir_path)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO move to storage
|
||||||
def verify_files(self):
|
def verify_files(self):
|
||||||
'''Verify that files accessed by this machine are sane.
|
'''Verify that files accessed by this machine are sane.
|
||||||
|
|
||||||
@ -1564,14 +1545,16 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
|
|
||||||
self.storage.verify_files()
|
self.storage.verify_files()
|
||||||
|
|
||||||
if not os.path.exists(os.path.join(self.kernels_dir, 'vmlinuz')):
|
if not os.path.exists(
|
||||||
|
os.path.join(self.storage.kernels_dir, 'vmlinuz')):
|
||||||
raise qubes.QubesException('VM kernel does not exist: {0}'.format(
|
raise qubes.QubesException('VM kernel does not exist: {0}'.format(
|
||||||
os.path.join(self.kernels_dir, 'vmlinuz')))
|
os.path.join(self.storage.kernels_dir, 'vmlinuz')))
|
||||||
|
|
||||||
if not os.path.exists(os.path.join(self.kernels_dir, 'initramfs')):
|
if not os.path.exists(
|
||||||
|
os.path.join(self.storage.kernels_dir, 'initramfs')):
|
||||||
raise qubes.QubesException(
|
raise qubes.QubesException(
|
||||||
'VM initramfs does not exist: {0}'.format(
|
'VM initramfs does not exist: {0}'.format(
|
||||||
os.path.join(self.kernels_dir, 'initramfs')))
|
os.path.join(self.storage.kernels_dir, 'initramfs')))
|
||||||
|
|
||||||
self.fire_event('verify-files')
|
self.fire_event('verify-files')
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
<loader>hvmloader</loader>
|
<loader>hvmloader</loader>
|
||||||
<boot dev='cdrom'/>
|
<boot dev='cdrom'/>
|
||||||
<boot dev='hd'/>
|
<boot dev='hd'/>
|
||||||
|
<!-- server_ip is the address of stubdomain. It hosts it's own DNS server. -->
|
||||||
{disable_network1}<cmdline>-net lwip,client_ip={ip},server_ip={dns2},dns={dns1},gw={gateway},netmask={netmask}</cmdline>{disable_network2}
|
{disable_network1}<cmdline>-net lwip,client_ip={ip},server_ip={dns2},dns={dns1},gw={gateway},netmask={netmask}</cmdline>{disable_network2}
|
||||||
</os>
|
</os>
|
||||||
<features>
|
<features>
|
||||||
|
Loading…
Reference in New Issue
Block a user