From: Ralph Ronnquist <rrq@rrq.au>
Date: Thu, 19 Sep 2024 00:22:51 +0000 (+1000)
Subject: Fixed to handle qemu testrun
X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=495e9ed4d9b19aaea51bc9b8485204b0e0de1820;p=rrq%2Fbespoke-installer.git

Fixed to handle qemu testrun
---

diff --git a/initrd-init b/initrd-init
index ebdb300..d3c2488 100755
--- a/initrd-init
+++ b/initrd-init
@@ -15,9 +15,19 @@ echo NOW WE ARE HERE >&2
 /lib/debian-installer/start-udev
 
 # The virtio_{net,blk} drivers suit the virt platform used by vm.sh
+modprobe virtio_blk
 modprobe virtio_net
 ip l
-modprobe virtio_blk
+
+if grep -q -w testrun /proc/cmdline ; then
+    ROOT=/dev/vda1
+    TYPE=ext4
+    if mount -t $TYPE $ROOT /mnt ; then
+	exec /sbin/switch_root /mnt /sbin/init
+    fi
+    echo "Emergency console" >&2
+    exec /bin/sh < /dev/console > /dev/console 2>&1
+fi
 
 # Set up the pool media
 modprobe loop
diff --git a/vm.sh b/vm.sh
index c14b755..59e937b 100755
--- a/vm.sh
+++ b/vm.sh
@@ -1,16 +1,16 @@
 #!/bin/bash
 
-ARCH=${1:=arm64}
+ARCH=${1-arm64}
 
 IMG=disk-$ARCH.raw
+INITRD="-initrd $ARCH/initrd.gz"
 if [ -f $IMG ] ; then
     read -p "(r)un or (i)nstall: " CMD
     case "$CMD" in
 	r|run)
-	    APPEND="root=/dev/vda1"
+	    APPEND=" testrun"
 	    ;;
 	i|install)
-	    INITRD="-initrd $ARCH/initrd.gz"
 	    ;;
 	*)
 	    echo "** Aborted. Need an r or an i..." >&2
@@ -19,7 +19,6 @@ if [ -f $IMG ] ; then
     esac
 else
     dd if=/dev/zero of=$IMG bs=1G count=0 seek=4
-    INITRD="-initrd $ARCH/initrd.gz"
 fi
 
 case "$ARCH" in
@@ -45,10 +44,10 @@ ARGS=(
     # boot setup
     -kernel $ARCH/vmlinuz
     $INITRD
-    -append "console=ttyAMA0 root=/dev/vda1 roottype=ext4"
+    -append "console=ttyAMA0 root=/dev/vda1 roottype=ext4$APPEND"
     -serial stdio
     # qemu monitor interface
-    -chardev socket,id=QEMU,server=on,wait=off,path=QEMU
+    -chardev socket,id=QEMU-$ARCH,server=on,wait=off,path=QEMU
     -mon chardev=QEMU-$ARCH,mode=readline
     # graphics setup
     -nographic