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 | #============================================================================ |
---|
17 | |
---|
18 | # Define script variables here. |
---|
19 | # xm_vars is defined automatically, use xm_vars.var() to define a variable. |
---|
20 | |
---|
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 |
---|
28 | |
---|
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) |
---|
33 | |
---|
34 | # Check the defined variables have valid values.. |
---|
35 | xm_vars.check() |
---|
36 | |
---|
37 | #---------------------------------------------------------------------------- |
---|
38 | # Kernel image file. |
---|
39 | kernel = "/path/to/domU/kernel" |
---|
40 | |
---|
41 | # Optional ramdisk. |
---|
42 | #ramdisk = "/boot/initrd.gz" |
---|
43 | |
---|
44 | # The domain build function. Default is 'linux'. |
---|
45 | #builder='linux' |
---|
46 | |
---|
47 | # Initial memory allocation (in megabytes) for the new domain. |
---|
48 | # |
---|
49 | # WARNING: Creating a domain with insufficient memory may cause out of |
---|
50 | # memory errors. The domain needs enough memory to boot kernel |
---|
51 | # and modules. Allocating less than 32MBs is not recommended. |
---|
52 | memory = 64 |
---|
53 | |
---|
54 | # A name for the new domain. All domains have to have different names, |
---|
55 | # so we use the vmid to create a name. |
---|
56 | name = "VM%d" % vmid |
---|
57 | |
---|
58 | # 128-bit UUID for the domain. The default behavior is to generate a new UUID |
---|
59 | # on each call to 'xm create'. |
---|
60 | #uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9" |
---|
61 | |
---|
62 | # List of which CPUS this domain is allowed to use, default Xen picks |
---|
63 | #cpus = "" # leave to Xen to pick |
---|
64 | #cpus = "0" # all vcpus run on CPU0 |
---|
65 | #cpus = "0-3,5,^1" # run on cpus 0,2,3,5 |
---|
66 | cpus = "%s" % vmid # set based on vmid (mod number of CPUs) |
---|
67 | |
---|
68 | #---------------------------------------------------------------------------- |
---|
69 | # Define network interfaces. |
---|
70 | |
---|
71 | # Optionally define mac and/or bridge for the network interfaces. |
---|
72 | # Random MACs are assigned if not given. |
---|
73 | |
---|
74 | vif = [ 'ip=192.168.%d.1/24' % (vmid)] |
---|
75 | |
---|
76 | #---------------------------------------------------------------------------- |
---|
77 | # Define the disk devices you want the domain to have access to, and |
---|
78 | # what you want them accessible as. |
---|
79 | # Each disk entry is of the form phy:UNAME,DEV,MODE |
---|
80 | # where UNAME is the device, DEV is the device name the domain will see, |
---|
81 | # and MODE is r for read-only, w for read-write. |
---|
82 | |
---|
83 | # This makes the disk device depend on the vmid - assuming |
---|
84 | # tHat devices sda7, sda8 etc. exist. The device is exported |
---|
85 | # to all domains as sda1. |
---|
86 | # All domains get sda6 read-only (to use for /usr, see below). |
---|
87 | disk = [ 'phy:hda%d,hda1,w' % (vmid)] |
---|
88 | |
---|
89 | #---------------------------------------------------------------------------- |
---|
90 | # Define frame buffer device. |
---|
91 | # |
---|
92 | # By default, no frame buffer device is configured. |
---|
93 | # |
---|
94 | # To create one using the SDL backend and sensible defaults: |
---|
95 | # |
---|
96 | # vfb = [ 'type=sdl' ] |
---|
97 | # |
---|
98 | # This uses environment variables XAUTHORITY and DISPLAY. You |
---|
99 | # can override that: |
---|
100 | # |
---|
101 | # vfb = [ 'type=sdl,xauthority=/home/bozo/.Xauthority,display=:1' ] |
---|
102 | # |
---|
103 | # To create one using the VNC backend and sensible defaults: |
---|
104 | # |
---|
105 | # vfb = [ 'type=vnc' ] |
---|
106 | # |
---|
107 | # The backend listens on 127.0.0.1 port 5900+N by default, where N is |
---|
108 | # the domain ID. You can override both address and N: |
---|
109 | # |
---|
110 | # vfb = [ 'type=vnc,vnclisten=127.0.0.1,vncdisplay=%d' % vmid ] |
---|
111 | # |
---|
112 | # Or you can bind the first unused port above 5900: |
---|
113 | # |
---|
114 | # vfb = [ 'type=vnc,vnclisten=0.0.0.0,vnunused=1' ] |
---|
115 | # |
---|
116 | # You can override the password: |
---|
117 | # |
---|
118 | # vfb = [ 'type=vnc,vncpasswd=MYPASSWD' ] |
---|
119 | # |
---|
120 | # Empty password disables authentication. Defaults to the vncpasswd |
---|
121 | # configured in xend-config.sxp. |
---|
122 | |
---|
123 | #---------------------------------------------------------------------------- |
---|
124 | # Define to which TPM instance the user domain should communicate. |
---|
125 | # The vtpm entry is of the form 'instance=INSTANCE,backend=DOM' |
---|
126 | # where INSTANCE indicates the instance number of the TPM the VM |
---|
127 | # should be talking to and DOM provides the domain where the backend |
---|
128 | # is located. |
---|
129 | # Note that no two virtual machines should try to connect to the same |
---|
130 | # TPM instance. The handling of all TPM instances does require |
---|
131 | # some management effort in so far that VM configration files (and thus |
---|
132 | # a VM) should be associated with a TPM instance throughout the lifetime |
---|
133 | # of the VM / VM configuration file. The instance number must be |
---|
134 | # greater or equal to 1. |
---|
135 | #vtpm = ['instance=%d,backend=0' % (vmid) ] |
---|
136 | |
---|
137 | #---------------------------------------------------------------------------- |
---|
138 | # Set the kernel command line for the new domain. |
---|
139 | # You only need to define the IP parameters and hostname if the domain's |
---|
140 | # IP config doesn't, e.g. in ifcfg-eth0 or via DHCP. |
---|
141 | # You can use 'extra' to set the runlevel and custom environment |
---|
142 | # variables used by custom rc scripts (e.g. VMID=, usr= ). |
---|
143 | |
---|
144 | # Set if you want dhcp to allocate the IP address. |
---|
145 | dhcp="off" |
---|
146 | ip="192.168.%d.2" % (vmid) |
---|
147 | # Set netmask. |
---|
148 | netmask="255.255.255.0" |
---|
149 | # Set default gateway. |
---|
150 | gateway="192.168.%d.1" % (vmid) |
---|
151 | # Set the hostname. |
---|
152 | hostname= "domain-%d.xeno" % vmid |
---|
153 | |
---|
154 | # Set root device. |
---|
155 | root = "/dev/hda1 ro" |
---|
156 | |
---|
157 | # Root device for nfs. |
---|
158 | #root = "/dev/nfs" |
---|
159 | # The nfs server. |
---|
160 | #nfs_server = "10.212.4.103" |
---|
161 | # Root directory on the nfs server. |
---|
162 | #nfs_root = "/path/to/root/filesystem" |
---|
163 | |
---|
164 | # Sets runlevel 4 and the device for /usr. |
---|
165 | extra = "4 VMID=%d" % vmid |
---|
166 | |
---|
167 | #---------------------------------------------------------------------------- |
---|
168 | # Configure the behaviour when a domain exits. There are three 'reasons' |
---|
169 | # for a domain to stop: poweroff, reboot, and crash. For each of these you |
---|
170 | # may specify: |
---|
171 | # |
---|
172 | # "destroy", meaning that the domain is cleaned up as normal; |
---|
173 | # "restart", meaning that a new domain is started in place of the old |
---|
174 | # one; |
---|
175 | # "preserve", meaning that no clean-up is done until the domain is |
---|
176 | # manually destroyed (using xm destroy, for example); or |
---|
177 | # "rename-restart", meaning that the old domain is not cleaned up, but is |
---|
178 | # renamed and a new domain started in its place. |
---|
179 | # |
---|
180 | # The default is |
---|
181 | # |
---|
182 | # on_poweroff = 'destroy' |
---|
183 | # on_reboot = 'restart' |
---|
184 | # on_crash = 'restart' |
---|
185 | # |
---|
186 | # For backwards compatibility we also support the deprecated option restart |
---|
187 | # |
---|
188 | # restart = 'onreboot' means on_poweroff = 'destroy' |
---|
189 | # on_reboot = 'restart' |
---|
190 | # on_crash = 'destroy' |
---|
191 | # |
---|
192 | # restart = 'always' means on_poweroff = 'restart' |
---|
193 | # on_reboot = 'restart' |
---|
194 | # on_crash = 'restart' |
---|
195 | # |
---|
196 | # restart = 'never' means on_poweroff = 'destroy' |
---|
197 | # on_reboot = 'destroy' |
---|
198 | # on_crash = 'destroy' |
---|
199 | |
---|
200 | #on_poweroff = 'destroy' |
---|
201 | #on_reboot = 'restart' |
---|
202 | #on_crash = 'restart' |
---|
203 | |
---|
204 | #============================================================================ |
---|