#!/usr/bin/env bash # Boot the (non-headless) kernel with no window, wait a moment, then ask the # QEMU monitor to dump the VGA screen to boot.png. Handy on a headless box. set -euo pipefail cd "$(dirname "$0")/.." cargo bootimage IMG=target/x86_64-rust_kernel/debug/bootimage-rust_kernel.bin OUT="${1:-$PWD/boot.png}" SOCK=$(mktemp -u /tmp/qemu-mon.XXXXXX) qemu-system-x86_64 -drive format=raw,file="$IMG" \ -serial stdio -display none -monitor unix:"$SOCK",server,nowait & QPID=$! sleep 3 # give the BIOS + bootloader + kernel time to draw # Talk to the QEMU monitor over its UNIX socket (python avoids needing socat). python3 - "$SOCK" "$OUT" <<'PY' import socket, sys, time s = socket.socket(socket.AF_UNIX); s.connect(sys.argv[1]) s.sendall(f"screendump {sys.argv[2]} -f png\n".encode()); time.sleep(1) s.sendall(b"quit\n"); time.sleep(0.5) PY wait $QPID || true echo "[screenshot] saved $OUT"