From: john.levon@sun.com Subject: [PATCH] Fix file resouce leak on resume of suspended managed domains Date: Fri, 12 Oct 2007 06:27:10 -0700 Message-ID: <53138c4401b249907c7b.1192195630@hatchback> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org # HG changeset patch # User john.levon@sun.com # Date 1192195547 25200 # Node ID 53138c4401b249907c7b29bb5a2eeeabfa8c9b8d # Parent 2d3217b3425dd8516468581863461c573b6361ae 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 diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -903,6 +903,7 @@ class XendDomain: self.domains_lock.acquire() try: try: + fd = None dominfo = self.domain_lookup_nr(domname) if not dominfo: @@ -925,8 +926,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) @@ -938,6 +940,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()