summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2016-02-25 18:06:26 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-25 10:29:14 +0000
commit6716eb245dcf91b98d8ab9af1ab436f10122b094 (patch)
treefdac95623556c5efbed8832d606131d63afc2b7e /scripts
parent258cfa891eb65e52a0dd546f3f556da166e7940f (diff)
downloadpoky-6716eb245dcf91b98d8ab9af1ab436f10122b094.tar.gz
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] (From OE-Core rev: 88c081b10902ec52928be78ad320c474bb918e01) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/runqemu77
-rwxr-xr-xscripts/runqemu-internal29
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 @@
19 19
20usage() { 20usage() {
21 MYNAME=`basename $0` 21 MYNAME=`basename $0`
22 echo "" 22cat <<_EOF
23 echo "Usage: you can run this script with any valid combination" 23
24 echo "of the following environment variables (in any order):" 24Usage: you can run this script with any valid combination
25 echo " KERNEL - the kernel image file to use" 25of the following environment variables (in any order):
26 echo " ROOTFS - the rootfs image file or nfsroot directory to use" 26 KERNEL - the kernel image file to use
27 echo " MACHINE - the machine name (optional, autodetected from KERNEL filename if unspecified)" 27 ROOTFS - the rootfs image file or nfsroot directory to use
28 echo " RAMFS - boot a ramfs-based image" 28 MACHINE - the machine name (optional, autodetected from KERNEL filename if unspecified)
29 echo " ISO - boot an ISO image" 29 RAMFS - boot a ramfs-based image
30 echo " VM - boot a virtual machine image (= a file representing a full disk with boot loader)" 30 ISO - boot an ISO image
31 echo " Simplified QEMU command-line options can be passed with:" 31 Simplified QEMU command-line options can be passed with:
32 echo " nographic - disables video console" 32 nographic - disables video console
33 echo " serial - enables a serial console on /dev/ttyS0" 33 serial - enables a serial console on /dev/ttyS0
34 echo " kvm - enables KVM when running qemux86/qemux86-64 (VT-capable CPU required)" 34 kvm - enables KVM when running qemux86/qemux86-64 (VT-capable CPU required)
35 echo " kvm-vhost - enables KVM with vhost support when running qemux86/qemux86-64 (VT-capable CPU required)" 35 kvm-vhost - enables KVM with vhost support when running qemux86/qemux86-64 (VT-capable CPU required)
36 echo " publicvnc - enable a VNC server open to all hosts" 36 publicvnc - enable a VNC server open to all hosts
37 echo " qemuparams=\"xyz\" - specify custom parameters to QEMU" 37 qemuparams="xyz" - specify custom parameters to QEMU
38 echo " bootparams=\"xyz\" - specify custom kernel parameters during boot" 38 bootparams="xyz" - specify custom kernel parameters during boot
39 echo "" 39
40 echo "Examples:" 40Examples:
41 echo " $MYNAME qemuarm" 41 $MYNAME qemuarm
42 echo " $MYNAME qemux86-64 core-image-sato ext4" 42 $MYNAME qemux86-64 core-image-sato ext4
43 echo " $MYNAME qemux86-64 wic-image-minimal wic" 43 $MYNAME qemux86-64 wic-image-minimal wic
44 echo " $MYNAME path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial" 44 $MYNAME path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial
45 echo " $MYNAME qemux86 ramfs" 45 $MYNAME qemux86 ramfs
46 echo " $MYNAME qemux86 iso" 46 $MYNAME qemux86 iso
47 echo " $MYNAME qemux86 qemuparams=\"-m 256\"" 47 $MYNAME qemux86 qemuparams="-m 256"
48 echo " $MYNAME qemux86 bootparams=\"psplash=false\"" 48 $MYNAME qemux86 bootparams="psplash=false"
49 echo " $MYNAME path/to/<image>-<machine>.vmdk" 49 $MYNAME path/to/<image>-<machine>.vmdk
50 echo " $MYNAME path/to/<image>-<machine>.wic" 50 $MYNAME path/to/<image>-<machine>.wic
51_EOF
51 exit 1 52 exit 1
52} 53}
53 54
@@ -63,7 +64,6 @@ error() {
63MACHINE=${MACHINE:=""} 64MACHINE=${MACHINE:=""}
64KERNEL=${KERNEL:=""} 65KERNEL=${KERNEL:=""}
65ROOTFS=${ROOTFS:=""} 66ROOTFS=${ROOTFS:=""}
66VM=${VM:=""}
67FSTYPE=${FSTYPE:=""} 67FSTYPE=${FSTYPE:=""}
68LAZY_ROOTFS="" 68LAZY_ROOTFS=""
69SCRIPT_QEMU_OPT="" 69SCRIPT_QEMU_OPT=""
@@ -101,6 +101,7 @@ process_filename() {
101 /hddimg/|/hdddirect/|/vmdk/) 101 /hddimg/|/hdddirect/|/vmdk/)
102 FSTYPE=$EXT 102 FSTYPE=$EXT
103 VM=$filename 103 VM=$filename
104 ROOTFS=$filename
104 ;; 105 ;;
105 *) 106 *)
106 error "unknown file arg [$filename]" 107 error "unknown file arg [$filename]"
@@ -118,7 +119,7 @@ while true; do
118 [ -z "$MACHINE" -o "$MACHINE" = "$arg" ] && MACHINE=$arg || \ 119 [ -z "$MACHINE" -o "$MACHINE" = "$arg" ] && MACHINE=$arg || \
119 error "conflicting MACHINE types [$MACHINE] and [$arg]" 120 error "conflicting MACHINE types [$MACHINE] and [$arg]"
120 ;; 121 ;;
121 "ext2" | "ext3" | "ext4" | "jffs2" | "nfs" | "btrfs" | "hddimg" | "hdddirect" | "wic" ) 122 "ext2" | "ext3" | "ext4" | "jffs2" | "nfs" | "btrfs" | "hddimg" | "hdddirect" | "wic" | "vmdk")
122 [ -z "$FSTYPE" -o "$FSTYPE" = "$arg" ] && FSTYPE=$arg || \ 123 [ -z "$FSTYPE" -o "$FSTYPE" = "$arg" ] && FSTYPE=$arg || \
123 error "conflicting FSTYPE types [$FSTYPE] and [$arg]" 124 error "conflicting FSTYPE types [$FSTYPE] and [$arg]"
124 ;; 125 ;;
@@ -127,8 +128,8 @@ while true; do
127 RAMFS=true 128 RAMFS=true
128 ;; 129 ;;
129 "iso") 130 "iso")
130 FSTYPE=iso 131 FSTYPE=iso
131 ISOFS=true 132 ISOFS=true
132 ;; 133 ;;
133 "nographic") 134 "nographic")
134 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -nographic" 135 SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -nographic"
@@ -142,7 +143,7 @@ while true; do
142 "tcpserial="*) 143 "tcpserial="*)
143 TCPSERIAL_PORTNUM=${arg##tcpserial=} 144 TCPSERIAL_PORTNUM=${arg##tcpserial=}
144 ;; 145 ;;
145 "biosdir="*) 146 "biosdir="*)
146 CUSTOMBIOSDIR="${arg##biosdir=}" 147 CUSTOMBIOSDIR="${arg##biosdir=}"
147 ;; 148 ;;
148 "biosfilename="*) 149 "biosfilename="*)
@@ -187,7 +188,7 @@ while true; do
187 ;; 188 ;;
188 *-image*) 189 *-image*)
189 [ -z "$ROOTFS" ] || \ 190 [ -z "$ROOTFS" ] || \
190 error "conflicting ROOTFS args [$ROOTFS] and [$arg]" 191 error "conflicting ROOTFS args [$ROOTFS] and [$arg]"
191 if [ -f "$arg" ]; then 192 if [ -f "$arg" ]; then
192 process_filename $arg 193 process_filename $arg
193 elif [ -d "$arg" ]; then 194 elif [ -d "$arg" ]; then
@@ -237,7 +238,7 @@ fi
237 238
238# Report errors for missing combinations of options 239# Report errors for missing combinations of options
239if [ -z "$MACHINE" -a -z "$KERNEL" -a -z "$VM" -a "$FSTYPE" != "wic" ]; then 240if [ -z "$MACHINE" -a -z "$KERNEL" -a -z "$VM" -a "$FSTYPE" != "wic" ]; then
240 error "you must specify at least a MACHINE, VM, or KERNEL argument" 241 error "you must specify at least a MACHINE or KERNEL argument"
241fi 242fi
242if [ "$FSTYPE" = "nfs" -a -z "$ROOTFS" ]; then 243if [ "$FSTYPE" = "nfs" -a -z "$ROOTFS" ]; then
243 error "NFS booting without an explicit ROOTFS path is not yet supported" 244 error "NFS booting without an explicit ROOTFS path is not yet supported"
@@ -489,7 +490,7 @@ if [ "$LAZY_ROOTFS" = "true" ]; then
489 fi 490 fi
490fi 491fi
491 492
492if [ -z "$ROOTFS" -a "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTYPE" != "xhdddirect" ]; then 493if [ -z "$ROOTFS" ]; then
493 setup_path_vars 1 494 setup_path_vars 1
494 T=$DEPLOY_DIR_IMAGE 495 T=$DEPLOY_DIR_IMAGE
495 eval rootfs_list=\$${machine2}_DEFAULT_ROOTFS 496 eval rootfs_list=\$${machine2}_DEFAULT_ROOTFS
@@ -497,6 +498,8 @@ if [ -z "$ROOTFS" -a "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTY
497 498
498 if [ -z "$ROOTFS" ]; then 499 if [ -z "$ROOTFS" ]; then
499 error "Unable to determine default rootfs for MACHINE [$MACHINE]" 500 error "Unable to determine default rootfs for MACHINE [$MACHINE]"
501 elif [ "x$FSTYPE" = "xvmdk" -o "x$FSTYPE" = "xhddimg" -o "x$FSTYPE" = "xhdddirect" ]; then
502 VM=$ROOTFS
500 fi 503 fi
501fi 504fi
502# ROOTFS is now set for all cases, now expand it to be an absolute path, it should exist at this point 505# 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 @@
28# ROOTFS - the disk image file to use 28# ROOTFS - the disk image file to use
29# 29#
30 30
31
32mem_size=-1 31mem_size=-1
33 32
34#Get rid of <> and get the contents of extra qemu running params 33#Get rid of <> and get the contents of extra qemu running params
@@ -720,18 +719,32 @@ elif [ "$NUM_SERIAL_OPTS" = "1" ]; then
720 SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT $SECOND_SERIAL_OPT" 719 SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT $SECOND_SERIAL_OPT"
721fi 720fi
722 721
723
724echo "Running $QEMU..." 722echo "Running $QEMU..."
725# -no-reboot is a mandatory option - see bug #100 723# -no-reboot is a mandatory option - see bug #100
726if [ "$FSTYPE" = "vmdk" -o "$FSTYPE" = "hddimg" -o "$FSTYPE" = "hdddirect" ]; then 724if [ "$FSTYPE" = "vmdk" -o "$FSTYPE" = "hddimg" -o "$FSTYPE" = "hdddirect" ]; then
727 echo $QEMUBIN $VM $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT 725 # Check root=/dev/sdX or root=/dev/vdX
728 LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN $VM $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT 726 [ ! -e "$VM" ] && error "VM image is not found!"
727 if grep -q 'root=/dev/sd' $VM; then
728 echo "Using scsi drive"
729 VM_DRIVE="-drive if=none,id=hd,file=$VM -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd"
730 elif grep -q 'root=/dev/hd' $VM; then
731 echo "Using ide drive"
732 VM_DRIVE="$VM"
733 else
734 echo "Using virtio block drive"
735 VM_DRIVE="-drive if=virtio,file=$VM"
736 fi
737 QEMU_FIRE="$QEMUBIN $VM_DRIVE $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT"
738 echo $QEMU_FIRE
739 LD_PRELOAD="$GL_LD_PRELOAD" $QEMU_FIRE
729elif [ "$FSTYPE" = "iso" -o "$FSTYPE" = "wic" ]; then 740elif [ "$FSTYPE" = "iso" -o "$FSTYPE" = "wic" ]; then
730 echo $QEMUBIN $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT 741 QEMU_FIRE="$QEMUBIN $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT"
731 LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT 742 echo $QEMU_FIRE
743 LD_PRELOAD="$GL_LD_PRELOAD" $QEMU_FIRE
732else 744else
733 echo $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SLIRP_CMD $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"' 745 QEMU_FIRE="$QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SLIRP_CMD $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT"
734 LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" 746 echo $QEMU_FIRE -append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"'
747 LD_PRELOAD="$GL_LD_PRELOAD" $QEMU_FIRE -append "$KERNCMDLINE $SCRIPT_KERNEL_OPT"
735fi 748fi
736ret=$? 749ret=$?
737if [ "$SLIRP_ENABLED" != "yes" ]; then 750if [ "$SLIRP_ENABLED" != "yes" ]; then