ia64/xen-unstable

view tools/examples/xmexample2 @ 2422:2274a0386cc9

bitkeeper revision 1.1159.69.5 (4138e882jA1YaR_OfTfNHe_uT4PDIg)

trivial
author iap10@labyrinth.cl.cam.ac.uk
date Fri Sep 03 21:56:18 2004 +0000 (2004-09-03)
parents b1347b2eb538
children fddd7da6fe9a fd5c7fbfbd1d
line source
1 # -*- mode: python; -*-
2 #============================================================================
3 # Example Python setup script for 'xm create'.
4 # This script sets the parameters used when a domain is created using 'xm create'.
5 #
6 # This is a relatively advanced script that uses a parameter, vmid, to control
7 # the settings. So this script can be used to start a set of domains by
8 # setting the vmid parameter on the 'xm create' command line. For example:
9 #
10 # xm create vmid=1
11 # xm create vmid=2
12 # xm create vmid=3
13 #
14 # The vmid is purely a script variable, and has no effect on the the domain
15 # id assigned to the new domain.
16 #============================================================================
18 # Define script variables here.
19 # xm_vars is defined automatically, use xm_vars.var() to define a variable.
21 # This function checks that 'vmid' has been given a valid value.
22 # It is called automatically by 'xm create'.
23 def vmid_check(var, val):
24 val = int(val)
25 if val <= 0:
26 raise ValueError
27 return val
29 # Define the 'vmid' variable so that 'xm create' knows about it.
30 xm_vars.var('vmid',
31 use="Virtual machine id. Integer greater than 0.",
32 check=vmid_check)
34 # Check the defined variables have valid values..
35 xm_vars.check()
37 #----------------------------------------------------------------------------
38 # Kernel image file.
39 kernel = "/boot/vmlinuz-2.4.26-xenU"
41 # Optional ramdisk.
42 #ramdisk = "/boot/initrd.gz"
44 # The domain build function. Default is 'linux'.
45 #builder='linux'
46 #builder='netbsd'
48 # Initial memory allocation (in megabytes) for the new domain.
49 memory = 64
51 # A name for the new domain. All domains have to have different names,
52 # so we use the vmid to create a name.
53 name = "VM%d" % vmid
55 # Which CPU to start domain on?
56 #cpu = -1 # leave to Xen to pick
57 cpu = vmid # set based on vmid (mod number of CPUs)
59 #----------------------------------------------------------------------------
60 # Define network interfaces.
62 # Number of network interfaces. Default is 1.
63 #nics=1
65 # Optionally define mac and/or bridge for the network interfaces.
66 # Random MACs are assigned if not given.
67 #vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ]
69 #----------------------------------------------------------------------------
70 # Define the disk devices you want the domain to have access to, and
71 # what you want them accessible as.
72 # Each disk entry is of the form phy:UNAME,DEV,MODE
73 # where UNAME is the device, DEV is the device name the domain will see,
74 # and MODE is r for read-only, w for read-write.
76 # This makes the disk device depend on the vmid - assuming
77 # that devices sda7, sda8 etc. exist. The device is exported
78 # to all domains as sda1.
79 # All domains get sda6 read-only (to use for /usr, see below).
80 disk = [ 'phy:sda%d,sda1,w' % (7+vmid),
81 'phy:sda6,sda6,r' ]
83 #----------------------------------------------------------------------------
84 # Set the kernel command line for the new domain.
85 # You only need to define the IP parameters and hostname if the domain's
86 # IP config doesn't, e.g. in ifcfg-eth0 or via DHCP.
87 # You can use 'extra' to set the runlevel and custom environment
88 # variables used by custom rc scripts (e.g. VMID=, usr= ).
90 # Set if you want dhcp to allocate the IP address.
91 #dhcp="dhcp"
92 # Set netmask.
93 #netmask=
94 # Set default gateway.
95 #gateway=
96 # Set the hostname.
97 #hostname= "vm%d" % vmid
99 # Set root device.
100 root = "/dev/sda1 ro"
102 # Root device for nfs.
103 #root = "/dev/nfs"
104 # The nfs server.
105 #nfs_server = '169.254.1.0'
106 # Root directory on the nfs server.
107 #nfs_root = '/full/path/to/root/directory'
109 # Sets runlevel 4 and the device for /usr.
110 extra = "4 VMID=%d usr=/dev/sda6" % vmid
112 #----------------------------------------------------------------------------
113 # Set according to whether you want the domain restarted when it exits.
114 # The default is 'onreboot', which restarts the domain when it shuts down
115 # with exit code reboot.
116 # Other values are 'always', and 'never'.
118 #restart = 'onreboot'
120 #============================================================================