debuggers.hg

view tools/misc/xend @ 21595:8bcaec29574e

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>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jun 07 15:49:46 2010 +0100 (2010-06-07)
parents 9ced12c28e05
children
line source
1 #!/usr/bin/env python
2 # -*- mode: python; -*-
3 #============================================================================
4 # Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
5 # Copyright (C) 2005-2006 XenSource Inc
6 #============================================================================
8 """Xen management daemon.
9 Provides console server and HTTP management api.
11 Run:
12 xend start
14 Restart:
15 xend restart
17 The daemon is stopped with:
18 xend stop
20 The daemon should reconnect to device control interfaces
21 and recover its state when restarted.
23 On Solaris, the daemons are SMF managed, and you should not attempt
24 to start xend by hand.
25 """
26 import fcntl
27 import glob
28 import os
29 import os.path
30 import sys
31 import socket
32 import signal
33 import time
34 import commands
36 from xen.xend.server import SrvDaemon
38 class CheckError(ValueError):
39 pass
41 def hline():
42 print >>sys.stderr, "*" * 70
44 def msg(message):
45 print >>sys.stderr, "*" * 3, message
47 def check_logging():
48 """Check python logging is installed and raise an error if not.
49 Logging is standard from Python 2.3 on.
50 """
51 try:
52 import logging
53 except ImportError:
54 hline()
55 msg("Python logging is not installed.")
56 msg("Use 'make install-logging' at the xen root to install.")
57 msg("")
58 msg("Alternatively download and install from")
59 msg("http://www.red-dove.com/python_logging.html")
60 hline()
61 raise CheckError("logging is not installed")
63 def check_user():
64 """Check that the effective user id is 0 (root).
65 """
66 if os.geteuid() != 0:
67 hline()
68 msg("Xend must be run as root.")
69 hline()
70 raise CheckError("invalid user")
72 def start_daemon(daemon, *args):
73 if os.fork() == 0:
74 os.execvp(daemon, (daemon,) + args)
76 def start_blktapctrl():
77 start_daemon("blktapctrl", "")
79 def main():
80 try:
81 check_logging()
82 check_user()
83 except CheckError:
84 sys.exit(1)
86 daemon = SrvDaemon.instance()
87 if not sys.argv[1:]:
88 print 'usage: %s {start|stop|reload|restart}' % sys.argv[0]
89 elif sys.argv[1] == 'start':
90 if os.uname()[0] != "SunOS":
91 start_blktapctrl()
92 return daemon.start()
93 elif sys.argv[1] == 'trace_start':
94 start_blktapctrl()
95 return daemon.start(trace=1)
96 elif sys.argv[1] == 'stop':
97 return daemon.stop()
98 elif sys.argv[1] == 'reload':
99 return daemon.reloadConfig()
100 elif sys.argv[1] == 'restart':
101 start_blktapctrl()
102 return daemon.stop() or daemon.start()
103 elif sys.argv[1] == 'status':
104 return daemon.status()
105 else:
106 print 'not an option:', sys.argv[1]
107 return 1
109 if __name__ == '__main__':
110 sys.exit(main())