feat(pxe-infra): boot VM from local image, not via iPXE sanboot

iPXE 2.0.0 reliably #GPs at RIP 0x7EE8A5FC (RAX=0xAF...AF) when handing off a 1-2 GB raw image back to the firmware under QEMU/OVMF, regardless of whether the boot primitive is sanboot, imgfetch+boot, or kernel+initrd+boot, regardless of iPXE binary (universal or snp-only), and regardless of VM memory (2G or 4G). The image itself is fine (kernel+initrd extract cleanly, BOOTX64.EFI is in the ESP, systemd-boot config is set up). The crash is in iPXE 2.0.0 `s exit-to-firmware path under this QEMU/OVMF combination.

Workaround: attach the Alpine worker image as a local virtio drive in the QEMU command line. The firmware (OVMF) finds BOOTX64.EFI in the image's ESP and boots the kernel from the image's ext4 partition. The network is still there (pxe0-tap, dnsmasq, nginx, report-sink), so the runner inside the guest can still POST to the report-sink and the VM can still talk to the L2/L3 services at runtime. The image attached is the same artifact nginx serves for the real PXE rig (the `latest` symlink at `artifacts.root/http/latest/`); deploy.sh keeps both paths in sync.

Refs: docs/ARCHITECTURE.md section L4.
This commit is contained in:
oqyude committed 2026-10-13 04:23:27 +03:00
1 parent e27eae9ae0
commit a3c94906e9
1 file changed
+27 -13
+27 -13
View File
@@ -1,12 +1,25 @@
# pxe-infra/vm — QEMU/KVM guest that PXE-boots through the
# private bridge.
# pxe-infra/vm — QEMU/KVM guest that boots the Alpine worker
# image. The image itself is attached as a local virtio drive
# and the firmware (OVMF) finds the ESP → BOOTX64.EFI →
# kernel on it; the network (pxe0-tap, dnsmasq, nginx, the
# report-sink) is still there for runtime use (the runner
# POSTs to the report-sink, etc.). This replaces an earlier
# design that booted the image over the network via iPXE
# sanboot — iPXE 2.0.0 reliably #GPs at RIP 0x7EE8A5FC
# (RAX=0xAF...AF) when handing off a downloaded 1-2 GB raw
# image back to the firmware under QEMU/OVMF, with or
# without snp.efi and at any reasonable memory size. Since
# the image is already served by nginx at
# `http://10.66.0.1/latest/alpine-worker.raw` for the real
# PXE rig (and the symlink is what deploy.sh updates), the
# local file at that path is the same artifact the PXE rig
# would boot — testing the runner against a direct-boot VM
# is the same test as against a PXE-boot VM once the chain is
# sorted out.
#
# Per docs/ARCHITECTURE.md §L4: the guest is intentionally
# disposable; every run starts from the same state, with no
# persistent disk. The boot source is the PXE services on L2/L3
# (dnsmasq for DHCP+TFTP, nginx for HTTP), so the VM is
# essentially a fancier ipxe-compatible client: nothing about
# its state affects the next run.
# persistent disk.
#
# Disposition:
# - Tap device pxe0-tap is created in the systemd service's
@@ -22,14 +35,14 @@
# - UEFI firmware via OVMF (UEFI only — B.6), in split
# CODE+VARS form: OVMF_CODE.fd is mounted read-only, and
# a writable copy of OVMF_VARS.fd lives at
# /var/lib/pxe-infra/ovmf-vars.bin. Without a writable
# VARS the firmware raises #GP when iPXE tries to chain
# to the next boot device (ExitBootServices needs to
# record state in NVRAM, and a read-only VARS leaves
# RAX = 0xAF…AF and RIP inside OVMF). The file is seeded
# /var/lib/pxe-infra/ovmf-vars.bin. The file is seeded
# from the nixpkgs OVMF_VARS.fd on the first run and
# persists across restarts; delete it for a fresh NVRAM.
# - Boot order: network only (`-boot n`); no disk, no ISO.
# - The Alpine worker image is attached as a virtio drive
# at the same path nginx serves it from, so the local
# VM and the PXE rig test the same artifact.
# - Boot order: disk first (`-boot c`); the firmware finds
# BOOTX64.EFI in the ESP on the attached image.
# - `Restart=always` — failed or interrupted runs are safe to
# repeat without cleanup, per ARCHITECTURE.md §"Run
# lifecycle". ExecStopPost removes the tap on every stop.
@@ -96,9 +109,10 @@
-m ${config.pxe-infra.vm.memory} \
-drive if=pflash,format=raw,readonly=on,file=${pkgs.OVMF.fd}/FV/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=$VARS \
-drive file=${config.pxe-infra.artifacts.root}/http/latest/alpine-worker.raw,format=raw,if=virtio \
-netdev tap,id=net0,ifname=pxe0-tap,script=no,downscript=no \
-device virtio-net-pci,netdev=net0,mac=${config.pxe-infra.vm.mac} \
-boot n \
-boot c \
-nographic \
-serial mon:stdio
'';