From 62759fb1f6b817ee9405e84a804ef57d3dd1995a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 10 Feb 2016 17:51:16 +0100 Subject: [PATCH] core: move maxmem default initialization to property itself Also fix (for now?) units - memory_total is int bytes while maxmem in megabytes. QubesOS/qubes-issues#1737 --- qubes/vm/qubesvm.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index 0f7730d8..b7727585 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -177,7 +177,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): default=qubes.config.defaults['memory'], doc='Memory currently available for this VM.') - maxmem = qubes.property('maxmem', type=int, default=None, + maxmem = qubes.property('maxmem', type=int, + default=(lambda self: self.app.host.memory_total / 1024 / 1024 / 2), doc='''Maximum amount of memory available for this VM (for the purpose of the memory balancer).''') @@ -431,12 +432,6 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): assert hasattr(self, 'qid') assert hasattr(self, 'name') - # Not in generic way to not create QubesHost() to frequently - # XXX this doesn't apply, host is instantiated once - if self.maxmem is None and not self.app.vmm.offline_mode: - total_mem_mb = self.app.host.memory_total/1024 - self.maxmem = total_mem_mb/2 - # Linux specific cap: max memory can't scale beyond 10.79*init_mem # see https://groups.google.com/forum/#!topic/qubes-devel/VRqkFj1IOtA if self.maxmem > self.memory * 10: