ia64/xen-unstable

changeset 1637:ebcc736aed4f

bitkeeper revision 1.1040 (40e2a907DdoQGsSPReiCr496bEgtTQ)

Remove obsolete files.
author kaf24@scramble.cl.cam.ac.uk
date Wed Jun 30 11:50:31 2004 +0000 (2004-06-30)
parents 5f52968e99a7
children 5810a8961c25 d353df1b15d2
files .rootkeys tools/examples/Makefile tools/examples/defaults tools/examples/democd tools/examples/init.d/xendomains tools/examples/netbsd tools/examples/xc_dom_control.py tools/examples/xc_dom_create.py
line diff
     1.1 --- a/.rootkeys	Wed Jun 30 11:44:47 2004 +0000
     1.2 +++ b/.rootkeys	Wed Jun 30 11:50:31 2004 +0000
     1.3 @@ -155,14 +155,8 @@ 40e1b09db5mN69Ijj0X_Eol-S7dXiw tools/Mak
     1.4  3f776bd1Hy9rn69ntXBhPReUFw9IEA tools/Makefile
     1.5  401d7e160vaxMBAUSLSicuZ7AQjJ3w tools/examples/Makefile
     1.6  401d7e16UgeqroJQTIhwkrDVkoWgZQ tools/examples/README
     1.7 -401d7e16GS8YesM1zateRbaOoI6YLQ tools/examples/defaults
     1.8 -401d7e16NoWaBGC1RXbBcqAOr5Uaag tools/examples/democd
     1.9  405ff55dawQyCHFEnJ067ChPRoXBBA tools/examples/init.d/xend
    1.10 -40278d94cIUWl2eRgnwZtr4hTyWT1Q tools/examples/init.d/xendomains
    1.11 -40278d91ZjLhxdjjrGe8HEdwHLj5xQ tools/examples/netbsd
    1.12  40e15b7edWEtBf_oe3eBwGKuh1dyzQ tools/examples/vifctl
    1.13 -401d7e16NpnVrFSsR7lKKKfTwCYvWA tools/examples/xc_dom_control.py
    1.14 -401d7e16RJj-lbtsVEjua6HYAIiKiA tools/examples/xc_dom_create.py
    1.15  40cf2937oKlROYOJTN8GWwWM5AmjBg tools/examples/xmdefaults
    1.16  40dfd40auJwNnb8NoiSnRkvZaaXkUg tools/examples/xmnetbsd
    1.17  3fbba6dbDfYvJSsw9500b4SZyUhxjQ tools/libxc/Makefile
     2.1 --- a/tools/examples/Makefile	Wed Jun 30 11:44:47 2004 +0000
     2.2 +++ b/tools/examples/Makefile	Wed Jun 30 11:50:31 2004 +0000
     2.3 @@ -1,21 +1,17 @@
     2.4  
     2.5  INSTALL  = $(wildcard *.py)
     2.6  
     2.7 -ETC	 = defaults democd netbsd xmdefaults
     2.8 +ETC	 = xmdefaults
     2.9  ETCDIR   = /etc/xen
    2.10  
    2.11 -INITD    = init.d/xendomains init.d/xend
    2.12 +INITD    = init.d/xend
    2.13  
    2.14  XEND     = vifctl
    2.15  XEND_DIR = $(ETCDIR)/xend
    2.16  
    2.17  all: 
    2.18  
    2.19 -install: all install-bin install-initd install-etc install-xend
    2.20 -
    2.21 -install-bin:
    2.22 -	mkdir -p $(prefix)/usr/bin
    2.23 -	install -m0755 $(INSTALL) $(prefix)/usr/bin
    2.24 +install: all install-initd install-etc install-xend
    2.25  
    2.26  install-initd:
    2.27  	mkdir -p $(prefix)/etc/init.d
    2.28 @@ -36,5 +32,4 @@ install-xend:
    2.29  	    install -m0755 $$i $(prefix)$(XEND_DIR); \
    2.30  	done
    2.31  
    2.32 -
    2.33  clean:
     3.1 --- a/tools/examples/defaults	Wed Jun 30 11:44:47 2004 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,97 +0,0 @@
     3.4 -import xenctl.ip
     3.5 -
     3.6 -##### Edit this python file to reflect the configuration of your system
     3.7 -
     3.8 -##### This example script expects a variable called 'vmid' to be set.
     3.9 -
    3.10 -def config_usage ():
    3.11 -    print >>sys.stderr,"""
    3.12 -The config file '%s' requires the following variable to be defined:
    3.13 - vmid             -- Numeric identifier for the new domain, used to calculate
    3.14 -                     the VM's IP address and root partition. E.g. -Dvmid=1
    3.15 -""" % config_file
    3.16 -
    3.17 -
    3.18 -try:
    3.19 -    vmid=int(vmid) # convert to integer
    3.20 -except:
    3.21 -    print >>sys.stderr,"%s: This script expects 'vmid' to be set using -D vmid=X" % config_file
    3.22 -    assert()
    3.23 -
    3.24 -if vmid == 0:
    3.25 -    print >>sys.stderr,"%s: 'vmid' must be greater than 0" % config_file
    3.26 -    assert()
    3.27 -
    3.28 -
    3.29 -# STEP 1. Specify kernel image file and otional ramdisk. Can be gzip'ed.
    3.30 -image = "../../../install/boot/xenolinux.gz"
    3.31 -ramdisk = ""
    3.32 -#ramdisk = "/boot/initrd.gz"
    3.33 -builder_fn='linux' # this is a linux domain
    3.34 -
    3.35 -# STEP 2. The initial memory allocation (in megabytes) for the new domain.
    3.36 -mem_size = 64
    3.37 -
    3.38 -# STEP 3. A handy name for your new domain.
    3.39 -domain_name = "This is VM %d" % vmid
    3.40 -
    3.41 -# STEP 4. Which CPU to start domain on? 
    3.42 -#cpu = -1   # leave to Xen to pick
    3.43 -cpu = vmid  # set based on vmid (mod number of CPUs)
    3.44 -
    3.45 -
    3.46 -# STEP 5. Specify IP address(es), for the new domain.  You need to
    3.47 -# configure IP addrs within the domain just as you do normally.  This
    3.48 -# is just to let Xen know about them so it can route packets
    3.49 -# appropriately.
    3.50 -
    3.51 -#vfr_ipaddr = ["111.222.333.444","222.333.444.555"]
    3.52 -vfr_ipaddr  = [xenctl.ip.add_offset_to_ip(xenctl.ip.get_current_ipaddr(),vmid),
    3.53 -	       xenctl.ip.add_offset_to_ip('169.254.1.0',vmid),]
    3.54 -
    3.55 -
    3.56 -# STEP 6. Identify any physcial partitions or virtual disks you want the
    3.57 -# domain to have access to, and what you want them accessible as
    3.58 -# e.g. vbd_list = [ ('phy:sda1','sda1', 'w'),
    3.59 -#	 ('phy:sda%d' % (3+vmid), 'hda2', 'r'), 
    3.60 -#	 ('vd:as73gd784dh','hda1','w'),
    3.61 -#	 ('phy:cdrom','hdd','r')
    3.62 -
    3.63 -vbd_list = [ ('phy:sda%d'%(7+vmid),'sda1','w' ), 
    3.64 -	     ('phy:sda6','sda6','r') ]
    3.65 -
    3.66 -
    3.67 -
    3.68 -# STEP 5b. Set the VBD expertise level.  Most people should leave this
    3.69 -# on 0, at least to begin with - this script can detect most dangerous
    3.70 -# disk sharing between domains and with this set to zero it will only
    3.71 -# allow read only sharing.
    3.72 -
    3.73 -vbd_expert = 0
    3.74 -
    3.75 -
    3.76 -# STEP 7. Build the command line for the new domain. Edit as req'd.
    3.77 -# You only need the ip= line if you're NFS booting or the root file system
    3.78 -# doesn't set it later e.g. in ifcfg-eth0 or via DHCP
    3.79 -# You can use 'extrabit' to set the runlevel and custom environment
    3.80 -# variables used by custom rc scripts (e.g. VMID=, usr= )
    3.81 -
    3.82 -netmask = xenctl.ip.get_current_ipmask()
    3.83 -gateway = xenctl.ip.get_current_ipgw()
    3.84 -nfsserv = '169.254.1.0'  
    3.85 -
    3.86 -cmdline_ip = "ip="+vfr_ipaddr[0]+":"+nfsserv+":"+gateway+":"+netmask+"::eth0:off"
    3.87 -cmdline_root = "root=/dev/sda1 ro"
    3.88 -#cmdline_root = "root=/dev/nfs nfsroot=/full/path/to/root/directory"
    3.89 -cmdline_extra = "4 VMID=%d usr=/dev/sda6" % vmid
    3.90 -
    3.91 -
    3.92 -# STEP 8. Set according to whether you want the script to watch the domain 
    3.93 -# and auto-restart it should it die or exit.
    3.94 -
    3.95 -auto_restart = False
    3.96 -#auto_restart = True
    3.97 -
    3.98 -# STEP 9. (Optional) Define a console port number for the new domain.
    3.99 -
   3.100 -# console_port = 9610+vmid
     4.1 --- a/tools/examples/democd	Wed Jun 30 11:44:47 2004 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,145 +0,0 @@
     4.4 -
     4.5 -##### Edit this python file to reflect the configuration of your system
     4.6 -
     4.7 -##### This example script requires variable 'ip' to be set, and optionally
     4.8 -##### netmask and gatewaty for the kernel command line
     4.9 -
    4.10 -def config_usage ():
    4.11 -    print >>sys.stderr, """
    4.12 -The config file %s requires the following vars to be defined:
    4.13 - ip               -- List of IP addr(s) for Xen to route to domain 
    4.14 -                     e.g. '-Dip=1.2.3.4,5.6.7.8'
    4.15 -The following variables may be optionally defined:
    4.16 - mem              -- Adjust initial memory allocation (default 64MB)
    4.17 - netmask          -- Override gateway for kernel ip= command line
    4.18 - gateway          -- Override network for kernel ip= command line
    4.19 -""" % config_file
    4.20 -
    4.21 -try:
    4.22 -    ip
    4.23 -except:
    4.24 -    print "Set variable 'ip' using '-Dip=1.2.3.4,5.6.7.8'"
    4.25 -    assert()
    4.26 -
    4.27 -# STEP 1. Specify kernel image file and otional ramdisk. Can be gzip'ed.
    4.28 -image   = "/boot/xenolinux.gz"
    4.29 -ramdisk = "/boot/initrd.gz"
    4.30 -builder_fn='linux' # this is a linux domain
    4.31 -
    4.32 -# STEP 2. The initial memory allocation (in megabytes) for the new domain.
    4.33 -try:
    4.34 -    mem_size = int(mem)
    4.35 -except NameError:
    4.36 -    mem_size = 64
    4.37 -
    4.38 -
    4.39 -# STEP 3. A handy name for your new domain.
    4.40 -# appends either first hostname or last quad of first IP address dependant on value passed
    4.41 -
    4.42 -quads = string.split(ip, '.')
    4.43 -if len(quads) == 4:					# fragile heuristic for valid IP verification
    4.44 -	domain_name = "Xen VM .%s" % quads[3]		# use last quad of IP
    4.45 -else:
    4.46 -	domain_name = "Xen VM: %s" % ip			# use hostname passed in
    4.47 -
    4.48 -
    4.49 -# STEP 4. Specify IP address(es), for the new domain.  You need to
    4.50 -# configure IP addrs within the domain just as you do normally.  This
    4.51 -# is just to let Xen know about them so it can route packets
    4.52 -# appropriately.
    4.53 -
    4.54 -#vfr_ipaddr = ["111.222.333.444","222.333.444.555"]
    4.55 -#vfr_ipaddr  = [xenctl.utils.add_offset_to_ip(xenctl.utils.get_current_ipaddr(),vmid)]
    4.56 -vfr_ipaddr  = map(socket.gethostbyname,string.split(ip,','))
    4.57 -
    4.58 -
    4.59 -
    4.60 -# STEP 5a. Identify any physcial partitions or virtual disks you want the
    4.61 -# domain to have access to, and what you want them accessible as
    4.62 -# e.g. vbd_list = [ ('phy:sda1','sda1', 'w'),
    4.63 -#	 ('phy:sda%d' % (3+vmid), 'hda2', 'r'), 
    4.64 -#	 ('vd:as73gd784dh','hda1','w'),
    4.65 -#	 ('phy:cdrom','hdd','r')
    4.66 -
    4.67 -vbd_list = [ ('phy:cdrom','hdd','r' ) ]
    4.68 -
    4.69 -
    4.70 -
    4.71 -# STEP 5b. Set the VBD expertise level.  Most people should leave this
    4.72 -# on 0, at least to begin with - this script can detect most dangerous
    4.73 -# disk sharing between domains and with this set to zero it will only
    4.74 -# allow read only sharing.
    4.75 -
    4.76 -vbd_expert = 0
    4.77 -
    4.78 -
    4.79 -# STEP 6. Build the command line for the new domain. Edit as req'd.
    4.80 -# You only need the ip= line if you're NFS booting or the root file system
    4.81 -# doesn't set it later e.g. in ifcfg-eth0 or via DHCP
    4.82 -# You can use 'extrabit' to set the runlevel and custom environment
    4.83 -# variables used by custom rc scripts (e.g. VMID=, usr= )
    4.84 -
    4.85 -
    4.86 -# see if we have a local IP at all
    4.87 -localip=''
    4.88 -for i in vfr_ipaddr:
    4.89 -    if xenctl.utils.check_subnet(i,'169.254.0.0','255.255.0.0'):
    4.90 -	localip=i
    4.91 -	break
    4.92 -
    4.93 -
    4.94 -# if either netmask and gateway has been set from the command line,
    4.95 -# associate it with the first IP address that has been specified.
    4.96 -
    4.97 -myip = ''
    4.98 -
    4.99 -try: 
   4.100 -    netmask = socket.gethostbyname( netmask )
   4.101 -    gateway = socket.gethostbyname( gateway )
   4.102 -    myip = vfr_ipaddr[0]
   4.103 -
   4.104 -except NameError:
   4.105 -    netmask = xenctl.utils.get_current_ipmask()
   4.106 -    gateway = xenctl.utils.get_current_ipgw()
   4.107 -
   4.108 -# if we haven't got an address, see if we have one that matches the LAN
   4.109 -
   4.110 -if not myip:
   4.111 -    if netmask and gateway:
   4.112 -	for i in vfr_ipaddr:
   4.113 -	    if xenctl.utils.check_subnet(i,gateway,netmask): 
   4.114 -		myip=i
   4.115 -		break
   4.116 -
   4.117 -# if we still haven't got an address, see if there's a link local one
   4.118 -
   4.119 -if not myip and localip:
   4.120 -    myip = localip
   4.121 -    netmask = '255.255.0.0'
   4.122 -    gateway = '169.254.1.0'
   4.123 -
   4.124 -
   4.125 -# As a final fallback, through everything down the interface
   4.126 -
   4.127 -if not myip:
   4.128 -    myip = vfr_ipaddr[0]
   4.129 -    netmask = '0.0.0.0' 
   4.130 -    gateway = '' 
   4.131 -
   4.132 -# Calculate the components with which we will build the command line
   4.133 -
   4.134 -nfsserv = '169.254.1.0'  
   4.135 -
   4.136 -cmdline_ip="ip="+myip+":"+nfsserv+":"+gateway+":"+netmask+"::eth0:off"
   4.137 -cmdline_root  = "root=/dev/ram0 rw init=/linuxrc"
   4.138 -
   4.139 -if localip:
   4.140 -    cmdline_extra = "4 LOCALIP=%s" % localip
   4.141 -else:
   4.142 -    cmdline_extra = "4"
   4.143 -
   4.144 -# STEP 7. Set according to whether you want the script to watch the domain 
   4.145 -# and auto-restart it should it die or exit.
   4.146 -
   4.147 -auto_restart = False
   4.148 -#auto_restart = True
     5.1 --- a/tools/examples/init.d/xendomains	Wed Jun 30 11:44:47 2004 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,146 +0,0 @@
     5.4 -#!/bin/sh
     5.5 -#
     5.6 -# /etc/init.d/xendomains
     5.7 -# Start / stop domains automatically when domain 0 boots / shuts down.
     5.8 -#
     5.9 -# chkconfig: 345 99 00
    5.10 -# description: Start / stop Xen domains.
    5.11 -#
    5.12 -# This script offers fairly basic functionality.  It should work on Redhat
    5.13 -# but also on LSB-compliant SuSE releases and on Debian with the LSB package
    5.14 -# installed.  (LSB is the Linux Standard Base)
    5.15 -#
    5.16 -# Based on the example in the "Designing High Quality Integrated Linux
    5.17 -# Applications HOWTO" by Avi Alkalay
    5.18 -# <http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/>
    5.19 -#
    5.20 -
    5.21 -RETVAL=0
    5.22 -
    5.23 -INITD=/etc/init.d/
    5.24 -
    5.25 -AUTODIR=/etc/xen/auto
    5.26 -LOCKFILE=/var/lock/subsys/xendomains
    5.27 -
    5.28 -if [ -e /lib/lsb ]; then
    5.29 -    # assume an LSB-compliant distro (Debian with LSB package,
    5.30 -    # recent-enough SuSE, others...)
    5.31 -
    5.32 -    . /lib/lsb/init-functions # source LSB standard functions
    5.33 -
    5.34 -    on_fn_exit()
    5.35 -    {
    5.36 -	if [ $RETVAL -eq 0 ]; then
    5.37 -	    log_success_msg
    5.38 -	else
    5.39 -	    log_failure_msg
    5.40 -	fi
    5.41 -    }
    5.42 -else
    5.43 -    # assume a Redhat-like distro
    5.44 -    . $INITD/functions # source Redhat functions
    5.45 -
    5.46 -    on_fn_exit()
    5.47 -    {
    5.48 -	if [ $RETVAL -eq 0 ]; then
    5.49 -	    success
    5.50 -	else
    5.51 -	    failure
    5.52 -	fi
    5.53 -	
    5.54 -	echo
    5.55 -    }
    5.56 -fi
    5.57 -
    5.58 -
    5.59 -
    5.60 -start() {
    5.61 -    if [ -f $LOCKFILE ]; then return; fi
    5.62 -
    5.63 -    echo -n $"Starting auto Xen domains:"
    5.64 -
    5.65 -    # We expect config scripts for auto starting domains to be in
    5.66 -    # AUTODIR - they could just be symlinks to files elsewhere
    5.67 -    if [ -d $AUTODIR ] && [ $(ls $AUTODIR | wc -l) -gt 0 ]; then
    5.68 -	touch $LOCKFILE
    5.69 -	
    5.70 -       # Create all domains with config files in AUTODIR.
    5.71 -	for dom in  $AUTODIR/*; do
    5.72 -	    xm create --quiet --defaults $dom
    5.73 -	    if [ $? -ne 0 ]; then
    5.74 -		RETVAL=$?
    5.75 -	    fi
    5.76 -	done
    5.77 -
    5.78 -    fi
    5.79 -
    5.80 -    on_fn_exit
    5.81 -}
    5.82 -
    5.83 -stop()
    5.84 -{
    5.85 -    # NB. this shuts down ALL Xen domains (politely), not just the ones in
    5.86 -    # AUTODIR/*
    5.87 -    # This is because it's easier to do ;-) but arguably if this script is run
    5.88 -    # on system shutdown then it's also the right thing to do.
    5.89 -    
    5.90 -    echo -n $"Shutting down all Xen domains:"
    5.91 -
    5.92 -    xm shutdown --all --wait --norestart
    5.93 -
    5.94 -    RETVAL=$?
    5.95 -
    5.96 -    [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
    5.97 -
    5.98 -    on_fn_exit
    5.99 -}
   5.100 -
   5.101 -# This does NOT necessarily restart all running domains: instead it
   5.102 -# stops all running domains and then boots all the domains specified in
   5.103 -# AUTODIR.  If other domains have been started manually then they will
   5.104 -# not get restarted.
   5.105 -# Commented out to avoid confusion!
   5.106 -#
   5.107 -#restart()
   5.108 -#{
   5.109 -#    stop
   5.110 -#    start
   5.111 -#}
   5.112 -
   5.113 -# same as restart for now - commented out to avoid confusion
   5.114 -#reload()
   5.115 -#{
   5.116 -#    restart
   5.117 -#}
   5.118 -
   5.119 -
   5.120 -case "$1" in
   5.121 -    start)
   5.122 -	start
   5.123 -	;;
   5.124 -
   5.125 -    stop)
   5.126 -	stop
   5.127 -	;;
   5.128 -
   5.129 -# The following are commented out to disable them by default to avoid confusion
   5.130 -# - see the notes above
   5.131 -#
   5.132 -#    restart)
   5.133 -#	restart
   5.134 -#	;;
   5.135 -#
   5.136 -#    reload)
   5.137 -#	reload
   5.138 -#	;;
   5.139 -
   5.140 -    status)
   5.141 -	xm list
   5.142 -	;;
   5.143 -
   5.144 -    *)
   5.145 -	echo $"Usage: $0 {start|stop|status}"
   5.146 -	;;
   5.147 -esac
   5.148 -
   5.149 -exit $RETVAL
     6.1 --- a/tools/examples/netbsd	Wed Jun 30 11:44:47 2004 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,113 +0,0 @@
     6.4 -
     6.5 -##### Edit this python file to reflect the configuration of your system
     6.6 -
     6.7 -##### This example script expects a variable called 'vmid' to be set.
     6.8 -
     6.9 -def config_usage ():
    6.10 -    print >>sys.stderr,"""
    6.11 -The config file '%s' requires the following variable to be defined:
    6.12 - vmid             -- Numeric identifier for the new domain, used to calculate
    6.13 -                     the VM's IP address and root partition. E.g. -Dvmid=1
    6.14 -
    6.15 -Additionally the following variable may be defined:
    6.16 - image            -- Path to kernel image, can be gzip'ed. [/boot/netbsd]
    6.17 - mem              -- Memory size. [16]
    6.18 - name             -- Domain name. [NetBSD VM vmid]
    6.19 - ip               -- Primary IP address for domain. [this domain's IP + vmid]
    6.20 - nfsserv          -- NFS server IP address. [169.254.1.0]
    6.21 - nfsroot          -- Path to nfs root filesystem. [/netboot/netbsd]
    6.22 -""" % config_file
    6.23 -
    6.24 -
    6.25 -try:
    6.26 -    vmid=int(vmid) # convert to integer
    6.27 -except:
    6.28 -    print >>sys.stderr,"%s: This script expects 'vmid' to be set using -D vmid=X" % config_file
    6.29 -    assert()
    6.30 -
    6.31 -if vmid == 0:
    6.32 -    print >>sys.stderr,"%s: 'vmid' must be greater than 0" % config_file
    6.33 -    assert()
    6.34 -
    6.35 -
    6.36 -# STEP 1. Specify kernel image file. Can be gzip'ed.
    6.37 -if image == "": image = "/boot/netbsd"
    6.38 -
    6.39 -builder_fn='netbsd' # this is a NetBSD domain
    6.40 -
    6.41 -
    6.42 -# STEP 2. The initial memory allocation (in megabytes) for the new domain.
    6.43 -try:
    6.44 -    mem_size = int(mem)
    6.45 -except:
    6.46 -    mem_size = 16
    6.47 -
    6.48 -
    6.49 -# STEP 3. A handy name for your new domain.
    6.50 -try:
    6.51 -    domain_name = name
    6.52 -except:
    6.53 -    domain_name = "NetBSD VM %d" % vmid
    6.54 -
    6.55 -
    6.56 -# STEP 4. Specify IP address(es), for the new domain.  You need to
    6.57 -# configure IP addrs within the domain just as you do normally.  This
    6.58 -# is just to let Xen know about them so it can route packets
    6.59 -# appropriately.
    6.60 -
    6.61 -#vfr_ipaddr = ["111.222.333.444","222.333.444.555"]
    6.62 -try:
    6.63 -    vfr_ipaddr = [ip, xenctl.utils.add_offset_to_ip('169.254.1.0',vmid),]
    6.64 -except:
    6.65 -    vfr_ipaddr = [xenctl.utils.add_offset_to_ip(xenctl.utils.get_current_ipaddr(),vmid),
    6.66 -                  xenctl.utils.add_offset_to_ip('169.254.1.0',vmid),]
    6.67 -
    6.68 -
    6.69 -# STEP 5a. Identify any physcial partitions or virtual disks you want the
    6.70 -# domain to have access to, and what you want them accessible as
    6.71 -# e.g. vbd_list = [ ('phy:sda1','sda1', 'w'),
    6.72 -#	 ('phy:sda%d' % (3+vmid), 'hda2', 'r'), 
    6.73 -#	 ('vd:as73gd784dh','hda1','w'),
    6.74 -#	 ('phy:cdrom','hdd','r')
    6.75 -
    6.76 -#vbd_list = [ ('phy:sda%d'%(7+vmid),'sda1','w' ), 
    6.77 -#	     ('phy:sda6','sda6','r') ]
    6.78 -
    6.79 -
    6.80 -
    6.81 -# STEP 5b. Set the VBD expertise level.  Most people should leave this
    6.82 -# on 0, at least to begin with - this script can detect most dangerous
    6.83 -# disk sharing between domains and with this set to zero it will only
    6.84 -# allow read only sharing.
    6.85 -
    6.86 -vbd_expert = 0
    6.87 -
    6.88 -
    6.89 -# STEP 6. Build the command line for the new domain. Edit as req'd.
    6.90 -# You only need the ip= line if you're NFS booting or the root file system
    6.91 -# doesn't set it later e.g. in ifcfg-eth0 or via DHCP
    6.92 -# You can use 'extrabit' to set the runlevel and custom environment
    6.93 -# variables used by custom rc scripts (e.g. VMID=, usr= )
    6.94 -
    6.95 -netmask = xenctl.utils.get_current_ipmask()
    6.96 -gateway = xenctl.utils.get_current_ipgw()
    6.97 -try:
    6.98 -    nfsserv
    6.99 -except:
   6.100 -    nfsserv = '169.254.1.0'
   6.101 -
   6.102 -cmdline_ip = "ip="+vfr_ipaddr[0]+":"+nfsserv+":"+gateway+":"+netmask+"::eth0:off"
   6.103 -try:
   6.104 -    cmdline_root = "nfsroot="+nfsserv+":"+nfsroot
   6.105 -except:
   6.106 -    cmdline_root = "nfsroot="+nfsserv+":/netboot/netbsd"
   6.107 -    #cmdline_root = "nfsroot=/full/path/to/root/directory"
   6.108 -
   6.109 -cmdline_extra = "bootdev=xennet0"
   6.110 -
   6.111 -
   6.112 -# STEP 7. Set according to whether you want the script to watch the domain 
   6.113 -# and auto-restart it should it die or exit.
   6.114 -
   6.115 -auto_restart = False
   6.116 -#auto_restart = True
     7.1 --- a/tools/examples/xc_dom_control.py	Wed Jun 30 11:44:47 2004 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,176 +0,0 @@
     7.4 -#!/usr/bin/env python
     7.5 -
     7.6 -# usage: xc_dom_control [command] <params>
     7.7 -#
     7.8 -# this script isn't very smart, but it'll do for now.
     7.9 -#
    7.10 -
    7.11 -def usage ():
    7.12 -    print >>sys.stderr, """
    7.13 -Usage: %s [command] <params>
    7.14 -
    7.15 -  pause     [dom]        -- pause a domain
    7.16 -  unpause   [dom]        -- un-pause a domain
    7.17 -  shutdown  [dom] [[-w]] -- request a domain to shutdown (can specify 'all')
    7.18 -                            (optionally wait for complete shutdown)
    7.19 -  destroy   [dom]        -- immediately terminate a domain
    7.20 -  pincpu    [dom] [cpu]  -- pin a domain to the specified CPU
    7.21 -  suspend   [dom] [file] -- write domain's memory to a file and terminate
    7.22 -			    (resume by re-running xc_dom_create with -L option)
    7.23 -  unwatch   [dom]        -- kill the auto-restart daemon for a domain
    7.24 -  list                   -- print info about all domains
    7.25 -  listvbds               -- print info about all virtual block devs
    7.26 -  cpu_bvtset [dom] [mcuadv] [warp] [warpl] [warpu]
    7.27 -                         -- set BVT scheduling parameters for domain
    7.28 -  cpu_bvtslice [slice]   -- set default BVT scheduler slice
    7.29 -  cpu_atropos_set [dom] [period] [slice] [latency] [xtratime]
    7.30 -                         -- set Atropos scheduling parameters for domain
    7.31 -  cpu_rrobin_slice [slice] -- set Round Robin scheduler slice
    7.32 -""" % sys.argv[0]
    7.33 -
    7.34 -import Xc, sys, re, string, time, os, signal
    7.35 -
    7.36 -if len(sys.argv) < 2:
    7.37 -    usage()
    7.38 -    sys.exit(-1)
    7.39 -
    7.40 -cmd = sys.argv[1]
    7.41 -
    7.42 -
    7.43 -xc = Xc.new()
    7.44 -rc = ''
    7.45 -dom = None
    7.46 -
    7.47 -
    7.48 -if len( sys.argv ) > 2 and re.match('\d+$', sys.argv[2]):
    7.49 -    dom = int(sys.argv[2])
    7.50 -
    7.51 -if cmd == 'pause':
    7.52 -    rc = xc.domain_pause( dom=dom )
    7.53 -
    7.54 -elif cmd == 'unpause':
    7.55 -    rc = xc.domain_unpause( dom=dom )    
    7.56 -
    7.57 -elif cmd == 'shutdown':
    7.58 -    list = []
    7.59 -    if dom != None:
    7.60 -        rc = xc.domain_destroy( dom=dom ) # should be CMSG_SHUTDOWN
    7.61 -        list.append(dom)
    7.62 -    elif sys.argv[2] == 'all':
    7.63 -        for i in xc.domain_getinfo():
    7.64 -            if i['dom'] != 0: # don't shutdown dom0!
    7.65 -                ret = xc.domain_destroy( dom=i['dom'] ) # should be CMSG_SHUTDOWN
    7.66 -                if ret !=0: rc = ret
    7.67 -                else: list.append(i['dom'])
    7.68 -
    7.69 -    if len(sys.argv) == 4 and sys.argv[3] == "-w":
    7.70 -        # wait for all domains we shut down to terminate
    7.71 -        for dom in list:
    7.72 -            while True:
    7.73 -                info = xc.domain_getinfo(dom,1)
    7.74 -                if not ( info != [] and info[0]['dom'] == dom ): break
    7.75 -                time.sleep(1)
    7.76 -
    7.77 -elif cmd == 'destroy':
    7.78 -    rc = xc.domain_destroy( dom=dom )    
    7.79 -
    7.80 -elif cmd == 'pincpu':
    7.81 -
    7.82 -    if len(sys.argv) < 4:
    7.83 -        usage()
    7.84 -        sys.exit(-1)
    7.85 -
    7.86 -    cpu = int(sys.argv[3])
    7.87 -    
    7.88 -    rc = xc.domain_pincpu( dom, cpu )
    7.89 -
    7.90 -elif cmd == 'list':
    7.91 -    print 'Dom  Name             Mem(kb)  CPU  State  Time(ms)'
    7.92 -    for domain in xc.domain_getinfo():
    7.93 -
    7.94 -	run   = (domain['running'] and 'R') or 'r'
    7.95 -        block = (domain['blocked'] and 'B') or 'b'
    7.96 -	stop  = (domain['paused']  and 'P') or 'p'
    7.97 -	susp  = (domain['shutdown'] and 'S') or 's'
    7.98 -	crash = (domain['crashed'] and 'C') or 'c'
    7.99 -
   7.100 -        domain['state'] = run + block + stop + susp + crash
   7.101 -        domain['cpu_time'] = domain['cpu_time']/1e6
   7.102 -
   7.103 -        print "%(dom)-4d %(name)-16s %(mem_kb)7d %(cpu)3d %(state)5s %(cpu_time)8d" % domain
   7.104 -
   7.105 -elif cmd == 'unwatch':
   7.106 -
   7.107 -    # the auto-restart daemon's pid file
   7.108 -    watcher = '/var/run/xendomains/%d.pid' % dom
   7.109 -
   7.110 -    if os.path.isfile(watcher):
   7.111 -        fd = open(watcher,'r')
   7.112 -        pid = int(fd.readline())
   7.113 -        os.kill(pid, signal.SIGTERM)
   7.114 -
   7.115 -elif cmd == 'listvbds':
   7.116 -    print 'Dom   Dev   Perm   Size(MB)'
   7.117 -    
   7.118 -    for vbd in xc.vbd_probe():
   7.119 -        vbd['size_mb'] = vbd['nr_sectors'] / 2048
   7.120 -        vbd['perm'] = (vbd['writeable'] and 'w') or 'r'
   7.121 -        print '%(dom)-4d  %(vbd)04x  %(perm)-1s      %(size_mb)d' % vbd
   7.122 -
   7.123 -elif cmd == 'suspend':
   7.124 -    if len(sys.argv) < 4:
   7.125 -        usage()
   7.126 -        sys.exit(-1)
   7.127 -
   7.128 -    file = sys.argv[3]
   7.129 -
   7.130 -    # the auto-restart daemon's pid file
   7.131 -    watcher = '/var/run/xendomains/%d.pid' % dom
   7.132 -
   7.133 -    if os.path.isfile(watcher):
   7.134 -        fd = open(watcher,'r')
   7.135 -        pid = int(fd.readline())
   7.136 -        os.kill(pid, signal.SIGTERM)
   7.137 -
   7.138 -    rc = xc.linux_save( dom=dom, state_file=file, progress=1)
   7.139 -
   7.140 -elif cmd == 'cpu_bvtslice':
   7.141 -    if len(sys.argv) < 3:
   7.142 -        usage()
   7.143 -        sys.exit(-1)
   7.144 -
   7.145 -    slice = dom # first int argument is in "dom" (!)
   7.146 -
   7.147 -    rc = xc.bvtsched_global_set(ctx_allow=slice)
   7.148 -
   7.149 -elif cmd == 'cpu_bvtset':
   7.150 -    if len(sys.argv) < 7:
   7.151 -        usage()
   7.152 -        sys.exit(-1)
   7.153 -
   7.154 -    mcuadv = int(sys.argv[3])
   7.155 -    warp   = int(sys.argv[4])
   7.156 -    warpl  = int(sys.argv[5])
   7.157 -    warpu  = int(sys.argv[6])
   7.158 -
   7.159 -    rc = xc.bvtsched_domain_set(dom=dom, mcuadv=mcuadv, warp=warp,
   7.160 -                                warpl=warpl, warpu=warpu)
   7.161 -
   7.162 -elif cmd == 'cpu_atropos_set': # args: dom period slice latency xtratime
   7.163 -    if len(sys.argv) < 6:
   7.164 -        usage()
   7.165 -        sys.exit(1)
   7.166 -
   7.167 -    (period, slice, latency, xtratime) = map(lambda x: int(x), sys.argv[3:7])
   7.168 -    
   7.169 -    rc = xc.atropos_domain_set(dom, period, slice, latency, xtratime)
   7.170 -
   7.171 -elif cmd == 'cpu_rrobin_slice':
   7.172 -    rc = xc.rrobin_global_set(slice=int(sys.argv[2]))
   7.173 -
   7.174 -else:
   7.175 -    usage()
   7.176 -    sys.exit(-1)
   7.177 -
   7.178 -if rc != '':
   7.179 -    print "return code %d" % rc
     8.1 --- a/tools/examples/xc_dom_create.py	Wed Jun 30 11:44:47 2004 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,437 +0,0 @@
     8.4 -#!/usr/bin/env python
     8.5 -
     8.6 -import string, sys, os, time, socket, getopt, signal, syslog
     8.7 -import Xc, xenctl.utils, xenctl.console_client, re
     8.8 -
     8.9 -config_dir  = '/etc/xc/'
    8.10 -config_file = xc_config_file = config_dir + 'defaults'
    8.11 -
    8.12 -def main_usage ():
    8.13 -    print >>sys.stderr,"""
    8.14 -Usage: %s <args>
    8.15 -
    8.16 -This tool is used to create and start new domains. It reads defaults
    8.17 -from a file written in Python, having allowed variables to be set and
    8.18 -passed into the file. Further command line arguments allow the
    8.19 -defaults to be overridden. The defaults for each parameter are listed
    8.20 -in [] brackets. Arguments are as follows:
    8.21 -
    8.22 -Arguments to control the parsing of the defaults file:
    8.23 - -f config_file   -- Use the specified defaults script. 
    8.24 -                     Default: ['%s']
    8.25 - -L state_file    -- Load virtual machine memory state from state_file
    8.26 - -D foo=bar       -- Set variable foo=bar before parsing config
    8.27 -                     E.g. '-D vmid=3;ip=1.2.3.4'
    8.28 - -h               -- Print extended help message, including all arguments
    8.29 - -n               -- Dry run only, don't actually create domain
    8.30 - -q               -- Quiet - write output only to the system log
    8.31 - -s               -- Don't start the domain, just build it.
    8.32 -""" % (sys.argv[0], xc_config_file)
    8.33 -
    8.34 -def extra_usage ():
    8.35 -    print >>sys.stderr,"""
    8.36 -Arguments to override current config read from '%s':
    8.37 - -c               -- Turn into console terminal after domain is created
    8.38 - -k image         -- Path to kernel image ['%s']
    8.39 - -r ramdisk       -- Path to ramdisk (or empty) ['%s']
    8.40 - -b builder_fn    -- Function to use to build domain ['%s']
    8.41 - -m mem_size      -- Initial memory allocation in MB [%dMB]
    8.42 - -N domain_name   -- Set textual name of domain ['%s']
    8.43 - -a auto_restart  -- Restart domain on exit, yes/no ['%d']
    8.44 - -e vbd_expert    -- Saftey catch to avoid some disk accidents ['%d'] 
    8.45 - -d udisk,dev,rw  -- Add disk, partition, or virtual disk to domain. E.g. to 
    8.46 -                     make partion sda4 available to the domain as hda1 with 
    8.47 -                     read-write access: '-d phy:sda4,hda1,rw' To add 
    8.48 -                     multiple disks use multiple -d flags or seperate with ';'
    8.49 -                     Default: ['%s']
    8.50 - -i vfr_ipaddr    -- Add IP address to the list which Xen will route to
    8.51 -                     the domain. Use multiple times to add more IP addrs.
    8.52 -		     Default: ['%s']
    8.53 -
    8.54 -Args to override the kernel command line, which is concatenated from these:
    8.55 - -I cmdline_ip    -- Override 'ip=ipaddr:nfsserv:gateway:netmask::eth0:off'
    8.56 -                     Default: ['%s']
    8.57 - -R cmdline_root  -- Override root device parameters.
    8.58 -                     Default: ['%s']
    8.59 - -E cmdline_extra -- Override extra kernel args and rc script env vars.
    8.60 -                     Default: ['%s']
    8.61 -
    8.62 -""" % (config_file,
    8.63 -       image, ramdisk, builder_fn, mem_size, domain_name, auto_restart,
    8.64 -       vbd_expert, 
    8.65 -       printvbds( vbd_list ), 
    8.66 -       reduce ( (lambda a,b: a+':'+b), vfr_ipaddr,'' )[1:],
    8.67 -       cmdline_ip, cmdline_root, cmdline_extra)
    8.68 -
    8.69 -def config_usage (): pass
    8.70 -
    8.71 -def answer ( s ):
    8.72 -    s = string.lower(s)
    8.73 -    if s == 'yes' or s == 'true' or s == '1': return 1
    8.74 -    return 0
    8.75 -
    8.76 -def printvbds ( v ):
    8.77 -    s=''
    8.78 -    for (a,b,c) in v:
    8.79 -	s = s + '; %s,%s,%s' % (a,b,c)
    8.80 -    return s[2:]
    8.81 -
    8.82 -def output(string):
    8.83 -    global quiet
    8.84 -    syslog.syslog(string)
    8.85 -    if not quiet:
    8.86 -        print string
    8.87 -    return
    8.88 -
    8.89 -bail=False; dryrun=False; extrahelp=False; quiet = False
    8.90 -image=''; ramdisk=''; builder_fn=''; restore=0; state_file=''
    8.91 -mem_size=0; domain_name=''; vfr_ipaddr=[];
    8.92 -vbd_expert=0; auto_restart=False;
    8.93 -vbd_list = []; cmdline_ip = ''; cmdline_root=''; cmdline_extra=''
    8.94 -pci_device_list = []; console_port = -1
    8.95 -auto_console = False
    8.96 -dontstart = False
    8.97 -flags = 0
    8.98 -
    8.99 -##### Determine location of defaults file
   8.100 -#####
   8.101 -
   8.102 -try:
   8.103 -    opts, args = getopt.getopt(sys.argv[1:], "h?nqcsf:D:k:r:b:m:N:a:e:d:i:I:R:E:L:" )
   8.104 -
   8.105 -    for opt in opts:
   8.106 -	if opt[0] == '-f': config_file= opt[1]
   8.107 -	if opt[0] == '-h' or opt[0] == '-?' : bail=True; extrahelp=True
   8.108 -	if opt[0] == '-n': dryrun=True
   8.109 -	if opt[0] == '-D': 
   8.110 -	    for o in string.split( opt[1], ';' ):
   8.111 -		(l,r) = string.split( o, '=' )
   8.112 -		exec "%s='%s'" % (l,r)
   8.113 -        if opt[0] == '-q': quiet = True
   8.114 -        if opt[0] == '-L': restore = True; state_file = opt[1]
   8.115 -        if opt[0] == '-s': dontstart = True
   8.116 -
   8.117 -
   8.118 -except getopt.GetoptError:
   8.119 -    bail=True
   8.120 -
   8.121 -
   8.122 -try:
   8.123 -    os.stat( config_file )
   8.124 -except:
   8.125 -    try:
   8.126 -	d = config_dir + config_file
   8.127 -	os.stat( d )
   8.128 -	config_file = d
   8.129 -    except:
   8.130 -	print >> sys.stderr, "Unable to open config file '%s'" % config_file
   8.131 -	bail = True
   8.132 -
   8.133 -
   8.134 -##### Parse the config file
   8.135 -#####
   8.136 -
   8.137 -if not quiet:
   8.138 -    print "Parsing config file '%s'" % config_file
   8.139 -
   8.140 -try:
   8.141 -    execfile ( config_file )
   8.142 -except (AssertionError,IOError):
   8.143 -    print >>sys.stderr,"Exiting %s" % sys.argv[0]
   8.144 -    bail = True
   8.145 -
   8.146 -##### Print out config if necessary 
   8.147 -##### 
   8.148 -
   8.149 -if bail:
   8.150 -    main_usage()
   8.151 -    config_usage()
   8.152 -    if extrahelp: extra_usage()
   8.153 -    sys.exit(1)
   8.154 -
   8.155 -##### Parse any command line overrides 
   8.156 -##### 
   8.157 -
   8.158 -x_vbd_list = []
   8.159 -x_vfr_ipaddr  = []
   8.160 -
   8.161 -for opt in opts:
   8.162 -    if opt[0] == '-k': image = opt[1]
   8.163 -    if opt[0] == '-r': ramdisk = opt[1]
   8.164 -    if opt[0] == '-b': builder_fn = opt[1]  
   8.165 -    if opt[0] == '-m': mem_size = int(opt[1])
   8.166 -    if opt[0] == '-C': cpu = int(opt[1])
   8.167 -    if opt[0] == '-N': domain_name = opt[1]
   8.168 -    if opt[0] == '-a': auto_restart = answer(opt[1])
   8.169 -    if opt[0] == '-e': vbd_expert = answer(opt[1])
   8.170 -    if opt[0] == '-I': cmdline_ip = opt[1]
   8.171 -    if opt[0] == '-R': cmdline_root = opt[1]
   8.172 -    if opt[0] == '-E': cmdline_extra = opt[1]
   8.173 -    if opt[0] == '-i': x_vfr_ipaddr.append(opt[1])
   8.174 -    if opt[0] == '-c': auto_console = True
   8.175 -    if opt[0] == '-d':
   8.176 -	try:
   8.177 -	    vv = string.split(opt[1],';')	    
   8.178 -	    for v in vv:
   8.179 -		(udisk,dev,mode) = string.split(v,',')
   8.180 -		x_vbd_list.append( (udisk,dev,mode) )
   8.181 -	except:
   8.182 -	    print >>sys.stderr, "Invalid block device specification : %s" % opt[1]
   8.183 -	    sys.exit(1)
   8.184 -
   8.185 -if x_vbd_list: vbd_list = x_vbd_list
   8.186 -if x_vfr_ipaddr: vfr_ipaddr = x_vfr_ipaddr
   8.187 -
   8.188 -cmdline = cmdline_ip +' '+ cmdline_root +' '+ cmdline_extra
   8.189 -
   8.190 -syslog.openlog('xc_dom_create.py %s' % config_file, 0, syslog.LOG_DAEMON)
   8.191 -
   8.192 -##### Print some debug info just in case things don't work out...
   8.193 -##### 
   8.194 -
   8.195 -output('VM image           : "%s"' % image)
   8.196 -output('VM ramdisk         : "%s"' % ramdisk)
   8.197 -output('VM memory (MB)     : "%d"' % mem_size)
   8.198 -output('VM IP address(es)  : "%s"'
   8.199 -                % reduce((lambda a,b: a+'; '+b),vfr_ipaddr,'' )[2:])
   8.200 -output('VM block device(s) : "%s"' % printvbds( vbd_list ))
   8.201 -output('VM cmdline         : "%s"' % cmdline)
   8.202 -
   8.203 -if dryrun:
   8.204 -    sys.exit(1)
   8.205 -
   8.206 -##### Code beyond this point is actually used to manage the mechanics of
   8.207 -##### starting (and watching if necessary) guest virtual machines.
   8.208 -
   8.209 -# Obtain an instance of the Xen control interface
   8.210 -xc = Xc.new()
   8.211 -
   8.212 -# This function creates, builds and starts a domain, using the values
   8.213 -# in the global variables, set above.  It is used in the subsequent
   8.214 -# code for starting the new domain and rebooting it if appropriate.
   8.215 -def make_domain():
   8.216 -    """Create, build and start a domain.
   8.217 -    Returns: [int] the ID of the new domain.
   8.218 -    """
   8.219 -
   8.220 -    # set up access to the global variables declared above
   8.221 -    global image, ramdisk, mem_size, cpu, domain_name, vfr_ipaddr, netmask
   8.222 -    global vbd_list, cmdline, xc, vbd_expert, builder_fn
   8.223 -    	
   8.224 -    if not os.path.isfile( image ):
   8.225 -        print "Image file '" + image + "' does not exist"
   8.226 -        sys.exit()
   8.227 -
   8.228 -    if ramdisk and not os.path.isfile( ramdisk ):
   8.229 -        print "Ramdisk file '" + ramdisk + "' does not exist"
   8.230 -        sys.exit()
   8.231 -
   8.232 -    id = xc.domain_create( mem_kb=mem_size*1024, name=domain_name, cpu=cpu )
   8.233 -    if id <= 0:
   8.234 -	print "Error creating domain"
   8.235 -	sys.exit()
   8.236 -
   8.237 -    cmsg = 'new_control_interface(dom='+str(id)+', console_port='+str(console_port)+')'
   8.238 -
   8.239 -    cons_response = xenctl.utils.xend_control_message(cmsg)
   8.240 -
   8.241 -    if not cons_response['success']:
   8.242 -	print "Error creating initial event channel"
   8.243 -	print "Error type: " + cons_response['error_type']
   8.244 -	if cons_response['error_type'] == 'exception':
   8.245 -	    print "Exception type: " + cons_response['exception_type']
   8.246 -	    print "Exception value: " + cons_response['exception_value']
   8.247 -	xc.domain_destroy ( dom=id )
   8.248 -	sys.exit()
   8.249 -
   8.250 -    if restore:
   8.251 -        ret = eval('xc.%s_restore ( dom=id, state_file=state_file, progress=1)' % (builder_fn) )
   8.252 -        if ret < 0:
   8.253 -            print "Error restoring domain"
   8.254 -            print "Return code = " + str(ret)
   8.255 -            xc.domain_destroy ( dom=id )
   8.256 -            sys.exit()
   8.257 -    else:
   8.258 -
   8.259 -        ret = eval('xc.%s_build ( dom=id, image=image, ramdisk=ramdisk, cmdline=cmdline, control_evtchn=cons_response["remote_port"], flags=flags )' % builder_fn )
   8.260 -        if ret < 0:
   8.261 -            print "Error building Linux guest OS: "
   8.262 -            print "Return code = " + str(ret)
   8.263 -            xc.domain_destroy ( dom=id )
   8.264 -            sys.exit()
   8.265 -
   8.266 -    # setup the virtual block devices
   8.267 -
   8.268 -    # set the expertise level appropriately
   8.269 -    xenctl.utils.VBD_EXPERT_MODE = vbd_expert
   8.270 -
   8.271 -    if not (flags & 1<<4): # It's not a block backend (or it's old IO world)
   8.272 -        cmsg = 'new_block_interface(dom='+str(id)+')'
   8.273 -        xend_response = xenctl.utils.xend_control_message(cmsg)
   8.274 -        if not xend_response['success']:
   8.275 -            print "Error creating block interface"
   8.276 -            print "Error type: " + xend_response['error_type']
   8.277 -            if xend_response['error_type'] == 'exception':
   8.278 -                print "Exception type: " + xend_response['exception_type']
   8.279 -                print "Exception val:  " + xend_response['exception_value']
   8.280 -            xc.domain_destroy ( dom=id )
   8.281 -            sys.exit()
   8.282 -
   8.283 -        for ( uname, virt_name, rw ) in vbd_list:
   8.284 -            virt_dev = xenctl.utils.blkdev_name_to_number( virt_name )
   8.285 -
   8.286 -            segments = xenctl.utils.lookup_disk_uname( uname )
   8.287 -            if not segments:
   8.288 -                print "Error looking up %s\n" % uname
   8.289 -                xc.domain_destroy ( dom=id )
   8.290 -                sys.exit()
   8.291 -
   8.292 -            if len(segments) > 1:
   8.293 -                print "New I/O world cannot deal with multi-extent vdisks"
   8.294 -                xc.domain_destroy ( dom=id )
   8.295 -                sys.exit()
   8.296 -            seg = segments[0]
   8.297 -            cmsg = 'new_block_device(dom=' + str(id) + \
   8.298 -                   ',handle=0,vdev=' + str(virt_dev) + \
   8.299 -                   ',pdev=' + str(seg['device']) + \
   8.300 -                   ',start_sect=' + str(seg['start_sector']) + \
   8.301 -                   ',nr_sect=' + str(seg['nr_sectors']) + \
   8.302 -                   ',readonly=' + str(not re.match('w',rw)) + ')'
   8.303 -            xend_response = xenctl.utils.xend_control_message(cmsg)
   8.304 -            if not xend_response['success']:
   8.305 -                print "Error creating virtual block device"
   8.306 -                print "Error type: " + xend_response['error_type']
   8.307 -                if xend_response['error_type'] == 'exception':
   8.308 -                    print "Exception type: " + xend_response['exception_type']
   8.309 -                    print "Exception val:  " + xend_response['exception_value']
   8.310 -                xc.domain_destroy ( dom=id )
   8.311 -                sys.exit()
   8.312 -    else: # It's a block backend - notify Xend.
   8.313 -        cmsg = 'set_block_backend(dom='+str(id)+')'
   8.314 -        xend_response = xenctl.utils.xend_control_message(cmsg)
   8.315 -        if not xend_response['success']:
   8.316 -            print "Error registering network backend"
   8.317 -            print "Error type: " + xend_response['error_type']
   8.318 -            if xend_response['error_type'] == 'exception':
   8.319 -                print "Exception type: " + xend_response['exception_type']
   8.320 -                print "Exception val:  " + xend_response['exception_value']
   8.321 -                xc.domain_destroy ( dom=id )
   8.322 -                sys.exit()
   8.323 -
   8.324 -    if not (flags & 1<<5): # If it's not the net backend, give it a frontend.
   8.325 -        cmsg = 'new_network_interface(dom='+str(id)+')'
   8.326 -        xend_response = xenctl.utils.xend_control_message(cmsg)
   8.327 -        if not xend_response['success']:
   8.328 -            print "Error creating network interface"
   8.329 -            print "Error type: " + xend_response['error_type']
   8.330 -            if xend_response['error_type'] == 'exception':
   8.331 -                print "Exception type: " + xend_response['exception_type']
   8.332 -                print "Exception val:  " + xend_response['exception_value']
   8.333 -                xc.domain_destroy ( dom=id )
   8.334 -                sys.exit()
   8.335 -    else: # It's a new net backend - notify Xend.
   8.336 -        cmsg = 'set_network_backend(dom='+str(id)+')'
   8.337 -        xend_response = xenctl.utils.xend_control_message(cmsg)
   8.338 -        if not xend_response['success']:
   8.339 -            print "Error registering network backend"
   8.340 -            print "Error type: " + xend_response['error_type']
   8.341 -            if xend_response['error_type'] == 'exception':
   8.342 -                print "Exception type: " + xend_response['exception_type']
   8.343 -                print "Exception val:  " + xend_response['exception_value']
   8.344 -                xc.domain_destroy ( dom=id )
   8.345 -                sys.exit()
   8.346 -
   8.347 -    # check for physical device access
   8.348 -    for (pci_bus, pci_dev, pci_func) in pci_device_list:
   8.349 -        if xc.physdev_pci_access_modify(
   8.350 -            dom=id, bus=pci_bus, dev=pci_dev,
   8.351 -            func=pci_func, enable=1 ) < 0:
   8.352 -            print "Non-fatal error enabling PCI device access."
   8.353 -        else:
   8.354 -            print "Enabled PCI access (%d:%d:%d)." % \
   8.355 -                  (pci_bus,pci_dev,pci_func)
   8.356 -		
   8.357 -    if restore:
   8.358 -	# send an unsolicited ARP reply for all non link-local IPs
   8.359 -	gw=xenctl.utils.get_current_ipgw()
   8.360 -	if gw == '': gw='255.255.255.255'
   8.361 -	nlb=open('/proc/sys/net/ipv4/ip_nonlocal_bind','r').read()[0]=='1'
   8.362 -	if not nlb: print >>open('/proc/sys/net/ipv4/ip_nonlocal_bind','w'), '1'
   8.363 -	for ip in vfr_ipaddr:
   8.364 -	    if not xenctl.utils.check_subnet(ip,'169.254.0.0','255.255.0.0'):
   8.365 -		print     '/usr/sbin/arping -A -b -I eth0 -c 1 -s %s %s' % (ip,gw)
   8.366 -		os.system('/usr/sbin/arping -A -b -I eth0 -c 1 -s %s %s' % (ip,gw))
   8.367 -	if not nlb: print >>open('/proc/sys/net/ipv4/ip_nonlocal_bind','w'), '0'
   8.368 -
   8.369 -    if not dontstart:
   8.370 -        if xc.domain_unpause( dom=id ) < 0:
   8.371 -            print "Error starting domain"
   8.372 -            xc.domain_destroy ( dom=id )
   8.373 -            sys.exit()
   8.374 -
   8.375 -    return (id, cons_response['console_port'])
   8.376 -# end of make_domain()
   8.377 -
   8.378 -def mkpidfile():
   8.379 -    global current_id
   8.380 -    if not os.path.isdir('/var/run/xendomains/'):
   8.381 -        os.mkdir('/var/run/xendomains/')
   8.382 -
   8.383 -    fd = open('/var/run/xendomains/%d.pid' % current_id, 'w')
   8.384 -    print >> fd, str(os.getpid())
   8.385 -    fd.close()
   8.386 -    return
   8.387 -
   8.388 -def rmpidfile():
   8.389 -    global current_id
   8.390 -    os.unlink('/var/run/xendomains/%d.pid' % current_id)
   8.391 -
   8.392 -def death_handler(dummy1,dummy2):
   8.393 -    global current_id
   8.394 -    os.unlink('/var/run/xendomains/%d.pid' % current_id)
   8.395 -    output('Auto-restart daemon: daemon PID = %d for domain %d is now exiting'
   8.396 -              % (os.getpid(),current_id))
   8.397 -    sys.exit(0)
   8.398 -    return
   8.399 -
   8.400 -# The starting / monitoring of the domain actually happens here...
   8.401 -
   8.402 -# start the domain and record its ID number
   8.403 -(current_id, current_port) = make_domain()
   8.404 -output("VM started in domain %d. Console I/O available on TCP port %d." % (current_id,current_port))
   8.405 -
   8.406 -if auto_console:
   8.407 -    xenctl.console_client.connect('127.0.0.1',int(current_port))
   8.408 -
   8.409 -# if the auto_restart flag is set then keep polling to see if the domain is
   8.410 -# alive - restart if it is not by calling make_domain() again (it's necessary
   8.411 -# to update the id variable, since the new domain may have a new ID)
   8.412 -
   8.413 -if auto_restart:
   8.414 -    # turn ourselves into a background daemon
   8.415 -    try:
   8.416 -	pid = os.fork()
   8.417 -	if pid > 0:
   8.418 -	    sys.exit(0)
   8.419 -	os.setsid()
   8.420 -	pid = os.fork()
   8.421 -	if pid > 0:
   8.422 -            output('Auto-restart daemon PID = %d' % pid)
   8.423 -	    sys.exit(0)
   8.424 -        signal.signal(signal.SIGTERM,death_handler)
   8.425 -    except OSError:
   8.426 -	print >> sys.stderr, 'Problem starting auto-restart daemon'
   8.427 -	sys.exit(1)
   8.428 -
   8.429 -    mkpidfile()
   8.430 -
   8.431 -    while True:
   8.432 -	time.sleep(1)
   8.433 -        info = xc.domain_getinfo(current_id, 1)
   8.434 -	if info == [] or info[0]['dom'] != current_id:
   8.435 -	    output("Auto-restart daemon: Domain %d has terminated, restarting VM in new domain"
   8.436 -                                     % current_id)
   8.437 -            rmpidfile()
   8.438 -	    (current_id, current_port) = make_domain()
   8.439 -            mkpidfile()
   8.440 -	    output("Auto-restart daemon: VM restarted in domain %d. Console on port %d." % (current_id,current_port))