ia64/xen-unstable

changeset 5358:4ad402c55b9f

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>
author cl349@firebug.cl.cam.ac.uk
date Tue Jun 07 12:54:45 2005 +0000 (2005-06-07)
parents 9ea2524b7d10
children fd8e5378d8ac
files BitKeeper/etc/ignore tools/python/xen/xend/server/SrvDaemon.py tools/python/xen/xend/server/params.py
line diff
     1.1 --- a/BitKeeper/etc/ignore	Tue Jun 07 12:43:58 2005 +0000
     1.2 +++ b/BitKeeper/etc/ignore	Tue Jun 07 12:54:45 2005 +0000
     1.3 @@ -130,6 +130,7 @@ tools/xcutils/xc_restore
     1.4  tools/xcutils/xc_save
     1.5  tools/xenstore/testsuite/tmp/*
     1.6  tools/xenstore/xen
     1.7 +tools/xenstore/xenstored
     1.8  tools/xenstore/xenstored_test
     1.9  tools/xenstore/xs_random
    1.10  tools/xenstore/xs_stress
     2.1 --- a/tools/python/xen/xend/server/SrvDaemon.py	Tue Jun 07 12:43:58 2005 +0000
     2.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py	Tue Jun 07 12:54:45 2005 +0000
     2.3 @@ -125,9 +125,13 @@ class Daemon:
     2.4      def cleanup_xend(self, kill=False):
     2.5          return self.cleanup_process(XEND_PID_FILE, "xend", kill)
     2.6  
     2.7 +    def cleanup_xenstored(self, kill=False):
     2.8 +        return self.cleanup_process(XENSTORED_PID_FILE, "xenstored", kill)
     2.9 +
    2.10      def cleanup(self, kill=False):
    2.11          self.cleanup_xend(kill=kill)
    2.12 -            
    2.13 +        self.cleanup_xenstored(kill=kill)
    2.14 +
    2.15      def status(self):
    2.16          """Returns the status of the xend daemon.
    2.17          The return value is defined by the LSB:
    2.18 @@ -163,6 +167,27 @@ class Daemon:
    2.19              pidfile.close()
    2.20          return pid
    2.21  
    2.22 +    def start_xenstored(self):
    2.23 +        """Fork and exec xenstored, writing its pid to XENSTORED_PID_FILE.
    2.24 +        """
    2.25 +        def mkdirs(p):
    2.26 +            try:
    2.27 +                os.makedirs(p)
    2.28 +            except:
    2.29 +                pass
    2.30 +        mkdirs(XENSTORED_RUN_DIR)
    2.31 +        mkdirs(XENSTORED_LIB_DIR)
    2.32 +        
    2.33 +        pid = self.fork_pid(XENSTORED_PID_FILE)
    2.34 +        if pid:
    2.35 +            # Parent
    2.36 +            log.info("Started xenstored, pid=%d", pid)
    2.37 +        else:
    2.38 +            # Child
    2.39 +            if XEND_DAEMONIZE and (not XENSTORED_DEBUG):
    2.40 +                self.daemonize()
    2.41 +            os.execl("/usr/sbin/xenstored", "xenstored", "--no-fork")
    2.42 +
    2.43      def daemonize(self):
    2.44          if not XEND_DAEMONIZE: return
    2.45          # Detach from TTY.
    2.46 @@ -193,11 +218,15 @@ class Daemon:
    2.47          4  Insufficient privileges
    2.48          """
    2.49          xend_pid = self.cleanup_xend()
    2.50 +        xenstored_pid = self.cleanup_xenstored()
    2.51  
    2.52          if self.set_user():
    2.53              return 4
    2.54          os.chdir("/")
    2.55  
    2.56 +        if xenstored_pid == 0:
    2.57 +            self.start_xenstored()
    2.58 +
    2.59          if xend_pid > 0:
    2.60              # Trying to run an already-running service is a success.
    2.61              return 0
     3.1 --- a/tools/python/xen/xend/server/params.py	Tue Jun 07 12:43:58 2005 +0000
     3.2 +++ b/tools/python/xen/xend/server/params.py	Tue Jun 07 12:54:45 2005 +0000
     3.3 @@ -21,9 +21,14 @@ def getenv(var, val, conv=None):
     3.4      return v
     3.5  
     3.6  # The following parameters could be placed in a configuration file.
     3.7 -XEND_PID_FILE     = '/var/run/xend.pid'
     3.8 -XEND_TRACE_FILE   = '/var/log/xend.trace'
     3.9 -XEND_DEBUG_LOG    = '/var/log/xend-debug.log'
    3.10 -XEND_USER         = 'root'
    3.11 -XEND_DEBUG        = getenv("XEND_DEBUG",     0, conv=int)
    3.12 -XEND_DAEMONIZE    = getenv("XEND_DAEMONIZE", not XEND_DEBUG, conv=int)
    3.13 +XEND_PID_FILE      = '/var/run/xend.pid'
    3.14 +XEND_TRACE_FILE    = '/var/log/xend.trace'
    3.15 +XEND_DEBUG_LOG     = '/var/log/xend-debug.log'
    3.16 +XEND_USER          = 'root'
    3.17 +XEND_DEBUG         = getenv("XEND_DEBUG",     0, conv=int)
    3.18 +XEND_DAEMONIZE     = getenv("XEND_DAEMONIZE", not XEND_DEBUG, conv=int)
    3.19 +
    3.20 +XENSTORED_PID_FILE = '/var/run/xenstored.pid'
    3.21 +XENSTORED_RUN_DIR  = '/var/run/xenstored'
    3.22 +XENSTORED_LIB_DIR  = '/var/lib/xenstored'
    3.23 +XENSTORED_DEBUG    = getenv("XSDAEMON_DEBUG", 0, conv=int)