From: Miroslav Rezanina Date: Thu, 28 Oct 2010 10:40:32 +0000 (+0100) Subject: Do not wait for memory teardown when live migrate X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~11328 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0f114a518128d42af0f82216ced729e9077eb62e;p=xen.git Do not wait for memory teardown when live migrate When trying to live migrate guest with great memory (e.g. 20 GB), there's delay caused by destroying source copy of domain. To speed up this process we can close socket before starting guest destroy, as source guest is not running anymore. Signed-off-by: Miroslav Rezanina Signed-off-by: Ian Jackson --- diff --git a/tools/python/xen/xend/XendCheckpoint.py b/tools/python/xen/xend/XendCheckpoint.py index 4c68fb38af..fa09757a48 100644 --- a/tools/python/xen/xend/XendCheckpoint.py +++ b/tools/python/xen/xend/XendCheckpoint.py @@ -65,7 +65,7 @@ def insert_after(list, pred, value): return -def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1): +def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1,sock=None): from xen.xend import XendDomain try: @@ -162,6 +162,13 @@ def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1): if checkpoint: dominfo.resumeDomain() else: + if live and sock != None: + try: + sock.shutdown(2) + except: + pass + sock.close() + dominfo.destroy() dominfo.testDeviceComplete() try: diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index 71aae2a58e..1d4da8ffbc 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -1412,7 +1412,7 @@ class XendDomain: try: try: XendCheckpoint.save(p2cwrite, dominfo, True, live, dst, - node=node) + node=node,sock=sock) except Exception, ex: m_dsterr = None try: @@ -1436,15 +1436,16 @@ class XendDomain: raise XendError("%s (from %s)" % (m_dsterr.group(2), dst)) raise finally: - try: - sock.shutdown(2) - except: - # Probably the socket is already disconnected by sock.close - # in the destination side. - # Ignore the exception because it has nothing to do with - # an exception of XendCheckpoint.save. - pass - sock.close() + if not live: + try: + sock.shutdown(2) + except: + # Probably the socket is already disconnected by sock.close + # in the destination side. + # Ignore the exception because it has nothing to do with + # an exception of XendCheckpoint.save. + pass + sock.close() os.close(p2cread) os.close(p2cwrite) @@ -1469,7 +1470,7 @@ class XendDomain: try: try: XendCheckpoint.save(sock.fileno(), dominfo, True, live, - dst, node=node) + dst, node=node,sock=sock) except Exception, ex: m_dsterr = None try: @@ -1493,15 +1494,16 @@ class XendDomain: raise XendError("%s (from %s)" % (m_dsterr.group(2), dst)) raise finally: - try: - sock.shutdown(2) - except: - # Probably the socket is already disconnected by sock.close - # in the destination side. - # Ignore the exception because it has nothing to do with - # an exception of XendCheckpoint.save. - pass - sock.close() + if not live: + try: + sock.shutdown(2) + except: + # Probably the socket is already disconnected by sock.close + # in the destination side. + # Ignore the exception because it has nothing to do with + # an exception of XendCheckpoint.save. + pass + sock.close() def domain_save(self, domid, dst, checkpoint=False): """Start saving a domain to file.