New patch submitted by Erez Sh (erez(a)redhat.com)
You can review this change at:
http://gerrit.usersys.redhat.com/732
commit 64f1f3b58dd740ba736d1279137f05da2462c18c
Author: Erez Sh <erez(a)redhat.com>
Date: Tue Jul 19 17:12:10 2011 +0300
BZ#723198 - Add timeout to migration: abort it if no progress has been made in a
while
Change-Id: If2eef2e38adbc5f187a51fa0caff8566af76e812
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index 21961c2..318080a 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -222,13 +222,28 @@ class MigrationMonitorThread(threading.Thread):
def run(self):
self._vm.log.debug('starting migration monitor thread')
+ lastProgressTime = time.time()
+ smallest_dataRemaining = None
+
while not self._stop.isSet():
self._stop.wait(self._MIGRATION_MONITOR_INTERVAL)
jobType, timeElapsed, _, \
- dataTotal, dataProcessed, _, \
+ dataTotal, dataProcessed, dataRemaining, \
memTotal, memProcessed, _, \
fileTotal, fileProcessed, _ = self._vm._dom.jobInfo()
+ if smallest_dataRemaining is None or smallest_dataRemaining >
dataRemaining:
+ smallest_dataRemaining = dataRemaining
+ lastProgressTime = time.time()
+ elif time.time() - lastProgressTime > config.getint('vars',
'migration_timeout'):
+ # Migration is stuck, abort
+ self._vm.log.warn(
+ 'Migration is stuck: Hasn\'t progressed in %s seconds.
Aborting.' % (time.time() - lastProgressTime)
+ )
+ self._vm._dom.abortJob()
+ self.stop()
+ break
+
if jobType == 0:
continue
@@ -240,6 +255,7 @@ class MigrationMonitorThread(threading.Thread):
% (timeElapsed/1000,dataProgress,memProgress)
)
+
def stop(self):
self._vm.log.debug('stopping migration monitor thread')
self._stop.set()