diff options
-rwxr-xr-x | scripts/runqemu | 27 | ||||
-rwxr-xr-x | scripts/runqemu-internal | 41 |
2 files changed, 56 insertions, 12 deletions
diff --git a/scripts/runqemu b/scripts/runqemu index d52ea159367..b6c9b542009 100755 --- a/scripts/runqemu +++ b/scripts/runqemu @@ -96,7 +96,7 @@ process_filename() { error "conflicting FSTYPE types [$FSTYPE] and [$EXT]" fi ;; - /hddimg/|/hdddirect/|/vmdk/|/wic/|/qcow2/|/vdi/) + /hddimg/|/hdddirect/|/vmdk/|/wic/|/qcow2/|/vdi/|/otaimg/) FSTYPE=$EXT VM=$filename ROOTFS=$filename @@ -128,7 +128,7 @@ while true; do "ext"[234] | "jffs2" | "nfs" | "btrfs") check_fstype_conflicts $arg ;; - "hddimg" | "hdddirect" | "wic" | "vmdk" | "qcow2" | "vdi" | "iso") + "hddimg" | "hdddirect" | "wic" | "vmdk" | "qcow2" | "vdi" | "iso" | "otaimg") check_fstype_conflicts $arg IS_VM="true" ;; @@ -447,6 +447,29 @@ findimage() { exit 1 } +# Bios is necessary when using otaimg, look for it +if [ "$FSTYPE" = "otaimg" ]; then + setup_path_vars 1 + bios_option=`expr "$SCRIPT_QEMU_OPT" : '.*\(-bios\)'` + echo "bios_option: $bios_option" + if [ -z $bios_option ]; then + echo "LOOK FOR BIOS at ${DEPLOY_DIR_IMAGE}" + # if -bios wasn't specified explicitly, try to look at the default location + if [ -e "${DEPLOY_DIR_IMAGE}/u-boot.rom" ]; then + SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -bios ${DEPLOY_DIR_IMAGE}/u-boot.rom" + else + error "OTA image requires specifying u-boot as BIOS" + fi + fi +fi + + +# Kernel command line is stored in compressed format as u-boot environment +# which breaks determining drive interface with grep in runqemu-internal +if [ "$FSTYPE" = "otaimg" ]; then + FORCE_DRIVE_IF="ide" +fi + if [ -e "$ROOTFS" -a -z "$FSTYPE" ]; then # Extract the filename extension EXT=`echo $ROOTFS | awk -F . '{ print \$NF }'` diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal index d10466d35cc..9811cf9e87c 100755 --- a/scripts/runqemu-internal +++ b/scripts/runqemu-internal @@ -705,16 +705,37 @@ echo "Running $QEMU..." if [ "$IS_VM" = "true" ]; then # 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 + + case "$FORCE_DRIVE_IF" in + "ide") + echo "Using ide drive" + VM_DRIVE="$VM" + ;; + "scsi") + echo "Using scsi drive" + VM_DRIVE="-drive if=none,id=hd,file=$VM -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd" + ;; + "virtio") + echo "Using virtio block drive" + VM_DRIVE="-drive if=virtio,file=$VM" + ;; + "") + 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 + ;; + *) + error "Invalid drive interface: $FORCE_DRIVE_IF" + ;; + esac + 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 |