]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
xend: Fix file resouce leak on resume of suspended managed domains.
authorKeir Fraser <keir@xensource.com>
Fri, 12 Oct 2007 13:30:41 +0000 (14:30 +0100)
committerKeir Fraser <keir@xensource.com>
Fri, 12 Oct 2007 13:30:41 +0000 (14:30 +0100)
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>
xen-unstable changeset:   16106:628f8ec692a0153af03a81b04f41b9edfcca7aad
xen-unstable date:        Fri Oct 12 14:30:41 2007 +0100

tools/python/xen/xend/XendDomain.py

index 502199114b133363bceb3cdb000fa48fc9252d55..10fcecdda299a195b4aa04fafe6ad3353910b136 100644 (file)
@@ -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()