qubes: minor fixes in handling defaults

- fix assigning 'template' property - do not do it if VM already have it
set
- cap default maxmem at 4000, as we clamp it to 10*memory anyway (and
  default memory is 400)
This commit is contained in:
Marek Marczykowski-Górecki 2016-08-17 00:50:38 +02:00
parent dd93650ea7
commit 5d8ecd60de
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 2 additions and 2 deletions

View File

@ -103,7 +103,7 @@ class AppVM(qubes.vm.qubesvm.QubesVM):
del self.volume_config[name]['vid']
super(AppVM, self).__init__(app, xml, **kwargs)
if not hasattr(template, 'template') and template is not None:
if not hasattr(self, 'template') and template is not None:
self.template = template
if 'source' not in self.volume_config['root']:
msg = 'missing source for root volume'

View File

@ -213,7 +213,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
maxmem = qubes.property('maxmem', type=int,
setter=_setter_positive_int,
default=(lambda self: self.app.host.memory_total / 1024 / 2),
default=(lambda self: min(self.app.host.memory_total / 1024 / 2, 4000)),
doc='''Maximum amount of memory available for this VM (for the purpose
of the memory balancer).''')