ia64/xen-unstable

changeset 16127:628f8ec692a0

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 <gary.pennington@sun.com>
author Keir Fraser <keir@xensource.com>
date Fri Oct 12 14:30:41 2007 +0100 (2007-10-12)
parents 1c4203730ff6
children 22175cd36a10
files tools/python/xen/xend/XendDomain.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Fri Oct 12 13:06:16 2007 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Fri Oct 12 14:30:41 2007 +0100
     1.3 @@ -886,6 +886,7 @@ class XendDomain:
     1.4          self.domains_lock.acquire()
     1.5          try:
     1.6              try:
     1.7 +                fd = None
     1.8                  dominfo = self.domain_lookup_nr(domname)
     1.9  
    1.10                  if not dominfo:
    1.11 @@ -908,8 +909,9 @@ class XendDomain:
    1.12                      oflags = os.O_RDONLY
    1.13                      if hasattr(os, "O_LARGEFILE"):
    1.14                          oflags |= os.O_LARGEFILE
    1.15 +                    fd = os.open(chkpath, oflags)
    1.16                      XendCheckpoint.restore(self,
    1.17 -                                           os.open(chkpath, oflags),
    1.18 +                                           fd,
    1.19                                             dominfo,
    1.20                                             paused = start_paused)
    1.21                      os.unlink(chkpath)
    1.22 @@ -921,6 +923,8 @@ class XendDomain:
    1.23                  log.exception("Exception occurred when resuming")
    1.24                  raise XendError("Error occurred when resuming: %s" % str(ex))
    1.25          finally:
    1.26 +            if fd is not None:
    1.27 +                os.close(fd)
    1.28              self.domains_lock.release()
    1.29  
    1.30