From c444ebc5f8ebe65358905b1e7f93a453e2987944 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 7 Jun 2011 16:19:52 +0200 Subject: [PATCH] dom0/qmemman: different approach of mem-set and maxmem (libxl way) Libxl stores maxmem in xenstore (/local/domain/X/memory/static-max) and sets maxmem and target_mem to actual memory. So qmemman should use xenstore entry as memory_maximum (when exists) and also adjust maxmem when changing domain memory. --- dom0/qmemman/qmemman.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dom0/qmemman/qmemman.py b/dom0/qmemman/qmemman.py index b62f08fd..2c30ebb7 100755 --- a/dom0/qmemman/qmemman.py +++ b/dom0/qmemman/qmemman.py @@ -44,7 +44,9 @@ class SystemState: id = str(domain['domid']) if self.domdict.has_key(id): self.domdict[id].memory_actual = domain['mem_kb']*1024 - self.domdict[id].memory_maximum = domain['maxmem_kb']*1024 + self.domdict[id].memory_maximum = self.xs.read('', '/local/domain/%s/memory/static-max' % str(id)) + if not self.domdict[id].memory_maximum: + self.domdict[id].memory_maximum = domain['maxmem_kb']*1024 #the below works (and is fast), but then 'xm list' shows unchanged memory value def mem_set(self, id, val): @@ -54,6 +56,7 @@ class SystemState: #can happen in the middle of domain shutdown #apparently xc.lowlevel throws exceptions too try: + self.xc.domain_setmaxmem(int(id), val/1024 + 1024) # LIBXL_MAXMEM_CONSTANT=1024 self.xc.domain_set_target_mem(int(id), val/1024) except: pass