Add volume_config to AppVM and TemplateVM
This commit is contained in:
parent
24193c4308
commit
9d646aabd3
@ -3,16 +3,44 @@
|
|||||||
|
|
||||||
import qubes.events
|
import qubes.events
|
||||||
import qubes.vm.qubesvm
|
import qubes.vm.qubesvm
|
||||||
|
from qubes.config import defaults
|
||||||
|
|
||||||
|
|
||||||
class AppVM(qubes.vm.qubesvm.QubesVM):
|
class AppVM(qubes.vm.qubesvm.QubesVM):
|
||||||
'''Application VM'''
|
'''Application VM'''
|
||||||
|
|
||||||
template = qubes.VMProperty('template', load_stage=4,
|
template = qubes.VMProperty('template',
|
||||||
vmclass=qubes.vm.templatevm.TemplateVM,
|
load_stage=4,
|
||||||
ls_width=31,
|
vmclass=qubes.vm.templatevm.TemplateVM,
|
||||||
doc='Template, on which this AppVM is based.')
|
ls_width=31,
|
||||||
|
doc='Template, on which this AppVM is based.')
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.volumes = {}
|
||||||
|
self.volume_config = {
|
||||||
|
'root': {
|
||||||
|
'name': 'root',
|
||||||
|
'pool': 'default',
|
||||||
|
'volume_type': 'snapshot',
|
||||||
|
},
|
||||||
|
'private': {
|
||||||
|
'name': 'private',
|
||||||
|
'pool': 'default',
|
||||||
|
'volume_type': 'read-write',
|
||||||
|
'size': defaults['private_img_size'],
|
||||||
|
},
|
||||||
|
'volatile': {
|
||||||
|
'name': 'volatile',
|
||||||
|
'pool': 'default',
|
||||||
|
'volume_type': 'volatile',
|
||||||
|
'size': defaults['root_img_size'],
|
||||||
|
},
|
||||||
|
'kernel': {
|
||||||
|
'name': 'kernel',
|
||||||
|
'pool': 'linux-kernel',
|
||||||
|
'volume_type': 'read-only',
|
||||||
|
}
|
||||||
|
}
|
||||||
super(AppVM, self).__init__(*args, **kwargs)
|
super(AppVM, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
@qubes.events.handler('domain-load')
|
@qubes.events.handler('domain-load')
|
||||||
@ -20,4 +48,4 @@ class AppVM(qubes.vm.qubesvm.QubesVM):
|
|||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
# Some additional checks for template based VM
|
# Some additional checks for template based VM
|
||||||
assert self.template
|
assert self.template
|
||||||
#self.template.appvms.add(self) # XXX
|
# self.template.appvms.add(self) # XXX
|
||||||
|
@ -464,7 +464,6 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
|||||||
self.features['check-updates'] = None
|
self.features['check-updates'] = None
|
||||||
|
|
||||||
# will be initialized after loading all the properties
|
# will be initialized after loading all the properties
|
||||||
self.storage = None
|
|
||||||
|
|
||||||
# fire hooks
|
# fire hooks
|
||||||
if xml is None:
|
if xml is None:
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
import qubes
|
import qubes
|
||||||
import qubes.config
|
import qubes.config
|
||||||
import qubes.vm.qubesvm
|
import qubes.vm.qubesvm
|
||||||
|
from qubes.config import defaults
|
||||||
|
|
||||||
|
|
||||||
class TemplateVM(qubes.vm.qubesvm.QubesVM):
|
class TemplateVM(qubes.vm.qubesvm.QubesVM):
|
||||||
'''Template for AppVM'''
|
'''Template for AppVM'''
|
||||||
@ -23,20 +25,40 @@ class TemplateVM(qubes.vm.qubesvm.QubesVM):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
assert 'template' not in kwargs, "A TemplateVM can not have a template"
|
assert 'template' not in kwargs, "A TemplateVM can not have a template"
|
||||||
|
self.volumes = {}
|
||||||
|
self.volume_config = {
|
||||||
|
'root': {
|
||||||
|
'name': 'root',
|
||||||
|
'pool': 'default',
|
||||||
|
'volume_type': 'origin',
|
||||||
|
'size': defaults['root_img_size'],
|
||||||
|
},
|
||||||
|
'private': {
|
||||||
|
'name': 'private',
|
||||||
|
'pool': 'default',
|
||||||
|
'volume_type': 'read-write',
|
||||||
|
'size': defaults['private_img_size'],
|
||||||
|
},
|
||||||
|
'volatile': {
|
||||||
|
'name': 'volatile',
|
||||||
|
'pool': 'default',
|
||||||
|
'size': defaults['root_img_size'],
|
||||||
|
'volume_type': 'volatile',
|
||||||
|
},
|
||||||
|
'kernel': {
|
||||||
|
'name': 'kernel',
|
||||||
|
'pool': 'linux-kernel',
|
||||||
|
'volume_type': 'read-only',
|
||||||
|
}
|
||||||
|
}
|
||||||
super(TemplateVM, self).__init__(*args, **kwargs)
|
super(TemplateVM, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
# Some additional checks for template based VM
|
|
||||||
# TODO find better way
|
|
||||||
# assert self.root_img is not None, "Missing root_img for standalone VM!"
|
|
||||||
|
|
||||||
|
|
||||||
def clone_disk_files(self, src):
|
def clone_disk_files(self, src):
|
||||||
super(TemplateVM, self).clone_disk_files(src)
|
super(TemplateVM, self).clone_disk_files(src)
|
||||||
|
|
||||||
# Create root-cow.img
|
# Create root-cow.img
|
||||||
self.commit_changes()
|
self.commit_changes()
|
||||||
|
|
||||||
|
|
||||||
def commit_changes(self):
|
def commit_changes(self):
|
||||||
'''Commit changes to template'''
|
'''Commit changes to template'''
|
||||||
self.log.debug('commit_changes()')
|
self.log.debug('commit_changes()')
|
||||||
@ -45,6 +67,6 @@ class TemplateVM(qubes.vm.qubesvm.QubesVM):
|
|||||||
assert not self.is_running(), \
|
assert not self.is_running(), \
|
||||||
'Attempt to commit changes on running Template VM!'
|
'Attempt to commit changes on running Template VM!'
|
||||||
|
|
||||||
self.log.info(
|
self.log.info('Commiting template update; COW: {}'.format(
|
||||||
'Commiting template update; COW: {}'.format(self.rootcow_img))
|
self.rootcow_img))
|
||||||
self.storage.commit_template_changes()
|
self.storage.commit_template_changes()
|
||||||
|
Loading…
Reference in New Issue
Block a user