From 9192a42b919e7d1a7ef3b8aa50c5934ce08cee37 Mon Sep 17 00:00:00 2001 From: Rafal Wojtczuk Date: Fri, 22 Jul 2011 13:40:21 +0200 Subject: [PATCH] qmemman: when balooning, make sure that past mem-set will not steal memory --- dom0/qmemman/qmemman.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dom0/qmemman/qmemman.py b/dom0/qmemman/qmemman.py index 41685978..66a33207 100755 --- a/dom0/qmemman/qmemman.py +++ b/dom0/qmemman/qmemman.py @@ -81,6 +81,15 @@ class SystemState: except XenAPI.Failure: pass +# this is called at the end of ballooning, when we have Xen free mem already +# make sure that past mem_set will not decrease Xen free mem + def inhibit_balloon_up(self): + for i in self.domdict.keys(): + dom = self.domdict[i] + if dom.memory_actual is not None and dom.memory_actual + 200*1024 < dom.last_target: + print "Preventing balloon up to", dom.last_target + self.mem_set(i, dom.memory_actual) + #perform memory ballooning, across all domains, to add "memsize" to Xen free memory def do_balloon(self, memsize): MAX_TRIES = 20 @@ -88,12 +97,14 @@ class SystemState: prev_memory_actual = None for i in self.domdict.keys(): self.domdict[i].no_progress = False + print "do_balloon start" while True: + self.refresh_memactual() xenfree = self.get_free_xen_memory() print 'got xenfree=', xenfree if xenfree >= memsize + self.XEN_FREE_MEM_MIN: + self.inhibit_balloon_up() return True - self.refresh_memactual() if prev_memory_actual is not None: for i in prev_memory_actual.keys(): if prev_memory_actual[i] == self.domdict[i].memory_actual: