feat(hack): add scripts to drive the dev environment headless

Start QEMU in the background with a QMP socket and console logs, take
screenshots, press keys and wait for serial output, so the graphical boot
menu can be driven without a terminal or a window. boot.sh gets opt-in
knobs for this and behaves as before otherwise.
This commit is contained in:
alex authored and Alex Zenla committed 2026-10-04 10:24:36 -07:00
1 parent 4e10d57143
commit c6524b7bed
12 files changed
+342 -2

No files matched your search

+20 -2
View File
@@ -9,7 +9,7 @@ if [ "${SKIP_BUILD}" != "1" ]; then
./hack/dev/build.sh "${TARGET_ARCH}" "${RUST_PROFILE}"
fi
clear
[ -t 1 ] && clear
set --
if [ "${TARGET_ARCH}" = "x86_64" ]; then
@@ -40,7 +40,7 @@ set -- "${@}" -nodefaults -smp 2 -m 4096
if [ "${NO_GRAPHICAL}" = "1" ]; then
set -- "${@}" -nographic
else
if [ "${GRAPHICAL_ONLY}" != "1" ]; then
if [ "${GRAPHICAL_ONLY}" != "1" ] && [ "${QEMU_HEADLESS}" != "1" ]; then
if [ "${QEMU_LEGACY_SERIAL}" = "1" ]; then
set -- "${@}" -serial stdio
else
@@ -51,6 +51,17 @@ else
fi
fi
# Headless keeps the virtual GPU, so screenshots still work, but shows no window. The firmware
# console and the Linux console go to files, as there is no terminal to attach to.
if [ "${QEMU_HEADLESS}" = "1" ]; then
set -- "${@}" \
-display none \
-serial "file:${QEMU_SERIAL_FILE:-/dev/null}" \
-device 'virtio-serial-pci,id=vs0' \
-chardev "file,id=file0,path=${QEMU_CONSOLE_FILE:-/dev/null}" \
-device 'virtconsole,chardev=file0,id=console0,name=alpine'
fi
if [ "${QEMU_LEGACY_VGA}" = "1" ]; then
set -- "${@}" -vga std
else
@@ -96,4 +107,11 @@ set -- "${@}" \
set -- "${@}" -name "sprout ${TARGET_ARCH}"
if [ -n "${QEMU_QMP}" ]; then
set -- "${@}" -qmp "unix:${QEMU_QMP},server=on,wait=off"
fi
# shellcheck disable=SC2086
set -- "${@}" ${QEMU_EXTRA_ARGS}
exec "${@}"