mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
bitkeeper revision 1.1662.1.16 (42a59915qzJ0eBmm6tVyIARo8G0cXA)
params.py, SrvDaemon.py: Add xenstored. ignore: Add tools/xenstore/xenstored. Signed-off-by: Mike Wray <mike.wray@hp.com> Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
This commit is contained in:
1 parent
29c9e570b1
commit
8359d0386f
3 files changed
+42
-7
No files matched your search
@@ -125,9 +125,13 @@ class Daemon:
|
||||
def cleanup_xend(self, kill=False):
|
||||
return self.cleanup_process(XEND_PID_FILE, "xend", kill)
|
||||
|
||||
def cleanup_xenstored(self, kill=False):
|
||||
return self.cleanup_process(XENSTORED_PID_FILE, "xenstored", kill)
|
||||
|
||||
def cleanup(self, kill=False):
|
||||
self.cleanup_xend(kill=kill)
|
||||
|
||||
self.cleanup_xenstored(kill=kill)
|
||||
|
||||
def status(self):
|
||||
"""Returns the status of the xend daemon.
|
||||
The return value is defined by the LSB:
|
||||
@@ -163,6 +167,27 @@ class Daemon:
|
||||
pidfile.close()
|
||||
return pid
|
||||
|
||||
def start_xenstored(self):
|
||||
"""Fork and exec xenstored, writing its pid to XENSTORED_PID_FILE.
|
||||
"""
|
||||
def mkdirs(p):
|
||||
try:
|
||||
os.makedirs(p)
|
||||
except:
|
||||
pass
|
||||
mkdirs(XENSTORED_RUN_DIR)
|
||||
mkdirs(XENSTORED_LIB_DIR)
|
||||
|
||||
pid = self.fork_pid(XENSTORED_PID_FILE)
|
||||
if pid:
|
||||
# Parent
|
||||
log.info("Started xenstored, pid=%d", pid)
|
||||
else:
|
||||
# Child
|
||||
if XEND_DAEMONIZE and (not XENSTORED_DEBUG):
|
||||
self.daemonize()
|
||||
os.execl("/usr/sbin/xenstored", "xenstored", "--no-fork")
|
||||
|
||||
def daemonize(self):
|
||||
if not XEND_DAEMONIZE: return
|
||||
# Detach from TTY.
|
||||
@@ -193,11 +218,15 @@ class Daemon:
|
||||
4 Insufficient privileges
|
||||
"""
|
||||
xend_pid = self.cleanup_xend()
|
||||
xenstored_pid = self.cleanup_xenstored()
|
||||
|
||||
if self.set_user():
|
||||
return 4
|
||||
os.chdir("/")
|
||||
|
||||
if xenstored_pid == 0:
|
||||
self.start_xenstored()
|
||||
|
||||
if xend_pid > 0:
|
||||
# Trying to run an already-running service is a success.
|
||||
return 0
|
||||
|
||||
@@ -21,9 +21,14 @@ def getenv(var, val, conv=None):
|
||||
return v
|
||||
|
||||
# The following parameters could be placed in a configuration file.
|
||||
XEND_PID_FILE = '/var/run/xend.pid'
|
||||
XEND_TRACE_FILE = '/var/log/xend.trace'
|
||||
XEND_DEBUG_LOG = '/var/log/xend-debug.log'
|
||||
XEND_USER = 'root'
|
||||
XEND_DEBUG = getenv("XEND_DEBUG", 0, conv=int)
|
||||
XEND_DAEMONIZE = getenv("XEND_DAEMONIZE", not XEND_DEBUG, conv=int)
|
||||
XEND_PID_FILE = '/var/run/xend.pid'
|
||||
XEND_TRACE_FILE = '/var/log/xend.trace'
|
||||
XEND_DEBUG_LOG = '/var/log/xend-debug.log'
|
||||
XEND_USER = 'root'
|
||||
XEND_DEBUG = getenv("XEND_DEBUG", 0, conv=int)
|
||||
XEND_DAEMONIZE = getenv("XEND_DAEMONIZE", not XEND_DEBUG, conv=int)
|
||||
|
||||
XENSTORED_PID_FILE = '/var/run/xenstored.pid'
|
||||
XENSTORED_RUN_DIR = '/var/run/xenstored'
|
||||
XENSTORED_LIB_DIR = '/var/lib/xenstored'
|
||||
XENSTORED_DEBUG = getenv("XSDAEMON_DEBUG", 0, conv=int)
|
||||