* [PULL 1/1] runqemu: add OTA image
2016-08-16 13:11 [PULL 0/1] runqemu: add OTA image Anton Gerasimov
@ 2016-08-16 13:11 ` Anton Gerasimov
0 siblings, 0 replies; 2+ messages in thread
From: Anton Gerasimov @ 2016-08-16 13:11 UTC (permalink / raw)
To: poky
Add support for "otaimg" live image. This type of image also requires providing
u-boot as bios.
Signed-off-by: Anton Gerasimov <anton@advancedtelematic.com>
---
scripts/runqemu | 27 +++++++++++++++++++++++++--
scripts/runqemu-internal | 41 +++++++++++++++++++++++++++++++----------
2 files changed, 56 insertions(+), 12 deletions(-)
diff --git a/scripts/runqemu b/scripts/runqemu
index d52ea15..b6c9b54 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 d10466d..9811cf9 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
--
2.8.3
^ permalink raw reply related [flat|nested] 2+ messages in thread