ia64/xen-unstable

view stubdom/stubdom-dm @ 17916:10e79ad54c91

blktap: Extend userland busid to 32 bits

Signed-off-by: Chris Lalancette <clalance@redhat.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 27 16:08:56 2008 +0100 (2008-06-27)
parents e0f9bee70cbf
children 035b4ee95328
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 # To fit xterms nicely
9 height=339
11 # Parse arguments
13 domid=
14 domname=
15 vncviewer=0
16 vncpid=
17 extra=
18 while [ "$#" -gt 0 ];
19 do
20 if [ "$#" -ge 2 ];
21 then
22 case "$1" in
23 -d)
24 domid=$2;
25 extra="$extra -d $domid";
26 shift
27 ;;
28 -domain-name)
29 domname=$2;
30 shift
31 ;;
32 -vnc)
33 ip=${2%:*};
34 vnc_port=${2#*:};
35 shift
36 ;;
37 -loadvm)
38 extra="$extra -loadvm $2";
39 shift
40 ;;
41 esac
42 fi
43 case "$1" in
44 -vncviewer) vncviewer=1 ;;
45 esac
46 shift
47 done
49 [ -z "$domid" ] && ( echo "couldn't find domain ID" ; exit 1 )
50 [ -z "$domname" ] && ( echo "couldn't find domain name" ; exit 1 )
52 # Termination handler
54 term() {
55 kill %1
56 (
57 [ -n "$vncpid" ] && kill -9 $vncpid
58 xm destroy stubdom-$domname
59 #xm destroy $domname
60 ) &
61 # We need to exit immediately so as to let xend do the commands above
62 exit 0
63 }
65 trap term SIGHUP
67 ############
68 # stubdomain
69 # Wait for any previous stubdom to terminate
70 while xm list | grep stubdom-$domname
71 do
72 sleep 1
73 done
75 creation="xm create -c stubdom-$domname target=$domid memory=32 extra=\"$extra\""
77 (while true ; do sleep 60 ; done) | /bin/sh -c "$creation" &
78 #xterm -geometry +0+0 -e /bin/sh -c "$creation ; echo ; echo press ENTER to shut down ; read" &
79 consolepid=$!
82 ###########
83 # vncviewer
84 if [ "$vncviewer" = 1 ]
85 then
86 # Wait for vnc server to appear
87 while ! vnc_port=`xenstore-read /local/domain/$domid/console/vnc-port`
88 do
89 # Check that the stubdom job is still alive
90 kill -0 $consolepid || term
91 sleep 1
92 done
94 vncviewer $ip:$vnc_port &
95 vncpid=$!
96 fi
98 # wait for SIGHUP or stubdom termination
99 wait $consolepid
101 term