Files
komorebi/e2e/platforms/qemu_windows/w0-boot.sh
T
LGUG2Z 0c6864b4bc feat(e2e): add the W0 probe for a Windows 11 guest under QEMU
An unattended install of the Windows 11 evaluation ISO under QEMU with nested
KVM on WSL2, and a boot script that times the golden image to a desktop.
Measured: install 21.6 min, desktop in 36 to 51 s, with other VMs running.
W0.md records the numbers and what was found on the way: no SMM under nested
SVM, so no secure-boot OVMF; the firmware needs TPM support for Setup to see
the TPM; and the evaluation reads as expired unless the guest clock is set
back.
2026-10-30 18:22:44 -07:00

56 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# W0: boot the golden image on a throwaway overlay and time it to a desktop.
# A screendump every 5 s goes to WORKDIR/boot/; a PNG of a desktop is much
# larger than one of a spinner on black, which is the (crude) signal.
#
# usage: w0-boot.sh WORKDIR [SECONDS] (WORKDIR has the golden disk.qcow2)
# needs on PATH: qemu-system-x86_64 qemu-img swtpm socat
# needs in env: OVMF_FD (an OVMF build with tpmSupport, without SMM)
set -euo pipefail
work=$1 limit=${2:-300}
: "${OVMF_FD:?set OVMF_FD to an OVMF fd store path with TPM support}"
: "${VCPUS:=4}" "${MEM:=6G}"
rm -rf "$work/boot" "$work/overlay.qcow2" "$work/qmp.sock" "$work/tpm.sock"
mkdir -p "$work/boot"
qemu-img create -q -f qcow2 -b "$work/disk.qcow2" -F qcow2 \
"$work/overlay.qcow2"
cp "$work/vars.fd" "$work/vars-boot.fd"
swtpm socket --tpm2 --tpmstate dir="$work/tpm" \
--ctrl type=unixio,path="$work/tpm.sock" --daemon \
--pid file="$work/swtpm.pid"
start=$(date +%s)
echo "boot start: $(date -Is)"
qemu-system-x86_64 -name w0-boot -accel kvm -machine q35,smm=off \
-cpu host -smp "$VCPUS" -m "$MEM" \
-drive "if=pflash,format=raw,readonly=on,unit=0,file=$OVMF_FD/FV/OVMF_CODE.fd" \
-drive "if=pflash,format=raw,unit=1,file=$work/vars-boot.fd" \
-chardev "socket,id=chrtpm,path=$work/tpm.sock" \
-tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-crb,tpmdev=tpm0 \
-drive "if=none,id=disk,file=$work/overlay.qcow2,format=qcow2" \
-device nvme,drive=disk,serial=e2e0,bootindex=1 \
-netdev user,id=net0,hostfwd=tcp:127.0.0.1:7878-:7878 \
-device e1000e,netdev=net0 \
-device qemu-xhci -device usb-tablet -device usb-kbd \
-device VGA,vgamem_mb=64 \
${QEMU_EXTRA:-} \
-display none -qmp "unix:$work/qmp.sock,server=on,wait=off" &
qpid=$!
while kill -0 "$qpid" 2>/dev/null; do
t=$(($(date +%s) - start))
[ "$t" -ge "$limit" ] && break
if [ -S "$work/qmp.sock" ]; then
f="$work/boot/$(printf '%04d' "$t").png"
printf '{"execute":"qmp_capabilities"}\n{"execute":"screendump","arguments":{"filename":"%s","format":"png"}}\n' "$f" |
socat - "UNIX-CONNECT:$work/qmp.sock" >/dev/null || true
[ -f "$f" ] && echo "t=$t png_bytes=$(stat -c %s "$f")"
fi
sleep 5
done
echo "boot end: $(date -Is) (left running; stop the unit to end it)"
wait "$qpid" || true