summaryrefslogtreecommitdiffstats
path: root/scripts/poky-qemu-internal
diff options
context:
space:
mode:
authorScott Garman <scott.a.garman@intel.com>2010-08-13 11:18:05 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2010-08-20 16:20:11 +0100
commitf203df83a5627eae8c66ace8533d2212a6b9cff0 (patch)
tree0e6b50ea0b40104e67e04752843eb4cfa9833edf /scripts/poky-qemu-internal
parent81ff1ee2375161772a4e2471740e4d30f5577aae (diff)
downloadpoky-f203df83a5627eae8c66ace8533d2212a6b9cff0.tar.gz
poky-qemu-internal: fixes for userspace NFS booting
Including a number of cases where the script could exit before releasing a tun/tap lockfile. Signed-off-by: Scott Garman <scott.a.garman@intel.com>
Diffstat (limited to 'scripts/poky-qemu-internal')
-rwxr-xr-xscripts/poky-qemu-internal41
1 files changed, 27 insertions, 14 deletions
diff --git a/scripts/poky-qemu-internal b/scripts/poky-qemu-internal
index 3d718391f7..01486ccff6 100755
--- a/scripts/poky-qemu-internal
+++ b/scripts/poky-qemu-internal
@@ -69,14 +69,23 @@ for tap in $POSSIBLE; do
69done 69done
70 70
71if [ "$TAP" = "" ]; then 71if [ "$TAP" = "" ]; then
72 USER=`id -u` 72 GROUPID=`id -g`
73 echo 'Setting up tap interface under sudo' 73 echo 'Setting up tap interface under sudo'
74 TAP=`sudo $QEMUIFUP $USER` 74 TAP=`sudo $QEMUIFUP $GROUPID`
75 LOCKFILE="" 75 LOCKFILE=""
76else 76else
77 echo "Using preconfigured tap device '$TAP'" 77 echo "Using preconfigured tap device '$TAP'"
78fi 78fi
79 79
80release_lock() {
81 if [ "$LOCKFILE" = "" ]; then
82 $QEMUIFDOWN $TAP
83 else
84 echo "Releasing lockfile of preconfigured tap device '$TAP'"
85 rm -f $LOCKFILE
86 fi
87}
88
80KERNEL_NETWORK_CMD="ip=192.168.7.2::192.168.7.1:255.255.255.0" 89KERNEL_NETWORK_CMD="ip=192.168.7.2::192.168.7.1:255.255.255.0"
81QEMU_TAP_CMD="-net tap,vlan=0,ifname=$TAP,script=no,downscript=no" 90QEMU_TAP_CMD="-net tap,vlan=0,ifname=$TAP,script=no,downscript=no"
82QEMU_NETWORK_CMD="-net nic,vlan=0 $QEMU_TAP_CMD" 91QEMU_NETWORK_CMD="-net nic,vlan=0 $QEMU_TAP_CMD"
@@ -108,12 +117,14 @@ esac
108 117
109if [ "$TYPE" != "nfs" -a ! -f "$HDIMAGE" ]; then 118if [ "$TYPE" != "nfs" -a ! -f "$HDIMAGE" ]; then
110 echo "Error: Image file $HDIMAGE doesn't exist" 119 echo "Error: Image file $HDIMAGE doesn't exist"
120 release_lock
111 return 121 return
112fi 122fi
113 123
114if [ "$TYPE" = "nfs" ]; then 124if [ "$TYPE" = "nfs" ]; then
115 NFS_SERVER=`echo $HDIMAGE | sed 's/^\([^:]*\):.*/\1/'` 125 NFS_SERVER="192.168.7.1"
116 NFS_DIR=`echo $HDIMAGE | sed 's/^[^:]*:\(.*\)/\1/'` 126 NFS_DIR=`echo $HDIMAGE | sed 's/^[^:]*:\(.*\)/\1/'`
127 UNFS_OPTS="nfsvers=2,mountprog=21111,nfsprog=11111,udp"
117fi 128fi
118 129
119if [ "$NFS_SERVER" = "" ]; then 130if [ "$NFS_SERVER" = "" ]; then
@@ -123,6 +134,7 @@ fi
123 134
124if [ ! -f "$ZIMAGE" ]; then 135if [ ! -f "$ZIMAGE" ]; then
125 echo "Error: Kernel image file $ZIMAGE doesn't exist" 136 echo "Error: Kernel image file $ZIMAGE doesn't exist"
137 release_lock
126 return 138 return
127fi 139fi
128 140
@@ -138,9 +150,10 @@ if [ "$MACHINE" = "qemuarm" -o "$MACHINE" = "qemuarmv6" -o "$MACHINE" = "qemuarm
138 if [ "$TYPE" = "nfs" ]; then 150 if [ "$TYPE" = "nfs" ]; then
139 if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then 151 if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
140 echo "Error: NFS mount point $HDIMAGE doesn't exist" 152 echo "Error: NFS mount point $HDIMAGE doesn't exist"
153 release_lock
141 return 154 return
142 fi 155 fi
143 KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" 156 KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
144 QEMUOPTIONS="$QEMU_NETWORK_CMD -M versatilepb --no-reboot $QEMU_UI_OPTIONS" 157 QEMUOPTIONS="$QEMU_NETWORK_CMD -M versatilepb --no-reboot $QEMU_UI_OPTIONS"
145 fi 158 fi
146 if [ "$MACHINE" = "qemuarmv6" ]; then 159 if [ "$MACHINE" = "qemuarmv6" ]; then
@@ -161,9 +174,10 @@ if [ "$MACHINE" = "qemux86" ]; then
161 if [ "$TYPE" = "nfs" ]; then 174 if [ "$TYPE" = "nfs" ]; then
162 if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then 175 if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
163 echo "Error: NFS mount point $HDIMAGE doesn't exist." 176 echo "Error: NFS mount point $HDIMAGE doesn't exist."
177 release_lock
164 return 178 return
165 fi 179 fi
166 KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" 180 KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
167 QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS" 181 QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
168 fi 182 fi
169fi 183fi
@@ -181,9 +195,10 @@ if [ "$MACHINE" = "qemux86-64" ]; then
181 fi 195 fi
182 if [ ! -d "$HDIMAGE" ]; then 196 if [ ! -d "$HDIMAGE" ]; then
183 echo "Error: NFS mount point $HDIMAGE doesn't exist." 197 echo "Error: NFS mount point $HDIMAGE doesn't exist."
198 release_lock
184 return 199 return
185 fi 200 fi
186 KERNCMDLINE="root=/dev/nfs nfsroot=192.168.7.1:$HDIMAGE rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" 201 KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
187 QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS" 202 QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
188 fi 203 fi
189fi 204fi
@@ -258,11 +273,13 @@ if [ "$MACHINE" = "nokia800-maemo" ]; then
258 if [ ! -e "$HDIMAGE.qemuflash" ]; then 273 if [ ! -e "$HDIMAGE.qemuflash" ]; then
259 if [ ! -e "$HDIMAGE.initfs" ]; then 274 if [ ! -e "$HDIMAGE.initfs" ]; then
260 echo "Error, $HDIMAGE.initfs must exist!" 275 echo "Error, $HDIMAGE.initfs must exist!"
276 release_lock
261 return 277 return
262 fi 278 fi
263 if [ ! -e "$HDIMAGE.config" ]; then 279 if [ ! -e "$HDIMAGE.config" ]; then
264 echo "Error, $HDIMAGE.config must exist!" 280 echo "Error, $HDIMAGE.config must exist!"
265 echo "To generate it, take an n800 and cat /dev/mtdblock1 > $HDIMAGE.config" 281 echo "To generate it, take an n800 and cat /dev/mtdblock1 > $HDIMAGE.config"
282 release_lock
266 return 283 return
267 fi 284 fi
268 echo "'Flashing' config partition, please wait..." 285 echo "'Flashing' config partition, please wait..."
@@ -280,6 +297,7 @@ fi
280 297
281if [ "x$QEMUOPTIONS" = "x" ]; then 298if [ "x$QEMUOPTIONS" = "x" ]; then
282 echo "Error: Unable to support this combination of options" 299 echo "Error: Unable to support this combination of options"
300 release_lock
283 return 301 return
284fi 302fi
285 303
@@ -302,6 +320,7 @@ QEMUBIN=`which $QEMU`
302 320
303if [ ! -x "$QEMUBIN" ]; then 321if [ ! -x "$QEMUBIN" ]; then
304 echo "Error: No QEMU binary '$QEMU' could be found." 322 echo "Error: No QEMU binary '$QEMU' could be found."
323 release_lock
305 return 324 return
306fi 325fi
307 326
@@ -310,6 +329,7 @@ function _quit() {
310 #echo kill `cat $PIDFILE` 329 #echo kill `cat $PIDFILE`
311 kill `cat $PIDFILE` 330 kill `cat $PIDFILE`
312 fi 331 fi
332 release_lock
313 return 333 return
314} 334}
315 335
@@ -326,18 +346,11 @@ else
326 echo "Warning: distccd not present, no distcc support loaded." 346 echo "Warning: distccd not present, no distcc support loaded."
327fi 347fi
328 348
329
330
331echo "Running $QEMU..." 349echo "Running $QEMU..."
332echo $QEMUBIN -kernel $ZIMAGE $QEMUOPTIONS $SERIALOPTS $* --append "$KERNCMDLINE" 350echo $QEMUBIN -kernel $ZIMAGE $QEMUOPTIONS $SERIALOPTS $* --append "$KERNCMDLINE"
333$QEMUBIN -kernel $ZIMAGE $QEMUOPTIONS $SERIALOPTS $* --append "$KERNCMDLINE" || /bin/true 351$QEMUBIN -kernel $ZIMAGE $QEMUOPTIONS $SERIALOPTS $* --append "$KERNCMDLINE" || /bin/true
334 352
335if [ "$LOCKFILE" = "" ]; then 353release_lock
336 $QEMUIFDOWN $TAP
337else
338 echo "Releasing preconfigured tap device '$TAP'"
339 rm -f $LOCKFILE
340fi
341 354
342trap - INT TERM QUIT 355trap - INT TERM QUIT
343return 356return