ia64/xen-unstable
changeset 2289:04a0d90a1547
bitkeeper revision 1.1159.1.86 (412495d3pSRY5XpdRb-xCxOKOJxElg)
Rename xmdefaults to xmdefconfig.
Rename other xm config examples.
Change default script dir to /etc/xen/scripts.
Rename xmdefaults to xmdefconfig.
Rename other xm config examples.
Change default script dir to /etc/xen/scripts.
author | mjw@wray-m-3.hpl.hp.com |
---|---|
date | Thu Aug 19 11:58:11 2004 +0000 (2004-08-19) |
parents | 91fe50be0e6c |
children | 709199bb8055 |
files | .rootkeys tools/examples/Makefile tools/examples/README tools/examples/network tools/examples/vifctl tools/examples/xmdefaults tools/examples/xmdefconfig tools/examples/xmdefconfig-example tools/examples/xmdefconfig-netbsd tools/examples/xmexample tools/examples/xmnetbsd-example tools/python/xen/xend/XendRoot.py tools/python/xen/xm/create.py tools/python/xen/xm/help.py tools/python/xen/xm/opts.py |
line diff
1.1 --- a/.rootkeys Thu Aug 19 09:10:04 2004 +0000 1.2 +++ b/.rootkeys Thu Aug 19 11:58:11 2004 +0000 1.3 @@ -251,11 +251,10 @@ 401d7e16UgeqroJQTIhwkrDVkoWgZQ tools/exa 1.4 405ff55dawQyCHFEnJ067ChPRoXBBA tools/examples/init.d/xend 1.5 40ee75a9xFz6S05sDKu-JCLqyVTkDA tools/examples/network 1.6 40ee75a967sxgcRY4Q7zXoVUaJ4flA tools/examples/vif-bridge 1.7 -40e15b7edWEtBf_oe3eBwGKuh1dyzQ tools/examples/vifctl 1.8 40ee75a93cqxHp6MiYXxxwR5j2_8QQ tools/examples/xend-config.sxp 1.9 -41090ec8Pj_bkgCBpg2W7WfmNkumEA tools/examples/xmdefaults 1.10 -40cf2937oKlROYOJTN8GWwWM5AmjBg tools/examples/xmexample 1.11 -40dfd40auJwNnb8NoiSnRkvZaaXkUg tools/examples/xmnetbsd-example 1.12 +41090ec8Pj_bkgCBpg2W7WfmNkumEA tools/examples/xmdefconfig 1.13 +40cf2937oKlROYOJTN8GWwWM5AmjBg tools/examples/xmdefconfig-example 1.14 +40dfd40auJwNnb8NoiSnRkvZaaXkUg tools/examples/xmdefconfig-netbsd 1.15 3fbba6dbDfYvJSsw9500b4SZyUhxjQ tools/libxc/Makefile 1.16 3fbba6dc1uU7U3IFeF6A-XEOYF2MkQ tools/libxc/rpm.spec 1.17 3fbba6dcrNxtygEcgJYAJJ1gCQqfsA tools/libxc/xc.h
2.1 --- a/tools/examples/Makefile Thu Aug 19 09:10:04 2004 +0000 2.2 +++ b/tools/examples/Makefile Thu Aug 19 11:58:11 2004 +0000 2.3 @@ -1,32 +1,37 @@ 2.4 2.5 -INSTALL = $(wildcard *.py) 2.6 - 2.7 -INITD = init.d/xend 2.8 +# Init scripts. 2.9 +XEND_INITD = init.d/xend 2.10 2.11 -XEN_CONFIG_DIR = /etc/xen 2.12 -XEN_CONFIGS = xmdefaults xmnetbsd xend-config.sxp 2.13 +# Xen configuration dir and configs to go there. 2.14 +XEN_CONFIG_DIR = /etc/xen 2.15 +XEN_CONFIGS = xend-config.sxp 2.16 +XEN_CONFIGS += xmdefconfig 2.17 +XEN_CONFIGS += xmdefconfig-example 2.18 +XEN_CONFIGS += xmdefconfig-netbsd 2.19 2.20 -XEN_SCRIPT_DIR = /etc/xen 2.21 -XEN_SCRIPTS = vifctl network vif-bridge 2.22 +# Xen script dir and scripts to go there. 2.23 +XEN_SCRIPT_DIR = /etc/xen/scripts 2.24 +XEN_SCRIPTS = network 2.25 +XEN_SCRIPTS += vif-bridge 2.26 2.27 all: 2.28 2.29 install: all install-initd install-configs install-scripts 2.30 2.31 install-initd: 2.32 - mkdir -p $(prefix)/etc/init.d 2.33 - install -m0755 $(INITD) $(prefix)/etc/init.d 2.34 + install -d $(prefix)/etc/init.d 2.35 + install -m0755 $(XEND_INITD) $(prefix)/etc/init.d 2.36 2.37 install-configs: 2.38 - mkdir -p $(prefix)$(XEN_CONFIG_DIR) 2.39 - mkdir -p $(prefix)$(XEN_CONFIG_DIR)/auto 2.40 + install -d $(prefix)$(XEN_CONFIG_DIR) 2.41 + install -d $(prefix)$(XEN_CONFIG_DIR)/auto 2.42 for i in $(XEN_CONFIGS); \ 2.43 do [ -a $(prefix)/$(XEN_CONFIG_DIR)/$$i ] || \ 2.44 install -m0644 $$i $(prefix)$(XEN_CONFIG_DIR); \ 2.45 done 2.46 2.47 install-scripts: 2.48 - mkdir -p $(prefix)$(XEN_SCRIPT_DIR) 2.49 + install -d $(prefix)$(XEN_SCRIPT_DIR) 2.50 for i in $(XEN_SCRIPTS); \ 2.51 do [ -a $(prefix)/$()/$$i ] || \ 2.52 install -m0755 $$i $(prefix)$(XEN_SCRIPT_DIR); \
3.1 --- a/tools/examples/README Thu Aug 19 09:10:04 2004 +0000 3.2 +++ b/tools/examples/README Thu Aug 19 11:58:11 2004 +0000 3.3 @@ -1,138 +1,18 @@ 3.4 -Xen Control Tools - Example Scripts 3.5 +Xen Control Tools - Examples 3.6 =================================== 3.7 3.8 -This directory contains a set of example scripts for common Xen operations. 3.9 +This directory contains example scripts and configurations for Xen. 3.10 For many operations you will either be able to use these scripts directly, or 3.11 incorporate code from them into your own scripts. 3.12 3.13 -The Xc and xenctl.utils Python modules provide an API for accessing all this 3.14 -functionality - and more - from your own Python programs. These libraries may 3.15 -contain features for which there aren't yet example scripts written for... 3.16 - 3.17 If you write a useful script and would like to share it, please do 3.18 send it (preferably with a little summary to go in this file) to 3.19 <xen-devel@lists.sourceforge.net> so we can add it to this directory. 3.20 3.21 -xc_dom_control.py 3.22 - - general tool for controling running domains 3.23 - Usage: xc_dom_control.py [command] <params> 3.24 - 3.25 - stop [dom] -- pause a domain 3.26 - start [dom] -- un-pause a domain 3.27 - shutdown [dom] [[-w]] -- request a domain to shutdown (can specify 'all') 3.28 - (optionally wait for complete shutdown) 3.29 - destroy [dom] -- immediately terminate a domain 3.30 - pincpu [dom] [cpu] -- pin a domain to the specified CPU 3.31 - suspend [dom] [file] -- write domain's memory to a file and terminate 3.32 - (resume by re-running xc_dom_create with -L option) 3.33 - unwatch [dom] -- kill the auto-restart daemon for a domain 3.34 - list -- print info about all domains 3.35 - listvbds -- print info about all virtual block devs 3.36 - cpu_bvtset [dom] [mcuadv] [warp] [warpl] [warpu] 3.37 - -- set BVT scheduling parameters for domain 3.38 - cpu_bvtslice [slice] -- set default BVT scheduler slice 3.39 - cpu_atropos_set [dom] [period] [slice] [latency] [xtratime] 3.40 - -- set Atropos scheduling parameters for domain 3.41 - cpu_rrobin_slice [slice] -- set Round Robin scheduler slice 3.42 - vif_stats [dom] [vif] -- get stats for a given network vif 3.43 - vif_addip [dom] [vif] [ip] -- add an IP address to a given vif 3.44 - vif_setsched [dom] [vif] [bytes] [usecs] -- rate limit vif bandwidth 3.45 - vif_getsched [dom] [vif] -- print vif's scheduling parameters 3.46 - vbd_add [dom] [uname] [dev] [mode] -- make disk/partition uname available to 3.47 - domain as dev e.g. 'vbd_add 2 phy:sda3 hda1 w' 3.48 - vbd_remove [dom] [dev] -- remove disk or partition attached as 'dev' 3.49 - 3.50 - 3.51 -xc_dom_create.py 3.52 - - This tool is used to create and start new domains. It reads defaults 3.53 -from a file written in Python, having allowed variables to be set and 3.54 -passed into the file. Further command line arguments allow the 3.55 -defaults to be overridden. The defaults for each parameter are listed 3.56 -in [] brackets. Arguments are as follows: 3.57 - 3.58 -Arguments to control the parsing of the defaults file: 3.59 - -f config_file -- Use the specified defaults script. 3.60 - Default: ['/etc/xc/defaults'] 3.61 - -L state_file -- Load virtual machine memory state from state_file 3.62 - -D foo=bar -- Set variable foo=bar before parsing config 3.63 - E.g. '-D vmid=3;ip=1.2.3.4' 3.64 - -h -- Print extended help message, including all arguments 3.65 - -n -- Dry run only, don't actually create domain 3.66 - -q -- Quiet - write output only to the system log 3.67 - 3.68 - 3.69 -The config file 'defaults' requires the following variable to be defined: 3.70 - vmid -- Numeric identifier for the new domain, used to calculate 3.71 - the VM's IP address and root partition. E.g. -Dvmid=1 3.72 - 3.73 +network - default network setup script called by xend at startup. 3.74 +vif-bridge - default virtual network interface setup script. 3.75 +xend-config.sxp - default xend configuration file. 3.76 +xmdefconfig - default configuration script for 'xm create'. 3.77 +xmdefconfig-example - a more complex configuration script for 'xm create'. 3.78 +xmdefconfig-netbsd - an 'xm create' configuration script for NetBSD domains. 3.79 3.80 -Arguments to override current config read from 'defaults': 3.81 - -k image -- Path to kernel image [''] 3.82 - -r ramdisk -- Path to ramdisk (or empty) [''] 3.83 - -b builder_fn -- Function to use to build domain [''] 3.84 - -m mem_size -- Initial memory allocation in MB [0MB] 3.85 - -N domain_name -- Set textual name of domain [''] 3.86 - -a auto_restart -- Restart domain on exit, yes/no ['0'] 3.87 - -e vbd_expert -- Saftey catch to avoid some disk accidents ['0'] 3.88 - -d udisk,dev,rw -- Add disk, partition, or virtual disk to domain. E.g. to 3.89 - make partion sda4 available to the domain as hda1 with 3.90 - read-write access: '-b phy:sda4,hda1,rw' To add 3.91 - multiple disks use multiple -d flags or seperate with ';' 3.92 - Default: [''] 3.93 - -i vfr_ipaddr -- Add IP address to the list which Xen will route to 3.94 - the domain. Use multiple times to add more IP addrs. 3.95 - Default: [''] 3.96 - 3.97 -Args to override the kernel command line, which is concatenated from these: 3.98 - -I cmdline_ip -- Override 'ip=ipaddr:nfsserv:gateway:netmask::eth0:off' 3.99 - Default: [''] 3.100 - -R cmdline_root -- Override root device parameters. 3.101 - Default: [''] 3.102 - -E cmdline_extra -- Override extra kernel args and rc script env vars. 3.103 - Default: [''] 3.104 - 3.105 - 3.106 - 3.107 -xc_vd_tool.py 3.108 - - tool for manipulating virtual disks 3.109 - Usage: xc_vd_tool command <params> 3.110 - 3.111 - initalise [dev] [[ext_size]] - init. a physcial partition to store vd's 3.112 - create [size] [[expiry]] - allocate a vd of specified size (and expiry) 3.113 - delete [vdid] - delete a vd 3.114 - import [filename] [[expiry]] - create a vd and populate w/ image from file 3.115 - export [vdid] [filename] - copy vd's contents to a file 3.116 - setexpiry [vdid] [[expiry]] - update the expiry time for a vd 3.117 - list - list all the unexpired virtual disks 3.118 - undelete [vdid] [[expiry]] - attempts to recover an expired vd 3.119 - freespace - print out the amount of space in free pool 3.120 - 3.121 - notes: 3.122 - vdid - the virtual disk's identity string 3.123 - size - measured in MB 3.124 - expiry - is the expiry time of the virtual disk in seconds from now 3.125 - (0 = don't expire) 3.126 - device - physical partition to 'format' to hold vd's. e.g. hda4 3.127 - ext_size - extent size (default 64MB) 3.128 - 3.129 - 3.130 -xendomains 3.131 -This is a Sys-V init script for RedHat systems. 3.132 - 3.133 - - Usage: xendomains {start|stop|status} 3.134 - 3.135 - start -- starts all the domains with config files in /etc/xc/auto/ 3.136 - stop -- stops ALL running domains, waiting for them to shutdown cleanly 3.137 - (if possible) before returning 3.138 - status -- prints a list of the running domains, the same as 3.139 - "xc_dom_control.py list" 3.140 - 3.141 -On a RedHat system it should be possible to issue commands to this 3.142 -script using the "service" command and to configure if / when it is 3.143 -run automatically, using the "chkconfig" command. 3.144 - 3.145 -xend 3.146 -This is a Sys-V init script for RedHat systems, which can be used to 3.147 -start the Xen Daemon (xend) at boot time. 3.148 - 3.149 - - Usage: xend {start|stop|status|restart|reload}
4.1 --- a/tools/examples/network Thu Aug 19 09:10:04 2004 +0000 4.2 +++ b/tools/examples/network Thu Aug 19 11:58:11 2004 +0000 4.3 @@ -1,10 +1,22 @@ 4.4 #!/bin/sh 4.5 #============================================================================ 4.6 -# Example Xen network start/stop script. 4.7 +# Default Xen network start/stop script. 4.8 # Xend calls a network script when it starts. 4.9 -# This is the default script. 4.10 +# The script name to use is defined in /etc/xen/xend-config.sxp 4.11 +# in the network-script field. 4.12 +# 4.13 +# This script creates a bridge (default xen-br0), adds a device 4.14 +# (default eth0) to it, copies the IP addresses from the device 4.15 +# to the bridge and adjusts the routes accordingly. 4.16 # 4.17 -# /etc/xen/network (start|stop|status) {VAR=VAL}* 4.18 +# If all goes well, this should ensure that networking stays up. 4.19 +# However, some configurations are upset by this, especially 4.20 +# NFS roots. If the bridged setup does not meet your needs, 4.21 +# configure a different script, for example using routing instead. 4.22 +# 4.23 +# Usage: 4.24 +# 4.25 +# network (start|stop|status) {VAR=VAL}* 4.26 # 4.27 # Vars: 4.28 #
5.1 --- a/tools/examples/vifctl Thu Aug 19 09:10:04 2004 +0000 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,149 +0,0 @@ 5.4 -#!/usr/bin/python 5.5 -# -*- mode: python; -*- 5.6 -#============================================================================ 5.7 -# Xen vif control script. Lives in /etc/xen/xend. 5.8 -# 5.9 -# vifctl init [bridge=<bridge>] [interface=<interface>] 5.10 -# 5.11 -# Called when xend starts up. Default behaviour is to create <bridge> 5.12 -# and add <interface> to it, moving its IP address to <bridge> and adjusting routes. 5.13 -# 5.14 -# vifctl (up|down) vif=<vif> mac=<mac> [bridge=<bridge>] (ipaddr=<ipaddr>)* 5.15 -# 5.16 -# Called when a vif is brought up or down. Default behaviour is to add 5.17 -# the vif to <bridge> on up and remove it from the bridge on down. 5.18 -# If ipaddr is specified, iptables rules for the ip addresses are 5.19 -# added on up and removed on down. The bridge a vif is added to can 5.20 -# be set in the vm config. 5.21 -# 5.22 -# The default bridge is xen-br0. 5.23 -# The default interface is eth0. 5.24 -# 5.25 -#============================================================================ 5.26 - 5.27 -import sys 5.28 -import types 5.29 - 5.30 -from xen.util import Brctl 5.31 - 5.32 -from xen.xend import XendRoot 5.33 -xroot = XendRoot.instance() 5.34 - 5.35 -class VifControl: 5.36 - 5.37 - prefix = 'vifctl_' 5.38 - 5.39 - DEFAULT_BRIDGE = 'xen-br0' 5.40 - DEFAULT_INTERFACE = 'eth0' 5.41 - 5.42 - def __init__(self): 5.43 - self.name = 'vifctl' 5.44 - 5.45 - def main(self, args): 5.46 - #print self.name, args 5.47 - if len(args) < 2: 5.48 - usage(args) 5.49 - self.name = args[0] 5.50 - cmd = self.prefix + args[1] 5.51 - meth = getattr(self, cmd, self.unknown) 5.52 - meth(args[1:]) 5.53 - 5.54 - def usage(self, args, out=sys.stderr): 5.55 - print >>out, 'Missing command, try \n%s help' % self.name 5.56 - 5.57 - def unknown(self, args, out=sys.stderr): 5.58 - print >>out, 'Unknown command:', args[1] 5.59 - self.help(out=out) 5.60 - sys.exit(1) 5.61 - 5.62 - def help(self, out=sys.stdout): 5.63 - print >>out, 'Commands are:', 5.64 - for x in vars(self): 5.65 - if x.startswith(prefix): 5.66 - cmd = x[len(prefix):] 5.67 - print >>out, cmd, 5.68 - print >>out 5.69 - 5.70 - def getparams(self, d, args, req=[]): 5.71 - """Parse args of the form 'key=val'. Valid keys are the ones 5.72 - in the dict 'd' passed in. If entries in 'd' have list values the 5.73 - values of the keys are appended. 5.74 - 5.75 - If 'req' is specified it is a list of required keys. 5.76 - """ 5.77 - for x in args: 5.78 - (k, v) = x.split('=') 5.79 - k = k.strip() 5.80 - v = v.strip() 5.81 - if k not in d: 5.82 - print >>sys.stderr, 'Invalid parameter: ', k 5.83 - sys.exit(1) 5.84 - vold = d[k] 5.85 - if isinstance(vold , types.ListType): 5.86 - d[k] = vold + v 5.87 - else: 5.88 - d[k] = v 5.89 - for x in req: 5.90 - if not d[x]: 5.91 - print >>sys.stderr, 'Missing parameter:', x 5.92 - sys.exit(1) 5.93 - return d 5.94 - 5.95 - def vifctl_help(self, args): 5.96 - self.help() 5.97 - 5.98 - def default_bridge(self): 5.99 - return xroot.get_config_value('bridge', self.DEFAULT_BRIDGE) 5.100 - 5.101 - def default_interface(self): 5.102 - return xroot.get_config_value('interface', self.DEFAULT_INTERFACE) 5.103 - 5.104 - def vifctl_init(self, args): 5.105 - """Entry point for 'vifctl init'. 5.106 - """ 5.107 - d = { 'bridge' : self.default_bridge(), 5.108 - 'interface': self.default_interface() } 5.109 - params = self.getparams(d, args[1:]) 5.110 - interface = params['interface'] 5.111 - bridge = params['bridge'] 5.112 - # Create bridge 'bridge'. 5.113 - Brctl.bridge_create(bridge) 5.114 - # Reconfigure so that 'interface' is added to 'bridge', 5.115 - # and 'bridge' has the IP address from 'interface'. 5.116 - Brctl.reconfigure(interface, bridge) 5.117 - 5.118 - def vifparams(self, args): 5.119 - d = { 'vif' : None, 5.120 - 'mac' : None, 5.121 - 'bridge': self.default_bridge(), 5.122 - 'ipaddr': [] } 5.123 - d = self.getparams(d, args, req=['vif', 'mac']) 5.124 - return d 5.125 - 5.126 - def vifctl_up(self, args): 5.127 - """Entry point for 'vifctl up'. 5.128 - """ 5.129 - params = self.vifparams(args[1:]) 5.130 - # Add the vif to its bridge. 5.131 - Brctl.vif_bridge_add(params) 5.132 - if params['ipaddr']: 5.133 - # Add iptables rules for the ip addresses. 5.134 - vif = params['vif'] 5.135 - for ipaddr in params['ipaddr']: 5.136 - Brctl.vif_restrict_addr(vif, ipaddr) 5.137 - 5.138 - def vifctl_down(self, args): 5.139 - """Entry point for 'vifctl down'. 5.140 - """ 5.141 - params = self.vifparams(args[1:]) 5.142 - # Remove the vif from its bridge. 5.143 - Brctl.vif_bridge_rem(params) 5.144 - if params['ipaddr']: 5.145 - # Remove iptables rules for the ip addresses. 5.146 - vif = params['vif'] 5.147 - for ip in params['ipaddr']: 5.148 - Brctl.vif_restrict_addr(vif, ip, delete=1) 5.149 - 5.150 - 5.151 -if __name__ == "__main__": 5.152 - VifControl().main(sys.argv)
6.1 --- a/tools/examples/xmdefaults Thu Aug 19 09:10:04 2004 +0000 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,85 +0,0 @@ 6.4 -# -*- mode: python; -*- 6.5 -#============================================================================ 6.6 -# Python defaults setup for 'xm create'. 6.7 -# This script sets the parameters used when a domain is created using 'xm create'. 6.8 -# You use a separate script for each domain you want to create, or 6.9 -# you can set the parameters for the domain on the xm command line. 6.10 -#============================================================================ 6.11 - 6.12 -#---------------------------------------------------------------------------- 6.13 -# Kernel image file. 6.14 -kernel = "/boot/vmlinuz-2.4.26-xenU" 6.15 - 6.16 -# Optional ramdisk. 6.17 -#ramdisk = "/boot/initrd.gz" 6.18 - 6.19 -# The domain build function. Default is 'linux'. 6.20 -#builder='linux' 6.21 -#builder='netbsd' 6.22 - 6.23 -# Initial memory allocation (in megabytes) for the new domain. 6.24 -memory = 64 6.25 - 6.26 -# A name for your domain. All domains must have different names. 6.27 -name = "ExampleDomain" 6.28 - 6.29 -# Which CPU to start domain on? 6.30 -#cpu = -1 # leave to Xen to pick 6.31 - 6.32 -#---------------------------------------------------------------------------- 6.33 -# Define network interfaces. 6.34 - 6.35 -# Number of network interfaces. Default is 1. 6.36 -#nics=1 6.37 - 6.38 -# Optionally define mac and/or bridge for the network interfaces. 6.39 -# Random MACs are assigned if not given. 6.40 -#vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ] 6.41 - 6.42 -#---------------------------------------------------------------------------- 6.43 -# Define the disk devices you want the domain to have access to, and 6.44 -# what you want them accessible as. 6.45 -# Each disk entry is of the form phy:UNAME,DEV,MODE 6.46 -# where UNAME is the device, DEV is the device name the domain will see, 6.47 -# and MODE is r for read-only, w for read-write. 6.48 - 6.49 -disk = [ 'phy:hda1,xda1,r' ] 6.50 - 6.51 -#---------------------------------------------------------------------------- 6.52 -# Set the kernel command line for the new domain. 6.53 -# You only need to define the IP parameters and hostname if the domain's 6.54 -# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP. 6.55 -# You can use 'extra' to set the runlevel and custom environment 6.56 -# variables used by custom rc scripts (e.g. VMID=, usr= ). 6.57 - 6.58 -# Set if you want dhcp to allocate the IP address. 6.59 -#dhcp="dhcp" 6.60 -# Set netmask. 6.61 -#netmask= 6.62 -# Set default gateway. 6.63 -#gateway= 6.64 -# Set the hostname. 6.65 -#hostname= "vm%d" % vmid 6.66 - 6.67 -# Set root device. 6.68 -root = "/dev/xda1 ro" 6.69 - 6.70 -# Root device for nfs. 6.71 -#root = "/dev/nfs" 6.72 -# The nfs server. 6.73 -#nfs_server = '169.254.1.0' 6.74 -# Root directory on the nfs server. 6.75 -#nfs_root = '/full/path/to/root/directory' 6.76 - 6.77 -# Sets runlevel 4. 6.78 -extra = "4" 6.79 - 6.80 -#---------------------------------------------------------------------------- 6.81 -# Set according to whether you want the domain restarted when it exits. 6.82 -# The default is 'onreboot', which restarts the domain when it shuts down 6.83 -# with exit code reboot. 6.84 -# Other values are 'always', and 'never'. 6.85 - 6.86 -#restart = 'onreboot' 6.87 - 6.88 -#============================================================================
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/tools/examples/xmdefconfig Thu Aug 19 11:58:11 2004 +0000 7.3 @@ -0,0 +1,85 @@ 7.4 +# -*- mode: python; -*- 7.5 +#============================================================================ 7.6 +# Python configuration setup for 'xm create'. 7.7 +# This script sets the parameters used when a domain is created using 'xm create'. 7.8 +# You use a separate script for each domain you want to create, or 7.9 +# you can set the parameters for the domain on the xm command line. 7.10 +#============================================================================ 7.11 + 7.12 +#---------------------------------------------------------------------------- 7.13 +# Kernel image file. 7.14 +kernel = "/boot/vmlinuz-2.4.26-xenU" 7.15 + 7.16 +# Optional ramdisk. 7.17 +#ramdisk = "/boot/initrd.gz" 7.18 + 7.19 +# The domain build function. Default is 'linux'. 7.20 +#builder='linux' 7.21 +#builder='netbsd' 7.22 + 7.23 +# Initial memory allocation (in megabytes) for the new domain. 7.24 +memory = 64 7.25 + 7.26 +# A name for your domain. All domains must have different names. 7.27 +name = "ExampleDomain" 7.28 + 7.29 +# Which CPU to start domain on? 7.30 +#cpu = -1 # leave to Xen to pick 7.31 + 7.32 +#---------------------------------------------------------------------------- 7.33 +# Define network interfaces. 7.34 + 7.35 +# Number of network interfaces. Default is 1. 7.36 +#nics=1 7.37 + 7.38 +# Optionally define mac and/or bridge for the network interfaces. 7.39 +# Random MACs are assigned if not given. 7.40 +#vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ] 7.41 + 7.42 +#---------------------------------------------------------------------------- 7.43 +# Define the disk devices you want the domain to have access to, and 7.44 +# what you want them accessible as. 7.45 +# Each disk entry is of the form phy:UNAME,DEV,MODE 7.46 +# where UNAME is the device, DEV is the device name the domain will see, 7.47 +# and MODE is r for read-only, w for read-write. 7.48 + 7.49 +disk = [ 'phy:hda1,xda1,r' ] 7.50 + 7.51 +#---------------------------------------------------------------------------- 7.52 +# Set the kernel command line for the new domain. 7.53 +# You only need to define the IP parameters and hostname if the domain's 7.54 +# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP. 7.55 +# You can use 'extra' to set the runlevel and custom environment 7.56 +# variables used by custom rc scripts (e.g. VMID=, usr= ). 7.57 + 7.58 +# Set if you want dhcp to allocate the IP address. 7.59 +#dhcp="dhcp" 7.60 +# Set netmask. 7.61 +#netmask= 7.62 +# Set default gateway. 7.63 +#gateway= 7.64 +# Set the hostname. 7.65 +#hostname= "vm%d" % vmid 7.66 + 7.67 +# Set root device. 7.68 +root = "/dev/xda1 ro" 7.69 + 7.70 +# Root device for nfs. 7.71 +#root = "/dev/nfs" 7.72 +# The nfs server. 7.73 +#nfs_server = '169.254.1.0' 7.74 +# Root directory on the nfs server. 7.75 +#nfs_root = '/full/path/to/root/directory' 7.76 + 7.77 +# Sets runlevel 4. 7.78 +extra = "4" 7.79 + 7.80 +#---------------------------------------------------------------------------- 7.81 +# Set according to whether you want the domain restarted when it exits. 7.82 +# The default is 'onreboot', which restarts the domain when it shuts down 7.83 +# with exit code reboot. 7.84 +# Other values are 'always', and 'never'. 7.85 + 7.86 +#restart = 'onreboot' 7.87 + 7.88 +#============================================================================
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/tools/examples/xmdefconfig-example Thu Aug 19 11:58:11 2004 +0000 8.3 @@ -0,0 +1,120 @@ 8.4 +# -*- mode: python; -*- 8.5 +#============================================================================ 8.6 +# Example Python setup script for 'xm create'. 8.7 +# This script sets the parameters used when a domain is created using 'xm create'. 8.8 +# 8.9 +# This is a relatively advanced script that uses a parameter, vmid, to control 8.10 +# the settings. So this script can be used to start a set of domains by 8.11 +# setting the vmid parameter on the 'xm create' command line. For example: 8.12 +# 8.13 +# xm create vmid=1 8.14 +# xm create vmid=2 8.15 +# xm create vmid=3 8.16 +# 8.17 +# The vmid is purely a script variable, and has no effect on the the domain 8.18 +# id assigned to the new domain. 8.19 +#============================================================================ 8.20 + 8.21 +# Define script variables here. 8.22 +# xm_vars is defined automatically, use xm_vars.var() to define a variable. 8.23 + 8.24 +# This function checks that 'vmid' has been given a valid value. 8.25 +# It is called automatically by 'xm create'. 8.26 +def vmid_check(var, val): 8.27 + val = int(val) 8.28 + if val <= 0: 8.29 + raise ValueError 8.30 + return val 8.31 + 8.32 +# Define the 'vmid' variable so that 'xm create' knows about it. 8.33 +xm_vars.var('vmid', 8.34 + use="Virtual machine id. Integer greater than 0.", 8.35 + check=vmid_check) 8.36 + 8.37 +# Check the defined variables have valid values.. 8.38 +xm_vars.check() 8.39 + 8.40 +#---------------------------------------------------------------------------- 8.41 +# Kernel image file. 8.42 +kernel = "/boot/vmlinuz-2.4.26-xenU" 8.43 + 8.44 +# Optional ramdisk. 8.45 +#ramdisk = "/boot/initrd.gz" 8.46 + 8.47 +# The domain build function. Default is 'linux'. 8.48 +#builder='linux' 8.49 +#builder='netbsd' 8.50 + 8.51 +# Initial memory allocation (in megabytes) for the new domain. 8.52 +memory = 64 8.53 + 8.54 +# A name for the new domain. All domains have to have different names, 8.55 +# so we use the vmid to create a name. 8.56 +name = "VM%d" % vmid 8.57 + 8.58 +# Which CPU to start domain on? 8.59 +#cpu = -1 # leave to Xen to pick 8.60 +cpu = vmid # set based on vmid (mod number of CPUs) 8.61 + 8.62 +#---------------------------------------------------------------------------- 8.63 +# Define network interfaces. 8.64 + 8.65 +# Number of network interfaces. Default is 1. 8.66 +#nics=1 8.67 + 8.68 +# Optionally define mac and/or bridge for the network interfaces. 8.69 +# Random MACs are assigned if not given. 8.70 +#vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ] 8.71 + 8.72 +#---------------------------------------------------------------------------- 8.73 +# Define the disk devices you want the domain to have access to, and 8.74 +# what you want them accessible as. 8.75 +# Each disk entry is of the form phy:UNAME,DEV,MODE 8.76 +# where UNAME is the device, DEV is the device name the domain will see, 8.77 +# and MODE is r for read-only, w for read-write. 8.78 + 8.79 +# This makes the disk device depend on the vmid - assuming 8.80 +# that devices sda7, sda8 etc. exist. The device is exported 8.81 +# to all domains as sda1. 8.82 +# All domains get sda6 read-only (to use for /usr, see below). 8.83 +disk = [ 'phy:sda%d,sda1,w' % (7+vmid), 8.84 + 'phy:sda6,sda6,r' ] 8.85 + 8.86 +#---------------------------------------------------------------------------- 8.87 +# Set the kernel command line for the new domain. 8.88 +# You only need to define the IP parameters and hostname if the domain's 8.89 +# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP. 8.90 +# You can use 'extra' to set the runlevel and custom environment 8.91 +# variables used by custom rc scripts (e.g. VMID=, usr= ). 8.92 + 8.93 +# Set if you want dhcp to allocate the IP address. 8.94 +#dhcp="dhcp" 8.95 +# Set netmask. 8.96 +#netmask= 8.97 +# Set default gateway. 8.98 +#gateway= 8.99 +# Set the hostname. 8.100 +#hostname= "vm%d" % vmid 8.101 + 8.102 +# Set root device. 8.103 +root = "/dev/sda1 ro" 8.104 + 8.105 +# Root device for nfs. 8.106 +#root = "/dev/nfs" 8.107 +# The nfs server. 8.108 +#nfs_server = '169.254.1.0' 8.109 +# Root directory on the nfs server. 8.110 +#nfs_root = '/full/path/to/root/directory' 8.111 + 8.112 +# Sets runlevel 4 and the device for /usr. 8.113 +extra = "4 VMID=%d usr=/dev/sda6" % vmid 8.114 + 8.115 +#---------------------------------------------------------------------------- 8.116 +# Set according to whether you want the domain restarted when it exits. 8.117 +# The default is 'onreboot', which restarts the domain when it shuts down 8.118 +# with exit code reboot. 8.119 +# Other values are 'always', and 'never'. 8.120 + 8.121 +#restart = 'onreboot' 8.122 + 8.123 +#============================================================================
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/tools/examples/xmdefconfig-netbsd Thu Aug 19 11:58:11 2004 +0000 9.3 @@ -0,0 +1,123 @@ 9.4 +# -*- mode: python; -*- 9.5 +#============================================================================ 9.6 +# Example Python setup script for 'xm create'. 9.7 +# This script sets the parameters used when a domain is created using 'xm create'. 9.8 +# 9.9 +# This is a relatively advanced script that uses a parameter, vmid, to control 9.10 +# the settings. So this script can be used to start a set of domains by 9.11 +# setting the vmid parameter on the 'xm create' command line. For example: 9.12 +# 9.13 +# xm create vmid=1 9.14 +# xm create vmid=2 9.15 +# xm create vmid=3 9.16 +# 9.17 +# The vmid is purely a script variable, and has no effect on the the domain 9.18 +# id assigned to the new domain. 9.19 +#============================================================================ 9.20 + 9.21 +# Define script variables here. 9.22 +# xm_vars is defined automatically, use xm_vars.var() to define a variable. 9.23 + 9.24 +# This function checks that 'vmid' has been given a valid value. 9.25 +# It is called automatically by 'xm create'. 9.26 +def vmid_check(var, val): 9.27 + val = int(val) 9.28 + if val <= 0: 9.29 + raise ValueError 9.30 + return val 9.31 + 9.32 +# Define the 'vmid' variable so that 'xm create' knows about it. 9.33 +xm_vars.var('vmid', 9.34 + use="Virtual machine id. Integer greater than 0.", 9.35 + check=vmid_check) 9.36 + 9.37 +# Check the defined variables have valid values.. 9.38 +xm_vars.check() 9.39 + 9.40 +#---------------------------------------------------------------------------- 9.41 +# Kernel image file. 9.42 +image = "/boot/netbsd" 9.43 + 9.44 +# The domain build function. 9.45 +builder='netbsd' 9.46 + 9.47 +# Initial memory allocation (in megabytes) for the new domain. 9.48 +memory = 16 9.49 + 9.50 +# A name for the new domain. All domains have to have different names, 9.51 +# so we use the vmid to create a name. 9.52 +name = "NETBSD%d" % vmid 9.53 + 9.54 +#---------------------------------------------------------------------------- 9.55 +# Define network interfaces. 9.56 + 9.57 +# Number of network interfaces. Default is 1. 9.58 +#nics=1 9.59 + 9.60 +# Optionally define mac and/or bridge for the network interfaces. 9.61 +# Random MACs are assigned if not given. 9.62 +#vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ] 9.63 + 9.64 +# Specify IP address(es), for the new domain. You need to 9.65 +# configure IP addrs within the domain just as you do normally. This 9.66 +# is just to let Xen know about them so it can route packets 9.67 +# appropriately. 9.68 + 9.69 +#ipaddr = [ xenctl.utils.add_offset_to_ip(xenctl.utils.get_current_ipaddr(),vmid), 9.70 +# xenctl.utils.add_offset_to_ip('169.254.1.0',vmid), 9.71 +# ] 9.72 + 9.73 +#---------------------------------------------------------------------------- 9.74 +# Define the disk devices you want the domain to have access to, and 9.75 +# what you want them accessible as. 9.76 +# Each disk entry is of the form phy:UNAME,DEV,MODE 9.77 +# where UNAME is the device, DEV is the device name the domain will see, 9.78 +# and MODE is r for read-only, w for read-write. 9.79 + 9.80 +# This makes the disk device depend on the vmid - assuming 9.81 +# that devices sda7, sda8 etc. exist. The device is exported 9.82 +# to all domains as sda1. 9.83 +# All domains get sda6 read-only (to use for /usr, see below). 9.84 +disk = [ 'phy:sda%d,sda1,w' % (7+vmid), 9.85 + 'phy:sda6,sda6,r' ] 9.86 + 9.87 +#---------------------------------------------------------------------------- 9.88 +# Set the kernel command line for the new domain. 9.89 +# You only need to define the IP parameters and hostname if the domain's 9.90 +# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP. 9.91 +# You can use 'extra' to set the runlevel and custom environment 9.92 +# variables used by custom rc scripts (e.g. VMID=, usr= ). 9.93 + 9.94 +# Set if you want dhcp to allocate the IP address. 9.95 +#dhcp="dhcp" 9.96 +# Set netmask. 9.97 +#netmask= 9.98 +# Set default gateway. 9.99 +#gateway= 9.100 +# Set the hostname. 9.101 +#hostname= "vm%d" % vmid 9.102 + 9.103 +# Set root device. 9.104 +root = "/dev/sda1 ro" 9.105 + 9.106 +# Root device for nfs. 9.107 +#root = "/dev/nfs" 9.108 +# The nfs server. 9.109 +#nfs_server = '169.254.1.0' 9.110 +# Root directory on the nfs server. 9.111 +#nfs_root = '/full/path/to/root/directory' 9.112 + 9.113 +# Sets runlevel 4 and the device for /usr. 9.114 +#extra = "4 VMID=%d usr=/dev/sda6" % vmid 9.115 +extra = "4 VMID=%d bootdev=xennet0" % vmid 9.116 + 9.117 + 9.118 +#---------------------------------------------------------------------------- 9.119 +# Set according to whether you want the domain restarted when it exits. 9.120 +# The default is 'onreboot', which restarts the domain when it shuts down 9.121 +# with exit code reboot. 9.122 +# Other values are 'always', and 'never'. 9.123 +# 9.124 +#restart = 'onreboot' 9.125 + 9.126 +#============================================================================
10.1 --- a/tools/examples/xmexample Thu Aug 19 09:10:04 2004 +0000 10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 10.3 @@ -1,120 +0,0 @@ 10.4 -# -*- mode: python; -*- 10.5 -#============================================================================ 10.6 -# Example Python setup script for 'xm create'. 10.7 -# This script sets the parameters used when a domain is created using 'xm create'. 10.8 -# 10.9 -# This is a relatively advanced script that uses a parameter, vmid, to control 10.10 -# the settings. So this script can be used to start a set of domains by 10.11 -# setting the vmid parameter on the 'xm create' command line. For example: 10.12 -# 10.13 -# xm create vmid=1 10.14 -# xm create vmid=2 10.15 -# xm create vmid=3 10.16 -# 10.17 -# The vmid is purely a script variable, and has no effect on the the domain 10.18 -# id assigned to the new domain. 10.19 -#============================================================================ 10.20 - 10.21 -# Define script variables here. 10.22 -# xm_vars is defined automatically, use xm_vars.var() to define a variable. 10.23 - 10.24 -# This function checks that 'vmid' has been given a valid value. 10.25 -# It is called automatically by 'xm create'. 10.26 -def vmid_check(var, val): 10.27 - val = int(val) 10.28 - if val <= 0: 10.29 - raise ValueError 10.30 - return val 10.31 - 10.32 -# Define the 'vmid' variable so that 'xm create' knows about it. 10.33 -xm_vars.var('vmid', 10.34 - use="Virtual machine id. Integer greater than 0.", 10.35 - check=vmid_check) 10.36 - 10.37 -# Check the defined variables have valid values.. 10.38 -xm_vars.check() 10.39 - 10.40 -#---------------------------------------------------------------------------- 10.41 -# Kernel image file. 10.42 -kernel = "/boot/vmlinuz-2.4.26-xenU" 10.43 - 10.44 -# Optional ramdisk. 10.45 -#ramdisk = "/boot/initrd.gz" 10.46 - 10.47 -# The domain build function. Default is 'linux'. 10.48 -#builder='linux' 10.49 -#builder='netbsd' 10.50 - 10.51 -# Initial memory allocation (in megabytes) for the new domain. 10.52 -memory = 64 10.53 - 10.54 -# A name for the new domain. All domains have to have different names, 10.55 -# so we use the vmid to create a name. 10.56 -name = "VM%d" % vmid 10.57 - 10.58 -# Which CPU to start domain on? 10.59 -#cpu = -1 # leave to Xen to pick 10.60 -cpu = vmid # set based on vmid (mod number of CPUs) 10.61 - 10.62 -#---------------------------------------------------------------------------- 10.63 -# Define network interfaces. 10.64 - 10.65 -# Number of network interfaces. Default is 1. 10.66 -#nics=1 10.67 - 10.68 -# Optionally define mac and/or bridge for the network interfaces. 10.69 -# Random MACs are assigned if not given. 10.70 -#vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ] 10.71 - 10.72 -#---------------------------------------------------------------------------- 10.73 -# Define the disk devices you want the domain to have access to, and 10.74 -# what you want them accessible as. 10.75 -# Each disk entry is of the form phy:UNAME,DEV,MODE 10.76 -# where UNAME is the device, DEV is the device name the domain will see, 10.77 -# and MODE is r for read-only, w for read-write. 10.78 - 10.79 -# This makes the disk device depend on the vmid - assuming 10.80 -# that devices sda7, sda8 etc. exist. The device is exported 10.81 -# to all domains as sda1. 10.82 -# All domains get sda6 read-only (to use for /usr, see below). 10.83 -disk = [ 'phy:sda%d,sda1,w' % (7+vmid), 10.84 - 'phy:sda6,sda6,r' ] 10.85 - 10.86 -#---------------------------------------------------------------------------- 10.87 -# Set the kernel command line for the new domain. 10.88 -# You only need to define the IP parameters and hostname if the domain's 10.89 -# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP. 10.90 -# You can use 'extra' to set the runlevel and custom environment 10.91 -# variables used by custom rc scripts (e.g. VMID=, usr= ). 10.92 - 10.93 -# Set if you want dhcp to allocate the IP address. 10.94 -#dhcp="dhcp" 10.95 -# Set netmask. 10.96 -#netmask= 10.97 -# Set default gateway. 10.98 -#gateway= 10.99 -# Set the hostname. 10.100 -#hostname= "vm%d" % vmid 10.101 - 10.102 -# Set root device. 10.103 -root = "/dev/sda1 ro" 10.104 - 10.105 -# Root device for nfs. 10.106 -#root = "/dev/nfs" 10.107 -# The nfs server. 10.108 -#nfs_server = '169.254.1.0' 10.109 -# Root directory on the nfs server. 10.110 -#nfs_root = '/full/path/to/root/directory' 10.111 - 10.112 -# Sets runlevel 4 and the device for /usr. 10.113 -extra = "4 VMID=%d usr=/dev/sda6" % vmid 10.114 - 10.115 -#---------------------------------------------------------------------------- 10.116 -# Set according to whether you want the domain restarted when it exits. 10.117 -# The default is 'onreboot', which restarts the domain when it shuts down 10.118 -# with exit code reboot. 10.119 -# Other values are 'always', and 'never'. 10.120 - 10.121 -#restart = 'onreboot' 10.122 - 10.123 -#============================================================================
11.1 --- a/tools/examples/xmnetbsd-example Thu Aug 19 09:10:04 2004 +0000 11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 11.3 @@ -1,123 +0,0 @@ 11.4 -# -*- mode: python; -*- 11.5 -#============================================================================ 11.6 -# Example Python setup script for 'xm create'. 11.7 -# This script sets the parameters used when a domain is created using 'xm create'. 11.8 -# 11.9 -# This is a relatively advanced script that uses a parameter, vmid, to control 11.10 -# the settings. So this script can be used to start a set of domains by 11.11 -# setting the vmid parameter on the 'xm create' command line. For example: 11.12 -# 11.13 -# xm create vmid=1 11.14 -# xm create vmid=2 11.15 -# xm create vmid=3 11.16 -# 11.17 -# The vmid is purely a script variable, and has no effect on the the domain 11.18 -# id assigned to the new domain. 11.19 -#============================================================================ 11.20 - 11.21 -# Define script variables here. 11.22 -# xm_vars is defined automatically, use xm_vars.var() to define a variable. 11.23 - 11.24 -# This function checks that 'vmid' has been given a valid value. 11.25 -# It is called automatically by 'xm create'. 11.26 -def vmid_check(var, val): 11.27 - val = int(val) 11.28 - if val <= 0: 11.29 - raise ValueError 11.30 - return val 11.31 - 11.32 -# Define the 'vmid' variable so that 'xm create' knows about it. 11.33 -xm_vars.var('vmid', 11.34 - use="Virtual machine id. Integer greater than 0.", 11.35 - check=vmid_check) 11.36 - 11.37 -# Check the defined variables have valid values.. 11.38 -xm_vars.check() 11.39 - 11.40 -#---------------------------------------------------------------------------- 11.41 -# Kernel image file. 11.42 -image = "/boot/netbsd" 11.43 - 11.44 -# The domain build function. 11.45 -builder='netbsd' 11.46 - 11.47 -# Initial memory allocation (in megabytes) for the new domain. 11.48 -memory = 16 11.49 - 11.50 -# A name for the new domain. All domains have to have different names, 11.51 -# so we use the vmid to create a name. 11.52 -name = "NETBSD%d" % vmid 11.53 - 11.54 -#---------------------------------------------------------------------------- 11.55 -# Define network interfaces. 11.56 - 11.57 -# Number of network interfaces. Default is 1. 11.58 -#nics=1 11.59 - 11.60 -# Optionally define mac and/or bridge for the network interfaces. 11.61 -# Random MACs are assigned if not given. 11.62 -#vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ] 11.63 - 11.64 -# Specify IP address(es), for the new domain. You need to 11.65 -# configure IP addrs within the domain just as you do normally. This 11.66 -# is just to let Xen know about them so it can route packets 11.67 -# appropriately. 11.68 - 11.69 -#ipaddr = [ xenctl.utils.add_offset_to_ip(xenctl.utils.get_current_ipaddr(),vmid), 11.70 -# xenctl.utils.add_offset_to_ip('169.254.1.0',vmid), 11.71 -# ] 11.72 - 11.73 -#---------------------------------------------------------------------------- 11.74 -# Define the disk devices you want the domain to have access to, and 11.75 -# what you want them accessible as. 11.76 -# Each disk entry is of the form phy:UNAME,DEV,MODE 11.77 -# where UNAME is the device, DEV is the device name the domain will see, 11.78 -# and MODE is r for read-only, w for read-write. 11.79 - 11.80 -# This makes the disk device depend on the vmid - assuming 11.81 -# that devices sda7, sda8 etc. exist. The device is exported 11.82 -# to all domains as sda1. 11.83 -# All domains get sda6 read-only (to use for /usr, see below). 11.84 -disk = [ 'phy:sda%d,sda1,w' % (7+vmid), 11.85 - 'phy:sda6,sda6,r' ] 11.86 - 11.87 -#---------------------------------------------------------------------------- 11.88 -# Set the kernel command line for the new domain. 11.89 -# You only need to define the IP parameters and hostname if the domain's 11.90 -# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP. 11.91 -# You can use 'extra' to set the runlevel and custom environment 11.92 -# variables used by custom rc scripts (e.g. VMID=, usr= ). 11.93 - 11.94 -# Set if you want dhcp to allocate the IP address. 11.95 -#dhcp="dhcp" 11.96 -# Set netmask. 11.97 -#netmask= 11.98 -# Set default gateway. 11.99 -#gateway= 11.100 -# Set the hostname. 11.101 -#hostname= "vm%d" % vmid 11.102 - 11.103 -# Set root device. 11.104 -root = "/dev/sda1 ro" 11.105 - 11.106 -# Root device for nfs. 11.107 -#root = "/dev/nfs" 11.108 -# The nfs server. 11.109 -#nfs_server = '169.254.1.0' 11.110 -# Root directory on the nfs server. 11.111 -#nfs_root = '/full/path/to/root/directory' 11.112 - 11.113 -# Sets runlevel 4 and the device for /usr. 11.114 -#extra = "4 VMID=%d usr=/dev/sda6" % vmid 11.115 -extra = "4 VMID=%d bootdev=xennet0" % vmid 11.116 - 11.117 - 11.118 -#---------------------------------------------------------------------------- 11.119 -# Set according to whether you want the domain restarted when it exits. 11.120 -# The default is 'onreboot', which restarts the domain when it shuts down 11.121 -# with exit code reboot. 11.122 -# Other values are 'always', and 'never'. 11.123 -# 11.124 -#restart = 'onreboot' 11.125 - 11.126 -#============================================================================
12.1 --- a/tools/python/xen/xend/XendRoot.py Thu Aug 19 09:10:04 2004 +0000 12.2 +++ b/tools/python/xen/xend/XendRoot.py Thu Aug 19 11:58:11 2004 +0000 12.3 @@ -44,7 +44,7 @@ class XendRoot: 12.4 config_var = "XEND_CONFIG" 12.5 12.6 """Where network control scripts live.""" 12.7 - network_script_dir = "/etc/xen" 12.8 + network_script_dir = "/etc/xen/scripts" 12.9 12.10 logfile_default = "/var/log/xend.log" 12.11
13.1 --- a/tools/python/xen/xm/create.py Thu Aug 19 09:10:04 2004 +0000 13.2 +++ b/tools/python/xen/xm/create.py Thu Aug 19 11:58:11 2004 +0000 13.3 @@ -20,48 +20,47 @@ Create a domain. 13.4 13.5 Domain creation parameters can be set by command-line switches, from 13.6 a python configuration script or an SXP config file. See documentation 13.7 -for --defaults, --config. Configuration variables can be set using 13.8 +for --defconfig, --config. Configuration variables can be set using 13.9 VAR=VAL on the command line. For example vmid=3 sets vmid to 3. 13.10 13.11 """) 13.12 13.13 gopts.opt('help', short='h', 13.14 - fn=set_true, default=0, 13.15 - use="Print this help.") 13.16 + fn=set_true, default=0, 13.17 + use="Print this help.") 13.18 13.19 gopts.opt('help_config', 13.20 fn=set_true, default=0, 13.21 - use="Print help for configuration file.") 13.22 + use="Print help for the configuration script.") 13.23 13.24 gopts.opt('quiet', short='q', 13.25 - fn=set_true, default=0, 13.26 - use="Quiet.") 13.27 + fn=set_true, default=0, 13.28 + use="Quiet.") 13.29 13.30 gopts.opt('path', val='PATH', 13.31 - fn=set_value, default='.:/etc/xen', 13.32 - use="Search path for default scripts.") 13.33 + fn=set_value, default='.:/etc/xen', 13.34 + use="""Search path for configuration scripts. 13.35 + The value of PATH is a colon-separated directory list.""") 13.36 13.37 -gopts.opt('defaults', short='f', val='FILE', 13.38 - fn=set_value, default='xmdefaults', 13.39 - use="""Use the given Python defaults script. 13.40 -The defaults script is loaded after arguments have been processed. 13.41 -Each command-line option sets a configuration variable named after 13.42 -its long option name, and these variables are placed in the 13.43 -environment of the script before it is loaded. 13.44 -Variables for options that may be repeated have list values. 13.45 -Other variables can be set using VAR=VAL on the command line. 13.46 - 13.47 -After the script is loaded, option values that were not set on the 13.48 -command line are replaced by the values set in the script. 13.49 -""") 13.50 +gopts.opt('defconfig', short='f', val='FILE', 13.51 + fn=set_value, default='xmdefconfig', 13.52 + use="""Use the given Python configuration script. 13.53 + The configuration script is loaded after arguments have been processed. 13.54 + Each command-line option sets a configuration variable named after 13.55 + its long option name, and these variables are placed in the 13.56 + environment of the script before it is loaded. 13.57 + Variables for options that may be repeated have list values. 13.58 + Other variables can be set using VAR=VAL on the command line. 13.59 + 13.60 + After the script is loaded, option values that were not set on the 13.61 + command line are replaced by the values set in the script.""") 13.62 13.63 gopts.opt('config', short='F', val='FILE', 13.64 - fn=set_value, default=None, 13.65 - use="""Domain configuration to use (SXP). 13.66 -SXP is the underlying configuration format used by Xen. 13.67 -SXP configs can be hand-written or generated from Python defaults 13.68 -scripts, using the -n (dryrun) option to print the config. 13.69 -""") 13.70 + fn=set_value, default=None, 13.71 + use="""Domain configuration to use (SXP). 13.72 + SXP is the underlying configuration format used by Xen. 13.73 + SXP configurations can be hand-written or generated from Python configuration 13.74 + scripts, using the -n (dryrun) option to print the configuration.""") 13.75 13.76 gopts.opt('load', short='L', val='FILE', 13.77 fn=set_value, default=None, 13.78 @@ -69,9 +68,8 @@ gopts.opt('load', short='L', val='FILE', 13.79 13.80 gopts.opt('dryrun', short='n', 13.81 fn=set_true, default=0, 13.82 - use="""Dry run - print the config but don't create the domain. 13.83 -The defaults file is loaded and the SXP configuration is created and printed. 13.84 -""") 13.85 + use="""Dry run - print the configuration but don't create the domain. 13.86 + Loads the configuration script, creates the SXP configuration and prints it.""") 13.87 13.88 gopts.opt('paused', short='p', 13.89 fn=set_true, default=0, 13.90 @@ -83,7 +81,7 @@ gopts.opt('console_autoconnect', short=' 13.91 13.92 gopts.var('name', val='NAME', 13.93 fn=set_value, default=None, 13.94 - use="Domain name.") 13.95 + use="Domain name. Must be unique.") 13.96 13.97 gopts.var('kernel', val='FILE', 13.98 fn=set_value, default=None, 13.99 @@ -98,13 +96,17 @@ gopts.var('builder', val='FUNCTION', 13.100 use="Function to use to build the domain.") 13.101 13.102 gopts.var('memory', val='MEMORY', 13.103 - fn=set_value, default=128, 13.104 + fn=set_int, default=128, 13.105 use="Domain memory in MB.") 13.106 13.107 +gopts.var('cpu', val='CPU', 13.108 + fn=set_int, default=None, 13.109 + use="CPU to run the domain on.") 13.110 + 13.111 gopts.var('cpu_weight', val='WEIGHT', 13.112 - fn=set_float, default=1, 13.113 - use="""Set the new domain's cpu weight. WEIGHT is a float that controls the 13.114 -domain's share of the cpu.""") 13.115 + fn=set_float, default=None, 13.116 + use="""Set the new domain's cpu weight. 13.117 + WEIGHT is a float that controls the domain's share of the cpu.""") 13.118 13.119 gopts.var('console', val='PORT', 13.120 fn=set_int, default=None, 13.121 @@ -113,10 +115,9 @@ gopts.var('console', val='PORT', 13.122 gopts.var('restart', val='onreboot|always|never', 13.123 fn=set_value, default=None, 13.124 use="""Whether the domain should be restarted on exit. 13.125 - - onreboot: restart on exit with shutdown code reboot 13.126 - - always: always restart on exit, ignore exit code 13.127 - - never: never restart on exit, ignore exit code 13.128 - """) 13.129 + - onreboot: restart on exit with shutdown code reboot 13.130 + - always: always restart on exit, ignore exit code 13.131 + - never: never restart on exit, ignore exit code""") 13.132 13.133 gopts.var('blkif', val='no|yes', 13.134 fn=set_bool, default=0, 13.135 @@ -129,18 +130,16 @@ gopts.var('netif', val='no|yes', 13.136 gopts.var('disk', val='phy:DEV,VDEV,MODE[,DOM]', 13.137 fn=append_value, default=[], 13.138 use="""Add a disk device to a domain. The physical device is DEV, 13.139 - which is exported to the domain as VDEV. The disk is read-only if MODE 13.140 - is 'r', read-write if MODE is 'w'. If DOM is specified it defines the 13.141 - backend driver domain to use for the disk. 13.142 - The option may be repeated to add more than one disk. 13.143 - """) 13.144 + which is exported to the domain as VDEV. The disk is read-only if MODE 13.145 + is 'r', read-write if MODE is 'w'. If DOM is specified it defines the 13.146 + backend driver domain to use for the disk. 13.147 + The option may be repeated to add more than one disk.""") 13.148 13.149 gopts.var('pci', val='BUS,DEV,FUNC', 13.150 fn=append_value, default=[], 13.151 use="""Add a PCI device to a domain, using given params (in hex). 13.152 For example '-pci c0,02,1a'. 13.153 - The option may be repeated to add more than one pci device. 13.154 - """) 13.155 + The option may be repeated to add more than one pci device.""") 13.156 13.157 gopts.var('ipaddr', val="IPADDR", 13.158 fn=append_value, default=[], 13.159 @@ -149,27 +148,25 @@ gopts.var('ipaddr', val="IPADDR", 13.160 gopts.var('vif', val="mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM", 13.161 fn=append_value, default=[], 13.162 use="""Add a network interface with the given MAC address and bridge. 13.163 - The vif is configured by calling the given configuration script. 13.164 - If mac is not specified a random MAC address is used. 13.165 - If bridge is not specified the default bridge is used. 13.166 - If script is not specified the default script is used. 13.167 - If backend is not specified the default backend driver domain is used. 13.168 - This option may be repeated to add more than one vif. 13.169 - Specifying vifs will increase the number of interfaces as needed. 13.170 - """) 13.171 + The vif is configured by calling the given configuration script. 13.172 + If mac is not specified a random MAC address is used. 13.173 + If bridge is not specified the default bridge is used. 13.174 + If script is not specified the default script is used. 13.175 + If backend is not specified the default backend driver domain is used. 13.176 + This option may be repeated to add more than one vif. 13.177 + Specifying vifs will increase the number of interfaces as needed.""") 13.178 13.179 gopts.var('nics', val="NUM", 13.180 fn=set_int, default=1, 13.181 use="""Set the number of network interfaces. 13.182 - Use the vif option to define interface parameters, otherwise 13.183 - defaults are used. Specifying vifs will increase the 13.184 - number of interfaces as needed. 13.185 - """) 13.186 + Use the vif option to define interface parameters, otherwise 13.187 + defaults are used. Specifying vifs will increase the 13.188 + number of interfaces as needed.""") 13.189 13.190 gopts.var('root', val='DEVICE', 13.191 fn=set_value, default='', 13.192 use="""Set the root= parameter on the kernel command line. 13.193 - Use a device, e.g. /dev/sda1, or /dev/nfs for NFS root.""") 13.194 + Use a device, e.g. /dev/sda1, or /dev/nfs for NFS root.""") 13.195 13.196 gopts.var('extra', val="ARGS", 13.197 fn=set_value, default='', 13.198 @@ -261,7 +258,7 @@ def randomMAC(): 13.199 The remaining 3 fields are random, with the first bit of the first 13.200 random field set 0. 13.201 13.202 - returns MAC address string 13.203 + @return: MAC address string 13.204 """ 13.205 mac = [ 0xaa, 0x00, 0x00, 13.206 random.randint(0x00, 0x7f), 13.207 @@ -312,10 +309,11 @@ def make_config(vals): 13.208 13.209 config = ['vm', 13.210 ['name', vals.name ], 13.211 - ['memory', vals.memory ], 13.212 - ['cpu_weight', vals.cpu_weight] ] 13.213 - if vals.cpu: 13.214 + ['memory', vals.memory ]] 13.215 + if vals.cpu is not None: 13.216 config.append(['cpu', vals.cpu]) 13.217 + if vals.cpu_weight is not None: 13.218 + config.append(['cpu_weight', vals.cpu_weight]) 13.219 if vals.blkif: 13.220 config.append(['backend', ['blkif']]) 13.221 if vals.netif: 13.222 @@ -445,7 +443,7 @@ def main(argv): 13.223 if opts.vals.help: 13.224 opts.usage() 13.225 if opts.vals.help or opts.vals.help_config: 13.226 - opts.load_defaults(help=1) 13.227 + opts.load_defconfig(help=1) 13.228 if opts.vals.help or opts.vals.help_config: 13.229 return 13.230 # Process remaining args as config variables. 13.231 @@ -456,7 +454,7 @@ def main(argv): 13.232 if opts.vals.config: 13.233 config = opts.vals.config 13.234 else: 13.235 - opts.load_defaults() 13.236 + opts.load_defconfig() 13.237 preprocess(opts, opts.vals) 13.238 config = make_config(opts.vals) 13.239 if opts.vals.dryrun:
14.1 --- a/tools/python/xen/xm/help.py Thu Aug 19 09:10:04 2004 +0000 14.2 +++ b/tools/python/xen/xm/help.py Thu Aug 19 11:58:11 2004 +0000 14.3 @@ -1,6 +1,6 @@ 14.4 # Copyright (C) 2004 Mike Wray <mike.wray@hp.com> 14.5 14.6 -"""Variable definition and help support for Python defaults files. 14.7 +"""Variable definition and help support for Python defconfig files. 14.8 """ 14.9 14.10 import sys 14.11 @@ -12,7 +12,7 @@ class Vars: 14.12 def __init__(self, name, help, env): 14.13 """Create a variable set. 14.14 14.15 - name name of the defaults file 14.16 + name name of the defconfig file 14.17 help help flag 14.18 env local environment 14.19 """
15.1 --- a/tools/python/xen/xm/opts.py Thu Aug 19 09:10:04 2004 +0000 15.2 +++ b/tools/python/xen/xm/opts.py Thu Aug 19 11:58:11 2004 +0000 15.3 @@ -88,19 +88,31 @@ class Opt: 15.4 else: 15.5 return None 15.6 15.7 - def show(self): 15.8 - sep = '' 15.9 + def format(self, str, start=' ', out=sys.stdout): 15.10 + """Print a string, with consistent indentation at the start of lines. 15.11 + """ 15.12 + lines = str.split('\n') 15.13 + for l in lines: 15.14 + l = l.strip() 15.15 + if start: 15.16 + out.write(start) 15.17 + out.write(l) 15.18 + out.write('\n') 15.19 + 15.20 + def show(self, out=sys.stdout): 15.21 + sep = ' ' 15.22 for x in self.optkeys: 15.23 - print sep, x, 15.24 - sep = ',' 15.25 + out.write(sep) 15.26 + out.write(x) 15.27 + sep = ', ' 15.28 if self.val: 15.29 - print self.val, 15.30 - print 15.31 + out.write(' ') 15.32 + out.write(self.val) 15.33 + out.write('\n') 15.34 if self.use: 15.35 - print '\t', 15.36 - print self.use 15.37 + self.format(self.use, out=out); 15.38 if self.val: 15.39 - print '\tDefault', self.default or 'None' 15.40 + self.format('Default ' + str(self.default or 'None'), out=out) 15.41 15.42 def specify(self, k, v): 15.43 """Specify the option. Called when the option is set 15.44 @@ -153,14 +165,12 @@ class OptVar(Opt): 15.45 def long_opt(self): 15.46 return None 15.47 15.48 - def show(self): 15.49 - print '%s=%s' %(self.optkeys[0], self.val) 15.50 - print 15.51 + def show(self, out=sys.stdout): 15.52 + print >>out, ' %s=%s' % (self.optkeys[0], self.val) 15.53 if self.use: 15.54 - print '\t', 15.55 - print self.use 15.56 + self.format(self.use, out=out); 15.57 if self.val: 15.58 - print '\tDefault', self.default or 'None' 15.59 + self.format('Default ' + str(self.default or 'None'), out=out) 15.60 15.61 class OptVals: 15.62 """Class to hold option values. 15.63 @@ -328,29 +338,48 @@ class Opts: 15.64 15.65 def usage(self): 15.66 print 'Usage: ', self.argv[0], self.use or 'OPTIONS' 15.67 + print 15.68 for opt in self.options: 15.69 + opt.show() 15.70 print 15.71 - opt.show() 15.72 + if self.options: 15.73 + print 15.74 15.75 - def load_defaults(self, help=0): 15.76 - """Load a defaults script. Assumes these options set: 15.77 + def var_usage(self): 15.78 + if self.vars: 15.79 + print 'The defconfig defines the following variables:' 15.80 + for var in self.vars: 15.81 + var.show() 15.82 + print 15.83 + print 15.84 + 15.85 + def config_usage(self): 15.86 + if self.imports: 15.87 + print 'The following are automically imported:' 15.88 + for x in self.imports: 15.89 + print ' ', x 15.90 + print 15.91 + self.var_usage() 15.92 + 15.93 + def load_defconfig(self, help=0): 15.94 + """Load a defconfig script. Assumes these options set: 15.95 'path' search path 15.96 - 'default' script name 15.97 + 'defconfig' script name 15.98 """ 15.99 for x in [ '' ] + self.vals.path.split(':'): 15.100 if x: 15.101 - p = os.path.join(x, self.vals.defaults) 15.102 + p = os.path.join(x, self.vals.defconfig) 15.103 else: 15.104 - p = self.vals.defaults 15.105 + p = self.vals.defconfig 15.106 if os.path.exists(p): 15.107 - self.info('Using config file %s' % p) 15.108 + self.info('Using defconfig file %s.' % p) 15.109 self.load(p, help) 15.110 break 15.111 else: 15.112 - self.err("Cannot open defaults file %s" % self.vals.defaults) 15.113 + self.err("Cannot open defconfig file %s" % self.vals.defconfig) 15.114 15.115 - def load(self, defaults, help): 15.116 - """Load a defaults file. Local variables in the file 15.117 + def load(self, defconfig, help): 15.118 + """Load a defconfig file. Local variables in the file 15.119 are used to set options with the same names. 15.120 Variables are not used to set options that are already specified. 15.121 """ 15.122 @@ -363,19 +392,17 @@ class Opts: 15.123 locals.update(self.vars) 15.124 cmd = '\n'.join(self.imports + 15.125 [ "from xen.xm.help import Vars", 15.126 - "xm_file = '%s'" % defaults, 15.127 + "xm_file = '%s'" % defconfig, 15.128 "xm_help = %d" % help, 15.129 "xm_vars = Vars(xm_file, xm_help, locals())" 15.130 ]) 15.131 exec cmd in globals, locals 15.132 try: 15.133 - execfile(defaults, globals, locals) 15.134 + execfile(defconfig, globals, locals) 15.135 except: 15.136 if not help: raise 15.137 if help: 15.138 - print 'The following imports are done automatically:' 15.139 - for x in self.imports: 15.140 - print x 15.141 + self.config_usage() 15.142 return 15.143 # Extract the values set by the script and set the corresponding 15.144 # options, if not set on the command line.