# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 6f8ce90246f8d420d0ab8edf6a0bdb3b4783e888
# Parent a2cf10b8da5a696075edb9b734d0b37aec0f0c74
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@xxxxxxxxxxxxx>
diff -r a2cf10b8da5a -r 6f8ce90246f8 tools/python/xen/xend/Vifctl.py
--- a/tools/python/xen/xend/Vifctl.py Sat Oct 22 09:33:26 2005
+++ b/tools/python/xen/xend/Vifctl.py Sat Oct 22 10:04:45 2005
@@ -20,8 +20,8 @@
"""
import os
-import xen.util.process
import XendRoot
+
def network(op):
"""Call a network control script.
@@ -32,6 +32,4 @@
raise ValueError('Invalid operation: ' + op)
script = XendRoot.instance().get_network_script()
if script:
- xen.util.process.runscript(script + " " + op)
- #os.spawnl(os.P_WAIT, script, script, op)
-
+ os.spawnl(os.P_WAIT, script, script, op)
diff -r a2cf10b8da5a -r 6f8ce90246f8 tools/python/xen/xend/server/SrvServer.py
--- a/tools/python/xen/xend/server/SrvServer.py Sat Oct 22 09:33:26 2005
+++ b/tools/python/xen/xend/server/SrvServer.py Sat Oct 22 10:04:45 2005
@@ -39,6 +39,7 @@
# todo Support security settings etc. in the config file.
# todo Support command-line args.
+import fcntl
from threading import Thread
from xen.web.httpserver import HttpServer, UnixHttpServer
@@ -64,6 +65,11 @@
self.servers.append(server)
def start(self, status):
+ # Running the network script will spawn another process, which takes
+ # the status fd with it unless we set FD_CLOEXEC. Failing to do this
+ # causes the read in SrvDaemon to hang even when we have written here.
+ fcntl.fcntl(status, fcntl.F_SETFD, fcntl.FD_CLOEXEC)
+
Vifctl.network('start')
threads = []
for server in self.servers:
diff -r a2cf10b8da5a -r 6f8ce90246f8 tools/python/xen/util/process.py
--- a/tools/python/xen/util/process.py Sat Oct 22 09:33:26 2005
+++ /dev/null Sat Oct 22 10:04:45 2005
@@ -1,39 +0,0 @@
-# Copyright (C) 2005 Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
-
-# os.system() replacement which outputs through the logger
-
-import popen2
-import select
-import string
-
-from xen.xend.XendLogging import log
-
-def runscript(cmd):
- # split after first space, then grab last component of path
- cmdname = "[%s] " % cmd.split()[0].split('/')[-1]
- # run command and grab stdin, stdout and stderr
- cout, cin, cerr = popen2.popen3(cmd)
- # close stdin to get command to terminate if it waits for input
- cin.close()
- # wait for output and process
- p = select.poll()
- p.register(cout)
- p.register(cerr)
- stdout = ""
- while True:
- r = p.poll()
- for (fd, event) in r:
- if event == select.POLLHUP:
- cout.close()
- cerr.close()
- return stdout
- if fd == cout.fileno():
- stdout = stdout + cout.readline()
- if fd == cerr.fileno():
- l = cerr.readline()
- if l[0] == '-':
- log.debug(cmdname + l[1:].rstrip())
- elif l[0] == '*':
- log.info(cmdname + l[1:].rstrip())
- else:
- log.error(cmdname + l.rstrip())
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|