Files
xen/tools/misc/xend
T
Keir Fraser 702890192a xl: init scripts (v2)
Now the init script is called xencommons and, as the name suggests, it
is a common script between xl and xend because it is used to start
xenconsoled, xenstored and xenbackendd and the initialization of these
three daemons has been removed from xend.  The global
xen_toolstack=xl/xend variable has been removed.  Regarding the
network setup, I made the vif scripts follow the same pattern as the
other scripts in xen-backend: a new script called vif-setup is
executed unconditionally. vif-setup is going to do the right thing
depending on the value of the environmental variable "script" (same
technique used before), defaulting to vif-bridge.  In the common
scenario the toolstack doesn't need to set the variable "script"
because vif-bridge is going to be called anyway.  There is no global
network script to setup the network bridges with xl, so if you are
using xl without xend, you need to manually configure the bridges
using your distro network setup, or, if you are lazy, you can just add
something like:

/etc/xen/scripts/network-bridge start

to your rc.local.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2010-06-07 15:49:46 +01:00

111 lines
2.7 KiB
Python

#!/usr/bin/env python
# -*- mode: python; -*-
#============================================================================
# Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
# Copyright (C) 2005-2006 XenSource Inc
#============================================================================
"""Xen management daemon.
Provides console server and HTTP management api.
Run:
xend start
Restart:
xend restart
The daemon is stopped with:
xend stop
The daemon should reconnect to device control interfaces
and recover its state when restarted.
On Solaris, the daemons are SMF managed, and you should not attempt
to start xend by hand.
"""
import fcntl
import glob
import os
import os.path
import sys
import socket
import signal
import time
import commands
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_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_blktapctrl()
return daemon.start()
elif sys.argv[1] == 'trace_start':
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_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
if __name__ == '__main__':
sys.exit(main())