`scripts/runtime-dead`, `scripts/qemu-build`. Four defects, each of which alone made the instrument useless, and none of which it reported. **1. It exited after its first banner line, with status 0.** The stale-VM guard is `stale="$(ps … | grep '[q]emu-system-x86_64' | awk …)"`, and the healthy case is grep finding nothing — exit 1, which under `set -o pipefail` is the whole pipeline's status, which `set -e` turns into an abort. So the script ran past this guard only when the condition it refuses on was already true, and returned success without doing anything every other time. Same shape in the loop that waits for QEMU's pid. Both now end in `|| true`. **2. The guest-wait loop finished in under a second.** It polls `ssh -o ConnectTimeout=4 macos-vm true` 120 times with no delay between attempts. `ConnectTimeout` bounds a connection being *accepted slowly*; QEMU's hostfwd **refuses** instantly until the guest is listening, so all 120 attempts returned immediately and the script declared a guest that had another twenty seconds to go. Added the `sleep 2`. **3. The profile it merged was a build script's, not QEMU's.** `LLVM_PROFILE_FILE` was a single fixed path exported before the build — and `-C instrument-coverage` instruments the crate's build scripts too, which run during that build and write there on exit. That is why the one run that got far enough reported **3010 of 3010 functions never ran** on a boot whose own log says it presented frames. `%p` per process now, the build is run explicitly so its raw files can be swept before the boot, and every remaining raw file is merged. **4. The profile writer was never linked in.** `hw/display/meson.build` reads `REIMS_VGPU_COVERAGE` with `run_command` and turns it into a `--whole-archive` link argument — a **configure-time** decision. `qemu-build.sh` skips configure when `build/build.ninja` exists and its stamp matches, and the stamp carried only target and backend. So a tree configured once without coverage stayed without it forever: the staticlib carried `__llvm_prf_*` counters and nothing that writes them, and QEMU's exit produced no profile at all. The stamp now carries `cov=$REIMS_VGPU_COVERAGE`, so turning coverage on or off reconfigures, in both directions. The path rather than a flag, because a different clang major is a different archive. Verified end to end on this host: after the fixes, a driven run (`--seconds 25 --app Safari`, 22 s of real compositing) merges 5 raw profiles and reports **1203 of 3010 functions never ran**, with plausible per-file coverage (`caps/api_floor.rs` 100 %, `pools/teardown.rs` 30 %, `pools/images_and_registry.rs` 44 %). Before the fixes the same command printed one line and exited. No product code touched; nothing in `crates/` changes and no test count moves.
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:
- Populates the submodule if needed (
git submodule update --init vendor/qemu). - Resolves
--target(orQEMU_TARGET) and--backend metal|vulkan(orREIMS_VGPU_BACKEND). - Builds
crates/reims-vgpuas 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).
- aarch64: expects
CONFIG_VMAPPLE, HVF/Cocoa configure, verifies-M vmapple. - 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.