Component: `crates/reims-vgpu`, Vulkan backend and the runtime rails that feed it. Pathway: x86 macOS / Linux Vulkan, and the MoltenVK arm by construction — neither booted for this commit. ## What runs now - `caps::host_pointer` — the capability rungs for `VK_EXT_external_memory_host`, in the same shape the dma-buf rungs had and for the same reason: a bug report has to say which check refused. The granularity travels with the rung rather than beside it, because a rung with no granularity is not actionable and a granularity from a device that declined the handle type is a number nothing may act on. `minImportedHostPointerAlignment` is queried, never assumed: MoltenVK reports Apple's page size and a Linux driver may report more. - `runtime::guest_ram_map` — the process's imports, built once from ABI v17's spans on the first guest-memory reference of a boot, and the only place a GPA becomes a bindable reference. The backend measures the granularity and the runtime holds the `HostOps`; neither side has both, so the granularity is latched by the backend and the spans fetched here. - `engine::host_ram` — the import site. One `VkDeviceMemory` and one `VkBuffer` per RAMBlock, held for the device's life, in a map with no eviction policy and no capacity. That is the prize: the dma-buf rail needed an LRU bounded by pinned bytes because `UDMABUF_CREATE_LIST` walked every page and pinned it, and here the expensive step happens once and the cheap step is a range check. - Memory-type selection goes through `caps::memory_topology::select_memory_type` rather than ranking a second time, so the two cannot diverge on the first host where the ranking mattered. ## What was deleted, and why in this commit `runtime::guest_dmabuf`, `engine::dmabuf` and `caps::external_memory` are gone, along with `GuestDmaBuf`, `GuestPageWindow`, the engine's import cache, the `DeferredHandle::DmaBufImport` graveyard arm, `external_memory_fd`, and the `export_available()` pre-gate in `mapping_write`. The plan sequenced this as its own phase, but rewiring the consumers left the dma-buf types with no producer: keeping them would have been the two-spellings-of-one-rail divergence the plan warns about, in the same tree. The C shim's `dmabuf_for_pages`, its ABI codes and `reims-vgpu-dmabuf.c` are still present and now unused; they go next, with the `AGENTS.md` rewrite. `REIMS_VGPU_DMABUF` becomes `REIMS_VGPU_GUEST_IMPORT`, still narrow-only. Two decline variants became unrepresentable rather than untested: `BufferImportDecline::WindowTooSmall` and its sampled twin. The range now comes from a `GuestRef` whose bound is checked where it is built, so there is no longer a way for a bind to name bytes past what was resolved. ## What this commit does not do A page list that is not one GPA-contiguous stretch is refused by name (`guest_ram_map_scattered`) and gathered on the CPU. That is a property of the *bind* and not of the import — the pages are all inside one RAMBlock and each is nameable — but a `VkBuffer` range is one offset and one length, and no consumer takes several yet. The refusal is counted so how often it costs anything is measurable on a driven boot, which is what should decide whether widening the bind sites is worth doing. Tests: 1641 lib + all integration green, ignored counts unchanged (the wire-layout fixtures are absent on this checkout as usual). New: 8 rung tests in `caps::host_pointer`, 10 in `runtime::guest_ram_map` (per-span resolution on a machine with a PCI hole, the host asked exactly once, each refusal keeping its own name, a reset rebuilding against fresh identities, and the expected refusal landing on the off channel rather than the fail one), 3 in `engine::host_ram`, 1 more on the `vk_caps` line. Clippy `-D warnings` clean on all three arms (native Vulkan, `--target x86_64-unknown-linux-gnu`, `--target aarch64-apple-darwin --features backend-metal`). `scripts/feature-matrix`: all three arms pass, warnings=0. Not verified: no live boot on either pathway — the import has never run against a real driver, so `host_pointer_import=supported` and the bind path are untested against hardware. The `backend-metal` test arm was not run (Linux host). The Metal-direct arm still has no import at all; that is the next phase. Co-Authored-By: Claude <noreply@anthropic.com>
reims-vgpu
Alpha. This project is early and under active development. The QEMU device ABI, boot scripts, crate layout, backend behavior, and supported host/guest pathways may change without a stable compatibility guarantee. Treat it as research-quality: useful for experimentation and bring-up, not a frozen virtualization product.
reims-vgpu is an experimental virtual GPU for macOS guests. It aims to let macOS running inside a VM use accelerated graphics instead of a basic framebuffer, while keeping the guest operating system unchanged.
macOS already includes a paravirtual GPU driver named AppleParavirtGPU.kext.
reims-vgpu provides the QEMU device that driver attaches to, then decodes the guest's GPU command
stream on the host and executes it through Metal (TODO) or Vulkan, with Vulkan translation handled
by metal2vulkan. There is no custom macOS kext and
no guest driver to install.
Contributions are welcome. I am especially interested in collaborating with developers who want to work on correctness, visual glitches, synchronization bugs, command-stream decoding, Metal/Vulkan translation, and making more host/guest combinations reliable.
arm64 macOS 13 Ventura guest on an Apple Silicon host.
x86_64 macOS 13 Ventura guest on a Linux host.
Three pathways
crates/reims-vgpu targets the following host/guest/backend combinations. Agents pick the pathway
their unit of work is on.
| Pathway | Host | Guest | Device attach | Backend | Boot |
|---|---|---|---|---|---|
| x86 macOS / Linux Vulkan | Linux x86_64 (KVM) | x86_64 macOS Metal guest | PCI reims-vgpu-pci |
host Vulkan via metal2vulkan |
vm/boot-x86.sh |
| arm64 macOS / macOS Metal | Apple Silicon macOS (HVF) | arm64 macOS Metal guest (vmapple) |
sysbus MMIO reims-vgpu-mmio |
host Metal | vm/boot-arm64.sh |
| arm64 macOS / macOS Vulkan | Apple Silicon macOS (HVF) | arm64 macOS Metal guest (vmapple) |
sysbus MMIO reims-vgpu-mmio |
host Vulkan via metal2vulkan through MoltenVK |
vm/boot-arm64.sh |
- QEMU device shims:
vendor/qemutrackssteelbrain/qemu-reims-vgpu@host-reims-vgpu-vmapple(thin C — QOM/MMIO/IRQ/console/HostOps only) - Product logic:
crates/reims-vgpu(decode + device model + Metal/Vulkan backends) - Wire layouts:
crates/reims-vgpu-wire(derived serializer views/parsers; decode uses these as the layout authority for covered records) - Vulkan translator dependency: public
steelbrain/metal2vulkanGit crate. On macOS, the Vulkan host backend runs through MoltenVK. - VM lifecycle:
vm/(snapshot-revert; arm and x86 guest boot scripts)
Getting started
This tree ships boot scripts and the device, not a ready-made macOS disk image. Guest disks,
firmware vars, and OpenCore blobs are private/gitignored under vm/. Pick a pathway, provision a
guest once, freeze a golden snapshot, then use the snapshot-revert boots for day-to-day work.
macOS 13 Ventura is the recommended guest release for bring-up.
x86_64 guest on Linux (KVM)
-
Host prep. You need KVM (
/dev/kvm), a working NVIDIA (or other) Vulkan stack for the product backend, and build deps for the in-tree QEMU (scripts/qemu-build/qemu-build.sh --target x86_64 --backend vulkan). KVM must ignore unhandled MSRs or macOS will not boot — e.g. a modprobe conf withoptions kvm ignore_msrs=1(reboot or reload the module after). -
Generate OpenCore, OVMF, and a guest disk with OSX-KVM. macOS 13 is recommended.Follow that project’s docs to fetch recovery media, build OpenCore, and install macOS under QEMU+KVM. The point of this step is only to produce a working, post-Setup-Assistant guest plus the usual OpenCore/OVMF pieces — not to stay on OSX-KVM’s long-term launcher.
-
Drop the artifacts where this repo expects them (paths are the defaults in
vm/boot-x86.sh; override with env if you prefer):Artifact Default location Guest system disk vm/disks/macos.imgOpenCore boot disk vm/disks/OpenCore.qcow2OVMF code vm/ovmf/OVMF_CODE_4M.fdOVMF vars template vm/ovmf/OVMF_VARS-1920x1080.fdFinish install in the guest: enable Remote Login, install your SSH key, turn off sleep/screensaver as you like. Host SSH is typically
localhost:2222→ guest:22(seevm/boot-x86.sh). -
Capture the first immutable snapshot. From a clean guest state (logged in, network/SSH known-good), shut down cleanly while booting in snapshot-capture mode:
vm/boot-x86.sh --snapshot --device vmware-svga # clean shutdown from inside the guest → new label under vm/disks/snapshots/ # and snapshots/current points at itEvery later boot clones
snapshots/current(COW when possible) and throws the clone away on exit, so wedges and hard kills never poison the golden image. -
Day-to-day boots.
# Console only (mainstream OSX-KVM-style VGA) while you debug the host stack vm/boot-x86.sh --testing --device vmware-svga # Product Reims VGPU device (needs in-tree QEMU + reims-vgpu Vulkan) REIMS_VGPU_BACKEND=vulkan scripts/qemu-build/qemu-build.sh --target x86_64 vm/boot-x86.sh --testing --device reims-vgpu-pci # Host-window screenshot on the Linux/Plasma host scripts/screenshot-when-kde-plasma-host/screenshot-when-kde-plasma-host.sh -o /tmp/screen.png
arm64 guest on Apple Silicon (HVF / vmapple)
Arm bring-up is in-tree: Virtualization.framework via Homebrew macosvm, then QEMU’s
vmapple machine under HVF. There is no OSX-KVM step.
-
Install
macosvm, and build the vendored QEMU:scripts/qemu-build/qemu-build.sh --target aarch64 --backend metal -
Provision a guest from a UniversalMac IPSW with the project helpers in
scripts/vmapple-provision/. The live bundle lives undervm/guest/(disk, aux,vm.json/ ECID). -
Configure the guest once: enable Remote Login, run
scripts/vmapple-guest-config/for no-sleep settings, and optionally enable auto-login by hand in System Settings. Capture a golden undervm/guest/snapshots/with the snapshot helpers (scripts/vmapple-snapshot/, orvm/boot-arm64.sh --snapshotonce the disk is ready). -
Boot:
vm/boot-arm64.sh --testing --device reims-vgpu-mmio # product vm/boot-arm64.sh --testing --device apple-gfx-mmio # Apple ParavirtualizedGraphics A/B scripts/screenshot-when-macos-host/screenshot-when-macos-host.sh /tmp/screen.pngOptional performance ceiling reference: the same guest under native VZ via
macosvm --gui.
After the first snapshot
- Prefer
--testingfor agent/measurement boots (time-bounded, always reverts). - Use
--interactivewhen you need an open-ended GUI session (still reverts unless you are in--snapshotcapture mode). - Never commit disks, IPSWs, or OpenCore/OVMF runtime under
vm/. - Device/backend work lives in
crates/reims-vgpu+ the thin shims invendor/qemu; rebuild QEMU after product changes before claiming a live boot result.
Environment overrides
Set on the boot command; every one is optional and every default is "let the device decide". The
full list, with the parse, is crates/reims-vgpu/src/env.rs. Each accepts 1/on/true/yes and
0/off/false/no, case-insensitively.
| Variable | Effect |
|---|---|
REIMS_VGPU_DMABUF=off |
Stop reaching guest pages through a dma-buf, even where the host can. Every guest-memory rail takes the copying path instead — which is what runs on any host without VK_EXT_external_memory_dma_buf, so this is how that half is exercised on a machine that has it. |
REIMS_VGPU_DRAW_LOG=on |
Verbose per-draw detail on top of the always-on failure log. |
An override can only narrow what the device does. There is no way to switch a rail on that the
host reported it cannot run: capability is measured from the device at startup, and asking a driver
for an extension it does not advertise fails device creation rather than degrading. REIMS_VGPU_DMABUF
has no on direction for that reason — on a host without the extension it is already off, and the
vk_caps line in /tmp/reims-vgpu-fail.log names which check said so.
Repo layout
AGENTS.md - repo operating guide for agents
crates/ - Rust crates (`reims-vgpu`, `reims-vgpu-wire`, `reims-vgpu-efi`)
scripts/ - host setup, VM lifecycle, screenshot, and diagnostic helpers
vendor/ - vendored QEMU submodule and patch record
vm/ - VM launch/configuration glue; images are private/untracked
crates/reims-vgpu-wire holds zero-copy views and parsers for the Apple
paravirtualized GPU serializer format, derived from Apple's own encoder rather
than inferred from captures. crates/reims-vgpu's runtime::decode uses those
exports for opcodes, record framing, and field layouts on wire-covered
families (encoder blit/compute/render binds and state, and the create records
above); decode remains the mapping layer into the device's Command / Kind
model and decline naming. Gaps without a wire export (FIFO, event opcodes,
unobserved compute residency, pipeline TLV) stay local to decode.
License
Licensed under the GNU Lesser General Public License v3.0 or later
(LGPL-3.0-or-later).
Metal, macOS are trademarks of Apple Inc. reims-vgpu is an independent project and is not affiliated with, sponsored by, or endorsed by Apple Inc.

