Fixed to handle qemu testrun
authorRalph Ronnquist <rrq@rrq.au>
Thu, 19 Sep 2024 00:22:51 +0000 (10:22 +1000)
committerRalph Ronnquist <rrq@rrq.au>
Thu, 19 Sep 2024 00:22:51 +0000 (10:22 +1000)
initrd-init
vm.sh

index ebdb300729f98faddb3888a31d955b15c231c262..d3c24883163db9fec0b2752fb6a31b58519059f0 100755 (executable)
@@ -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 c14b755e106a175b03f7b80706af0e71630bca4a..59e937b847d80e897c770f36bec5f874f380915a 100755 (executable)
--- 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