From d456ec45753c5d6a1f9b93c43062f6a817ac3adb Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Fri, 30 Sep 2011 15:23:57 +0200 Subject: [PATCH] dom0/qmemman: call do_balance after each domain list change notification (#246) For unknown reason watch '@releaseDomain' is called twice: first when domain disappeared from xenstore, second when resources (including memory) are freed. So call do_balance after each of this event to redistribute freed memory. --- dom0/qmemman/qmemman.py | 1 - dom0/qmemman/qmemman_server.py | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dom0/qmemman/qmemman.py b/dom0/qmemman/qmemman.py index 66a33207..227cc812 100755 --- a/dom0/qmemman/qmemman.py +++ b/dom0/qmemman/qmemman.py @@ -29,7 +29,6 @@ class SystemState: def del_domain(self, id): self.domdict.pop(id) - self.do_balance() def get_free_xen_memory(self): return self.xc.physinfo()['free_memory']*1024 diff --git a/dom0/qmemman/qmemman_server.py b/dom0/qmemman/qmemman_server.py index cf28e905..63fddfb5 100755 --- a/dom0/qmemman/qmemman_server.py +++ b/dom0/qmemman/qmemman_server.py @@ -29,11 +29,11 @@ class WatchType: class XS_Watcher: def __init__(self): self.handle = xen.lowlevel.xs.xs() - self.handle.watch('/local/domain', WatchType(XS_Watcher.domain_list_changed, None)) + self.handle.watch('@introduceDomain', WatchType(XS_Watcher.domain_list_changed, None)) + self.handle.watch('@releaseDomain', WatchType(XS_Watcher.domain_list_changed, None)) self.watch_token_dict = {} def domain_list_changed(self, param): - time.sleep(0.05) curr = self.handle.ls('', '/local/domain') if curr == None: return @@ -50,6 +50,7 @@ class XS_Watcher: self.watch_token_dict.pop(i) system_state.del_domain(i) global_lock.release() + system_state.do_balance() def meminfo_changed(self, domain_id): untrusted_meminfo_key = self.handle.read('', get_domain_meminfo_key(domain_id))