From f0bb11de2839dcb3a65d4fb4bc2e871d5d61a0f5 Mon Sep 17 00:00:00 2001 From: oqyude Date: Tue, 13 Oct 2026 20:21:22 +0300 Subject: [PATCH] pxe-infra: add vm.bootMode option (direct | pxe) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default "direct" preserves the proven E2E behavior (2026-10-13). "pxe" enables the full L3 boot chain (-boot n, no virtio drive) for reproducing T10 (iPXE 2.0.0 #GP at ExitBootServices, RIP 0x7EE8A5FC) and verifying any fix. Switch modes by editing pxe-infra.vm.bootMode in configurations/rydiwo and running nixos-rebuild switch — no other changes needed. --- modules/options.nix | 25 +++++++++++++++++++++++++ modules/pxe-infra/vm.nix | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/modules/options.nix b/modules/options.nix index 2b853f2..c3cac83 100644 --- a/modules/options.nix +++ b/modules/options.nix @@ -348,6 +348,31 @@ option flipping. ''; }; + bootMode = lib.mkOption { + type = lib.types.enum [ "direct" "pxe" ]; + default = "direct"; + description = '' + How the guest obtains its boot image. + + `direct` attaches the deployed `latest/alpine-worker.raw` + as a virtio drive and uses `-boot c`. The OVMF firmware + finds BOOTX64.EFI in the image's ESP. This is the + rig's normal mode: the same artifact the PXE chain + would serve is loaded directly, the boot is + deterministic, and the firmware chain (TFTP→iPXE→HTTP) + is not exercised. + + `pxe` uses `-boot n` and does NOT attach the virtio + drive. The firmware does PXE: dnsmasq hands out DHCP + and the iPXE binary, iPXE loads boot.ipxe over HTTP, + boot.ipxe boots the image. This exercises the full + L3 boot chain. iPXE 2.0.0 currently #GPs at the + handoff back to OVMF (RIP 0x7EE8A5FC, RAX 0xAF...AF) + under QEMU 11.x and OVMF 202608, so this mode is for + reproducing that bug (T10) and verifying fixes; the + rig itself should run in `direct` mode in steady state. + ''; + }; }; # iPXE bootloader staging. Bridges the UEFI firmware (which diff --git a/modules/pxe-infra/vm.nix b/modules/pxe-infra/vm.nix index 8a1d339..b6f694e 100644 --- a/modules/pxe-infra/vm.nix +++ b/modules/pxe-infra/vm.nix @@ -104,6 +104,34 @@ cp ${pkgs.OVMF.fd}/FV/OVMF_VARS.fd "$VARS" fi + # bootMode=direct: attach the deployed raw image as a + # virtio drive, boot from disk. Always works (proven E2E + # 2026-10-13), and is what the rig should run in steady + # state since the rig is a pipeline validator, not a + # test of the iPXE chain itself. + # + # bootMode=pxe: no virtio drive, -boot n. The firmware + # does PXE → dnsmasq hands out DHCP and the iPXE binary + # → iPXE loads boot.ipxe over HTTP → boot.ipxe boots + # the image via sanboot/kernel+initrd. This is the + # path that crashes at iPXE 2.0.0 ExitBootServices + # (RIP 0x7EE8A5FC, RAX 0xAF...AF). Used to reproduce + # T10 and verify any fix. + case "${config.pxe-infra.vm.bootMode}" in + pxe) + EXTRA_DRIVES="" + BOOT_ORDER=n + ;; + direct) + EXTRA_DRIVES="-drive file=${config.pxe-infra.artifacts.root}/http/latest/alpine-worker.raw,format=raw,if=virtio" + BOOT_ORDER=c + ;; + *) + echo "pxe-infra-vm: unknown bootMode '${config.pxe-infra.vm.bootMode}'" >&2 + exit 1 + ;; + esac + exec qemu-system-x86_64 \ -name pxe-infra-vm \ -machine type=q35,accel=kvm:tcg \ @@ -112,10 +140,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 \ + $EXTRA_DRIVES \ -netdev tap,id=net0,ifname=pxe0-tap,script=no,downscript=no \ -device virtio-net-pci,netdev=net0,mac=${config.pxe-infra.vm.mac} \ - -boot c \ + -boot $BOOT_ORDER \ -nographic \ -serial mon:stdio '';