diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2016-02-25 18:06:26 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-03-23 14:24:25 +0000 |
commit | 88c081b10902ec52928be78ad320c474bb918e01 (patch) | |
tree | f53b404aa75fbbf1ec47947515ac35d26ca7bf6a /scripts | |
parent | 8cc5e36cd7978186d5ea1fe8af2f2bd6b3df8885 (diff) | |
download | openembedded-core-88c081b10902ec52928be78ad320c474bb918e01.tar.gz openembedded-core-88c081b10902ec52928be78ad320c474bb918e01.tar.bz2 openembedded-core-88c081b10902ec52928be78ad320c474bb918e01.zip |
runqemu: fix ROOTFS for vmdk
* Make it can boot scsi and virtio block drive such as root=/dev/sdX and
/dev/vdX.
* Drop VM from help info, id doesn't work, and the script can check
whether it is a vm disk or not.
* Make it can be run by:
$ runqemu tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.vmdk
or:
$ runqemu qemux86-64 vmdk
[YOCTO #9170]
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/runqemu | 77 | ||||
-rwxr-xr-x | scripts/runqemu-internal | 29 |
2 files changed, 61 insertions, 45 deletions
diff --git a/scripts/runqemu b/scripts/runqemu index 48b7551464..771aa3878d 100755 --- a/scripts/runqemu +++ b/scripts/runqemu @@ -19,35 +19,36 @@ usage() { MYNAME=`basename $0` - echo "" - echo "Usage: you can run this script with any valid combination" - echo "of the following environment variables (in any order):" - echo " KERNEL - the kernel image file to use" - echo " ROOTFS - the rootfs image file or nfsroot directory to use" - echo " MACHINE - the machine name (optional, autodetected from KERNEL filename if unspecified)" - echo " RAMFS - boot a ramfs-based image" - echo " ISO - boot an ISO image" - echo " VM - boot a virtual machine image (= a file representing a full disk with boot loader)" - echo " Simplified QEMU command-line options can be passed with:" - echo " nographic - disables video console" - echo " serial - enables a serial console on /dev/ttyS0" - echo " kvm - enables KVM when running qemux86/qemux86-64 (VT-capable CPU required)" - echo " kvm-vhost - enables KVM with vhost support when running qemux86/qemux86-64 (VT-capable CPU required)" - echo " publicvnc - enable a VNC server open to all hosts" - echo " qemuparams=\"xyz\" - specify custom parameters to QEMU" - echo " bootparams=\"xyz\" - specify custom kernel parameters during boot" - echo "" - echo "Examples:" - echo " $MYNAME qemuarm" - echo " $MYNAME qemux86-64 core-image-sato ext4" - echo " $MYNAME qemux86-64 wic-image-minimal wic" - echo " $MYNAME path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial" - echo " $MYNAME qemux86 ramfs" - echo " $MYNAME qemux86 iso" - echo " $MYNAME qemux86 qemuparams=\"-m 256\"" - echo " $MYNAME qemux86 bootparams=\"psplash=false\"" - echo " $MYNAME path/to/<image>-<machine>.vmdk" - echo " $MYNAME path/to/<image>-<machine>.wic" +cat <<_EOF + +Usage: you can run this script with any valid combination +of the following environment variables (in any order): + KERNEL - the kernel image file to use + ROOTFS - the rootfs image file or nfsroot directory to use + MACHINE - the machine name (optional, autodetected from KERNEL filename if unspecified) + RAMFS - boot a ramfs-based image + ISO - boot an ISO image + Simplified QEMU command-line options can be passed with: + nographic - disables video console + serial - enables a serial console on /dev/ttyS0 + kvm - enables KVM when running qemux86/qemux86-64 (VT-capable CPU required) + kvm-vhost - enables KVM with vhost support when running qemux86/qemux86-64 (VT-capable CPU required) + publicvnc - enable a VNC server open to all hosts + qemuparams="xyz" - specify custom parameters to QEMU + bootparams="xyz" - specify custom kernel parameters during boot + +Examples: + $MYNAME qemuarm + $MYNAME qemux86-64 core-image-sato ext4 + $MYNAME qemux86-64 wic-image-minimal wic + $MYNAME path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial + $MYNAME qemux86 ramfs + $MYNAME qemux86 iso + $MYNAME qemux86 qemuparams="-m 256" + $MYNAME qemux86 bootparams="psplash=false" + $MYNAME path/to/<image>-<machine>.vmdk + $MYNAME path/to/<image>-<machine>.wic +_EOF exit 1 } @@ -63,7 +64,6 @@ error() { MACHINE=${MACHINE:=""} KERNEL=${KERNEL:=""} ROOTFS=${ROOTFS:=""} -VM=${VM:=""} FSTYPE=${FSTYPE:=""} LAZY_ROOTFS="" SCRIPT_QEMU_OPT="" @@ -101,6 +101,7 @@ process_filename() { /hddimg/|/hdddirect/|/vmdk/) FSTYPE=$EXT VM=$filename + ROOTFS=$filename ;; *) error "unknown file arg [$filename]" @@ -118,7 +119,7 @@ while true; do [ -z "$MACHINE" -o "$MACHINE" = "$arg" ] && MACHINE=$arg || \ error "conflicting MACHINE types [$MACHINE] and [$arg]" ;; - "ext2" | "ext3" | "ext4" | "jffs2" | "nfs" | "btrfs" | "hddimg" | "hdddirect" | "wic" ) + "ext2" | "ext3" | "ext4" | "jffs2" | "nfs" | "btrfs" | "hddimg" | "hdddirect" | "wic" | "vmdk") [ -z "$FSTYPE" -o "$FSTYPE" = "$arg" ] && FSTYPE=$arg || \ error "conflicting FSTYPE types [$FSTYPE] and [$arg]" ;; @@ -127,8 +128,8 @@ while true; do RAMFS=true ;; "iso") - FSTYPE=iso - ISOFS=true + FSTYPE=iso + ISOFS=true ;; "nographic") SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -nographic" @@ -142,7 +143,7 @@ while true; do "tcpserial="*) TCPSERIAL_PORTNUM=${arg##tcpserial=} ;; - "biosdir="*) + "biosdir="*) CUSTOMBIOSDIR="${arg##biosdir=}" ;; "biosfilename="*) @@ -187,7 +188,7 @@ while true; do ;; *-image*) [ -z "$ROOTFS" ] || \ - error "conflicting ROOTFS args [$ROOTFS] and [$arg]" + error "conflicting ROOTFS args [$ROOTFS] and [$arg]" if [ -f "$arg" ]; then process_filename $arg elif [ -d "$arg" ]; then @@ -237,7 +238,7 @@ fi # Report errors for missing combinations of options if [ -z "$MACHINE" -a -z "$KERNEL" -a -z "$VM" -a "$FSTYPE" != "wic" ]; then - error "you must specify at least a MACHINE, VM, or KERNEL argument" + error "you must specify at least a MACHINE or KERNEL argument" fi if [ "$FSTYPE" = "nfs" -a -z "$ROOTFS" ]; then error "NFS booting without an explicit ROOTFS path is not yet supported" @@ -489,7 +490,7 @@ if [ "$LAZY_ROOTFS" = "true" ]; then fi fi -if [ -z "$ROOTFS" -a "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTYPE" != "xhdddirect" ]; then +if [ -z "$ROOTFS" ]; then setup_path_vars 1 T=$DEPLOY_DIR_IMAGE eval rootfs_list=\$${machine2}_DEFAULT_ROOTFS @@ -497,6 +498,8 @@ if [ -z "$ROOTFS" -a "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTY if [ -z "$ROOTFS" ]; then error "Unable to determine default rootfs for MACHINE [$MACHINE]" + elif [ "x$FSTYPE" = "xvmdk" -o "x$FSTYPE" = "xhddimg" -o "x$FSTYPE" = "xhdddirect" ]; then + VM=$ROOTFS fi fi # ROOTFS is now set for all cases, now expand it to be an absolute path, it should exist at this point diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal index ebed2bdd01..0c00d8f9cb 100755 --- a/scripts/runqemu-internal +++ b/scripts/runqemu-internal @@ -28,7 +28,6 @@ # ROOTFS - the disk image file to use # - mem_size=-1 #Get rid of <> and get the contents of extra qemu running params @@ -720,18 +719,32 @@ elif [ "$NUM_SERIAL_OPTS" = "1" ]; then SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT $SECOND_SERIAL_OPT" fi - echo "Running $QEMU..." # -no-reboot is a mandatory option - see bug #100 if [ "$FSTYPE" = "vmdk" -o "$FSTYPE" = "hddimg" -o "$FSTYPE" = "hdddirect" ]; then - echo $QEMUBIN $VM $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT - LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN $VM $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT + # Check root=/dev/sdX or root=/dev/vdX + [ ! -e "$VM" ] && error "VM image is not found!" + if grep -q 'root=/dev/sd' $VM; then + echo "Using scsi drive" + VM_DRIVE="-drive if=none,id=hd,file=$VM -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd" + elif grep -q 'root=/dev/hd' $VM; then + echo "Using ide drive" + VM_DRIVE="$VM" + else + echo "Using virtio block drive" + VM_DRIVE="-drive if=virtio,file=$VM" + fi + QEMU_FIRE="$QEMUBIN $VM_DRIVE $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT" + echo $QEMU_FIRE + LD_PRELOAD="$GL_LD_PRELOAD" $QEMU_FIRE elif [ "$FSTYPE" = "iso" -o "$FSTYPE" = "wic" ]; then - echo $QEMUBIN $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT - LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT + QEMU_FIRE="$QEMUBIN $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT" + echo $QEMU_FIRE + LD_PRELOAD="$GL_LD_PRELOAD" $QEMU_FIRE else - echo $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SLIRP_CMD $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" + QEMU_FIRE="$QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SLIRP_CMD $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT" + echo $QEMU_FIRE -append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"' + LD_PRELOAD="$GL_LD_PRELOAD" $QEMU_FIRE -append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" fi ret=$? if [ "$SLIRP_ENABLED" != "yes" ]; then |