xend: Fix a ssl migration hang issue
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 9 Jan 2009 10:04:24 +0000 (10:04 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 9 Jan 2009 10:04:24 +0000 (10:04 +0000)
When another VM is started by xend, the spawned qemu process will keep
the p2cwrite file descriptor open.
Thus there will be two open descriptors associated with the write end
of the pipe. The read end of the pipe only sees EOF when the qemu
process has terminated.

Signed-off-by: Zhigang Wang <zhigang.x.wang@oracle.com>
tools/python/xen/util/oshelp.py
tools/python/xen/xend/server/relocate.py

index b5a0a2a371dc5e3fb97e488f9d88133ee9e4196f..3efc43d57fdaa0e89c7999e7db152380f705c115 100644 (file)
@@ -5,7 +5,7 @@ def fcntl_setfd_cloexec(file, bool):
         f = fcntl.fcntl(file, fcntl.F_GETFD)
         if bool: f |= fcntl.FD_CLOEXEC
         else: f &= ~fcntl.FD_CLOEXEC
-        fcntl.fcntl(file, fcntl.F_SETFD)
+        fcntl.fcntl(file, fcntl.F_SETFD, f)
 
 def waitstatus_description(st):
         if os.WIFEXITED(st):
index 007884b46aca6e2ef7e41b29ebd42ca2fe46047c..6aa6f83d405ce6f6585cc6d3be92353400db29db 100644 (file)
@@ -122,6 +122,8 @@ class RelocationProtocol(protocol.Protocol):
         if self.transport:
             self.send_reply(["ready", name])
             p2cread, p2cwrite = os.pipe()
+            from xen.util import oshelp
+            oshelp.fcntl_setfd_cloexec(p2cwrite, True)
             threading.Thread(target=connection.SSLSocketServerConnection.recv2fd,
                              args=(self.transport.sock, p2cwrite)).start()
             try: