diff -rupN xen-3.2.0.orig/tools/examples/init.d/blktapctrl xen-3.2.0.new/tools/examples/init.d/blktapctrl --- xen-3.2.0.orig/tools/examples/init.d/blktapctrl 1969-12-31 19:00:00.000000000 -0500 +++ xen-3.2.0.new/tools/examples/init.d/blktapctrl 2008-02-01 17:45:49.000000000 -0500 @@ -0,0 +1,80 @@ +#!/bin/bash +# +# blktapctrl Script to start the Xen blktapctrl daemon +# +# Author: Daniel Berrange +# +# chkconfig: 2345 97 01 +# description: Starts and stops the Xen blktapctrl daemon. +### BEGIN INIT INFO +# Provides: blktapctrl +# Required-Start: $syslog $remote_fs +# Should-Start: +# Required-Stop: $syslog $remote_fs +# Should-Stop: +# Default-Start: 3 4 5 +# Default-Stop: 0 1 2 6 +# Default-Enabled: yes +# Short-Description: Start/stop blktapctrl +# Description: Starts and stops the Xen blktapctrl daemon +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +if [ ! -d /proc/xen ]; then + exit 0 +fi +if ! grep -q "control_d" /proc/xen/capabilities ; then + exit 0 +fi + +# Default config params +BLKTAPCTRL_ARGS= + +# User customized params +test -f /etc/sysconfig/blktapctrl && . /etc/sysconfig/blktapctrl + +start() { + echo -n $"Starting xen blktapctrl daemon: " + /usr/sbin/blktapctrl $BLKTAPCTRL_ARGS + RETVAL=$? + test $RETVAL = 0 && echo_success || echo_failure + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/blktapctrl +} + +stop() { + echo -n $"Stoping xen blktapctrl daemon: " + # Refuse to stop blktapctrl as it'll kill all guests + RETVAL=1 + echo_failure + echo +} + +rcstatus() { + status blktapctrl + RETVAL=$? + test $RETVAL = 0 && echo_success || echo_failure + echo +} + + +RETVAL=0 +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + rcstatus + ;; + *) + echo $"Usage: $0 {start|stop|status}" + exit 1 +esac + +exit $RETVAL + diff -rupN xen-3.2.0.orig/tools/examples/init.d/sysconfig.blktapctrl xen-3.2.0.new/tools/examples/init.d/sysconfig.blktapctrl --- xen-3.2.0.orig/tools/examples/init.d/sysconfig.blktapctrl 1969-12-31 19:00:00.000000000 -0500 +++ xen-3.2.0.new/tools/examples/init.d/sysconfig.blktapctrl 2008-02-01 17:49:46.000000000 -0500 @@ -0,0 +1 @@ +#BLKTAPCTRL_ARGS= diff -rupN xen-3.2.0.orig/tools/examples/init.d/sysconfig.xenconsoled xen-3.2.0.new/tools/examples/init.d/sysconfig.xenconsoled --- xen-3.2.0.orig/tools/examples/init.d/sysconfig.xenconsoled 1969-12-31 19:00:00.000000000 -0500 +++ xen-3.2.0.new/tools/examples/init.d/sysconfig.xenconsoled 2008-02-01 17:49:56.000000000 -0500 @@ -0,0 +1,12 @@ + +# Log all hypervisor messages (cf xm dmesg) +#XENCONSOLED_LOG_HYPERVISOR=no + +# Log all guest console output (cf xm console) +#XENCONSOLED_LOG_GUESTS=no + +# Location to store guest & hypervisor logs +#XENCONSOLED_LOG_DIR=/var/log/xen/console + +#XENCONSOLED_ARGS= + diff -rupN xen-3.2.0.orig/tools/examples/init.d/sysconfig.xenstored xen-3.2.0.new/tools/examples/init.d/sysconfig.xenstored --- xen-3.2.0.orig/tools/examples/init.d/sysconfig.xenstored 1969-12-31 19:00:00.000000000 -0500 +++ xen-3.2.0.new/tools/examples/init.d/sysconfig.xenstored 2008-02-01 17:50:02.000000000 -0500 @@ -0,0 +1,4 @@ + +#XENSTORED_PID="/var/run/xenstore.pid" +#XENSTORED_ARGS= + diff -rupN xen-3.2.0.orig/tools/examples/init.d/xenconsoled xen-3.2.0.new/tools/examples/init.d/xenconsoled --- xen-3.2.0.orig/tools/examples/init.d/xenconsoled 1969-12-31 19:00:00.000000000 -0500 +++ xen-3.2.0.new/tools/examples/init.d/xenconsoled 2008-02-01 18:07:00.000000000 -0500 @@ -0,0 +1,121 @@ +#!/bin/bash +# +# xenconsoled Script to start and stop the Xen xenconsoled daemon +# +# Author: Daniel P. Berrange +# +# chkconfig: 2345 97 01 +# description: Starts and stops the Xen control daemon. +### BEGIN INIT INFO +# Provides: xenconsoled +# Required-Start: $syslog $remote_fs +# Should-Start: +# Required-Stop: $syslog $remote_fs +# Should-Stop: +# Default-Start: 3 4 5 +# Default-Stop: 0 1 2 6 +# Default-Enabled: yes +# Short-Description: Start/stop xenconsoled +# Description: Starts and stops the Xen xenconsoled daemon. +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +if [ ! -d /proc/xen ]; then + exit 0 +fi +if ! grep -q "control_d" /proc/xen/capabilities ; then + exit 0 +fi + +# Default config params +XENCONSOLED_LOG_HYPERVISOR=no +XENCONSOLED_LOG_GUESTS=no +XENCONSOLED_LOG_DIR=/var/log/xen/console +XENCONSOLED_ARGS= + +# User customized params +test -f /etc/sysconfig/xenconsoled && . /etc/sysconfig/xenconsoled + +XENCONSOLED_LOG=none +if [ "$XENCONSOLED_LOG_HYPERVISOR" = "yes" ] +then + if [ "$XENCONSOLED_LOG_GUESTS" = "yes" ] + then + XENCONSOLED_LOG=all + else + XENCONSOLED_LOG=hv + fi +else + if [ "$XENCONSOLED_LOG_GUESTS" = "yes" ] + then + XENCONSOLED_LOG=guest + fi +fi + +start() { + echo -n $"Starting xenconsoled daemon: " + /usr/sbin/xenconsoled --log=$XENCONSOLED_LOG --log-dir=$XENCONSOLED_LOG_DIR $XENCONSOLED_ARGS + RETVAL=$? + test $RETVAL = 0 && echo_success || echo_failure + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/xenconsoled +} + +stop() { + echo -n $"Stopping xenconsoled daemon: " + killproc xenconsoled > /dev/null + RETVAL=$? + test $RETVAL = 0 && echo_success || echo_failure + echo + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/xenconsoled +} + +rcstatus() { + status xenconsoled + RETVAL=$? + test $RETVAL = 0 && echo_success || echo_failure + echo +} + +reload() { + echo -n $"Reloading xenconsoled daemon: " + killproc xenconsoled -HUP > /dev/null + RETVAL=$? + test $RETVAL = 0 && echo_success || echo_failure + echo +} + +RETVAL=0 +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + rcstatus + ;; + reload) + reload + ;; + restart|force-reload) + stop + start + ;; + condrestart) + if [ -f /var/lock/subsys/xenconsoled ] + then + stop + start + fi + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}" + exit 1 +esac + +exit $RETVAL + diff -rupN xen-3.2.0.orig/tools/examples/init.d/xend xen-3.2.0.new/tools/examples/init.d/xend --- xen-3.2.0.orig/tools/examples/init.d/xend 2008-02-01 17:13:01.000000000 -0500 +++ xen-3.2.0.new/tools/examples/init.d/xend 2008-02-01 17:45:22.000000000 -0500 @@ -19,48 +19,79 @@ # Description: Starts and stops the Xen control daemon. ### END INIT INFO +# Source function library. +. /etc/rc.d/init.d/functions + +if [ ! -d /proc/xen ]; then + exit 0 +fi if ! grep -q "control_d" /proc/xen/capabilities ; then exit 0 fi -# Wait for Xend to be up -function await_daemons_up -{ - i=1 - rets=10 - xend status - while [ $? -ne 0 -a $i -lt $rets ]; do - sleep 1 - echo -n . - i=$(($i + 1)) - xend status - done +# Default config params +start() { + echo -n $"Starting xend daemon: " + /usr/sbin/xend + RETVAL=$? + test $RETVAL = 0 && echo_success || echo_failure + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/xend +} + +stop() { + echo -n $"Stopping xend daemon: " + killproc xend > /dev/null + RETVAL=$? + test $RETVAL = 0 && echo_success || echo_failure + echo + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/xend } +rcstatus() { + status xend + RETVAL=$? + test $RETVAL = 0 && echo_success || echo_failure + echo +} + +reload() { + echo -n $"Reloading xend daemon: " + killproc xend -HUP > /dev/null + RETVAL=$? + test $RETVAL = 0 && echo_success || echo_failure + echo +} + +RETVAL=0 case "$1" in start) - xend start - await_daemons_up + start ;; stop) - xend stop + stop ;; status) - xend status + rcstatus ;; reload) - xend reload + reload ;; restart|force-reload) - xend restart - await_daemons_up + stop + start ;; + condrestart) + if [ -f /var/lock/subsys/xend ] + then + stop + start + fi + ;; *) - # do not advertise unreasonable commands that there is no reason - # to use with this device - echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}" + echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}" exit 1 esac -exit $? +exit $RETVAL diff -rupN xen-3.2.0.orig/tools/examples/init.d/xenstored xen-3.2.0.new/tools/examples/init.d/xenstored --- xen-3.2.0.orig/tools/examples/init.d/xenstored 1969-12-31 19:00:00.000000000 -0500 +++ xen-3.2.0.new/tools/examples/init.d/xenstored 2008-02-01 18:06:42.000000000 -0500 @@ -0,0 +1,83 @@ +#!/bin/bash +# +# xenstored Script to start and stop the Xen control daemon. +# +# Author: Daniel Berrange >sys.stderr, result[1] - sys.exit(1) - sys.path.append(result[1]) from xen.xend.server import SrvDaemon -class CheckError(ValueError): - pass - -def hline(): - print >>sys.stderr, "*" * 70 - -def msg(message): - print >>sys.stderr, "*" * 3, message - -def check_logging(): - """Check python logging is installed and raise an error if not. - Logging is standard from Python 2.3 on. - """ - try: - import logging - except ImportError: - hline() - msg("Python logging is not installed.") - msg("Use 'make install-logging' at the xen root to install.") - msg("") - msg("Alternatively download and install from") - msg("http://www.red-dove.com/python_logging.html") - hline() - raise CheckError("logging is not installed") - -def check_user(): - """Check that the effective user id is 0 (root). - """ - if os.geteuid() != 0: - hline() - msg("Xend must be run as root.") - hline() - raise CheckError("invalid user") - -def start_daemon(daemon, *args): - if os.fork() == 0: - os.execvp(daemon, (daemon,) + args) - -def start_xenstored(): - pidfname = "/var/run/xenstore.pid" - try: - f = open(pidfname, "a") - try: - fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB) - rootdir = os.getenv("XENSTORED_ROOTDIR") or "/var/lib/xenstored" - for i in glob.glob(rootdir + "/tdb*"): - try: - os.unlink(i) - except: - pass - os.unlink(pidfname) - except: - pass - f.close() - except: - pass - XENSTORED_TRACE = os.getenv("XENSTORED_TRACE") - cmd = "xenstored --pid-file /var/run/xenstore.pid" - if XENSTORED_TRACE: - cmd += " -T /var/log/xen/xenstored-trace.log" - s,o = commands.getstatusoutput(cmd) - -def start_consoled(): - XENCONSOLED_TRACE = os.getenv("XENCONSOLED_TRACE") - args = "" - if XENCONSOLED_TRACE: - args += "--log=" + XENCONSOLED_TRACE - start_daemon("xenconsoled", args) - -def start_blktapctrl(): - start_daemon("blktapctrl", "") - def main(): - try: - check_logging() - check_user() - except CheckError: - sys.exit(1) - daemon = SrvDaemon.instance() - if not sys.argv[1:]: - print 'usage: %s {start|stop|reload|restart}' % sys.argv[0] - elif sys.argv[1] == 'start': - if os.uname()[0] != "SunOS": - start_xenstored() - start_consoled() - start_blktapctrl() - return daemon.start() - elif sys.argv[1] == 'trace_start': - start_xenstored() - start_consoled() - start_blktapctrl() - return daemon.start(trace=1) - elif sys.argv[1] == 'stop': - return daemon.stop() - elif sys.argv[1] == 'reload': - return daemon.reloadConfig() - elif sys.argv[1] == 'restart': - start_xenstored() - start_consoled() - start_blktapctrl() - return daemon.stop() or daemon.start() - elif sys.argv[1] == 'status': - return daemon.status() - else: - print 'not an option:', sys.argv[1] - return 1 + return daemon.start() if __name__ == '__main__': sys.exit(main()) diff -rup xen-3.3.0.orig/tools/python/xen/xend/osdep.py xen-3.3.0.new/tools/python/xen/xend/osdep.py --- xen-3.3.0.orig/tools/python/xen/xend/osdep.py 2008-08-22 10:49:08.000000000 +0100 +++ xen-3.3.0.new/tools/python/xen/xend/osdep.py 2008-08-29 11:08:54.000000000 +0100 @@ -26,7 +26,7 @@ _scripts_dir = { _xend_autorestart = { "NetBSD": True, - "Linux": True, + "Linux": False, "SunOS": False, } diff -rup xen-3.3.0.orig/tools/python/xen/xend/server/SrvDaemon.py xen-3.3.0.new/tools/python/xen/xend/server/SrvDaemon.py --- xen-3.3.0.orig/tools/python/xen/xend/server/SrvDaemon.py 2008-08-22 10:49:08.000000000 +0100 +++ xen-3.3.0.new/tools/python/xen/xend/server/SrvDaemon.py 2008-08-29 11:08:54.000000000 +0100 @@ -109,7 +109,14 @@ class Daemon: # Fork, this allows the group leader to exit, # which means the child can never again regain control of the # terminal - if os.fork(): + child = os.fork() + if child: + if not osdep.xend_autorestart: + pidfile = open(XEND_PID_FILE, 'w') + try: + pidfile.write(str(child)) + finally: + pidfile.close() os._exit(0) # Detach from standard file descriptors, and redirect them to