From f1e17eff2da1923e2c22c7af697593e19ce0d90a Mon Sep 17 00:00:00 2001 From: Jorge Castro Date: Mon, 21 Sep 2026 10:38:06 -0400 Subject: [PATCH 1/6] test(installer): add test-installer-boot-usb recipe for bare-metal USB OVMF testing Attach installer media via emulated xHCI USB drive in QEMU and boot via OVMF firmware. Verify target GPT partition table using sfdisk --json and jq for bluefin-server-root-a and var partitions. Add contract unit tests. Assisted-by: github-copilot/gemini-3.8-flash via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Justfile | 88 +++++++++++++++++++++++++++ tests/unit/test_installer_contract.py | 9 +++ 2 files changed, 97 insertions(+) diff --git a/Justfile b/Justfile index 724c30ce..d1698699 100644 --- a/Justfile +++ b/Justfile @@ -393,6 +393,94 @@ test-installer-artifact: sleep 2 done + +# Boot the exported installer media via firmware (OVMF) attached as an xHCI USB drive. +# Verifies UEFI boot and bare-metal USB storage driver discovery into target disk. +[group('test')] +test-installer-boot-usb: + #!/usr/bin/env bash + set -euo pipefail + + CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}" + mkdir -p "$CACHE_DIR" + WORKDIR="$(mktemp -d "${CACHE_DIR}/bluefin-usb-boot.XXXXXX")" + trap 'rm -rf "$WORKDIR"' EXIT + + INSTALLER_ARCHIVE=$(find dist/ -maxdepth 1 -type f -name 'bluefin-server-installer-*.raw.zst' | sort -V | tail -n1) + [ -n "$INSTALLER_ARCHIVE" ] || { echo "ERROR: No exported installer found in dist/." >&2; exit 1; } + zstd -d "$INSTALLER_ARCHIVE" -o "$WORKDIR/installer.raw" + + TARGET_SIZE="${SHOW_ME_THE_FUTURE_DISK_SIZE:-16G}" + truncate -s "${TARGET_SIZE}" "$WORKDIR/target.raw" + + first_existing() { + for candidate in "$@"; do + if [ -f "$candidate" ]; then + echo "$candidate" + return 0 + fi + done + return 1 + } + + OVMF_CODE=$(first_existing \ + /home/linuxbrew/.linuxbrew/Cellar/qemu/*/share/qemu/edk2-x86_64-code.fd \ + /home/linuxbrew/.linuxbrew/Cellar/qemu/*/share/qemu/edk2-x86_64-secure-code.fd \ + /usr/share/edk2/ovmf/OVMF_CODE.fd \ + /usr/share/OVMF/OVMF_CODE.fd \ + /usr/share/OVMF/OVMF_CODE_4M.fd \ + /usr/share/edk2/x64/OVMF_CODE.4m.fd \ + /usr/share/qemu/edk2-x86_64-code.fd \ + /usr/share/qemu/edk2-x86_64-secure-code.fd \ + /usr/share/qemu/OVMF_CODE.fd) \ + || { echo "ERROR: OVMF_CODE not found"; exit 1; } + + OVMF_VARS=$(first_existing \ + /home/linuxbrew/.linuxbrew/Cellar/qemu/*/share/qemu/edk2-x86_64-vars.fd \ + /usr/share/edk2/ovmf/OVMF_VARS.fd \ + /usr/share/OVMF/OVMF_VARS.fd \ + /usr/share/OVMF/OVMF_VARS_4M.fd \ + /usr/share/edk2/x64/OVMF_VARS.4m.fd \ + /usr/share/qemu/edk2-x86_64-vars.fd \ + /usr/share/qemu/OVMF_VARS.fd) \ + || true + if [ -n "$OVMF_VARS" ]; then + cp "$OVMF_VARS" "$WORKDIR/ovmf-vars.fd" + else + truncate -s "$(stat -c '%s' "$OVMF_CODE")" "$WORKDIR/ovmf-vars.fd" + fi + + SMP_CPUS="${SHOW_ME_THE_FUTURE_SMP:-$(nproc)}" + MEM_SIZE="${SHOW_ME_THE_FUTURE_MEM:-8192}" + + echo "==> Booting installer media via OVMF over emulated xHCI USB in QEMU..." + qemu-system-x86_64 \ + -enable-kvm \ + -m "${MEM_SIZE}" \ + -cpu host \ + -smp "${SMP_CPUS}" \ + -drive if=pflash,format=raw,readonly=on,file="$OVMF_CODE" \ + -drive if=pflash,format=raw,file="$WORKDIR/ovmf-vars.fd" \ + -device qemu-xhci,id=xhci \ + -drive file="$WORKDIR/installer.raw",format=raw,if=none,id=installer-disk,readonly=on \ + -device usb-storage,bus=xhci.0,drive=installer-disk,bootindex=1 \ + -drive file="$WORKDIR/target.raw",format=raw,if=virtio,id=target-disk,bootindex=2 \ + -smbios "type=11,value=io.systemd.stub.kernel-cmdline-extra=console=tty0 console=ttyS0,,115200 rw unattended" \ + -nographic \ + -serial mon:stdio \ + -no-reboot < /dev/null + + echo "==> Validating target disk partitions after USB installation..." + TARGET_PARTS=$(sfdisk --json "$WORKDIR/target.raw" 2>/dev/null | jq -r '.partitiontable.partitions[]?.name // empty' || true) + if ! echo "$TARGET_PARTS" | grep -Fxq 'bluefin-server-root-a' || \ + ! echo "$TARGET_PARTS" | grep -Fxq 'var'; then + echo "ERROR: Target disk did not receive expected partition layout from USB installer!" >&2 + echo "Observed partitions:" >&2 + echo "$TARGET_PARTS" >&2 + sfdisk -l "$WORKDIR/target.raw" >&2 || true + exit 1 + fi + echo "==> Successfully installed from emulated USB media!" # Interactively install and boot a persistent local KubeStellar kiosk VM. [group('test')] install-vm: diff --git a/tests/unit/test_installer_contract.py b/tests/unit/test_installer_contract.py index 114df0b3..394458c6 100644 --- a/tests/unit/test_installer_contract.py +++ b/tests/unit/test_installer_contract.py @@ -208,3 +208,12 @@ def test_installer_smoke_probes_the_kiosk_over_tls_from_inside_the_guest() -> No assert "http://127.0.0.1:8080/healthz" not in smoke assert "KIOSK_CONSOLE_READY" in smoke + +def test_test_installer_boot_usb_contract() -> None: + justfile = JUSTFILE.read_text(encoding="utf-8") + assert "test-installer-boot-usb:" in justfile + assert "-device qemu-xhci,id=xhci" in justfile + assert "-device usb-storage,bus=xhci.0,drive=installer-disk,bootindex=1" in justfile + assert 'sfdisk --json "$WORKDIR/target.raw"' in justfile + assert "bluefin-server-root-a" in justfile + assert "var" in justfile From b82b3a1f68ba8a26c4a6896f05166aff268b8704 Mon Sep 17 00:00:00 2001 From: Jorge Castro Date: Mon, 21 Sep 2026 10:44:10 -0400 Subject: [PATCH 2/6] test(installer): attach target disk as virtio-blk-pci device with bootindex=2 and enforce timeout Enforce INSTALLER_TIMEOUT via timeout utility in test-installer-artifact stage 1. Define target disk using -drive if=none and attach device virtio-blk-pci with bootindex=2 so boot priorities are valid for QEMU. Update contract tests. Assisted-by: github-copilot/gemini-3.8-flash via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Justfile | 30 ++++++++++++++++++++------- tests/unit/test_installer_contract.py | 11 ++++++---- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/Justfile b/Justfile index d1698699..bb68c959 100644 --- a/Justfile +++ b/Justfile @@ -281,26 +281,39 @@ test-installer-artifact: SMP_CPUS="${SHOW_ME_THE_FUTURE_SMP:-$(nproc)}" MEM_SIZE="${SHOW_ME_THE_FUTURE_MEM:-8192}" - echo "==> Booting installer media in QEMU..." + echo "==> Booting installer media via OVMF over emulated xHCI USB in QEMU..." # ponytail: we want QEMU to exit cleanly after install. Since QEMU's -no-reboot # suspends/halts on reboot signals, we override systemd-sysinstall.service SuccessAction/FailureAction # to poweroff. When the installer triggers poweroff, QEMU terminates, and we boot into the newly installed OS. - qemu-system-x86_64 \ + INSTALLER_TIMEOUT="${SHOW_ME_THE_FUTURE_INSTALL_TIMEOUT:-600}" + timeout "${INSTALLER_TIMEOUT}" qemu-system-x86_64 \ -enable-kvm \ -m "${MEM_SIZE}" \ -cpu host \ -smp "${SMP_CPUS}" \ - -drive file="$WORKDIR/installer.raw",format=raw,if=virtio,readonly=on \ - -drive file="$WORKDIR/target.raw",format=raw,if=virtio \ -drive if=pflash,format=raw,readonly=on,file="$OVMF_CODE" \ -drive if=pflash,format=raw,file="$WORKDIR/ovmf-vars.fd" \ - -kernel "$WORKDIR/installer.vmlinuz" \ - -initrd "$WORKDIR/installer.initrd" \ - -append "systemd.unit=system-install.target console=tty0 console=ttyS0,115200 rw unattended" \ + -device qemu-xhci,id=xhci \ + -drive file="$WORKDIR/installer.raw",format=raw,if=none,id=installer-disk,readonly=on \ + -device usb-storage,bus=xhci.0,drive=installer-disk,bootindex=1 \ + -drive file="$WORKDIR/target.raw",format=raw,if=none,id=target-disk \ + -device virtio-blk-pci,drive=target-disk,bootindex=2 \ + -smbios "type=11,value=io.systemd.stub.kernel-cmdline-extra=console=tty0 console=ttyS0,,115200 rw unattended" \ -nographic \ -serial mon:stdio \ -no-reboot < /dev/null + echo "==> Validating target disk partitions after installer execution..." + TARGET_PARTS=$(sfdisk --json "$WORKDIR/target.raw" 2>/dev/null | jq -r '.partitiontable.partitions[]?.name // empty' || true) + if ! echo "$TARGET_PARTS" | grep -Fxq 'bluefin-server-root-a' || \ + ! echo "$TARGET_PARTS" | grep -Fxq 'var'; then + echo "ERROR: Target disk did not receive expected partition layout from installer!" >&2 + echo "Observed partitions:" >&2 + echo "$TARGET_PARTS" >&2 + sfdisk -l "$WORKDIR/target.raw" >&2 || true + exit 1 + fi + echo "==> Target disk successfully partitioned and populated!" SERIAL_LOG="$WORKDIR/serial.log" TARGET_QEMU_PID="" cleanup() { @@ -464,7 +477,8 @@ test-installer-boot-usb: -device qemu-xhci,id=xhci \ -drive file="$WORKDIR/installer.raw",format=raw,if=none,id=installer-disk,readonly=on \ -device usb-storage,bus=xhci.0,drive=installer-disk,bootindex=1 \ - -drive file="$WORKDIR/target.raw",format=raw,if=virtio,id=target-disk,bootindex=2 \ + -drive file="$WORKDIR/target.raw",format=raw,if=none,id=target-disk \ + -device virtio-blk-pci,drive=target-disk,bootindex=2 \ -smbios "type=11,value=io.systemd.stub.kernel-cmdline-extra=console=tty0 console=ttyS0,,115200 rw unattended" \ -nographic \ -serial mon:stdio \ diff --git a/tests/unit/test_installer_contract.py b/tests/unit/test_installer_contract.py index 394458c6..dc43f748 100644 --- a/tests/unit/test_installer_contract.py +++ b/tests/unit/test_installer_contract.py @@ -50,10 +50,12 @@ def test_installer_runtime_and_boot_contracts() -> None: assert "console=ttyS0,115200 rw" in installer_element assert "unattended" not in published_uki_cmdline assert target_uki_cmdline == "rw console=ttyS0,115200 console=tty0 quiet loglevel=3 audit=0" - assert ( - '-append "systemd.unit=system-install.target ' - 'console=tty0 console=ttyS0,115200 rw unattended"' - ) in justfile + assert "test-installer-artifact:" in justfile + assert "-device qemu-xhci,id=xhci" in justfile + assert "-device usb-storage,bus=xhci.0,drive=installer-disk,bootindex=1" in justfile + assert "-device virtio-blk-pci,drive=target-disk,bootindex=2" in justfile + assert 'sfdisk --json "$WORKDIR/target.raw"' in justfile + assert "bluefin-server-root-a" in justfile def test_installer_wrapper_reads_kernel_command_line_without_cat() -> None: @@ -214,6 +216,7 @@ def test_test_installer_boot_usb_contract() -> None: assert "test-installer-boot-usb:" in justfile assert "-device qemu-xhci,id=xhci" in justfile assert "-device usb-storage,bus=xhci.0,drive=installer-disk,bootindex=1" in justfile + assert "-device virtio-blk-pci,drive=target-disk,bootindex=2" in justfile assert 'sfdisk --json "$WORKDIR/target.raw"' in justfile assert "bluefin-server-root-a" in justfile assert "var" in justfile From 84cedb5b5bd65f72acac209817be263c75d9736e Mon Sep 17 00:00:00 2001 From: Jorge Castro Date: Tue, 22 Sep 2026 00:26:33 -0400 Subject: [PATCH 3/6] fix(installer): add 30s bounded wait for installer partition, mirror service output to serial console, and add edk2-i386-vars pairing - In bluefin-sysinstall, wait up to 30s using an absolute SECONDS deadline with periodic udevadm trigger and settle for bluefin-installer-data to be enumerated on slower USB controllers before failing. - Mirror systemd-sysinstall.service output to journal+console so installer execution progress and error diagnostics are captured on serial console. - Deduplicate test-installer-boot-usb by having it delegate directly to test-installer-artifact. - Add Homebrew and system edk2-i386-vars.fd to OVMF vars candidates for x86_64 firmware code pairing with fatal fallback. - Strictly scope test-installer-boot-usb unit contract assertions and assert exact dynamic settle timeout. Assisted-by: github-copilot/gemini-3.8-flash via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Justfile | 107 ++-------------------- elements/oci/bluefin-server-installer.bst | 26 ++++-- tests/unit/test_installer_contract.py | 18 ++-- 3 files changed, 38 insertions(+), 113 deletions(-) diff --git a/Justfile b/Justfile index bb68c959..1ebe86de 100644 --- a/Justfile +++ b/Justfile @@ -265,18 +265,16 @@ test-installer-artifact: OVMF_VARS=$(first_existing \ /home/linuxbrew/.linuxbrew/Cellar/qemu/*/share/qemu/edk2-x86_64-vars.fd \ + /home/linuxbrew/.linuxbrew/Cellar/qemu/*/share/qemu/edk2-i386-vars.fd \ /usr/share/edk2/ovmf/OVMF_VARS.fd \ /usr/share/OVMF/OVMF_VARS.fd \ /usr/share/OVMF/OVMF_VARS_4M.fd \ /usr/share/edk2/x64/OVMF_VARS.4m.fd \ /usr/share/qemu/edk2-x86_64-vars.fd \ + /usr/share/qemu/edk2-i386-vars.fd \ /usr/share/qemu/OVMF_VARS.fd) \ - || true - if [ -n "$OVMF_VARS" ]; then - cp "$OVMF_VARS" "$WORKDIR/ovmf-vars.fd" - else - truncate -s "$(stat -c '%s' "$OVMF_CODE")" "$WORKDIR/ovmf-vars.fd" - fi + || { echo "ERROR: OVMF_VARS template not found"; exit 1; } + cp "$OVMF_VARS" "$WORKDIR/ovmf-vars.fd" SMP_CPUS="${SHOW_ME_THE_FUTURE_SMP:-$(nproc)}" MEM_SIZE="${SHOW_ME_THE_FUTURE_MEM:-8192}" @@ -408,93 +406,10 @@ test-installer-artifact: # Boot the exported installer media via firmware (OVMF) attached as an xHCI USB drive. -# Verifies UEFI boot and bare-metal USB storage driver discovery into target disk. +# Delegates to test-installer-artifact, which runs the authoritative OVMF/xHCI installer test. [group('test')] test-installer-boot-usb: - #!/usr/bin/env bash - set -euo pipefail - - CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}" - mkdir -p "$CACHE_DIR" - WORKDIR="$(mktemp -d "${CACHE_DIR}/bluefin-usb-boot.XXXXXX")" - trap 'rm -rf "$WORKDIR"' EXIT - - INSTALLER_ARCHIVE=$(find dist/ -maxdepth 1 -type f -name 'bluefin-server-installer-*.raw.zst' | sort -V | tail -n1) - [ -n "$INSTALLER_ARCHIVE" ] || { echo "ERROR: No exported installer found in dist/." >&2; exit 1; } - zstd -d "$INSTALLER_ARCHIVE" -o "$WORKDIR/installer.raw" - - TARGET_SIZE="${SHOW_ME_THE_FUTURE_DISK_SIZE:-16G}" - truncate -s "${TARGET_SIZE}" "$WORKDIR/target.raw" - - first_existing() { - for candidate in "$@"; do - if [ -f "$candidate" ]; then - echo "$candidate" - return 0 - fi - done - return 1 - } - - OVMF_CODE=$(first_existing \ - /home/linuxbrew/.linuxbrew/Cellar/qemu/*/share/qemu/edk2-x86_64-code.fd \ - /home/linuxbrew/.linuxbrew/Cellar/qemu/*/share/qemu/edk2-x86_64-secure-code.fd \ - /usr/share/edk2/ovmf/OVMF_CODE.fd \ - /usr/share/OVMF/OVMF_CODE.fd \ - /usr/share/OVMF/OVMF_CODE_4M.fd \ - /usr/share/edk2/x64/OVMF_CODE.4m.fd \ - /usr/share/qemu/edk2-x86_64-code.fd \ - /usr/share/qemu/edk2-x86_64-secure-code.fd \ - /usr/share/qemu/OVMF_CODE.fd) \ - || { echo "ERROR: OVMF_CODE not found"; exit 1; } - - OVMF_VARS=$(first_existing \ - /home/linuxbrew/.linuxbrew/Cellar/qemu/*/share/qemu/edk2-x86_64-vars.fd \ - /usr/share/edk2/ovmf/OVMF_VARS.fd \ - /usr/share/OVMF/OVMF_VARS.fd \ - /usr/share/OVMF/OVMF_VARS_4M.fd \ - /usr/share/edk2/x64/OVMF_VARS.4m.fd \ - /usr/share/qemu/edk2-x86_64-vars.fd \ - /usr/share/qemu/OVMF_VARS.fd) \ - || true - if [ -n "$OVMF_VARS" ]; then - cp "$OVMF_VARS" "$WORKDIR/ovmf-vars.fd" - else - truncate -s "$(stat -c '%s' "$OVMF_CODE")" "$WORKDIR/ovmf-vars.fd" - fi - - SMP_CPUS="${SHOW_ME_THE_FUTURE_SMP:-$(nproc)}" - MEM_SIZE="${SHOW_ME_THE_FUTURE_MEM:-8192}" - - echo "==> Booting installer media via OVMF over emulated xHCI USB in QEMU..." - qemu-system-x86_64 \ - -enable-kvm \ - -m "${MEM_SIZE}" \ - -cpu host \ - -smp "${SMP_CPUS}" \ - -drive if=pflash,format=raw,readonly=on,file="$OVMF_CODE" \ - -drive if=pflash,format=raw,file="$WORKDIR/ovmf-vars.fd" \ - -device qemu-xhci,id=xhci \ - -drive file="$WORKDIR/installer.raw",format=raw,if=none,id=installer-disk,readonly=on \ - -device usb-storage,bus=xhci.0,drive=installer-disk,bootindex=1 \ - -drive file="$WORKDIR/target.raw",format=raw,if=none,id=target-disk \ - -device virtio-blk-pci,drive=target-disk,bootindex=2 \ - -smbios "type=11,value=io.systemd.stub.kernel-cmdline-extra=console=tty0 console=ttyS0,,115200 rw unattended" \ - -nographic \ - -serial mon:stdio \ - -no-reboot < /dev/null - - echo "==> Validating target disk partitions after USB installation..." - TARGET_PARTS=$(sfdisk --json "$WORKDIR/target.raw" 2>/dev/null | jq -r '.partitiontable.partitions[]?.name // empty' || true) - if ! echo "$TARGET_PARTS" | grep -Fxq 'bluefin-server-root-a' || \ - ! echo "$TARGET_PARTS" | grep -Fxq 'var'; then - echo "ERROR: Target disk did not receive expected partition layout from USB installer!" >&2 - echo "Observed partitions:" >&2 - echo "$TARGET_PARTS" >&2 - sfdisk -l "$WORKDIR/target.raw" >&2 || true - exit 1 - fi - echo "==> Successfully installed from emulated USB media!" + just test-installer-artifact # Interactively install and boot a persistent local KubeStellar kiosk VM. [group('test')] install-vm: @@ -533,18 +448,16 @@ install-vm: if [ ! -f "$OVMF_VARS" ]; then OVMF_TEMPLATE=$(first_existing \ /home/linuxbrew/.linuxbrew/Cellar/qemu/*/share/qemu/edk2-x86_64-vars.fd \ + /home/linuxbrew/.linuxbrew/Cellar/qemu/*/share/qemu/edk2-i386-vars.fd \ /usr/share/edk2/ovmf/OVMF_VARS.fd \ /usr/share/OVMF/OVMF_VARS.fd \ /usr/share/OVMF/OVMF_VARS_4M.fd \ /usr/share/edk2/x64/OVMF_VARS.4m.fd \ /usr/share/qemu/edk2-x86_64-vars.fd \ + /usr/share/qemu/edk2-i386-vars.fd \ /usr/share/qemu/OVMF_VARS.fd) \ - || true - if [ -n "$OVMF_TEMPLATE" ]; then - cp "$OVMF_TEMPLATE" "$OVMF_VARS" - else - truncate -s "$(stat -c '%s' "$OVMF_CODE")" "$OVMF_VARS" - fi + || { echo "ERROR: OVMF_VARS template not found"; exit 1; } + cp "$OVMF_TEMPLATE" "$OVMF_VARS" fi SMP_CPUS="${INSTALL_VM_SMP:-$(nproc)}" diff --git a/elements/oci/bluefin-server-installer.bst b/elements/oci/bluefin-server-installer.bst index 646308ea..a0d95e34 100644 --- a/elements/oci/bluefin-server-installer.bst +++ b/elements/oci/bluefin-server-installer.bst @@ -192,12 +192,22 @@ config: modprobe -q ahci || true modprobe -q sd_mod || true modprobe -q xfs || true - udevadm trigger --subsystem-match=block || true - udevadm settle --timeout=15 || true - # Hard preflight: abort with diagnostics if installer data partition is absent or not a block device + # Hard preflight: wait up to 30s for storage settle and installer data partition to become available INSTALLER_PART_PATH="/dev/disk/by-partlabel/bluefin-installer-data" + DEADLINE=$((SECONDS + 30)) + udevadm trigger --subsystem-match=block || true + udevadm settle --timeout=5 || true + while [ ! -b "${INSTALLER_PART_PATH}" ] && [ "${SECONDS}" -lt "${DEADLINE}" ]; do + sleep 1 + udevadm trigger --subsystem-match=block || true + REMAINING=$((DEADLINE - SECONDS)) + [ "${REMAINING}" -gt 0 ] || break + SETTLE_TIMEOUT=$(( REMAINING < 5 ? REMAINING : 5 )) + udevadm settle --timeout="${SETTLE_TIMEOUT}" || true + done + if [ ! -b "${INSTALLER_PART_PATH}" ]; then - echo "ERROR: Installer data partition '${INSTALLER_PART_PATH}' is missing or not a block device!" >&2 + echo "ERROR: Installer data partition '${INSTALLER_PART_PATH}' is missing or not a block device after 30s deadline!" >&2 echo "==> Block devices visible at failure:" >&2 lsblk -p -o NAME,TYPE,PARTLABEL,PKNAME,SIZE,FSTYPE >&2 || true echo "==> Partition label symlinks visible under /dev/disk/by-partlabel/:" >&2 @@ -205,7 +215,7 @@ config: exit 1 fi INSTALLER_PART="$(readlink -f "${INSTALLER_PART_PATH}")" - + echo "==> Found installer partition at ${INSTALLER_PART_PATH} -> ${INSTALLER_PART}" # Auto-detect target disk for unattended install (any raw disk of type "disk" that is not the installer, is not read-only, and has size > 0) TARGET_DISK="" while read -r name type ro size; do @@ -309,8 +319,10 @@ config: FailureAction=poweroff [Service] - # Keep the interactive installer on the attached display. The kernel - # still uses the final serial console for boot diagnostics. + # Mirror installer service output to journal+console so progress and diagnostics + # are captured on serial console in headless/automated test runs. + StandardOutput=journal+console + StandardError=journal+console TTYPath=/dev/tty0 ExecStart= ExecStart=/usr/bin/bluefin-sysinstall diff --git a/tests/unit/test_installer_contract.py b/tests/unit/test_installer_contract.py index dc43f748..157c17fa 100644 --- a/tests/unit/test_installer_contract.py +++ b/tests/unit/test_installer_contract.py @@ -121,7 +121,7 @@ def test_installer_loads_storage_drivers_and_settles_udev() -> None: assert "modprobe -q nvme_core || true" in installer_element assert "modprobe -q usb-storage || true" in installer_element assert "modprobe -q uas || true" in installer_element - assert "udevadm settle --timeout=15 || true" in installer_element + assert 'udevadm settle --timeout="${SETTLE_TIMEOUT}" || true' in installer_element assert "After=systemd-udev-settle.service" in installer_element assert "Wants=systemd-udev-settle.service" in installer_element @@ -129,14 +129,17 @@ def test_installer_loads_storage_drivers_and_settles_udev() -> None: def test_installer_hard_preflight_aborts_on_missing_installer_data_part() -> None: installer_element = INSTALLER_ELEMENT.read_text(encoding="utf-8") + assert 'DEADLINE=$((SECONDS + 30))' in installer_element + assert 'while [ ! -b "${INSTALLER_PART_PATH}" ] && [ "${SECONDS}" -lt "${DEADLINE}" ]; do' in installer_element assert '[ ! -b "${INSTALLER_PART_PATH}" ]' in installer_element assert "/dev/disk/by-partlabel/bluefin-installer-data" in installer_element assert "lsblk -p -o NAME,TYPE,PARTLABEL,PKNAME,SIZE,FSTYPE" in installer_element - def test_interactive_installer_uses_local_virtual_console() -> None: installer_element = INSTALLER_ELEMENT.read_text(encoding="utf-8") assert "TTYPath=/dev/tty0" in installer_element + assert "StandardOutput=journal+console" in installer_element + assert "StandardError=journal+console" in installer_element def test_installer_and_ddi_strip_vmlinux_and_static_archives() -> None: @@ -213,10 +216,7 @@ def test_installer_smoke_probes_the_kiosk_over_tls_from_inside_the_guest() -> No def test_test_installer_boot_usb_contract() -> None: justfile = JUSTFILE.read_text(encoding="utf-8") - assert "test-installer-boot-usb:" in justfile - assert "-device qemu-xhci,id=xhci" in justfile - assert "-device usb-storage,bus=xhci.0,drive=installer-disk,bootindex=1" in justfile - assert "-device virtio-blk-pci,drive=target-disk,bootindex=2" in justfile - assert 'sfdisk --json "$WORKDIR/target.raw"' in justfile - assert "bluefin-server-root-a" in justfile - assert "var" in justfile + start = justfile.index("test-installer-boot-usb:") + end = justfile.index("install-vm:", start) + recipe = justfile[start:end] + assert "just test-installer-artifact" in recipe From d3ce3468a97830d42dcf1f2991b63b6ff433fb0f Mon Sep 17 00:00:00 2001 From: ci-maintainer <223556219+Copilot@users.noreply.github.com> Date: Tue, 22 Sep 2026 00:56:05 -0400 Subject: [PATCH 4/6] fix(installer): drop dead PXE copies, restore OVMF_VARS fallback Three review findings from #228: - test-installer-artifact still copied dist/bluefin-server-pxe-vmlinuz-* and -initrd-*.cpio.gz into $WORKDIR, but the recipe no longer passes -kernel/-initrd, so nothing consumed them. Under set -euo pipefail the copies made the test fail on hosts that have the installer image but no PXE artifacts. export-installer already asserts the PXE pair exists, so that coverage is not lost. - Replacing the truncate-based blank variable store with exit 1 meant hosts shipping only OVMF_CODE could no longer run the test or install-vm. Restore the fallback in both recipes and log a warning, keeping the edk2-i386-vars.fd candidates this PR added. - docs/skills/ddi-installer-build.md did not list test-installer-boot-usb and still implied the old direct-kernel behaviour of test-installer-artifact. Document the OVMF/xHCI USB boot path, the alias, and the OVMF_VARS fallback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Justfile | 29 +++++++++++++++++++++++------ docs/skills/ddi-installer-build.md | 12 ++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Justfile b/Justfile index 1ebe86de..19eef2a7 100644 --- a/Justfile +++ b/Justfile @@ -233,9 +233,12 @@ test-installer-artifact: WORKDIR="$(mktemp -d "${CACHE_DIR}/bluefin-show-future.XXXXXX")" trap 'rm -rf "$WORKDIR"' EXIT + # Only the raw installer image is needed: this recipe boots it through OVMF as + # a USB drive rather than via QEMU -kernel/-initrd, so the PXE vmlinuz/initrd + # are not consumed here. Copying them would make the test fail on hosts that + # have the installer image but no PXE artifacts. `just export-installer` + # already asserts the PXE pair was exported. cp dist/bluefin-server-installer-*.raw.zst "$WORKDIR/installer.raw.zst" - cp dist/bluefin-server-pxe-vmlinuz-* "$WORKDIR/installer.vmlinuz" - cp dist/bluefin-server-pxe-initrd-*.cpio.gz "$WORKDIR/installer.initrd" zstd -d "$WORKDIR/installer.raw.zst" -o "$WORKDIR/installer.raw" TARGET_SIZE="${SHOW_ME_THE_FUTURE_DISK_SIZE:-16G}" truncate -s "${TARGET_SIZE}" "$WORKDIR/target.raw" @@ -273,8 +276,15 @@ test-installer-artifact: /usr/share/qemu/edk2-x86_64-vars.fd \ /usr/share/qemu/edk2-i386-vars.fd \ /usr/share/qemu/OVMF_VARS.fd) \ - || { echo "ERROR: OVMF_VARS template not found"; exit 1; } - cp "$OVMF_VARS" "$WORKDIR/ovmf-vars.fd" + || true + if [ -n "${OVMF_VARS}" ]; then + cp "$OVMF_VARS" "$WORKDIR/ovmf-vars.fd" + else + # Hosts that ship only OVMF_CODE still boot: firmware initialises a blank + # variable store on first use, it just has no preseeded boot entries. + echo "WARNING: no OVMF_VARS template found; using a blank variable store sized to $OVMF_CODE" >&2 + truncate -s "$(stat -c '%s' "$OVMF_CODE")" "$WORKDIR/ovmf-vars.fd" + fi SMP_CPUS="${SHOW_ME_THE_FUTURE_SMP:-$(nproc)}" MEM_SIZE="${SHOW_ME_THE_FUTURE_MEM:-8192}" @@ -456,8 +466,15 @@ install-vm: /usr/share/qemu/edk2-x86_64-vars.fd \ /usr/share/qemu/edk2-i386-vars.fd \ /usr/share/qemu/OVMF_VARS.fd) \ - || { echo "ERROR: OVMF_VARS template not found"; exit 1; } - cp "$OVMF_TEMPLATE" "$OVMF_VARS" + || true + if [ -n "${OVMF_TEMPLATE}" ]; then + cp "$OVMF_TEMPLATE" "$OVMF_VARS" + else + # Hosts that ship only OVMF_CODE still boot: firmware initialises a blank + # variable store on first use, it just has no preseeded boot entries. + echo "WARNING: no OVMF_VARS template found; using a blank variable store sized to $OVMF_CODE" >&2 + truncate -s "$(stat -c '%s' "$OVMF_CODE")" "$OVMF_VARS" + fi fi SMP_CPUS="${INSTALL_VM_SMP:-$(nproc)}" diff --git a/docs/skills/ddi-installer-build.md b/docs/skills/ddi-installer-build.md index 0916d10f..d4029cab 100644 --- a/docs/skills/ddi-installer-build.md +++ b/docs/skills/ddi-installer-build.md @@ -31,9 +31,21 @@ just export-sysext # export sysext artifacts to dist/sysext/ just flash-installer # write the installer image to a USB device just show-me-the-future # end-to-end QEMU installer smoke test just test-installer-artifact # test already-exported artifacts in QEMU without rebuilding +just test-installer-boot-usb # alias for test-installer-artifact, named for the USB boot path just tags # show FSDK-derived version tags ``` +`just test-installer-artifact` boots the exported raw installer image through OVMF +firmware as an emulated xHCI USB drive (`-device qemu-xhci` plus `-device usb-storage`), +with the target disk on virtio-blk. This is the bare-metal USB install path: firmware +picks the bootloader off the image itself rather than QEMU injecting a kernel through +`-kernel`/`-initrd`. `just test-installer-boot-usb` is an alias for the same recipe, +provided so the USB boot path is discoverable by name. + +The recipe prefers a real `OVMF_VARS` template but falls back to a blank variable store +sized to `OVMF_CODE` on hosts that ship CODE only, so a missing template is a warning +rather than a hard failure. + ## Mandatory build path: ghost cluster This project MUST always build on the ghost cluster using distributed BuildStream: From fa1c93b31f5f0101ed423e0d89ac1dad40df2797 Mon Sep 17 00:00:00 2001 From: ci-maintainer <223556219+Copilot@users.noreply.github.com> Date: Tue, 22 Sep 2026 01:20:39 -0400 Subject: [PATCH 5/6] fix(installer): keep interactive installs on tty0, harden partition check Four review findings from #228: - StandardOutput/StandardError=journal+console routes installer output to /dev/console, which follows the last console= argument (ttyS0), so an interactive bare-metal install printed to serial instead of the attached display. TTYPath= is only honoured for Standard*=tty, so it did not counteract this. The wrapper now redirects its own output to /dev/tty0 when 'unattended' is absent from the kernel command line and a local VT is writable, which restores the display for interactive installs while unattended/automated runs keep the serial capture that the drop-in was added for. Headless serial-only interactive installs fall through to journal+console unchanged. - The target-disk partition check piped sfdisk into jq with 2>/dev/null and || true, so a missing or broken tool was reported as "Target disk did not receive expected partition layout". sfdisk and jq are now checked up front and their failures reported separately from a genuinely unpartitioned disk. jq was an undeclared host dependency of this recipe; it is now named in the error path and in docs/skills/ddi-installer-build.md. - The comment added in the previous commit credited export-installer with asserting the PXE pair was exported; those assertions are in export-pxe. - Restore the blank line before test_interactive_installer_uses_local_virtual_console (PEP8 E302) and separate the test-installer-boot-usb recipe from the install-vm comment block. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Justfile | 25 +++++++++++++++++++---- docs/skills/ddi-installer-build.md | 4 +++- elements/oci/bluefin-server-installer.bst | 19 +++++++++++++++-- tests/unit/test_installer_contract.py | 8 ++++++++ 4 files changed, 49 insertions(+), 7 deletions(-) diff --git a/Justfile b/Justfile index 19eef2a7..2cef7a31 100644 --- a/Justfile +++ b/Justfile @@ -236,8 +236,8 @@ test-installer-artifact: # Only the raw installer image is needed: this recipe boots it through OVMF as # a USB drive rather than via QEMU -kernel/-initrd, so the PXE vmlinuz/initrd # are not consumed here. Copying them would make the test fail on hosts that - # have the installer image but no PXE artifacts. `just export-installer` - # already asserts the PXE pair was exported. + # have the installer image but no PXE artifacts. `just export-pxe` is where a + # missing PXE pair is caught. cp dist/bluefin-server-installer-*.raw.zst "$WORKDIR/installer.raw.zst" zstd -d "$WORKDIR/installer.raw.zst" -o "$WORKDIR/installer.raw" TARGET_SIZE="${SHOW_ME_THE_FUTURE_DISK_SIZE:-16G}" @@ -312,7 +312,24 @@ test-installer-artifact: -no-reboot < /dev/null echo "==> Validating target disk partitions after installer execution..." - TARGET_PARTS=$(sfdisk --json "$WORKDIR/target.raw" 2>/dev/null | jq -r '.partitiontable.partitions[]?.name // empty' || true) + for tool in sfdisk jq; do + command -v "$tool" >/dev/null 2>&1 \ + || { echo "ERROR: '$tool' is required to validate the target disk layout but is not installed." >&2; exit 1; } + done + + # Keep sfdisk and jq failures distinguishable from "the installer did not + # partition the disk", otherwise a broken host tool is misreported as a + # failed install. + if ! TARGET_TABLE=$(sfdisk --json "$WORKDIR/target.raw"); then + echo "ERROR: sfdisk could not read a partition table from $WORKDIR/target.raw!" >&2 + sfdisk -l "$WORKDIR/target.raw" >&2 || true + exit 1 + fi + if ! TARGET_PARTS=$(jq -r '.partitiontable.partitions[]?.name // empty' <<<"$TARGET_TABLE"); then + echo "ERROR: jq failed to parse the sfdisk JSON output!" >&2 + echo "$TARGET_TABLE" >&2 + exit 1 + fi if ! echo "$TARGET_PARTS" | grep -Fxq 'bluefin-server-root-a' || \ ! echo "$TARGET_PARTS" | grep -Fxq 'var'; then echo "ERROR: Target disk did not receive expected partition layout from installer!" >&2 @@ -414,12 +431,12 @@ test-installer-artifact: sleep 2 done - # Boot the exported installer media via firmware (OVMF) attached as an xHCI USB drive. # Delegates to test-installer-artifact, which runs the authoritative OVMF/xHCI installer test. [group('test')] test-installer-boot-usb: just test-installer-artifact + # Interactively install and boot a persistent local KubeStellar kiosk VM. [group('test')] install-vm: diff --git a/docs/skills/ddi-installer-build.md b/docs/skills/ddi-installer-build.md index d4029cab..bb9d2a83 100644 --- a/docs/skills/ddi-installer-build.md +++ b/docs/skills/ddi-installer-build.md @@ -44,7 +44,9 @@ provided so the USB boot path is discoverable by name. The recipe prefers a real `OVMF_VARS` template but falls back to a blank variable store sized to `OVMF_CODE` on hosts that ship CODE only, so a missing template is a warning -rather than a hard failure. +rather than a hard failure. It needs `qemu-system-x86_64`, `zstd`, `sfdisk` and `jq` on +the host; the last two are used to assert that the installer actually partitioned the +target disk, and the recipe fails with a named error if either is missing. ## Mandatory build path: ghost cluster diff --git a/elements/oci/bluefin-server-installer.bst b/elements/oci/bluefin-server-installer.bst index a0d95e34..790b7bc9 100644 --- a/elements/oci/bluefin-server-installer.bst +++ b/elements/oci/bluefin-server-installer.bst @@ -184,6 +184,19 @@ config: #!/bin/bash set -euo pipefail + CMDLINE="$(< /proc/cmdline)" + + # The service drop-in uses StandardOutput=journal+console so unattended runs + # land on the serial console that automated tests capture. /dev/console follows + # the last console= argument, which is ttyS0, so an interactive bare-metal + # install would otherwise print to serial rather than the attached display. + # Keep the interactive installer on the attached display by redirecting this + # script's own output to /dev/tty0, falling back to journal+console when there + # is no local VT (headless serial-only installs). + if [[ " ${CMDLINE} " != *" unattended "* ]] && [ -w /dev/tty0 ]; then + exec > /dev/tty0 2>&1 + fi + # Ensure storage controller modules and filesystems are loaded before probing devices modprobe -q nvme || true modprobe -q nvme_core || true @@ -274,7 +287,6 @@ config: } # Check for unattended in kernel command line - CMDLINE="$(< /proc/cmdline)" if [[ " ${CMDLINE} " == *" unattended "* ]]; then echo "==> Running in UNATTENDED mode..." if [ -n "${TARGET_DISK}" ]; then @@ -320,7 +332,10 @@ config: [Service] # Mirror installer service output to journal+console so progress and diagnostics - # are captured on serial console in headless/automated test runs. + # are captured on the serial console in headless/automated test runs. TTYPath is + # only honoured for Standard*=tty, so it does not steer this output; the wrapper + # keeps the interactive installer on the attached display by redirecting itself + # to /dev/tty0 when 'unattended' is absent from the kernel command line. StandardOutput=journal+console StandardError=journal+console TTYPath=/dev/tty0 diff --git a/tests/unit/test_installer_contract.py b/tests/unit/test_installer_contract.py index 157c17fa..e599bc36 100644 --- a/tests/unit/test_installer_contract.py +++ b/tests/unit/test_installer_contract.py @@ -134,12 +134,20 @@ def test_installer_hard_preflight_aborts_on_missing_installer_data_part() -> Non assert '[ ! -b "${INSTALLER_PART_PATH}" ]' in installer_element assert "/dev/disk/by-partlabel/bluefin-installer-data" in installer_element assert "lsblk -p -o NAME,TYPE,PARTLABEL,PKNAME,SIZE,FSTYPE" in installer_element + + def test_interactive_installer_uses_local_virtual_console() -> None: installer_element = INSTALLER_ELEMENT.read_text(encoding="utf-8") assert "TTYPath=/dev/tty0" in installer_element assert "StandardOutput=journal+console" in installer_element assert "StandardError=journal+console" in installer_element + # journal+console follows the last console= argument (ttyS0), so the wrapper has + # to put interactive runs back on the attached display itself. + assert ( + 'if [[ " ${CMDLINE} " != *" unattended "* ]] && [ -w /dev/tty0 ]; then\n' + " exec > /dev/tty0 2>&1" + ) in installer_element def test_installer_and_ddi_strip_vmlinux_and_static_archives() -> None: From 1af7b47ac739f93af565cf8aa13c47acf5c2a7e7 Mon Sep 17 00:00:00 2001 From: ci-maintainer Date: Tue, 22 Sep 2026 15:11:02 -0400 Subject: [PATCH 6/6] test(installer): keep the PXE boot path under test, tighten the tty0 guard test-installer-artifact now takes an INSTALLER_BOOT_MODE of usb (default, firmware boots the raw image off an emulated xHCI USB drive) or pxe (QEMU boots the exported vmlinuz/initrd pair with -kernel/-initrd/-append). Everything after the install is shared. test-installer-boot-usb and test-installer-boot-pxe are the named entry points, so the direct-kernel path the previous revision dropped is exercised again rather than merely existence-checked by export-pxe. Document next to the -smbios flag that systemd-stub ignores io.systemd.stub.kernel-cmdline-extra under Secure Boot, so a secure-boot OVMF build boots interactive and hangs until the install timeout, and point at pxe mode as the way to test unattended installs on such firmware. Restrict the interactive /dev/tty0 redirect to boots where the kernel actually registered tty0 as a console. A writable VT device exists on serial-only bare metal too, so the -w test alone sent the whole interactive install to a display nobody was watching. Correct the ci-tooling sentence that still claimed the uploaded PXE artifacts feed test-installer-artifact. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Justfile | 98 ++++++++++++++++++----- docs/skills/ci-tooling.md | 2 +- docs/skills/ddi-installer-build.md | 16 +++- elements/oci/bluefin-server-installer.bst | 12 ++- tests/unit/test_installer_contract.py | 27 ++++++- 5 files changed, 124 insertions(+), 31 deletions(-) diff --git a/Justfile b/Justfile index 2cef7a31..47093fa5 100644 --- a/Justfile +++ b/Justfile @@ -222,23 +222,46 @@ show-me-the-future: just export-installer just test-installer-artifact +# INSTALLER_BOOT_MODE selects how the installer itself is started: +# usb (default) — firmware (OVMF) boots the raw image off an emulated xHCI USB +# drive, the bare-metal USB install path. +# pxe — QEMU boots the exported PXE vmlinuz/initrd pair directly with +# -kernel/-initrd/-append, the network install path. +# Everything after the install (target partition check, booting the installed +# system, kiosk readiness probe) is identical for both modes. # Install and reboot already-exported server artifacts in QEMU. [group('test')] test-installer-artifact: #!/usr/bin/env bash set -euo pipefail + BOOT_MODE="${INSTALLER_BOOT_MODE:-usb}" + case "${BOOT_MODE}" in + usb|pxe) ;; + *) echo "ERROR: INSTALLER_BOOT_MODE must be 'usb' or 'pxe', got '${BOOT_MODE}'." >&2; exit 1 ;; + esac + CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}" mkdir -p "$CACHE_DIR" WORKDIR="$(mktemp -d "${CACHE_DIR}/bluefin-show-future.XXXXXX")" trap 'rm -rf "$WORKDIR"' EXIT - # Only the raw installer image is needed: this recipe boots it through OVMF as - # a USB drive rather than via QEMU -kernel/-initrd, so the PXE vmlinuz/initrd - # are not consumed here. Copying them would make the test fail on hosts that - # have the installer image but no PXE artifacts. `just export-pxe` is where a - # missing PXE pair is caught. + # The raw installer image is always needed; usb mode boots it through firmware + # so it consumes nothing else. The PXE vmlinuz/initrd pair is only copied in pxe + # mode, because copying it unconditionally would fail the usb test on hosts that + # have the installer image but no PXE artifacts. cp dist/bluefin-server-installer-*.raw.zst "$WORKDIR/installer.raw.zst" + if [ "${BOOT_MODE}" = "pxe" ]; then + PXE_KERNEL=$(find dist/ -maxdepth 1 -type f -name 'bluefin-server-pxe-vmlinuz-*' | head -n1) + PXE_INITRD=$(find dist/ -maxdepth 1 -type f -name 'bluefin-server-pxe-initrd-*.cpio.gz' | head -n1) + if [ -z "${PXE_KERNEL}" ] || [ -z "${PXE_INITRD}" ]; then + echo "ERROR: INSTALLER_BOOT_MODE=pxe needs an exported PXE kernel and initrd in dist/." >&2 + echo "Please run: just build-installer && just export-pxe" >&2 + exit 1 + fi + cp "${PXE_KERNEL}" "$WORKDIR/installer.vmlinuz" + cp "${PXE_INITRD}" "$WORKDIR/installer.initrd" + fi zstd -d "$WORKDIR/installer.raw.zst" -o "$WORKDIR/installer.raw" TARGET_SIZE="${SHOW_ME_THE_FUTURE_DISK_SIZE:-16G}" truncate -s "${TARGET_SIZE}" "$WORKDIR/target.raw" @@ -289,24 +312,49 @@ test-installer-artifact: SMP_CPUS="${SHOW_ME_THE_FUTURE_SMP:-$(nproc)}" MEM_SIZE="${SHOW_ME_THE_FUTURE_MEM:-8192}" - echo "==> Booting installer media via OVMF over emulated xHCI USB in QEMU..." + echo "==> Booting installer media in QEMU (mode: ${BOOT_MODE})..." # ponytail: we want QEMU to exit cleanly after install. Since QEMU's -no-reboot # suspends/halts on reboot signals, we override systemd-sysinstall.service SuccessAction/FailureAction # to poweroff. When the installer triggers poweroff, QEMU terminates, and we boot into the newly installed OS. INSTALLER_TIMEOUT="${SHOW_ME_THE_FUTURE_INSTALL_TIMEOUT:-600}" + INSTALL_ARGS=( + -enable-kvm + -m "${MEM_SIZE}" + -cpu host + -smp "${SMP_CPUS}" + -drive if=pflash,format=raw,readonly=on,file="$OVMF_CODE" + -drive if=pflash,format=raw,file="$WORKDIR/ovmf-vars.fd" + ) + if [ "${BOOT_MODE}" = "usb" ]; then + # Firmware boots the image's own bootloader, so the unattended flag has to + # reach the UKI through systemd-stub rather than QEMU's -append. + # + # NOTE: systemd-stub deliberately ignores io.systemd.stub.kernel-cmdline-extra + # when Secure Boot is enabled, because the SMBIOS string is not covered by the + # signature. Point $OVMF_CODE at a secure-boot firmware build and this run + # boots interactive instead of unattended, then sits there until + # SHOW_ME_THE_FUTURE_INSTALL_TIMEOUT expires with a misleading "install did + # not finish" failure. Use INSTALLER_BOOT_MODE=pxe (-append is always honoured) + # to exercise unattended installs under Secure Boot firmware. + INSTALL_ARGS+=( + -device qemu-xhci,id=xhci + -drive file="$WORKDIR/installer.raw",format=raw,if=none,id=installer-disk,readonly=on + -device usb-storage,bus=xhci.0,drive=installer-disk,bootindex=1 + -drive file="$WORKDIR/target.raw",format=raw,if=none,id=target-disk + -device virtio-blk-pci,drive=target-disk,bootindex=2 + -smbios "type=11,value=io.systemd.stub.kernel-cmdline-extra=console=tty0 console=ttyS0,,115200 rw unattended" + ) + else + INSTALL_ARGS+=( + -drive file="$WORKDIR/installer.raw",format=raw,if=virtio,readonly=on + -drive file="$WORKDIR/target.raw",format=raw,if=virtio + -kernel "$WORKDIR/installer.vmlinuz" + -initrd "$WORKDIR/installer.initrd" + -append "systemd.unit=system-install.target console=tty0 console=ttyS0,115200 rw unattended" + ) + fi timeout "${INSTALLER_TIMEOUT}" qemu-system-x86_64 \ - -enable-kvm \ - -m "${MEM_SIZE}" \ - -cpu host \ - -smp "${SMP_CPUS}" \ - -drive if=pflash,format=raw,readonly=on,file="$OVMF_CODE" \ - -drive if=pflash,format=raw,file="$WORKDIR/ovmf-vars.fd" \ - -device qemu-xhci,id=xhci \ - -drive file="$WORKDIR/installer.raw",format=raw,if=none,id=installer-disk,readonly=on \ - -device usb-storage,bus=xhci.0,drive=installer-disk,bootindex=1 \ - -drive file="$WORKDIR/target.raw",format=raw,if=none,id=target-disk \ - -device virtio-blk-pci,drive=target-disk,bootindex=2 \ - -smbios "type=11,value=io.systemd.stub.kernel-cmdline-extra=console=tty0 console=ttyS0,,115200 rw unattended" \ + "${INSTALL_ARGS[@]}" \ -nographic \ -serial mon:stdio \ -no-reboot < /dev/null @@ -431,11 +479,19 @@ test-installer-artifact: sleep 2 done -# Boot the exported installer media via firmware (OVMF) attached as an xHCI USB drive. -# Delegates to test-installer-artifact, which runs the authoritative OVMF/xHCI installer test. +# This is the default mode of test-installer-artifact; the recipe exists so the USB +# boot path is discoverable by name. +# Boot the exported installer media via firmware (OVMF) as an xHCI USB drive. [group('test')] test-installer-boot-usb: - just test-installer-artifact + INSTALLER_BOOT_MODE=usb just test-installer-artifact + +# `just export-pxe` only checks that the two files exist, so this recipe is the only +# thing that proves they still boot and install. +# Boot the exported PXE kernel/initrd pair directly (QEMU -kernel/-initrd/-append). +[group('test')] +test-installer-boot-pxe: + INSTALLER_BOOT_MODE=pxe just test-installer-artifact # Interactively install and boot a persistent local KubeStellar kiosk VM. [group('test')] diff --git a/docs/skills/ci-tooling.md b/docs/skills/ci-tooling.md index c4deaf91..57346063 100644 --- a/docs/skills/ci-tooling.md +++ b/docs/skills/ci-tooling.md @@ -137,7 +137,7 @@ uploaded to a GitHub Release tagged `installer-v`. result as its own pull request against `main`. 3. **Full Compilation:** Builds the standalone DDI OS image, live installer, and k0s systemd-sysext on every pull request and push to `main`. -4. **Installer boot test:** Uploads the already-built installer and PXE artifacts and calls `projectbluefin/actions/.github/workflows/server-installer-test.yml`. The shared workflow prepares QEMU/KVM and runs this repository's `just test-installer-artifact`; Lima remains local-only. +4. **Installer boot test:** Uploads the already-built installer and PXE artifacts and calls `projectbluefin/actions/.github/workflows/server-installer-test.yml`. The shared workflow prepares QEMU/KVM and runs this repository's `just test-installer-artifact`, which defaults to the USB/firmware boot path and consumes only the raw installer image; the uploaded PXE pair is exercised by `just test-installer-boot-pxe` (`INSTALLER_BOOT_MODE=pxe`). Lima remains local-only. 5. **Version Derivation:** The release tag is derived with `just version`, which parses the pinned FSDK point release from `elements/freedesktop-sdk.bst`. 6. **Automated Publishing:** For pushes to `main` (including Renovate PR merges), diff --git a/docs/skills/ddi-installer-build.md b/docs/skills/ddi-installer-build.md index bb9d2a83..bd73be40 100644 --- a/docs/skills/ddi-installer-build.md +++ b/docs/skills/ddi-installer-build.md @@ -31,7 +31,8 @@ just export-sysext # export sysext artifacts to dist/sysext/ just flash-installer # write the installer image to a USB device just show-me-the-future # end-to-end QEMU installer smoke test just test-installer-artifact # test already-exported artifacts in QEMU without rebuilding -just test-installer-boot-usb # alias for test-installer-artifact, named for the USB boot path +just test-installer-boot-usb # test-installer-artifact in USB/firmware boot mode +just test-installer-boot-pxe # test-installer-artifact in PXE -kernel/-initrd boot mode just tags # show FSDK-derived version tags ``` @@ -39,8 +40,17 @@ just tags # show FSDK-derived version tags firmware as an emulated xHCI USB drive (`-device qemu-xhci` plus `-device usb-storage`), with the target disk on virtio-blk. This is the bare-metal USB install path: firmware picks the bootloader off the image itself rather than QEMU injecting a kernel through -`-kernel`/`-initrd`. `just test-installer-boot-usb` is an alias for the same recipe, -provided so the USB boot path is discoverable by name. +`-kernel`/`-initrd`. The boot method is selected by `INSTALLER_BOOT_MODE` (`usb`, the +default, or `pxe`); everything after the install is identical for both. `just +test-installer-boot-usb` and `just test-installer-boot-pxe` are the named entry points. + +Use `pxe` mode to exercise the exported `bluefin-server-pxe-vmlinuz-*` / +`bluefin-server-pxe-initrd-*.cpio.gz` pair, which is booted with `-kernel`/`-initrd` +and an explicit `-append` command line. `just export-pxe` only asserts that those two +files exist, so the PXE recipe is what proves they still boot and install. PXE mode is +also the way to test an unattended install under Secure Boot firmware: in USB mode the +unattended flag travels via `-smbios type=11 io.systemd.stub.kernel-cmdline-extra`, and +systemd-stub ignores that credential when Secure Boot is enabled. The recipe prefers a real `OVMF_VARS` template but falls back to a blank variable store sized to `OVMF_CODE` on hosts that ship CODE only, so a missing template is a warning diff --git a/elements/oci/bluefin-server-installer.bst b/elements/oci/bluefin-server-installer.bst index 790b7bc9..40e90bed 100644 --- a/elements/oci/bluefin-server-installer.bst +++ b/elements/oci/bluefin-server-installer.bst @@ -191,9 +191,15 @@ config: # the last console= argument, which is ttyS0, so an interactive bare-metal # install would otherwise print to serial rather than the attached display. # Keep the interactive installer on the attached display by redirecting this - # script's own output to /dev/tty0, falling back to journal+console when there - # is no local VT (headless serial-only installs). - if [[ " ${CMDLINE} " != *" unattended "* ]] && [ -w /dev/tty0 ]; then + # script's own output to /dev/tty0 — but only when the kernel actually drives + # tty0 as a console. On serial-only machines the VT device still exists and is + # writable, so a -w test alone would send the whole install to a display nobody + # is watching; /sys/class/tty/console/active lists the consoles the kernel + # really registered, and omits tty0 when the boot was serial-only. If that file + # is unreadable the redirect is skipped and output stays on journal+console. + if [[ " ${CMDLINE} " != *" unattended "* ]] \ + && [ -w /dev/tty0 ] \ + && grep -qw tty0 /sys/class/tty/console/active 2>/dev/null; then exec > /dev/tty0 2>&1 fi diff --git a/tests/unit/test_installer_contract.py b/tests/unit/test_installer_contract.py index e599bc36..e1f9eeab 100644 --- a/tests/unit/test_installer_contract.py +++ b/tests/unit/test_installer_contract.py @@ -56,6 +56,11 @@ def test_installer_runtime_and_boot_contracts() -> None: assert "-device virtio-blk-pci,drive=target-disk,bootindex=2" in justfile assert 'sfdisk --json "$WORKDIR/target.raw"' in justfile assert "bluefin-server-root-a" in justfile + # The PXE pair is still exported, so the direct-kernel boot path stays covered. + assert ( + '-append "systemd.unit=system-install.target ' + 'console=tty0 console=ttyS0,115200 rw unattended"' + ) in justfile def test_installer_wrapper_reads_kernel_command_line_without_cat() -> None: @@ -143,9 +148,13 @@ def test_interactive_installer_uses_local_virtual_console() -> None: assert "StandardOutput=journal+console" in installer_element assert "StandardError=journal+console" in installer_element # journal+console follows the last console= argument (ttyS0), so the wrapper has - # to put interactive runs back on the attached display itself. + # to put interactive runs back on the attached display itself — but only when the + # kernel actually registered tty0 as a console, otherwise serial-only machines + # lose the install output to a VT nobody is watching. assert ( - 'if [[ " ${CMDLINE} " != *" unattended "* ]] && [ -w /dev/tty0 ]; then\n' + 'if [[ " ${CMDLINE} " != *" unattended "* ]] \\\n' + " && [ -w /dev/tty0 ] \\\n" + " && grep -qw tty0 /sys/class/tty/console/active 2>/dev/null; then\n" " exec > /dev/tty0 2>&1" ) in installer_element @@ -225,6 +234,18 @@ def test_installer_smoke_probes_the_kiosk_over_tls_from_inside_the_guest() -> No def test_test_installer_boot_usb_contract() -> None: justfile = JUSTFILE.read_text(encoding="utf-8") start = justfile.index("test-installer-boot-usb:") + end = justfile.index("test-installer-boot-pxe:", start) + recipe = justfile[start:end] + assert "INSTALLER_BOOT_MODE=usb just test-installer-artifact" in recipe + + +def test_test_installer_boot_pxe_recipe_exercises_direct_kernel_boot() -> None: + justfile = JUSTFILE.read_text(encoding="utf-8") + start = justfile.index("test-installer-boot-pxe:") end = justfile.index("install-vm:", start) recipe = justfile[start:end] - assert "just test-installer-artifact" in recipe + assert "INSTALLER_BOOT_MODE=pxe just test-installer-artifact" in recipe + assert '-kernel "$WORKDIR/installer.vmlinuz"' in justfile + assert '-initrd "$WORKDIR/installer.initrd"' in justfile + assert "bluefin-server-pxe-vmlinuz-*" in justfile + assert "bluefin-server-pxe-initrd-*.cpio.gz" in justfile