ia64/xen-unstable
changeset 7485:6f8ce90246f8
Reintroduce the changes made by changeset 7455:021324804fbd, which were
disabled by workaround 7468:17a9f111fa93. We additionally need to set the
FD_CLOEXEC flag on the status fd given to SrvServer when spawning the network
script, as at least on some platforms this causes xend to fail to start
properly.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
disabled by workaround 7468:17a9f111fa93. We additionally need to set the
FD_CLOEXEC flag on the status fd given to SrvServer when spawning the network
script, as at least on some platforms this causes xend to fail to start
properly.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
author | emellor@leeni.uk.xensource.com |
---|---|
date | Sat Oct 22 11:04:45 2005 +0100 (2005-10-22) |
parents | a2cf10b8da5a |
children | e398a9797c4c |
files | tools/python/xen/xend/Vifctl.py tools/python/xen/xend/server/SrvServer.py |
line diff
1.1 --- a/tools/python/xen/util/process.py Sat Oct 22 10:33:26 2005 +0100 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,39 +0,0 @@ 1.4 -# Copyright (C) 2005 Christian Limpach <Christian.Limpach@cl.cam.ac.uk> 1.5 - 1.6 -# os.system() replacement which outputs through the logger 1.7 - 1.8 -import popen2 1.9 -import select 1.10 -import string 1.11 - 1.12 -from xen.xend.XendLogging import log 1.13 - 1.14 -def runscript(cmd): 1.15 - # split after first space, then grab last component of path 1.16 - cmdname = "[%s] " % cmd.split()[0].split('/')[-1] 1.17 - # run command and grab stdin, stdout and stderr 1.18 - cout, cin, cerr = popen2.popen3(cmd) 1.19 - # close stdin to get command to terminate if it waits for input 1.20 - cin.close() 1.21 - # wait for output and process 1.22 - p = select.poll() 1.23 - p.register(cout) 1.24 - p.register(cerr) 1.25 - stdout = "" 1.26 - while True: 1.27 - r = p.poll() 1.28 - for (fd, event) in r: 1.29 - if event == select.POLLHUP: 1.30 - cout.close() 1.31 - cerr.close() 1.32 - return stdout 1.33 - if fd == cout.fileno(): 1.34 - stdout = stdout + cout.readline() 1.35 - if fd == cerr.fileno(): 1.36 - l = cerr.readline() 1.37 - if l[0] == '-': 1.38 - log.debug(cmdname + l[1:].rstrip()) 1.39 - elif l[0] == '*': 1.40 - log.info(cmdname + l[1:].rstrip()) 1.41 - else: 1.42 - log.error(cmdname + l.rstrip())
2.1 --- a/tools/python/xen/xend/Vifctl.py Sat Oct 22 10:33:26 2005 +0100 2.2 +++ b/tools/python/xen/xend/Vifctl.py Sat Oct 22 11:04:45 2005 +0100 2.3 @@ -20,9 +20,9 @@ 2.4 """ 2.5 import os 2.6 2.7 -import xen.util.process 2.8 import XendRoot 2.9 2.10 + 2.11 def network(op): 2.12 """Call a network control script. 2.13 2.14 @@ -32,6 +32,4 @@ def network(op): 2.15 raise ValueError('Invalid operation: ' + op) 2.16 script = XendRoot.instance().get_network_script() 2.17 if script: 2.18 - xen.util.process.runscript(script + " " + op) 2.19 - #os.spawnl(os.P_WAIT, script, script, op) 2.20 - 2.21 + os.spawnl(os.P_WAIT, script, script, op)
3.1 --- a/tools/python/xen/xend/server/SrvServer.py Sat Oct 22 10:33:26 2005 +0100 3.2 +++ b/tools/python/xen/xend/server/SrvServer.py Sat Oct 22 11:04:45 2005 +0100 3.3 @@ -39,6 +39,7 @@ 3.4 # todo Support security settings etc. in the config file. 3.5 # todo Support command-line args. 3.6 3.7 +import fcntl 3.8 from threading import Thread 3.9 3.10 from xen.web.httpserver import HttpServer, UnixHttpServer 3.11 @@ -64,6 +65,11 @@ class XendServers: 3.12 self.servers.append(server) 3.13 3.14 def start(self, status): 3.15 + # Running the network script will spawn another process, which takes 3.16 + # the status fd with it unless we set FD_CLOEXEC. Failing to do this 3.17 + # causes the read in SrvDaemon to hang even when we have written here. 3.18 + fcntl.fcntl(status, fcntl.F_SETFD, fcntl.FD_CLOEXEC) 3.19 + 3.20 Vifctl.network('start') 3.21 threads = [] 3.22 for server in self.servers: