def __init__(self, app, xml, *args, **kwargs): self.volume_config = copy.deepcopy(self.default_volume_config) template = kwargs.get('template', None) if xml is None: assert template is not None if not getattr(template, 'template_for_dispvms', False): raise qubes.exc.QubesValueError( 'template for DispVM ({}) needs to be an AppVM with ' 'template_for_dispvms=True'.format(template.name)) if 'dispid' not in kwargs: kwargs['dispid'] = app.domains.get_new_unused_dispid() if 'name' not in kwargs: kwargs['name'] = 'disp' + str(kwargs['dispid']) if template is not None: # template is only passed if the AppVM is created, in other cases we # don't need to patch the volume_config because the config is # coming from XML, already as we need it for name, config in template.volume_config.items(): # in case the template vm has more volumes add them to own # config if name not in self.volume_config: self.volume_config[name] = config.copy() if 'vid' in self.volume_config[name]: del self.volume_config[name]['vid'] # copy pool setting from base AppVM; root and private would be # in the same pool anyway (because of snap_on_start), # but not volatile, which could be surprising elif 'pool' not in self.volume_config[name] \ and 'pool' in config: self.volume_config[name]['pool'] = config['pool'] super().__init__(app, xml, *args, **kwargs) if xml is None: # by default inherit properties from the DispVM template proplist = [ prop.__name__ for prop in template.property_list() if prop.clone and prop.__name__ not in ['template'] ] # Do not overwrite properties that have already been set to a # non-default value. self_props = [ prop.__name__ for prop in self.property_list() if self.property_is_default(prop) ] self.clone_properties(template, set(proplist).intersection(self_props)) self.firewall.clone(template.firewall) self.features.update(template.features) self.tags.update(template.tags)
def __init__(self, app, xml, *args, **kwargs): self.volume_config = { 'root': { 'name': 'root', 'snap_on_start': True, 'save_on_stop': False, 'rw': True, 'source': None, }, 'private': { 'name': 'private', 'snap_on_start': True, 'save_on_stop': False, 'rw': True, 'source': None, }, 'volatile': { 'name': 'volatile', 'snap_on_start': False, 'save_on_stop': False, 'rw': True, 'size': qubes.config.defaults['root_img_size'] + qubes.config.defaults['private_img_size'], }, 'kernel': { 'name': 'kernel', 'snap_on_start': False, 'save_on_stop': False, 'rw': False, } } template = kwargs.get('template', None) if xml is None: assert template is not None if not getattr(template, 'template_for_dispvms', False): raise qubes.exc.QubesValueError( 'template for DispVM ({}) needs to be an AppVM with ' 'template_for_dispvms=True'.format(template.name)) if 'dispid' not in kwargs: kwargs['dispid'] = app.domains.get_new_unused_dispid() if 'name' not in kwargs: kwargs['name'] = 'disp' + str(kwargs['dispid']) if template is not None: # template is only passed if the AppVM is created, in other cases we # don't need to patch the volume_config because the config is # coming from XML, already as we need it for name, config in template.volume_config.items(): # in case the template vm has more volumes add them to own # config if name not in self.volume_config: self.volume_config[name] = config.copy() if 'vid' in self.volume_config[name]: del self.volume_config[name]['vid'] super(DispVM, self).__init__(app, xml, *args, **kwargs) if xml is None: # by default inherit properties from the DispVM template proplist = [ prop.__name__ for prop in template.property_list() if prop.clone and prop.__name__ not in ['template'] ] self_props = [prop.__name__ for prop in self.property_list()] self.clone_properties(template, set(proplist).intersection(self_props)) self.firewall.clone(template.firewall) self.features.update(template.features) self.tags.update(template.tags)
def __init__(self, app, xml, *args, **kwargs): self.volume_config = { 'root': { 'name': 'root', 'snap_on_start': True, 'save_on_stop': False, 'rw': True, 'source': None, }, 'private': { 'name': 'private', 'snap_on_start': True, 'save_on_stop': False, 'rw': True, 'source': None, }, 'volatile': { 'name': 'volatile', 'snap_on_start': False, 'save_on_stop': False, 'rw': True, 'size': qubes.config.defaults['root_img_size'] + qubes.config.defaults['private_img_size'], }, 'kernel': { 'name': 'kernel', 'snap_on_start': False, 'save_on_stop': False, 'rw': False, } } template = kwargs.get('template', None) if xml is None: assert template is not None if not getattr(template, 'template_for_dispvms', False): raise qubes.exc.QubesValueError( 'template for DispVM ({}) needs to be an AppVM with ' 'template_for_dispvms=True'.format(template.name)) if 'dispid' not in kwargs: kwargs['dispid'] = app.domains.get_new_unused_dispid() if 'name' not in kwargs: kwargs['name'] = 'disp' + str(kwargs['dispid']) if template is not None: # template is only passed if the AppVM is created, in other cases we # don't need to patch the volume_config because the config is # coming from XML, already as we need it for name, config in template.volume_config.items(): # in case the template vm has more volumes add them to own # config if name not in self.volume_config: self.volume_config[name] = config.copy() if 'vid' in self.volume_config[name]: del self.volume_config[name]['vid'] super(DispVM, self).__init__(app, xml, *args, **kwargs) if xml is None: # by default inherit properties from the DispVM template proplist = [prop.__name__ for prop in template.property_list() if prop.clone and prop.__name__ not in ['template']] self_props = [prop.__name__ for prop in self.property_list()] self.clone_properties(template, set(proplist).intersection( self_props)) self.firewall.clone(template.firewall) self.features.update(template.features) self.tags.update(template.tags)