ia64/xen-unstable

view stubdom/stubdom-dm @ 19510:accf139b2eb9

tools/misc: Remove some obsolete scripts.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Apr 06 21:12:33 2009 +0100 (2009-04-06)
parents 988aee72f73d
children c7d2f046aa29
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 videoram=4
19 while [ "$#" -gt 0 ];
20 do
21 if [ "$#" -ge 2 ];
22 then
23 case "$1" in
24 -d)
25 domid=$2;
26 extra="$extra -d $domid";
27 shift
28 ;;
29 -domain-name)
30 domname=$2;
31 shift
32 ;;
33 -vnc)
34 ip=${2%:*};
35 vnc_port=${2#*:};
36 shift
37 ;;
38 -loadvm)
39 extra="$extra -loadvm $2";
40 shift
41 ;;
42 -videoram)
43 videoram="$2"
44 shift
45 ;;
46 esac
47 fi
48 case "$1" in
49 -vncviewer) vncviewer=1 ;;
50 esac
51 shift
52 done
54 [ -z "$domid" ] && ( echo "couldn't find domain ID" ; exit 1 )
55 [ -z "$domname" ] && ( echo "couldn't find domain name" ; exit 1 )
57 # Termination handler
59 term() {
60 kill %1
61 (
62 [ -n "$vncpid" ] && kill -9 $vncpid
63 xm destroy $domname-dm
64 #xm destroy $domname
65 ) &
66 # We need to exit immediately so as to let xend do the commands above
67 exit 0
68 }
70 trap term SIGHUP
72 ############
73 # stubdomain
74 # Wait for any previous stubdom to terminate
75 while xm list | grep $domname-dm
76 do
77 sleep 1
78 done
80 creation="xm create -c $domname-dm target=$domid memory=32 videoram=$videoram extra=\"$extra\""
82 (while true ; do sleep 60 ; done) | /bin/sh -c "$creation" &
83 #xterm -geometry +0+0 -e /bin/sh -c "$creation ; echo ; echo press ENTER to shut down ; read" &
84 consolepid=$!
87 ###########
88 # vncviewer
89 if [ "$vncviewer" = 1 ]
90 then
91 # Wait for vnc server to appear
92 while ! vnc_port=`xenstore-read /local/domain/$domid/console/vnc-port`
93 do
94 # Check that the stubdom job is still alive
95 kill -0 $consolepid || term
96 sleep 1
97 done
99 vncviewer $ip:$vnc_port &
100 vncpid=$!
101 fi
103 # wait for SIGHUP or stubdom termination
104 wait $consolepid
106 term