From: Keir Fraser Date: Fri, 12 Oct 2007 13:30:41 +0000 (+0100) Subject: xend: Fix file resouce leak on resume of suspended managed domains. X-Git-Tag: 3.1.2-rc1~13 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b93f46377e5261f6b074955a869065e3f4495cd5;p=people%2Fvhanquez%2Fxen.git xend: Fix file resouce leak on resume of suspended managed domains. When a suspended managed domain is resumed, the checkpoint file is removed, but xend retains a reference to the removed file. This represents a resource leak. Fixed by ensuring that the file reference is closed correctly. Signed-off-by: Gary Pennington xen-unstable changeset: 16106:628f8ec692a0153af03a81b04f41b9edfcca7aad xen-unstable date: Fri Oct 12 14:30:41 2007 +0100 --- diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index 502199114..10fcecdda 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -864,6 +864,7 @@ class XendDomain: self.domains_lock.acquire() try: try: + fd = None dominfo = self.domain_lookup_nr(domname) if not dominfo: @@ -886,8 +887,9 @@ class XendDomain: oflags = os.O_RDONLY if hasattr(os, "O_LARGEFILE"): oflags |= os.O_LARGEFILE + fd = os.open(chkpath, oflags) XendCheckpoint.restore(self, - os.open(chkpath, oflags), + fd, dominfo, paused = start_paused) os.unlink(chkpath) @@ -899,6 +901,8 @@ class XendDomain: log.exception("Exception occurred when resuming") raise XendError("Error occurred when resuming: %s" % str(ex)) finally: + if fd is not None: + os.close(fd) self.domains_lock.release()