summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2015-09-03 20:42:26 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-06 15:26:23 +0100
commit8215c42af1d2a2eae8e1538d5a8029bc1e221e5e (patch)
treecd2997393c00517ce39aaec379b99f93bc5378b1 /scripts
parent9337ce26f48bd82bb189773c8190981c069a5553 (diff)
downloadpoky-8215c42af1d2a2eae8e1538d5a8029bc1e221e5e.tar.gz
runqemu: support full-disk images
This makes it possible to boot images with multiple partitions (the ones ending in .hddimg or .hdddirect) in several ways: runqemu qemux86 core-image-minimal hddimg runqemu tmp/deploy/images/qemux86/core-image-minimal-qemux86.hddimg VM=tmp-glibc/deploy/images/qemux86/iot-os-image-qemux86.hddimg FSTYPE=hddimg runqemu Same for hdddirect. This is useful for testing initramfs scripts, secure boot (when switching to UEFI), or boot loaders like syslinux. For testing the content of the rootfs, the ext4 image is better because that approach is faster (no need to create another large image during build, rootfs can be read directly instead of reading boot.img through loop device). When booting a live image, the kernel, initramfs (if any) and kernel parameters are taken from the image by the virtual machine's BIOS, so any additional kernel parameters given to runqemu are ignored. This can be avoided (already without this change) in a slightly hacky runqemu setup: ROOTFS=tmp/deploy/images/qemux86/core-image-minimal-qemux86.hddimg \ FSTYPE=ext4 \ KERNEL=tmp/deploy/images/qemux86/bzImage-initramfs-qemux86.bin \ MACHINE=qemux86 \ runqemu serial kvm nographic 'bootparams=root=/dev/ram0' The additional bzImage-initramfs-qemux86.bin kernel here was created by adding this to local.conf: INITRAMFS_IMAGE = "core-image-minimal-initramfs" INITRAMFS_IMAGE_BUNDLE = "1" In the code, the new FSTYPE=hddimg resp. hdddirect behaves almost exactly like the older vmdk FSTYPE. New types were chosen because it seemed cleaner than using FSTYPE=vmdk when the actual image pointed to by VM is not in that format. The downside is that several checks for FSTYPE=vmdk had to be duplicated for FSTYPE=hddimg. The VM variable now gets interpreted as "virtual machine disk image" instead of "vmdk image". (From OE-Core rev: 37741c539f5d3021e59828b49e968cd42b89a368) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/runqemu24
-rwxr-xr-xscripts/runqemu-internal10
2 files changed, 19 insertions, 15 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index 82711606f6..a4d9a2306b 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -28,7 +28,7 @@ usage() {
28 echo " MACHINE - the machine name (optional, autodetected from KERNEL filename if unspecified)" 28 echo " MACHINE - the machine name (optional, autodetected from KERNEL filename if unspecified)"
29 echo " RAMFS - boot a ramfs-based image" 29 echo " RAMFS - boot a ramfs-based image"
30 echo " ISO - boot an ISO image" 30 echo " ISO - boot an ISO image"
31 echo " VM - boot a vmdk image" 31 echo " VM - boot a virtual machine image (= a file representing a full disk with boot loader)"
32 echo " Simplified QEMU command-line options can be passed with:" 32 echo " Simplified QEMU command-line options can be passed with:"
33 echo " nographic - disables video console" 33 echo " nographic - disables video console"
34 echo " serial - enables a serial console on /dev/ttyS0" 34 echo " serial - enables a serial console on /dev/ttyS0"
@@ -94,7 +94,7 @@ process_filename() {
94 error "conflicting FSTYPE types [$FSTYPE] and [$EXT]" 94 error "conflicting FSTYPE types [$FSTYPE] and [$EXT]"
95 fi 95 fi
96 ;; 96 ;;
97 /vmdk/) 97 /hddimg/|/hdddirect/|/vmdk/)
98 FSTYPE=$EXT 98 FSTYPE=$EXT
99 VM=$filename 99 VM=$filename
100 ;; 100 ;;
@@ -114,7 +114,7 @@ while true; do
114 [ -z "$MACHINE" ] && MACHINE=$arg || \ 114 [ -z "$MACHINE" ] && MACHINE=$arg || \
115 error "conflicting MACHINE types [$MACHINE] and [$arg]" 115 error "conflicting MACHINE types [$MACHINE] and [$arg]"
116 ;; 116 ;;
117 "ext2" | "ext3" | "ext4" | "jffs2" | "nfs" | "btrfs") 117 "ext2" | "ext3" | "ext4" | "jffs2" | "nfs" | "btrfs" | "hddimg" | "hdddirect" )
118 [ -z "$FSTYPE" -o "$FSTYPE" = "$arg" ] && FSTYPE=$arg || \ 118 [ -z "$FSTYPE" -o "$FSTYPE" = "$arg" ] && FSTYPE=$arg || \
119 error "conflicting FSTYPE types [$FSTYPE] and [$arg]" 119 error "conflicting FSTYPE types [$FSTYPE] and [$arg]"
120 ;; 120 ;;
@@ -235,12 +235,12 @@ if [ "$FSTYPE" = "nfs" -a -z "$ROOTFS" ]; then
235fi 235fi
236 236
237if [ -z "$MACHINE" ]; then 237if [ -z "$MACHINE" ]; then
238 if [ "x$FSTYPE" = "xvmdk" ]; then 238 if [ "x$FSTYPE" = "xvmdk" ] || [ "x$FSTYPE" = "xhddimg" ] || [ "x$FSTYPE" = "xhdddirect" ]; then
239 MACHINE=`basename $VM | sed -n 's/.*\(qemux86-64\|qemux86\|qemuarm64\|qemuarm\|qemumips64\|qemumips\|qemuppc\|qemush4\).*/\1/p'` 239 MACHINE=`basename $VM | sed -n 's/.*\(qemux86-64\|qemux86\|qemuarm64\|qemuarm\|qemumips64\|qemumips\|qemuppc\|qemush4\).*/\1/p'`
240 if [ -z "$MACHINE" ]; then 240 if [ -z "$MACHINE" ]; then
241 error "Unable to set MACHINE from vmdk filename [$VM]" 241 error "Unable to set MACHINE from image filename [$VM]"
242 fi 242 fi
243 echo "Set MACHINE to [$MACHINE] based on vmdk [$VM]" 243 echo "Set MACHINE to [$MACHINE] based on image [$VM]"
244 else 244 else
245 MACHINE=`basename $KERNEL | sed -n 's/.*\(qemux86-64\|qemux86\|qemuarm64\|qemuarm\|qemumips64\|qemumips\|qemuppc\|qemush4\).*/\1/p'` 245 MACHINE=`basename $KERNEL | sed -n 's/.*\(qemux86-64\|qemux86\|qemuarm64\|qemuarm\|qemumips64\|qemumips\|qemuppc\|qemush4\).*/\1/p'`
246 if [ -z "$MACHINE" ]; then 246 if [ -z "$MACHINE" ]; then
@@ -436,7 +436,7 @@ if [ -e "$ROOTFS" -a -z "$FSTYPE" ]; then
436 fi 436 fi
437fi 437fi
438 438
439if [ -z "$KERNEL" -a "x$FSTYPE" != "xvmdk" ]; then 439if [ -z "$KERNEL" -a "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTYPE" != "xhdddirect" ]; then
440 setup_path_vars 1 440 setup_path_vars 1
441 eval kernel_file=\$${machine2}_DEFAULT_KERNEL 441 eval kernel_file=\$${machine2}_DEFAULT_KERNEL
442 KERNEL=$DEPLOY_DIR_IMAGE/$kernel_file 442 KERNEL=$DEPLOY_DIR_IMAGE/$kernel_file
@@ -462,10 +462,14 @@ fi
462if [ "$LAZY_ROOTFS" = "true" ]; then 462if [ "$LAZY_ROOTFS" = "true" ]; then
463 setup_path_vars 1 463 setup_path_vars 1
464 echo "Assuming $ROOTFS really means $DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE" 464 echo "Assuming $ROOTFS really means $DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE"
465 ROOTFS=$DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE 465 if [ "$FSTYPE" = "hddimg" -o "x$FSTYPE" = "xhdddirect" ]; then
466 VM=$DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE
467 else
468 ROOTFS=$DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE
469 fi
466fi 470fi
467 471
468if [ -z "$ROOTFS" -a "x$FSTYPE" != "xvmdk" ]; then 472if [ -z "$ROOTFS" -a "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTYPE" != "xhdddirect" ]; then
469 setup_path_vars 1 473 setup_path_vars 1
470 T=$DEPLOY_DIR_IMAGE 474 T=$DEPLOY_DIR_IMAGE
471 eval rootfs_list=\$${machine2}_DEFAULT_ROOTFS 475 eval rootfs_list=\$${machine2}_DEFAULT_ROOTFS
@@ -481,7 +485,7 @@ ROOTFS=`readlink -f $ROOTFS`
481 485
482echo "" 486echo ""
483echo "Continuing with the following parameters:" 487echo "Continuing with the following parameters:"
484if [ "x$FSTYPE" != "xvmdk" ]; then 488if [ "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTYPE" != "xhdddirect" ]; then
485 echo "KERNEL: [$KERNEL]" 489 echo "KERNEL: [$KERNEL]"
486 echo "ROOTFS: [$ROOTFS]" 490 echo "ROOTFS: [$ROOTFS]"
487else 491else
diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
index a691a80a46..15272683b8 100755
--- a/scripts/runqemu-internal
+++ b/scripts/runqemu-internal
@@ -315,13 +315,13 @@ case "$MACHINE" in
315 ;; 315 ;;
316esac 316esac
317 317
318if [ ! -f "$KERNEL" -a "x$FSTYPE" != "xvmdk" ]; then 318if [ ! -f "$KERNEL" -a "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTYPE" != "xhdddirect" ]; then
319 echo "Error: Kernel image file $KERNEL doesn't exist" 319 echo "Error: Kernel image file $KERNEL doesn't exist"
320 cleanup 320 cleanup
321 return 1 321 return 1
322fi 322fi
323 323
324if [ "$FSTYPE" != "nfs" -a "$FSTYPE" != "vmdk" -a ! -f "$ROOTFS" ]; then 324if [ "$FSTYPE" != "nfs" -a "$FSTYPE" != "vmdk" -a "$FSTYPE" != "hddimg" -a "$FSTYPE" != "hdddirect" -a ! -f "$ROOTFS" ]; then
325 echo "Error: Image file $ROOTFS doesn't exist" 325 echo "Error: Image file $ROOTFS doesn't exist"
326 cleanup 326 cleanup
327 return 1 327 return 1
@@ -440,7 +440,7 @@ if [ "$MACHINE" = "qemux86" ]; then
440 KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" 440 KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
441 QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS" 441 QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
442 fi 442 fi
443 if [ "$FSTYPE" = "vmdk" ]; then 443 if [ "$FSTYPE" = "vmdk" -o "$FSTYPE" = "hddimg" -o "$FSTYPE" = "hdddirect" ]; then
444 QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS" 444 QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
445 fi 445 fi
446 # Currently oprofile's event based interrupt mode doesn't work(Bug #828) in 446 # Currently oprofile's event based interrupt mode doesn't work(Bug #828) in
@@ -476,7 +476,7 @@ if [ "$MACHINE" = "qemux86-64" ]; then
476 KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" 476 KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
477 QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $QEMU_UI_OPTIONS" 477 QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $QEMU_UI_OPTIONS"
478 fi 478 fi
479 if [ "$FSTYPE" = "vmdk" ]; then 479 if [ "$FSTYPE" = "vmdk" -o "$FSTYPE" = "hddimg" -o "$FSTYPE" = "hdddirect" ]; then
480 QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $QEMU_UI_OPTIONS" 480 QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $QEMU_UI_OPTIONS"
481 fi 481 fi
482 # Currently oprofile's event based interrupt mode doesn't work(Bug #828) in 482 # Currently oprofile's event based interrupt mode doesn't work(Bug #828) in
@@ -702,7 +702,7 @@ fi
702 702
703echo "Running $QEMU..." 703echo "Running $QEMU..."
704# -no-reboot is a mandatory option - see bug #100 704# -no-reboot is a mandatory option - see bug #100
705if [ "$FSTYPE" = "vmdk" ]; then 705if [ "$FSTYPE" = "vmdk" -o "$FSTYPE" = "hddimg" -o "$FSTYPE" = "hdddirect" ]; then
706 echo $QEMUBIN $VM $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT 706 echo $QEMUBIN $VM $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT
707 LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN $VM $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT 707 LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN $VM $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT
708elif [ "$FSTYPE" = "iso" ]; then 708elif [ "$FSTYPE" = "iso" ]; then