ia64/xen-unstable

view tools/examples/xmexample3 @ 7238:971e7c7411b3

Raise an exception if an error appears on the pipes to our children, and make
sure that the child's pipes are closed even under that exception. Move the
handling of POLLHUP to the end of the loop, so that we guarantee to read any
remaining data from the child if POLLHUP and POLLIN appear at the same time.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Thu Oct 06 10:13:11 2005 +0100 (2005-10-06)
parents 244f1aa98d30
children a9c35cd7e559
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 = "/path/to/domU/kernel"
41 # Optional ramdisk.
42 #ramdisk = "/boot/initrd.gz"
44 # The domain build function. Default is 'linux'.
45 #builder='linux'
47 # Initial memory allocation (in megabytes) for the new domain.
48 memory = 64
50 # A name for the new domain. All domains have to have different names,
51 # so we use the vmid to create a name.
52 name = "VM%d" % vmid
54 # Which CPU to start domain on?
55 #cpu = -1 # leave to Xen to pick
56 cpu = vmid # set based on vmid (mod number of CPUs)
58 #----------------------------------------------------------------------------
59 # Define network interfaces.
61 # Number of network interfaces. Default is 1.
62 #nics=1
64 # Optionally define mac and/or bridge for the network interfaces.
65 # Random MACs are assigned if not given.
67 vif = [ 'ip=192.168.%d.1/24' % (vmid)]
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:hda%d,hda1,w' % (vmid)]
82 #----------------------------------------------------------------------------
83 # Define to which TPM instance the user domain should communicate.
84 # The vtpm entry is of the form 'instance=INSTANCE,backend=DOM'
85 # where INSTANCE indicates the instance number of the TPM the VM
86 # should be talking to and DOM provides the domain where the backend
87 # is located.
88 # Note that no two virtual machines should try to connect to the same
89 # TPM instance. The handling of all TPM instances does require
90 # some management effort in so far that VM configration files (and thus
91 # a VM) should be associated with a TPM instance throughout the lifetime
92 # of the VM / VM configuration file. The instance number must be
93 # greater or equal to 1.
94 #vtpm = ['instance=%d,backend=0' % (vmid) ]
96 #----------------------------------------------------------------------------
97 # Set the kernel command line for the new domain.
98 # You only need to define the IP parameters and hostname if the domain's
99 # IP config doesn't, e.g. in ifcfg-eth0 or via DHCP.
100 # You can use 'extra' to set the runlevel and custom environment
101 # variables used by custom rc scripts (e.g. VMID=, usr= ).
103 # Set if you want dhcp to allocate the IP address.
104 dhcp="off"
105 ip="192.168.%d.2" % (vmid)
106 # Set netmask.
107 netmask="255.255.255.0"
108 # Set default gateway.
109 gateway="192.168.%d.1" % (vmid)
110 # Set the hostname.
111 hostname= "domain-%d.xeno" % vmid
113 # Set root device.
114 root = "/dev/hda1 ro"
116 # Root device for nfs.
117 #root = "/dev/nfs"
118 # The nfs server.
119 #nfs_server = "10.212.4.103"
120 # Root directory on the nfs server.
121 #nfs_root = "/path/to/root/filesystem"
123 # Sets runlevel 4 and the device for /usr.
124 extra = "4 VMID=%d" % vmid
126 #----------------------------------------------------------------------------
127 # Configure the behaviour when a domain exits. There are three 'reasons'
128 # for a domain to stop: poweroff, reboot, and crash. For each of these you
129 # may specify:
130 #
131 # "destroy", meaning that the domain is cleaned up as normal;
132 # "restart", meaning that a new domain is started in place of the old
133 # one;
134 # "preserve", meaning that no clean-up is done until the domain is
135 # manually destroyed (using xm destroy, for example); or
136 # "rename-restart", meaning that the old domain is not cleaned up, but is
137 # renamed and a new domain started in its place.
138 #
139 # The default is
140 #
141 # on_poweroff = 'destroy'
142 # on_reboot = 'restart'
143 # on_crash = 'restart'
144 #
145 # For backwards compatibility we also support the deprecated option restart
146 #
147 # restart = 'onreboot' means on_poweroff = 'destroy'
148 # on_reboot = 'restart'
149 # on_crash = 'destroy'
150 #
151 # restart = 'always' means on_poweroff = 'restart'
152 # on_reboot = 'restart'
153 # on_crash = 'restart'
154 #
155 # restart = 'never' means on_poweroff = 'destroy'
156 # on_reboot = 'destroy'
157 # on_crash = 'destroy'
159 #on_poweroff = 'destroy'
160 #on_reboot = 'restart'
161 #on_crash = 'restart'
163 #============================================================================