ia64/xen-unstable

annotate tools/examples/xmexample3 @ 19615:13a4f4e6d0a3

x86 hvm: Correctly emulate task switches into vm86 mode.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 19 02:12:04 2009 +0100 (2009-05-19)
parents 0942baa2a088
children
rev   line source
iap10@3592 1 # -*- mode: python; -*-
iap10@3592 2 #============================================================================
iap10@3592 3 # Example Python setup script for 'xm create'.
iap10@3592 4 # This script sets the parameters used when a domain is created using 'xm create'.
iap10@3592 5 #
iap10@3592 6 # This is a relatively advanced script that uses a parameter, vmid, to control
iap10@3592 7 # the settings. So this script can be used to start a set of domains by
iap10@3592 8 # setting the vmid parameter on the 'xm create' command line. For example:
iap10@3592 9 #
iap10@3592 10 # xm create vmid=1
iap10@3592 11 # xm create vmid=2
iap10@3592 12 # xm create vmid=3
iap10@3592 13 #
iap10@3592 14 # The vmid is purely a script variable, and has no effect on the the domain
iap10@3592 15 # id assigned to the new domain.
iap10@3592 16 #============================================================================
iap10@3592 17
iap10@3592 18 # Define script variables here.
iap10@3592 19 # xm_vars is defined automatically, use xm_vars.var() to define a variable.
iap10@3592 20
iap10@3592 21 # This function checks that 'vmid' has been given a valid value.
iap10@3592 22 # It is called automatically by 'xm create'.
iap10@3592 23 def vmid_check(var, val):
iap10@3592 24 val = int(val)
iap10@3592 25 if val <= 0:
iap10@3592 26 raise ValueError
iap10@3592 27 return val
iap10@3592 28
iap10@3592 29 # Define the 'vmid' variable so that 'xm create' knows about it.
iap10@3592 30 xm_vars.var('vmid',
iap10@3592 31 use="Virtual machine id. Integer greater than 0.",
iap10@3592 32 check=vmid_check)
iap10@3592 33
iap10@3592 34 # Check the defined variables have valid values..
iap10@3592 35 xm_vars.check()
iap10@3592 36
iap10@3592 37 #----------------------------------------------------------------------------
iap10@3592 38 # Kernel image file.
iap10@3592 39 kernel = "/path/to/domU/kernel"
iap10@3592 40
iap10@3592 41 # Optional ramdisk.
iap10@3592 42 #ramdisk = "/boot/initrd.gz"
iap10@3592 43
iap10@3592 44 # The domain build function. Default is 'linux'.
iap10@3592 45 #builder='linux'
iap10@3592 46
iap10@3592 47 # Initial memory allocation (in megabytes) for the new domain.
stekloff@9788 48 #
stekloff@9788 49 # WARNING: Creating a domain with insufficient memory may cause out of
stekloff@9788 50 # memory errors. The domain needs enough memory to boot kernel
stekloff@9788 51 # and modules. Allocating less than 32MBs is not recommended.
iap10@3592 52 memory = 64
iap10@3592 53
iap10@3592 54 # A name for the new domain. All domains have to have different names,
iap10@3592 55 # so we use the vmid to create a name.
iap10@3592 56 name = "VM%d" % vmid
iap10@3592 57
kaf24@10063 58 # 128-bit UUID for the domain. The default behavior is to generate a new UUID
kaf24@10063 59 # on each call to 'xm create'.
kaf24@10063 60 #uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"
kaf24@10063 61
emellor@8198 62 # List of which CPUS this domain is allowed to use, default Xen picks
emellor@8198 63 #cpus = "" # leave to Xen to pick
emellor@8198 64 #cpus = "0" # all vcpus run on CPU0
keir@17628 65 #cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5
keir@17628 66 #cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3
emellor@8198 67 cpus = "%s" % vmid # set based on vmid (mod number of CPUs)
iap10@3592 68
iap10@3592 69 #----------------------------------------------------------------------------
iap10@3592 70 # Define network interfaces.
iap10@3592 71
iap10@3592 72 # Optionally define mac and/or bridge for the network interfaces.
iap10@3592 73 # Random MACs are assigned if not given.
iap10@3592 74
iap10@3592 75 vif = [ 'ip=192.168.%d.1/24' % (vmid)]
iap10@3592 76
iap10@3592 77 #----------------------------------------------------------------------------
iap10@3592 78 # Define the disk devices you want the domain to have access to, and
iap10@3592 79 # what you want them accessible as.
iap10@3592 80 # Each disk entry is of the form phy:UNAME,DEV,MODE
iap10@3592 81 # where UNAME is the device, DEV is the device name the domain will see,
iap10@3592 82 # and MODE is r for read-only, w for read-write.
iap10@3592 83
iap10@3592 84 # This makes the disk device depend on the vmid - assuming
iap10@3592 85 # tHat devices sda7, sda8 etc. exist. The device is exported
iap10@3592 86 # to all domains as sda1.
iap10@3592 87 # All domains get sda6 read-only (to use for /usr, see below).
iap10@3592 88 disk = [ 'phy:hda%d,hda1,w' % (vmid)]
iap10@3592 89
iap10@3592 90 #----------------------------------------------------------------------------
kfraser@13407 91 # Define frame buffer device.
kfraser@13407 92 #
kfraser@13407 93 # By default, no frame buffer device is configured.
kfraser@13407 94 #
kfraser@13407 95 # To create one using the SDL backend and sensible defaults:
kfraser@13407 96 #
keir@19287 97 # vfb = [ 'sdl=1' ]
kfraser@13407 98 #
kfraser@13407 99 # This uses environment variables XAUTHORITY and DISPLAY. You
kfraser@13407 100 # can override that:
kfraser@13407 101 #
keir@19287 102 # vfb = [ 'sdl=1,xauthority=/home/bozo/.Xauthority,display=:1' ]
kfraser@13407 103 #
kfraser@13407 104 # To create one using the VNC backend and sensible defaults:
kfraser@13407 105 #
keir@19287 106 # vfb = [ 'vnc=1' ]
kfraser@13407 107 #
kfraser@13407 108 # The backend listens on 127.0.0.1 port 5900+N by default, where N is
kfraser@13407 109 # the domain ID. You can override both address and N:
kfraser@13407 110 #
keir@19287 111 # vfb = [ 'vnc=1,vnclisten=127.0.0.1,vncdisplay=%d' % vmid ]
kfraser@13407 112 #
kfraser@13407 113 # Or you can bind the first unused port above 5900:
kfraser@13407 114 #
keir@19287 115 # vfb = [ 'vnc=1,vnclisten=0.0.0.0,vncunused=1' ]
kfraser@13407 116 #
kfraser@13407 117 # You can override the password:
kfraser@13407 118 #
keir@19287 119 # vfb = [ 'vnc=1,vncpasswd=MYPASSWD' ]
kfraser@13407 120 #
kfraser@13407 121 # Empty password disables authentication. Defaults to the vncpasswd
kfraser@13407 122 # configured in xend-config.sxp.
kfraser@13407 123
kfraser@13407 124 #----------------------------------------------------------------------------
shand@6572 125 # Define to which TPM instance the user domain should communicate.
shand@6572 126 # The vtpm entry is of the form 'instance=INSTANCE,backend=DOM'
shand@6572 127 # where INSTANCE indicates the instance number of the TPM the VM
shand@6572 128 # should be talking to and DOM provides the domain where the backend
shand@6572 129 # is located.
shand@6572 130 # Note that no two virtual machines should try to connect to the same
shand@6572 131 # TPM instance. The handling of all TPM instances does require
shand@6572 132 # some management effort in so far that VM configration files (and thus
shand@6572 133 # a VM) should be associated with a TPM instance throughout the lifetime
shand@6572 134 # of the VM / VM configuration file. The instance number must be
shand@6572 135 # greater or equal to 1.
shand@6572 136 #vtpm = ['instance=%d,backend=0' % (vmid) ]
shand@6572 137
shand@6572 138 #----------------------------------------------------------------------------
iap10@3592 139 # Set the kernel command line for the new domain.
iap10@3592 140 # You only need to define the IP parameters and hostname if the domain's
iap10@3592 141 # IP config doesn't, e.g. in ifcfg-eth0 or via DHCP.
iap10@3592 142 # You can use 'extra' to set the runlevel and custom environment
iap10@3592 143 # variables used by custom rc scripts (e.g. VMID=, usr= ).
iap10@3592 144
iap10@3592 145 # Set if you want dhcp to allocate the IP address.
iap10@3592 146 dhcp="off"
iap10@3592 147 ip="192.168.%d.2" % (vmid)
iap10@3592 148 # Set netmask.
iap10@3592 149 netmask="255.255.255.0"
iap10@3592 150 # Set default gateway.
iap10@3592 151 gateway="192.168.%d.1" % (vmid)
iap10@3592 152 # Set the hostname.
iap10@3592 153 hostname= "domain-%d.xeno" % vmid
iap10@3592 154
iap10@3592 155 # Set root device.
iap10@3592 156 root = "/dev/hda1 ro"
iap10@3592 157
iap10@3592 158 # Root device for nfs.
iap10@3592 159 #root = "/dev/nfs"
iap10@3592 160 # The nfs server.
iap10@3592 161 #nfs_server = "10.212.4.103"
iap10@3592 162 # Root directory on the nfs server.
iap10@3592 163 #nfs_root = "/path/to/root/filesystem"
iap10@3592 164
iap10@3592 165 # Sets runlevel 4 and the device for /usr.
iap10@3592 166 extra = "4 VMID=%d" % vmid
iap10@3592 167
iap10@3592 168 #----------------------------------------------------------------------------
emellor@7153 169 # Configure the behaviour when a domain exits. There are three 'reasons'
emellor@7153 170 # for a domain to stop: poweroff, reboot, and crash. For each of these you
emellor@7156 171 # may specify:
emellor@7156 172 #
emellor@7156 173 # "destroy", meaning that the domain is cleaned up as normal;
emellor@7156 174 # "restart", meaning that a new domain is started in place of the old
emellor@7156 175 # one;
emellor@7156 176 # "preserve", meaning that no clean-up is done until the domain is
emellor@7156 177 # manually destroyed (using xm destroy, for example); or
emellor@7156 178 # "rename-restart", meaning that the old domain is not cleaned up, but is
emellor@7156 179 # renamed and a new domain started in its place.
emellor@7153 180 #
keir@16999 181 # In the event a domain stops due to a crash, you have the additional options:
keir@16999 182 #
keir@16999 183 # "coredump-destroy", meaning dump the crashed domain's core and then destroy;
keir@16999 184 # "coredump-restart', meaning dump the crashed domain's core and the restart.
keir@16999 185 #
emellor@7153 186 # The default is
emellor@7153 187 #
emellor@7153 188 # on_poweroff = 'destroy'
emellor@7153 189 # on_reboot = 'restart'
emellor@7153 190 # on_crash = 'restart'
emellor@7153 191 #
emellor@7153 192 # For backwards compatibility we also support the deprecated option restart
emellor@7153 193 #
emellor@7153 194 # restart = 'onreboot' means on_poweroff = 'destroy'
emellor@7153 195 # on_reboot = 'restart'
emellor@7153 196 # on_crash = 'destroy'
emellor@7153 197 #
emellor@7153 198 # restart = 'always' means on_poweroff = 'restart'
emellor@7153 199 # on_reboot = 'restart'
emellor@7153 200 # on_crash = 'restart'
emellor@7153 201 #
emellor@7153 202 # restart = 'never' means on_poweroff = 'destroy'
emellor@7153 203 # on_reboot = 'destroy'
emellor@7153 204 # on_crash = 'destroy'
iap10@3592 205
emellor@7153 206 #on_poweroff = 'destroy'
emellor@7153 207 #on_reboot = 'restart'
emellor@7153 208 #on_crash = 'restart'
iap10@3592 209
keir@18270 210 #-----------------------------------------------------------------------------
keir@18270 211 # Configure PVSCSI devices:
keir@18270 212 #
keir@18270 213 #vscsi=[ 'PDEV, VDEV' ]
keir@18270 214 #
keir@18270 215 # PDEV gives physical SCSI device to be attached to specified guest
keir@18270 216 # domain by one of the following identifier format.
keir@18270 217 # - XX:XX:XX:XX (4-tuples with decimal notation which shows
keir@18270 218 # "host:channel:target:lun")
keir@18270 219 # - /dev/sdxx or sdx
keir@18270 220 # - /dev/stxx or stx
keir@18270 221 # - /dev/sgxx or sgx
keir@18270 222 # - result of 'scsi_id -gu -s'.
keir@18270 223 # ex. # scsi_id -gu -s /block/sdb
keir@18270 224 # 36000b5d0006a0000006a0257004c0000
keir@18270 225 #
keir@18270 226 # VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as
keir@18270 227 # which the specified guest domain recognize.
keir@18270 228 #
keir@18270 229
keir@18270 230 #vscsi = [ '/dev/sdx, 0:0:0:0' ]
keir@18270 231
iap10@3592 232 #============================================================================