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>
This commit is contained in:
Keir Fraser committed 2007-10-12 14:30:41 +01:00
1 parent 4029f2451a
commit e972f8be18
1 file changed
+5 -1
+5 -1
View File
@@ -886,6 +886,7 @@ class XendDomain:
self.domains_lock.acquire()
try:
try:
fd = None
dominfo = self.domain_lookup_nr(domname)
if not dominfo:
@@ -908,8 +909,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)
@@ -921,6 +923,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()
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.