Files
reims-vgpu/scripts/qemu-build
Anees IqbalandClaude Opus 5 b4429dd022 config: the environment is how a switch arrives, not what a switch is
`reims-vgpu-env` becomes `reims-vgpu-config`, re-exported as `crate::config`,
and every call site moves with it.

The rename is the point. What the crate owns is a declaration, a total type for
each value, membership in `ALL`, and the rule that an override may only *narrow*
what this device does and may never widen it. None of that is a fact about
environment variables — the environment is the delivery mechanism, and naming
the crate after it invites a second mechanism to arrive as a second place the
set is written down. A second reader in front of the same declarations is the
shape that stays correct.

Nothing about the parse, the switches or the narrowing rule changes. 161 call
sites, the observe crate's draw-log read, the feature matrix's crate list and
the QEMU build script's comment all move together, and the workspace still
builds on every arm.

reims-vgpu-config 15 tests, reims-vgpu 2158 — both unchanged. Feature matrix all
arms warnings=0; clippy and rustfmt clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-01 10:29:35 +03:00
..
2026-07-26 15:24:53 +03:00

qemu-build.sh

Builds the vendored vendor/qemu submodule into vendor/qemu/build/qemu-system-<arch>, linking the thin device shim(s) to crates/reims-vgpu.

Target Typical host Output Pathway
aarch64 Darwin / Apple Silicon qemu-system-aarch64 arm64 macOS guest on macOS host (vm/boot-arm64.sh)
x86_64 Linux qemu-system-x86_64 x86 macOS guest on Linux host (vm/boot-x86.sh)
Backend Where it runs Role
metal Apple Silicon Metal-direct encode for the arm64 macOS guest
vulkan Linux native ICD or Apple Silicon MoltenVK Vulkan encode + metal2vulkan for x86/Linux and arm64/MoltenVK pathways

Defaults: target by host OS (aarch64 on Darwin, x86_64 on Linux); backend defaults by host OS (metal on Darwin, vulkan elsewhere) — override for the pathway you are on.

What it does

vendor/qemu already carries the project patches — this script does not clone or patch, it builds. Steps:

  1. Populates the submodule if needed (git submodule update --init vendor/qemu).
  2. Resolves --target (or QEMU_TARGET) and --backend metal|vulkan (or REIMS_VGPU_BACKEND).
  3. Builds crates/reims-vgpu as a staticlib and links it into the device shim:
    • Apple + metal: real MTL frameworks + encode path.
    • Non-Apple + metal: rejected; Metal is Apple-only.
    • vulkan: ash-based in-crate engine (native Vulkan on Linux, MoltenVK on macOS).
  4. aarch64: expects CONFIG_VMAPPLE, HVF/Cocoa configure, verifies -M vmapple.
  5. x86_64: x86_64-softmmu, HVF/Cocoa off; lists PCI/sysbus device help as applicable.

Re-runs are idempotent (skips configure when the target/backend stamp matches). Switching target or backend forces reconfigure. Patch record: vendor/qemu-patches/.

Run

# Explicit pathway builds
scripts/qemu-build/qemu-build.sh --target aarch64 --backend metal
scripts/qemu-build/qemu-build.sh --target aarch64 --backend vulkan
REIMS_VGPU_BACKEND=vulkan scripts/qemu-build/qemu-build.sh --target x86_64

# Point the matching boot script at the binary
QEMU_BIN=$PWD/vendor/qemu/build/qemu-system-aarch64 vm/boot-arm64.sh --device reims-vgpu-mmio --testing
QEMU_BIN=$PWD/vendor/qemu/build/qemu-system-x86_64 vm/boot-x86.sh --device reims-vgpu-pci --testing

Requirements

  • Both: cargo (crates/reims-vgpu), ninja, meson, pkg-config, glib, pixman.
  • aarch64 + metal: macOS, Xcode CLT, HVF/Cocoa.
  • aarch64 + vulkan: macOS, Xcode CLT, HVF/Cocoa, Vulkan loader, and MoltenVK ICD.
  • x86_64: Linux QEMU build deps; KVM for boots.