Skip to main content

max / alloy

1.2 KB · 28 lines History Blame Raw
1 #!/usr/bin/env bash
2 #
3 # vm.sh — boot state/disk.raw headless, with ssh forwarded to $SSH_PORT.
4 #
5 # No qemu monitor socket. The obvious place for one is state/, and under a
6 # session scratch path that exceeds the 108-byte limit a unix socket path has,
7 # which fails with a message about socket paths that reads as unrelated to
8 # anything being done. ssh is the control channel here, so the monitor was
9 # never needed; vmtest keeps one because it drives a ratatui installer through
10 # screendumps and has nothing else to talk to.
11 set -euo pipefail
12
13 # shellcheck source=build/layertest/common.sh
14 . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh"
15
16 [ -f "$STATE/disk.raw" ] || die "no state/disk.raw; run install-disk.sh first"
17 [ -f "$STATE/OVMF_VARS.fd" ] || cp /usr/share/OVMF/OVMF_VARS_4M.fd "$STATE/OVMF_VARS.fd"
18
19 exec qemu-system-x86_64 \
20 -enable-kvm -machine q35 -cpu host -m 4096 -smp 4 \
21 -drive if=pflash,format=raw,unit=0,readonly=on,file=/usr/share/OVMF/OVMF_CODE_4M.fd \
22 -drive "if=pflash,format=raw,unit=1,file=$STATE/OVMF_VARS.fd" \
23 -drive "file=$STATE/disk.raw,if=virtio,format=raw" \
24 -netdev "user,id=n0,hostfwd=tcp:127.0.0.1:$SSH_PORT-:22" \
25 -device virtio-net-pci,netdev=n0 \
26 -display none \
27 -serial "file:$STATE/serial.log"
28