vm-screendump.sh -U boots a raw stick image in OVMF and test.sh reads the screen.
The serial line of a UEFI boot ends at efiboot's ':-(' because the kernel console is the
framebuffer; the stick does boot to sysinst (measured 2026-11-17, OVMF, 10 GiB image).
79 lines
2.3 KiB
Bash
Executable File
79 lines
2.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
# vm-screendump.sh -- boot a CD or a disk once and save what the screen shows.
|
|
#
|
|
# usage: vm-screendump.sh [-f bios|uefi] [-t seconds] [-i iso | -d disk | -U stick] -o file.ppm
|
|
#
|
|
# For the question "the serial console is silent: where is the output?". The
|
|
# machine has a VGA card, the serial line goes to <file>.serial, and after the
|
|
# time limit the QEMU monitor writes the screen to <file> (PPM). The medium
|
|
# is attached read-only (a CD) or as given (a disk); -U is an install stick (a raw
|
|
# image, as a USB disk, writes go to a scratch overlay). Default medium: the CD
|
|
# this tree built.
|
|
#
|
|
# Exit status: 0 the dump exists, 1 anything else.
|
|
|
|
set -u
|
|
|
|
TOP=$(cd "$(dirname "$0")/.." && pwd)
|
|
# the version of the release, as newvers.sh reads it
|
|
VER=$(cat "$TOP/src/sys/conf/makronix-release")
|
|
ISO=$TOP/build/obj/releasedir/images/Makronix-$VER-amd64.iso
|
|
DISK=
|
|
USB=
|
|
FW=bios
|
|
SECS=70
|
|
OUT=
|
|
|
|
usage()
|
|
{
|
|
echo "usage: ${0##*/} [-f bios|uefi] [-t seconds] [-i iso | -d disk | -U stick] -o file.ppm" >&2
|
|
exit 1
|
|
}
|
|
|
|
while getopts f:t:i:d:U:o: ch; do
|
|
case $ch in
|
|
f) FW=$OPTARG ;;
|
|
t) SECS=$OPTARG ;;
|
|
i) ISO=$OPTARG; DISK= ;;
|
|
d) DISK=$OPTARG ;;
|
|
U) USB=$OPTARG; DISK= ;;
|
|
o) OUT=$OPTARG ;;
|
|
*) usage ;;
|
|
esac
|
|
done
|
|
[ -n "$OUT" ] || usage
|
|
|
|
D=$(mktemp -d "${TMPDIR:-/tmp}/vmscreen.XXXXXX") || exit 1
|
|
trap 'kill $QPID 2>/dev/null; rm -rf "$D"' EXIT INT TERM
|
|
|
|
set -- -m 2G -display none -serial "file:$OUT.serial" \
|
|
-monitor "unix:$D/mon,server,nowait" -vga std
|
|
[ -w /dev/kvm ] && set -- "$@" -enable-kvm -cpu host
|
|
case $FW in
|
|
bios) ;;
|
|
uefi)
|
|
cp /usr/share/OVMF/OVMF_VARS_4M.fd "$D/vars.fd" || exit 1
|
|
set -- "$@" \
|
|
-drive "if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE_4M.fd" \
|
|
-drive "if=pflash,format=raw,file=$D/vars.fd" ;;
|
|
*) usage ;;
|
|
esac
|
|
if [ -n "$USB" ]; then
|
|
set -- "$@" -device qemu-xhci,id=xhci \
|
|
-drive "file=$USB,if=none,id=usb0,format=raw,snapshot=on" \
|
|
-device usb-storage,drive=usb0,bootindex=0
|
|
elif [ -n "$DISK" ]; then
|
|
set -- "$@" -drive "file=$DISK,if=ide,index=0,format=qcow2"
|
|
else
|
|
set -- "$@" -drive "file=$ISO,media=cdrom,readonly=on,if=ide,index=2" \
|
|
-boot order=d
|
|
fi
|
|
|
|
qemu-system-x86_64 "$@" > /dev/null 2>&1 &
|
|
QPID=$!
|
|
sleep "$SECS"
|
|
echo "screendump $OUT" | socat - "UNIX-CONNECT:$D/mon" > /dev/null
|
|
sleep 2
|
|
[ -s "$OUT" ]
|