From 51e14fc8bbe877f155c1a544446879a506989c4c Mon Sep 17 00:00:00 2001 From: Rafal Wojtczuk Date: Thu, 9 Sep 2010 12:36:18 +0200 Subject: [PATCH] qmemman: trigger do_balance() on receiving /proc/meminfo data --- dom0/qmemman/qmemman.py | 1 + dom0/qmemman/qmemman_server.py | 17 ----------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/dom0/qmemman/qmemman.py b/dom0/qmemman/qmemman.py index a76b0bfa..eb9b4328 100755 --- a/dom0/qmemman/qmemman.py +++ b/dom0/qmemman/qmemman.py @@ -96,6 +96,7 @@ class SystemState: def refresh_meminfo(self, domid, val): qmemman_algo.refresh_meminfo_for_domain(self.domdict[domid], val) + self.do_balance() def is_balance_req_significant(self, memset_reqs): total_memory_transfer = 0 diff --git a/dom0/qmemman/qmemman_server.py b/dom0/qmemman/qmemman_server.py index 4a95fee3..52e35664 100755 --- a/dom0/qmemman/qmemman_server.py +++ b/dom0/qmemman/qmemman_server.py @@ -9,7 +9,6 @@ from qmemman import SystemState system_state = SystemState() global_lock = thread.allocate_lock() -additional_balance_delay = 0 def only_in_first_list(l1, l2): ret=[] @@ -75,7 +74,6 @@ class QMemmanReqHandler(SocketServer.BaseRequestHandler): """ def handle(self): - global additional_balance_delay got_lock = False # self.request is the TCP socket connected to the client while True: @@ -92,7 +90,6 @@ class QMemmanReqHandler(SocketServer.BaseRequestHandler): got_lock = True if system_state.do_balloon(int(self.data)): resp = "OK\n" - additional_balance_delay = 5 else: resp = "FAIL\n" self.request.send(resp) @@ -109,22 +106,8 @@ def start_server(): os.umask(077) server.serve_forever() -def start_balancer(): - global additional_balance_delay - while True: - time.sleep(1) - if additional_balance_delay != 0: - print 'waiting additional_balance_delay to allow VM to start' - time.sleep(additional_balance_delay) - additional_balance_delay = 0 - global_lock.acquire() - if additional_balance_delay == 0: - system_state.do_balance() - global_lock.release() - class QMemmanServer: @staticmethod def main(): thread.start_new_thread(start_server, tuple([])) - thread.start_new_thread(start_balancer, tuple([])) XS_Watcher().watch_loop()