diff options
author | Scott Garman <scott.a.garman@intel.com> | 2010-08-13 11:35:26 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-08-20 16:20:11 +0100 |
commit | 070096ec70651cf28138167b8d33b67051b872ca (patch) | |
tree | 62d04c24767892dbfec99abf4739e923ed1b04ba | |
parent | 313bda1d8781f625ff157dc7e6b5ba62f494077a (diff) | |
download | poky-070096ec70651cf28138167b8d33b67051b872ca.tar.gz |
runqemu-nfs: boot QEMU using nfsroot and local unfs export
This script automates the booting of QEMU using an nfsroot exported
by our userspace NFS tools. The rootfs should be created using
poky-extract-sdk.
Signed-off-by: Scott Garman <scott.a.garman@intel.com>
-rw-r--r-- | meta/packages/qemu/qemu-helper-nativesdk_1.0.bb | 2 | ||||
-rwxr-xr-x | scripts/runqemu-nfs | 86 |
2 files changed, 88 insertions, 0 deletions
diff --git a/meta/packages/qemu/qemu-helper-nativesdk_1.0.bb b/meta/packages/qemu/qemu-helper-nativesdk_1.0.bb index 9c7f6ecbd3..473411db92 100644 --- a/meta/packages/qemu/qemu-helper-nativesdk_1.0.bb +++ b/meta/packages/qemu/qemu-helper-nativesdk_1.0.bb | |||
@@ -13,6 +13,7 @@ SRC_URI = "file://${POKYBASE}/scripts/poky-qemu \ | |||
13 | file://${POKYBASE}/scripts/poky-find-native-sysroot \ | 13 | file://${POKYBASE}/scripts/poky-find-native-sysroot \ |
14 | file://${POKYBASE}/scripts/poky-extract-sdk \ | 14 | file://${POKYBASE}/scripts/poky-extract-sdk \ |
15 | file://${POKYBASE}/scripts/poky-export-rootfs \ | 15 | file://${POKYBASE}/scripts/poky-export-rootfs \ |
16 | file://${POKYBASE}/scripts/runqemu-nfs \ | ||
16 | file://tunctl.c \ | 17 | file://tunctl.c \ |
17 | file://raw2flash.c \ | 18 | file://raw2flash.c \ |
18 | " | 19 | " |
@@ -30,6 +31,7 @@ do_compile() { | |||
30 | do_install() { | 31 | do_install() { |
31 | install -d ${D}${bindir} | 32 | install -d ${D}${bindir} |
32 | install -m 0755 ${WORKDIR}${POKYBASE}/scripts/poky-* ${D}${bindir}/ | 33 | install -m 0755 ${WORKDIR}${POKYBASE}/scripts/poky-* ${D}${bindir}/ |
34 | install -m 0755 ${WORKDIR}${POKYBASE}/scripts/runqemu-nfs ${D}${bindir}/ | ||
33 | install tunctl ${D}${bindir}/ | 35 | install tunctl ${D}${bindir}/ |
34 | install raw2flash.spitz ${D}${bindir}/ | 36 | install raw2flash.spitz ${D}${bindir}/ |
35 | install flash2raw.spitz ${D}${bindir}/ | 37 | install flash2raw.spitz ${D}${bindir}/ |
diff --git a/scripts/runqemu-nfs b/scripts/runqemu-nfs new file mode 100755 index 0000000000..bccbc4c5c8 --- /dev/null +++ b/scripts/runqemu-nfs | |||
@@ -0,0 +1,86 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # Copyright (c) 2010 Intel Corp. | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License version 2 as | ||
7 | # published by the Free Software Foundation. | ||
8 | # | ||
9 | # This program is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
12 | # See the GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with this program; if not, write to the Free Software | ||
16 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | |||
18 | function usage() { | ||
19 | echo "Usage: $0 {machine-type} <kernel> <rootfs-dir>" | ||
20 | echo "Where <rootfs-dir> is a rootfs directory that was created using the poky-extract-sdk utility" | ||
21 | echo "machine-type is optional if the kernel file is named according to Poky conventions" | ||
22 | } | ||
23 | |||
24 | if [[ $# -lt 2 || $# -gt 3 ]]; then | ||
25 | usage | ||
26 | exit 1 | ||
27 | fi | ||
28 | |||
29 | if [ $# -eq 3 ]; then | ||
30 | QEMUARCH=$1 | ||
31 | ZIMAGE=$2 | ||
32 | SDK_ROOTFS_DIR=$(cd "$3" && pwd) | ||
33 | else | ||
34 | ZIMAGE=$1 | ||
35 | SDK_ROOTFS_DIR=$(cd "$2" && pwd) | ||
36 | |||
37 | QEMUARCH=`basename $ZIMAGE | sed -r -e 's#.*-([a-z]+[0-9]*)-?[0-9]*..*#\1#'` | ||
38 | if [ -z "$QEMUARCH" ]; then | ||
39 | echo "Error: Unable to determine machinetype from filename '$ZIMAGE'" | ||
40 | usage | ||
41 | exit 1 | ||
42 | fi | ||
43 | fi | ||
44 | |||
45 | if [ ! -e "$ZIMAGE" ]; then | ||
46 | echo "Error: kernel file '$ZIMAGE' does not exist" | ||
47 | usage | ||
48 | exit 1 | ||
49 | fi | ||
50 | |||
51 | QEMU_INTERNAL_SCRIPT=`which poky-qemu-internal` | ||
52 | if [ -z "$QEMU_INTERNAL_SCRIPT" ]; then | ||
53 | echo "Error: Unable to find the poky-qemu-internal script" | ||
54 | exit 1 | ||
55 | fi | ||
56 | |||
57 | SYSROOT_SETUP_SCRIPT=`which poky-find-native-sysroot` | ||
58 | if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then | ||
59 | echo "Error: Unable to find the poky-find-native-sysroot script" | ||
60 | echo "Did you forget to source your Poky environment script?" | ||
61 | exit 1 | ||
62 | fi | ||
63 | . $SYSROOT_SETUP_SCRIPT | ||
64 | |||
65 | PSEUDO_LOCALSTATEDIR=~/.poky-sdk/pseudo | ||
66 | export PSEUDO_LOCALSTATEDIR | ||
67 | |||
68 | # Start the userspace NFS server | ||
69 | echo "poky-export-rootfs restart $SDK_ROOTFS_DIR" | ||
70 | poky-export-rootfs restart $SDK_ROOTFS_DIR | ||
71 | if [ $? != 0 ]; then | ||
72 | exit 1 | ||
73 | fi | ||
74 | |||
75 | # Run QEMU | ||
76 | MACHINE=$QEMUARCH | ||
77 | TYPE="nfs" | ||
78 | HDIMAGE=$SDK_ROOTFS_DIR | ||
79 | CROSSPATH=$NATIVE_SYSROOT_DIR/usr/bin | ||
80 | . $QEMU_INTERNAL_SCRIPT | ||
81 | |||
82 | # Cleanup | ||
83 | echo "poky-export-rootfs stop $SDK_ROOTFS_DIR" | ||
84 | poky-export-rootfs stop $SDK_ROOTFS_DIR | ||
85 | |||
86 | exit 0 | ||