aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormjw@wray-m-3.hpl.hp.com <mjw@wray-m-3.hpl.hp.com>2004-06-24 15:24:36 +0000
committermjw@wray-m-3.hpl.hp.com <mjw@wray-m-3.hpl.hp.com>2004-06-24 15:24:36 +0000
commitd8855c862afc3d243ea7e8232ebb95bf541a77a7 (patch)
tree471c9a6fccdc2ddbe1f6271133ac4e3da91e7b31
parent5eb94a602b09559f1193fae2935d970da4d89c31 (diff)
downloadxen-d8855c862afc3d243ea7e8232ebb95bf541a77a7.tar.gz
xen-d8855c862afc3d243ea7e8232ebb95bf541a77a7.tar.bz2
xen-d8855c862afc3d243ea7e8232ebb95bf541a77a7.zip
bitkeeper revision 1.1010.1.2 (40daf234LK7ohaP4f1QHGPJq0t3yZw)
Change configs to live in /etc/xen, other stuff in /var/xen. Update xendomains to use xm.
-rw-r--r--tools/examples/Makefile9
-rwxr-xr-xtools/examples/init.d/xendomains46
-rw-r--r--tools/xenmgr/lib/XendBridge.py11
-rw-r--r--tools/xenmgr/lib/XendRoot.py6
-rw-r--r--tools/xenmgr/lib/xm/create.py17
-rw-r--r--tools/xenmgr/lib/xm/shutdown.py4
6 files changed, 48 insertions, 45 deletions
diff --git a/tools/examples/Makefile b/tools/examples/Makefile
index ed8e4c71b1..3f7075ed1d 100644
--- a/tools/examples/Makefile
+++ b/tools/examples/Makefile
@@ -1,19 +1,20 @@
INSTALL = $(wildcard *.py)
ETC = defaults democd netbsd xmdefaults
+ETCDIR = /etc/xen
INITD = init.d/xendomains init.d/xend
all:
install: all
mkdir -p $(prefix)/usr/bin
- mkdir -p $(prefix)/etc/xc
- mkdir -p $(prefix)/etc/xc/auto
+ mkdir -p $(prefix)$(ETCDIR)
+ mkdir -p $(prefix)$(ETCDIR)/auto
mkdir -p $(prefix)/etc/init.d
install -m0755 $(INSTALL) $(prefix)/usr/bin
for i in $(ETC); \
- do [ -a $(prefix)/etc/xc/$$i ] || \
- install -m0644 $$i $(prefix)/etc/xc; \
+ do [ -a $(prefix)/$(ETCDIR)/$$i ] || \
+ install -m0644 $$i $(prefix)$(ETCDIR); \
done
install -m0755 $(INITD) $(prefix)/etc/init.d
diff --git a/tools/examples/init.d/xendomains b/tools/examples/init.d/xendomains
index fa96ff8378..41524e6f57 100755
--- a/tools/examples/init.d/xendomains
+++ b/tools/examples/init.d/xendomains
@@ -19,6 +19,9 @@ RETVAL=0
INITD=/etc/init.d/
+AUTODIR=/etc/xen/auto
+LOCKFILE=/var/lock/subsys/xendomains
+
if [ -e /lib/lsb ]; then
# assume an LSB-compliant distro (Debian with LSB package,
# recent-enough SuSE, others...)
@@ -52,24 +55,23 @@ fi
start() {
- if [ -f /var/lock/subsys/xendomains ]; then return; fi
+ if [ -f $LOCKFILE ]; then return; fi
echo -n $"Starting auto Xen domains:"
- # we expect config scripts for auto starting domains to be in
- # /etc/xc/auto/ - they could just be symlinks to files elsewhere
- if [ -d /etc/xc/auto ] &&
- [ $(ls /etc/xc/auto/ | wc -l) -gt 0 ]; then
+ # We expect config scripts for auto starting domains to be in
+ # AUTODIR - they could just be symlinks to files elsewhere
+ if [ -d $AUTODIR ] && [ $(ls $AUTODIR | wc -l) -gt 0 ]; then
+ touch $LOCKFILE
- # create all domains with config files in /etc/xc/auto
- for dom in /etc/xc/auto/*; do
- xc_dom_create.py -q -f $dom
+ # Create all domains with config files in AUTODIR.
+ for dom in $AUTODIR/*; do
+ xm create --quiet --defaults $dom
if [ $? -ne 0 ]; then
RETVAL=$?
fi
done
- touch /var/lock/subsys/xendomains
fi
on_fn_exit
@@ -78,40 +80,24 @@ start() {
stop()
{
# NB. this shuts down ALL Xen domains (politely), not just the ones in
- # /etc/xc/auto/*
+ # AUTODIR/*
# This is because it's easier to do ;-) but arguably if this script is run
# on system shutdown then it's also the right thing to do.
echo -n $"Shutting down all Xen domains:"
- if [ -d /var/run/xendomains ] &&
- [ $(ls /var/run/xendomains/ | wc -l) -gt 0 ]; then
-
- cd /var/run/xendomains/
-
- for pid in *; do
-
- kill -s SIGTERM $(cat $pid)
-
- done
+ xm shutdown --all --wait --norestart
- fi
-
- sleep 3 # avoid races
-
- xc_dom_control.py shutdown all -w # shut down all domains, politely and wait
- # for all to exit
-
RETVAL=$?
- [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/xendomains
+ [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
on_fn_exit
}
# This does NOT necessarily restart all running domains: instead it
# stops all running domains and then boots all the domains specified in
-# /etc/xc/auto. If other domains have been started manually then they will
+# AUTODIR. If other domains have been started manually then they will
# not get restarted.
# Commented out to avoid confusion!
#
@@ -149,7 +135,7 @@ case "$1" in
# ;;
status)
- xc_dom_control.py list
+ xm list
;;
*)
diff --git a/tools/xenmgr/lib/XendBridge.py b/tools/xenmgr/lib/XendBridge.py
index 1be802477d..3ea16d57bf 100644
--- a/tools/xenmgr/lib/XendBridge.py
+++ b/tools/xenmgr/lib/XendBridge.py
@@ -12,6 +12,7 @@ os.defpath = os.defpath + ':/sbin:/usr/sbin:/usr/local/sbin'
CMD_IFCONFIG = 'ifconfig'
CMD_ROUTE = 'route'
CMD_BRCTL = 'brctl'
+CMD_IPTABLES = "iptables"
DEFAULT_BRIDGE = 'nbe-br'
DEFAULT_INTERFACE = 'eth0'
@@ -61,6 +62,16 @@ def vif_bridge_rem(dom, vif, bridge=None):
d = { 'bridge': bridge, 'vif': vif_dev(dom, vif) }
cmd(CMD_BRCTL, 'delif %(bridge)s %(vif)s' % d)
+def vif_restrict_addr(dom, vif, addr, delete=0):
+ d = { 'vif': vif_dev(dom, vif), 'addr': addr}
+ if delete:
+ d['flag'] = '-D'
+ else:
+ d['flag' = '-A'
+ cmd(CMD_IPTABLES, '-P FORWARD DROP')
+ cmd(CMD_IPTABLES, '%(flag)s FORWARD -m physdev --physdev-in %(vif)s -s %(addr)s -j ACCEPT' % d)
+ cmd(CMD_IPTABLES, '%(flag)s FORWARD -m physdev --physdev-out %(vif)s -d %(addr)s -j ACCEPT' % d)
+
def bridge_create(bridge=None, **kwd):
"""Create a bridge.
Defaults hello time to 0, forward delay to 0 and stp off.
diff --git a/tools/xenmgr/lib/XendRoot.py b/tools/xenmgr/lib/XendRoot.py
index 6d9903a91d..665f5df29e 100644
--- a/tools/xenmgr/lib/XendRoot.py
+++ b/tools/xenmgr/lib/XendRoot.py
@@ -30,13 +30,13 @@ def last_reboot():
class XendRoot:
"""Root of the management classes."""
- lastboot_default = "/etc/xen/xend/lastboot"
+ lastboot_default = "/var/xen/lastboot"
"""Default path to the root of the database."""
- dbroot_default = "/etc/xen/xend/xenmgr-db"
+ dbroot_default = "/var/xen/xend-db"
"""Default path to the config file."""
- config_default = "/etc/xen/xenmgr-config.sxp"
+ config_default = "/etc/xen/xend-config.sxp"
"""Environment variable used to override config_default."""
config_var = "XEND_CONFIG"
diff --git a/tools/xenmgr/lib/xm/create.py b/tools/xenmgr/lib/xm/create.py
index e3ccad20b7..3d4165d1f2 100644
--- a/tools/xenmgr/lib/xm/create.py
+++ b/tools/xenmgr/lib/xm/create.py
@@ -24,11 +24,11 @@ gopts.opt('quiet', short='q',
use="Quiet.")
gopts.opt('path', val='PATH',
- fn=set_value, default='.:/etc/xc',
+ fn=set_value, default='.:/etc/xen',
use="Search path for default scripts.")
gopts.opt('defaults', short='f', val='FILE',
- fn=set_value, default='xmdefaults',
+ fn=set_value, default='defaults',
use="Use the given default script.")
gopts.opt('config', short='F', val='FILE',
@@ -220,12 +220,13 @@ def configure_vifs(config_devs, opts):
config_vif.append(['bridge', bridge])
config_devs.append(['device', config_vif])
-## if vfr_ipaddr:
-## config_vfr = ['vfr']
-## idx = 0 # No way of saying which IP is for which vif?
-## for ip in vfr_ipaddr:
-## config_vfr.append(['vif', ['id', idx], ['ip', ip]])
-## config.append(config_vfr)
+def configure_vfr(config, opts):
+ if not opts.ipaddr: return
+ config_vfr = ['vfr']
+ idx = 0 # No way of saying which IP is for which vif?
+ for ip in opts.ipaddr:
+ config_vfr.append(['vif', ['id', idx], ['ip', ip]])
+ config.append(config_vfr)
def make_config(opts):
diff --git a/tools/xenmgr/lib/xm/shutdown.py b/tools/xenmgr/lib/xm/shutdown.py
index 90fff21f6a..7cdcc63105 100644
--- a/tools/xenmgr/lib/xm/shutdown.py
+++ b/tools/xenmgr/lib/xm/shutdown.py
@@ -24,6 +24,10 @@ gopts.opt('wait', short='w',
fn=set_true, default=0,
use='Wait for shutdown to complete.')
+gopts.opt('norestart', short='n',
+ fn=set_true, default=0,
+ use='Prevent domain restart.')
+
def shutdown(opts, doms, wait):
def domains():
return [ int(a) for a in server.xend_domains() ]