]> code.ossystems Code Review - openembedded-core.git/commitdiff
runqemu: Improve error handling/exit codes
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 20 Mar 2013 11:48:53 +0000 (11:48 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 27 Mar 2013 17:24:44 +0000 (17:24 +0000)
runqemu-internal is sourced so should be returning with an error code in
case of errors. runqemu needs to deal with this.

This patch fixes up the various error paths so we're consistent and get
a sane exit status for runqemu which helps a lot in its use in the qemu
runtime testing on the autobuilder.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/runqemu
scripts/runqemu-internal

index fc7d749944b75e1cfb3e5fff178825441e01bc32..04caa6d2646e9a29d95f6debed5c49f2f1e4a49d 100755 (executable)
@@ -422,3 +422,4 @@ INTERNAL_SCRIPT=`which runqemu-internal`
 fi
 
 . $INTERNAL_SCRIPT
+exit $?
index 7ca00f8fa090efc1a7ece354a4ea42420f765033..dfdde05e244a99e42b4a0c9bd53446bf2f07d56b 100755 (executable)
@@ -184,7 +184,7 @@ if [ "$TAP" = "" ]; then
     if [ $? -ne 0 ]; then
         # Re-run standalone to see verbose errors
         sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT
-        return
+        return 1
     fi
     LOCKFILE="$LOCKDIR/$tap"
     echo "Acquiring lockfile for $tap..."
@@ -256,20 +256,20 @@ case "$MACHINE" in
     "spitz") ;;
     *)
         echo "Error: Unsupported machine type $MACHINE"
-        return
+        return 1
     ;;
 esac
 
 if [ ! -f "$KERNEL" ]; then
     echo "Error: Kernel image file $KERNEL doesn't exist"
     cleanup
-    return
+    return 1
 fi
 
 if [ "$FSTYPE" != "nfs" -a ! -f "$ROOTFS" ]; then
     echo "Error: Image file $ROOTFS doesn't exist"
     cleanup
-    return
+    return 1
 fi
 
 if [ "$FSTYPE" = "nfs" ]; then
@@ -289,7 +289,7 @@ if [ "$FSTYPE" = "nfs" ]; then
     runqemu-export-rootfs restart $ROOTFS
     if [ $? != 0 ]; then
         cleanup
-        return
+        return 1
     fi
     NFSRUNNING="true"
 fi
@@ -312,7 +312,7 @@ if [ "$MACHINE" = "qemuarm" -o "$MACHINE" = "qemuarmv6" -o "$MACHINE" = "qemuarm
         if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
             echo "Error: NFS mount point $ROOTFS doesn't exist"
             cleanup
-            return
+            return 1
         fi
         KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
         QEMUOPTIONS="$QEMU_NETWORK_CMD -M versatilepb --no-reboot $QEMU_UI_OPTIONS"
@@ -336,7 +336,7 @@ if [ "$MACHINE" = "qemux86" ]; then
         if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
             echo "Error: NFS mount point $ROOTFS doesn't exist."
             cleanup
-            return
+            return 1
         fi
         KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
         QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
@@ -360,7 +360,7 @@ if [ "$MACHINE" = "qemux86-64" ]; then
         if [ ! -d "$ROOTFS" ]; then
             echo "Error: NFS mount point $ROOTFS doesn't exist."
             cleanup
-            return
+            return 1
         fi
         KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
         QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
@@ -401,7 +401,7 @@ if [ "$MACHINE" = "qemumips" -o "$MACHINE" = "qemumipsel" -o "$MACHINE" = "qemum
         if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
             echo "Error: NFS mount point $ROOTFS doesn't exist"
             cleanup
-            return
+            return 1
         fi
         KERNCMDLINE="root=/dev/nfs console=ttyS0 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
         QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS"
@@ -422,7 +422,7 @@ if [ "$MACHINE" = "qemuppc" ]; then
         if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
             echo "Error: NFS mount point $ROOTFS doesn't exist"
             cleanup
-            return
+            return 1
         fi
         KERNCMDLINE="root=/dev/nfs console=ttyS0 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
         QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS"
@@ -442,7 +442,7 @@ if [ "$MACHINE" = "qemush4" ]; then
         if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then
             echo "Error: NFS mount point $ROOTFS doesn't exist"
             cleanup
-            return
+            return 1
         fi
         KERNCMDLINE="root=/dev/nfs console=ttySC1 noiotrap earlyprintk=sh-sci.1 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
         QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS -monitor null -serial vc -serial stdio"
@@ -469,7 +469,7 @@ fi
 if [ "x$QEMUOPTIONS" = "x" ]; then
     echo "Error: Unable to support this combination of options"
     cleanup
-    return
+    return 1
 fi
 
 if [ "x$CROSSPATH" = "x" ]; then
@@ -482,7 +482,7 @@ QEMUBIN=`which $QEMU 2> /dev/null`
 if [ ! -x "$QEMUBIN" ]; then
     echo "Error: No QEMU binary '$QEMU' could be found."
     cleanup
-    return
+    return 1
 fi
 
 NEED_GL=`ldd $QEMUBIN/$QEMU 2>&1 | grep libGLU`
@@ -498,7 +498,7 @@ if [ "$NEED_GL" != "" ]; then
         echo "You need libGL.so and libGLU.so to exist in your library path to run the QEMU emulator.
         Ubuntu package names are: libgl1-mesa-dev and libglu1-mesa-dev.
         Fedora package names are: mesa-libGL-devel mesa-libGLU-devel."
-        exit 1;
+        return 1;
     fi
 fi
 
@@ -508,7 +508,7 @@ do_quit() {
         kill `cat $PIDFILE`
     fi
     cleanup
-    return
+    return 1
 }
 
 DISTCCD=`which distccd 2> /dev/null`
@@ -562,8 +562,10 @@ echo "Running $QEMU..."
 # -no-reboot is a mandatory option - see bug #100
 echo $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"'
 LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT"
-
+ret=$?
 
 cleanup
 
 trap - INT TERM QUIT
+
+return $ret