ia64/xen-unstable

view stubdom/stubdom-dm @ 19818:415505139333

Get rid of hardcoded pathes for stubdom and hotplug scripts

- Have the buid system generate a file which exports the install paths
for the hotplug scripts and stubdom / stubdom-dm
- Move file generation code from tools/python/Makefile into a gmake
macro
in Config.mk to avoid maintenance of three duplicates each with its
own
tweaks and bugs
- Export gmake variables into ioemu as shell variables
for upcoming ioemu patches
- Do above as a gmake macro to avoid maintenance of several duplicates
- Adjust hotplug scripts to find the right xen binaries from the
install directory
- Adjust stubdom-dm to use the install directories

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jun 23 17:25:51 2009 +0100 (2009-06-23)
parents c0d2838fc10f
children
line source
1 #!/bin/bash
2 #
3 # Copyright 2007-2008 Samuel Thibault <samuel.thibault@eu.citrix.net>
4 #
5 # dm script around stubdomains.
6 #
8 . ./stubdompath.sh
9 stubdom_configdir="${XEN_CONFIG_DIR}/stubdoms"
11 # To fit xterms nicely
12 height=339
14 # Parse arguments
16 domid=
17 domname=
18 vncviewer=0
19 vncpid=
20 extra=
21 sdl=0
22 opengl=1
23 vnc=0
24 vncunused=0
25 while [ "$#" -gt 0 ];
26 do
27 if [ "$#" -ge 2 ];
28 then
29 case "$1" in
30 -d)
31 domid=$2;
32 extra="$extra -d $domid";
33 shift
34 ;;
35 -domain-name)
36 domname=$2;
37 shift
38 ;;
39 -vnc)
40 vnc=1
41 op=${2%,*}
42 ip=${op%:*};
43 vnc_port=${op#*:};
44 shift
45 ;;
46 -vncunused)
47 vncunused=1
48 shift
49 ;;
50 -loadvm)
51 extra="$extra -loadvm $2";
52 shift
53 ;;
54 -k)
55 keymap=$2
56 shift
57 ;;
58 -serial)
59 serial="$2"
60 shift
61 ;;
62 -monitor)
63 monitor="$2"
64 shift
65 ;;
66 esac
67 fi
68 case "$1" in
69 -vncviewer) vncviewer=1 ;;
70 -sdl) sdl=1 ;;
71 -disable-opengl) opengl=0 ;;
72 esac
73 shift
74 done
76 [ -z "$domid" ] && ( echo "couldn't find domain ID" ; exit 1 )
77 [ -z "$domname" ] && ( echo "couldn't find domain name" ; exit 1 )
79 # Termination handler
81 term() {
82 kill %1
83 (
84 [ -n "$vncpid" ] && kill -9 $vncpid
85 xm destroy $domname-dm
86 rm ${stubdom_configdir}/$domname-dm
87 ) &
88 # We need to exit immediately so as to let xend do the commands above
89 exit 0
90 }
92 trap term SIGHUP
94 ############
95 # stubdomain
96 # Wait for any previous stubdom to terminate
97 while xm list | grep $domname-dm
98 do
99 sleep 1
100 done
102 # Generate stubdom config file
103 mkdir -p ${stubdom_configdir} &>/dev/null
104 echo "#This file is autogenerated, edit $domname instead!" > ${stubdom_configdir}/$domname-dm
105 echo "kernel = '${XENFIRMWAREDIR}/ioemu-stubdom.gz'" >> ${stubdom_configdir}/$domname-dm
107 vfb="sdl=$sdl, opengl=$opengl"
108 test "$DISPLAY" && vfb="$vfb, display=$DISPLAY"
109 test "$XAUTHORITY" && vfb="$vfb, xauthority=$XAUTHORITY"
110 test $vnc != 0 && vfb="$vfb, vnc=$vnc, vncdisplay=$vnc_port, vnclisten=$ip, vncunused=$vncunused"
111 vncpasswd=`xenstore-read /local/domain/0/backend/vfb/$domid/0/vncpasswd 2>/dev/null`
112 test "$vncpasswd" && vfb="$vfb, vncpasswd=$vncpasswd"
113 test "$keymap" && vfb="$vfb, keymap=$keymap"
114 test "$monitor" && vfb="$vfb, monitor=$monitor"
115 test "$serial" && vfb="$vfb, serial=$serial"
116 echo "vfb = ['$vfb']" >> ${stubdom_configdir}/$domname-dm
118 echo -n "disk = [ " >> ${stubdom_configdir}/$domname-dm
119 j=0
120 for i in `xenstore-ls /local/domain/$domid/device/vbd | grep 'backend =' | awk '{print $3}'`
121 do
122 i=${i%\"}
123 i=${i#\"}
124 vbd_mode=`xenstore-read $i/mode`
125 vbd_disk=`xenstore-read $i/params`
126 vbd_type=`xenstore-read $i/type`
127 vbd_dev=`xenstore-read $i/dev`
128 vbd_front=`xenstore-read $i/frontend`
129 vbd_devtype=`xenstore-read $vbd_front/device-type`
130 if [ $j -ne 0 ]
131 then
132 echo -n "," >> ${stubdom_configdir}/$domname-dm
133 fi
134 echo -n "'$vbd_type:$vbd_disk,$vbd_dev:$vbd_devtype,$vbd_mode'" >> ${stubdom_configdir}/$domname-dm
135 j=$(( $j + 1 ))
136 done
137 echo " ] " >> ${stubdom_configdir}/$domname-dm
138 echo -n "vif = [ " >> ${stubdom_configdir}/$domname-dm
139 j=0
140 for i in `xenstore-ls /local/domain/$domid/device/vif | grep 'backend =' | awk '{print $3}'`
141 do
142 i=${i%\"}
143 i=${i#\"}
144 vif_mac=`xenstore-read $i/mac`
145 if [ $j -ne 0 ]
146 then
147 echo -n "," >> ${stubdom_configdir}/$domname-dm
148 fi
149 echo -n "'mac=$vif_mac'" >> ${stubdom_configdir}/$domname-dm
150 j=$(( $j + 1 ))
151 done
152 echo " ] " >> ${stubdom_configdir}/$domname-dm
153 creation="xm create -c ${stubdom_configdir}/$domname-dm target=$domid memory=32 extra=\"$extra\""
155 (while true ; do sleep 60 ; done) | /bin/sh -c "$creation" &
156 #xterm -geometry +0+0 -e /bin/sh -c "$creation ; echo ; echo press ENTER to shut down ; read" &
157 consolepid=$!
160 ###########
161 # vncviewer
162 if [ "$vncviewer" = 1 ]
163 then
164 # Wait for vnc server to appear
165 while ! vnc_port=`xenstore-read /local/domain/$domid/console/vnc-port`
166 do
167 # Check that the stubdom job is still alive
168 kill -0 $consolepid || term
169 sleep 1
170 done
172 vncviewer $ip:$vnc_port &
173 vncpid=$!
174 fi
176 # wait for SIGHUP or stubdom termination
177 wait $consolepid
179 term