Procházet zdrojové kódy

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)
Marek Marczykowski-Górecki před 7 roky
rodič
revize
5d8ecd60de
2 změnil soubory, kde provedl 2 přidání a 2 odebrání
  1. 1 1
      qubes/vm/appvm.py
  2. 1 1
      qubes/vm/qubesvm.py

+ 1 - 1
qubes/vm/appvm.py

@@ -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'

+ 1 - 1
qubes/vm/qubesvm.py

@@ -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).''')