ia64/xen-unstable

view tools/examples/democd @ 1372:5a6113c65ead

bitkeeper revision 1.891.1.12 (40a248b0WTGoOa9206iWkyGN0mTPNw)

Allow forcing of IRQ trigger-type to edge or level
(NB. DANGEROUS!).
author kaf24@scramble.cl.cam.ac.uk
date Wed May 12 15:54:24 2004 +0000 (2004-05-12)
parents a6e98694ed63
children
line source
2 ##### Edit this python file to reflect the configuration of your system
4 ##### This example script requires variable 'ip' to be set, and optionally
5 ##### netmask and gatewaty for the kernel command line
7 def config_usage ():
8 print >>sys.stderr, """
9 The config file %s requires the following vars to be defined:
10 ip -- List of IP addr(s) for Xen to route to domain
11 e.g. '-Dip=1.2.3.4,5.6.7.8'
12 The following variables may be optionally defined:
13 mem -- Adjust initial memory allocation (default 64MB)
14 netmask -- Override gateway for kernel ip= command line
15 gateway -- Override network for kernel ip= command line
16 """ % config_file
18 try:
19 ip
20 except:
21 print "Set variable 'ip' using '-Dip=1.2.3.4,5.6.7.8'"
22 assert()
24 # STEP 1. Specify kernel image file and otional ramdisk. Can be gzip'ed.
25 image = "/boot/xenolinux.gz"
26 ramdisk = "/boot/initrd.gz"
27 builder_fn='linux' # this is a linux domain
29 # STEP 2. The initial memory allocation (in megabytes) for the new domain.
30 try:
31 mem_size = int(mem)
32 except NameError:
33 mem_size = 64
36 # STEP 3. A handy name for your new domain.
37 # appends either first hostname or last quad of first IP address dependant on value passed
39 quads = string.split(ip, '.')
40 if len(quads) == 4: # fragile heuristic for valid IP verification
41 domain_name = "Xen VM .%s" % quads[3] # use last quad of IP
42 else:
43 domain_name = "Xen VM: %s" % ip # use hostname passed in
46 # STEP 4. Specify IP address(es), for the new domain. You need to
47 # configure IP addrs within the domain just as you do normally. This
48 # is just to let Xen know about them so it can route packets
49 # appropriately.
51 #vfr_ipaddr = ["111.222.333.444","222.333.444.555"]
52 #vfr_ipaddr = [xenctl.utils.add_offset_to_ip(xenctl.utils.get_current_ipaddr(),vmid)]
53 vfr_ipaddr = map(socket.gethostbyname,string.split(ip,','))
57 # STEP 5a. Identify any physcial partitions or virtual disks you want the
58 # domain to have access to, and what you want them accessible as
59 # e.g. vbd_list = [ ('phy:sda1','sda1', 'w'),
60 # ('phy:sda%d' % (3+vmid), 'hda2', 'r'),
61 # ('vd:as73gd784dh','hda1','w'),
62 # ('phy:cdrom','hdd','r')
64 vbd_list = [ ('phy:cdrom','hdd','r' ) ]
68 # STEP 5b. Set the VBD expertise level. Most people should leave this
69 # on 0, at least to begin with - this script can detect most dangerous
70 # disk sharing between domains and with this set to zero it will only
71 # allow read only sharing.
73 vbd_expert = 0
76 # STEP 6. Build the command line for the new domain. Edit as req'd.
77 # You only need the ip= line if you're NFS booting or the root file system
78 # doesn't set it later e.g. in ifcfg-eth0 or via DHCP
79 # You can use 'extrabit' to set the runlevel and custom environment
80 # variables used by custom rc scripts (e.g. VMID=, usr= )
83 # see if we have a local IP at all
84 localip=''
85 for i in vfr_ipaddr:
86 if xenctl.utils.check_subnet(i,'169.254.0.0','255.255.0.0'):
87 localip=i
88 break
91 # if either netmask and gateway has been set from the command line,
92 # associate it with the first IP address that has been specified.
94 myip = ''
96 try:
97 netmask = socket.gethostbyname( netmask )
98 gateway = socket.gethostbyname( gateway )
99 myip = vfr_ipaddr[0]
101 except NameError:
102 netmask = xenctl.utils.get_current_ipmask()
103 gateway = xenctl.utils.get_current_ipgw()
105 # if we haven't got an address, see if we have one that matches the LAN
107 if not myip:
108 if netmask and gateway:
109 for i in vfr_ipaddr:
110 if xenctl.utils.check_subnet(i,gateway,netmask):
111 myip=i
112 break
114 # if we still haven't got an address, see if there's a link local one
116 if not myip and localip:
117 myip = localip
118 netmask = '255.255.0.0'
119 gateway = '169.254.1.0'
122 # As a final fallback, through everything down the interface
124 if not myip:
125 myip = vfr_ipaddr[0]
126 netmask = '0.0.0.0'
127 gateway = ''
129 # Calculate the components with which we will build the command line
131 nfsserv = '169.254.1.0'
133 cmdline_ip="ip="+myip+":"+nfsserv+":"+gateway+":"+netmask+"::eth0:off"
134 cmdline_root = "root=/dev/ram0 rw init=/linuxrc"
136 if localip:
137 cmdline_extra = "4 LOCALIP=%s" % localip
138 else:
139 cmdline_extra = "4"
141 # STEP 7. Set according to whether you want the script to watch the domain
142 # and auto-restart it should it die or exit.
144 auto_restart = False
145 #auto_restart = True