scripts/qemustart: Allow specifying custom rootfs for malta
authorPetr Štetiar <ynezz@true.cz>
Thu, 28 Mar 2019 21:13:26 +0000 (21:13 +0000)
committerPetr Štetiar <ynezz@true.cz>
Mon, 8 Apr 2019 16:37:05 +0000 (18:37 +0200)
Currently it's not possible to test boot squashfs root images, so this
patch now allows this use case as well.

Cc: Yousong Zhou <yszhou4tech@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
scripts/qemustart

index 2012d43a85287160c5a2adaaee89b613de18fd97..951f2252722ec8221dc1f94ec14981b9192f60e2 100755 (executable)
@@ -205,6 +205,7 @@ start_qemu_malta() {
        local is64
        local isel
        local qemu_exe
+       local rootfs="$o_rootfs"
        local kernel="$o_kernel"
        local mach="${o_mach:-malta}"
 
@@ -215,6 +216,16 @@ start_qemu_malta() {
 
        [ -n "$kernel" ] || kernel="$o_bindir/openwrt-malta-${o_subtarget%-*}-vmlinux-initramfs.elf"
 
+       [ -z "$rootfs" ] || {
+               if [ ! -f "$rootfs" -a -s "$rootfs.gz" ]; then
+                       gunzip "$rootfs.gz"
+               fi
+               o_qemu_extra+=( \
+                       "-drive" "file=$rootfs,format=raw" \
+                       "-append" "root=/dev/sda rootwait" \
+               )
+       }
+
        # NOTE: order of wan, lan -device arguments matters as it will affect which
        # one will be actually used as the wan, lan network interface inside the
        # guest machine