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 | openembedded-core-070096ec70651cf28138167b8d33b67051b872ca.tar.gz openembedded-core-070096ec70651cf28138167b8d33b67051b872ca.tar.bz2 openembedded-core-070096ec70651cf28138167b8d33b67051b872ca.tar.xz openembedded-core-070096ec70651cf28138167b8d33b67051b872ca.zip |
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 9c7f6ecbd..473411db9 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 \ file://${POKYBASE}/scripts/poky-find-native-sysroot \ file://${POKYBASE}/scripts/poky-extract-sdk \ file://${POKYBASE}/scripts/poky-export-rootfs \ + file://${POKYBASE}/scripts/runqemu-nfs \ file://tunctl.c \ file://raw2flash.c \ " @@ -30,6 +31,7 @@ do_compile() { do_install() { install -d ${D}${bindir} install -m 0755 ${WORKDIR}${POKYBASE}/scripts/poky-* ${D}${bindir}/ + install -m 0755 ${WORKDIR}${POKYBASE}/scripts/runqemu-nfs ${D}${bindir}/ install tunctl ${D}${bindir}/ install raw2flash.spitz ${D}${bindir}/ install flash2raw.spitz ${D}${bindir}/ diff --git a/scripts/runqemu-nfs b/scripts/runqemu-nfs new file mode 100755 index 000000000..bccbc4c5c --- /dev/null +++ b/scripts/runqemu-nfs @@ -0,0 +1,86 @@ +#!/bin/bash + +# Copyright (c) 2010 Intel Corp. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +function usage() { + echo "Usage: $0 {machine-type} <kernel> <rootfs-dir>" + echo "Where <rootfs-dir> is a rootfs directory that was created using the poky-extract-sdk utility" + echo "machine-type is optional if the kernel file is named according to Poky conventions" +} + +if [[ $# -lt 2 || $# -gt 3 ]]; then + usage + exit 1 +fi + +if [ $# -eq 3 ]; then + QEMUARCH=$1 + ZIMAGE=$2 + SDK_ROOTFS_DIR=$(cd "$3" && pwd) +else + ZIMAGE=$1 + SDK_ROOTFS_DIR=$(cd "$2" && pwd) + + QEMUARCH=`basename $ZIMAGE | sed -r -e 's#.*-([a-z]+[0-9]*)-?[0-9]*..*#\1#'` + if [ -z "$QEMUARCH" ]; then + echo "Error: Unable to determine machinetype from filename '$ZIMAGE'" + usage + exit 1 + fi +fi + +if [ ! -e "$ZIMAGE" ]; then + echo "Error: kernel file '$ZIMAGE' does not exist" + usage + exit 1 +fi + +QEMU_INTERNAL_SCRIPT=`which poky-qemu-internal` +if [ -z "$QEMU_INTERNAL_SCRIPT" ]; then + echo "Error: Unable to find the poky-qemu-internal script" + exit 1 +fi + +SYSROOT_SETUP_SCRIPT=`which poky-find-native-sysroot` +if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then + echo "Error: Unable to find the poky-find-native-sysroot script" + echo "Did you forget to source your Poky environment script?" + exit 1 +fi +. $SYSROOT_SETUP_SCRIPT + +PSEUDO_LOCALSTATEDIR=~/.poky-sdk/pseudo +export PSEUDO_LOCALSTATEDIR + +# Start the userspace NFS server +echo "poky-export-rootfs restart $SDK_ROOTFS_DIR" +poky-export-rootfs restart $SDK_ROOTFS_DIR +if [ $? != 0 ]; then + exit 1 +fi + +# Run QEMU +MACHINE=$QEMUARCH +TYPE="nfs" +HDIMAGE=$SDK_ROOTFS_DIR +CROSSPATH=$NATIVE_SYSROOT_DIR/usr/bin +. $QEMU_INTERNAL_SCRIPT + +# Cleanup +echo "poky-export-rootfs stop $SDK_ROOTFS_DIR" +poky-export-rootfs stop $SDK_ROOTFS_DIR + +exit 0 |