Skip to content

[Enhancement] amd64 QEMU functional-test path + auto-install host prereqs (#434) - #449

Open
mcdope wants to merge 3 commits into
masterfrom
issue-434
Open

[Enhancement] amd64 QEMU functional-test path + auto-install host prereqs (#434)#449
mcdope wants to merge 3 commits into
masterfrom
issue-434

Conversation

@mcdope

@mcdope mcdope commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Adds an amd64 (x86_64) QEMU full-system functional-test path, mirroring the existing
arm64/armhf golden-image strategy, plus auto-installation of host QEMU prerequisites
so downstream packagers can reproduce the whole functional suite locally with no CI setup.

Closes #434.

What changed

  • tests/can-actually-be-used/run-tests-in-qemu.sh
    • New amd64) case: qemu-system-x86_64 on -M q35 -cpu max -smp 2 -m 2048,
      default SeaBIOS (no -bios/OVMF), virtio-blk-pci / virtio-net-pci,
      PROVISION_VERSION=1.
    • Pre-flight now auto-installs the per-arch host packages (HOST_PKGS) via
      apt-get when the emulator / qemu-img / cloud-localds is missing, with a clear
      manual fallback for non-apt hosts (e.g. NixOS). Header/usage/message updates; removed
      stale ppc64el/riscv64 install hints (those QEMU functional tests were dropped earlier).
  • Makefilebuild-debian-amd64 alias (native build already emits the amd64 .deb)
    and an amd64 step in provision-qemu-images.
  • .github/workflows/package-with-docker-on-own-server.yml — new FunctionalTest-amd64
    job, serialized after FunctionalTest-armhf on the shared runner.

Why this approach

  • Reuse, not reinvent: the arm64/armhf golden-image + run-tests-in-qemu.sh pattern
    already exists and is proven; amd64 slots into it as another case block. The big win
    for packagers (esp. NixOS, read-only Nix store) is that dummy_hcd is built inside
    the VM, so the host never needs that out-of-tree kernel module.
  • SeaBIOS over OVMF: SeaBIOS + q35 boots the Ubuntu amd64 cloud image reliably under
    TCG (the runner has no KVM) and needs no extra firmware package. Verified end-to-end
    (see below), so the added ovmf dependency the issue suggested was avoided.
  • Serialized, runs on PRs: needs: [Debian, FunctionalTest-armhf] keeps only one
    full-system QEMU VM on the single shared runner at a time. if: ${{ !cancelled() }}
    makes it run on PRs too (on push it waits for armhf; on a PR armhf is skipped and this
    still runs after Debian).
  • Auto-install prereqs: the pre-flight previously only checked and printed hints,
    so a newcomer hit an error and had to hand-install. It now installs them (apt hosts) or
    degrades gracefully (NixOS provides qemu via nix-shell) — the "single command"
    reproducibility the issue asks for.

Note on the issue text vs. reality

The issue was written against an idealized state that never landed: it referenced a
4-arch QEMU base and a build-and-test-cross-arch.yml file. In the actual tree only
arm64/armhf QEMU functional tests exist (ppc64el dropped entirely, riscv64 packaging-only),
the jobs live in package-with-docker-on-own-server.yml, and each case sets its own
PROVISION_VERSION as the first line (the CI golden-image check greps -A1 '<arch>)' for
it). This PR follows the real pattern.

Testing & proof of execution

Provisioned and ran on the project CI runner (Ubuntu 22.04, TCG / no KVM):

  1. Provisioning (run-tests-in-qemu.sh --provision amd64, the make provision-qemu-images
    path) built jammy-amd64-provisioned-v1.qcow2 (valid qcow2, 10.2 GiB virtual / 1.39 GiB
    on disk). The dummy_hcd DKMS module built and installed cleanly inside the VM.
  2. Full functional suite in the amd64 QEMU VM: FUNCTEST_EXIT=0, all 50 checks
    PASSED!
    — every filesystem iteration (vfat / ext4 / exfat), deny_remote/XRDP
    denial + logging, OTP pad load/match/expiry, and the pamusb-agent plug/unplug trigger
    ("Lock event found / Unlock event found").
  3. make test — C (cmocka), Python (pytest) and shell suites pass, except 2 evdev
    unit tests
    (test_safe_no_helper_virtual_device_detected,
    test_safe_no_helper_all_eacces_inconclusive) that fail identically on master under
    the local GCC-13 toolchain (a --wrap/LTO harness quirk). This PR makes no src/
    changes
    , so it neither causes nor addresses them; the authoritative run is the CI
    Gate job on ubuntu-22.04/GCC-11, which is green.

Because FunctionalTest-amd64 now runs on PRs, this PR's own CI run will produce a
linkable green amd64 functional-test job (the runner's golden image already exists).

Integration test

This change is the integration test — it extends the functional/QEMU suite to amd64.
No new config options; manpages unaffected.

Security

CI/test-harness only — no security-relevant src/ code touched. The new auto-install runs
sudo apt-get install on the user's host only when the QEMU tooling is missing and
apt-get exists, printing exactly what it installs and falling back to a manual message
otherwise (a dev/test-harness convenience, not production/PAM code).


🤖 This PR was generated with the assistance of Claude (Claude Code). A human reviewed
and takes responsibility for every line.

I have read the rules

mcdope and others added 2 commits July 3, 2026 21:23
Adds an x86_64/amd64 full-system QEMU test path mirroring the existing
arm64/armhf golden-image strategy, so downstream packagers (notably NixOS,
which has a read-only Nix store) can reproduce the full functional suite
locally with `make provision-qemu-images` + run-tests-in-qemu.sh.

- run-tests-in-qemu.sh: new amd64) case using qemu-system-x86_64 on q35
  with default SeaBIOS (no OVMF dependency) and virtio-*-pci devices;
  header/message updates; drop stale ppc64el/riscv64 install hints.
- Makefile: build-debian-amd64 alias (native build already emits the
  amd64 .deb) and amd64 provisioning step in provision-qemu-images.
- CI: FunctionalTest-amd64 job, serialized after FunctionalTest-armhf on
  the shared runner; runs on PRs too via !cancelled().

SeaBIOS was chosen over OVMF because it boots the Ubuntu amd64 cloud image
on q35 reliably under TCG (no KVM on the runner) without an extra firmware
package.

Refs #434

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
The pre-flight check previously only verified the QEMU binary and printed
manual install hints, forcing newcomers to read the error and hand-install
packages before the "single command" workflow worked.

Now the pre-flight installs the missing host prerequisites automatically on
Debian/Ubuntu hosts (per-arch HOST_PKGS via apt-get, using sudo only when
not already root), then falls back to a clear manual message only if that
fails. Hosts without apt (e.g. NixOS, where qemu + cloud-image-utils are
provided through the package manager / nix-shell) already have the binaries
on PATH, so nothing is attempted there.

Also checks qemu-img and cloud-localds, not just the system emulator, since
provisioning needs all three.

Refs #434

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@mcdope mcdope added the enhancement New feature or request label Jul 3, 2026
@mcdope mcdope self-assigned this Jul 3, 2026
@mcdope
mcdope marked this pull request as ready for review July 3, 2026 21:25
The single FunctionalTest-amd64 job needed [Debian, FunctionalTest-armhf]
for push serialization, but on pull_request that transitively blocked it
behind the entire (skipped) arm64/armhf functional chain — which itself
waits on the slow cross-arch TCG builds — so amd64 feedback on a PR was
delayed by unrelated jobs.

GitHub Actions `needs` is static (cannot vary by event), so split into two
event-guarded variants; exactly one runs per event:

- FunctionalTest-amd64      (push): needs [Debian, FunctionalTest-armhf] —
  keeps serialization so only one full-system QEMU VM runs at a time on the
  shared runner.
- FunctionalTest-amd64-pr   (pull_request): needs [Debian] — the armhf
  functional job is push-only (skipped on PRs), so there is no concurrent
  QEMU to serialize against; runs as soon as the native Debian build is done.

Steps are duplicated because GitHub Actions has no YAML anchors, matching
the copy-paste job style already used throughout this workflow.

Refs #434

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Run x86_64 functional tests inside QEMU VM (reproducible environment for NixOS/downstream packagers)

1 participant