Experimental virtio-gpu display: msb display / msb run --display (macOS) - #1482
Draft
ya-luotao wants to merge 6 commits into
Draft
Experimental virtio-gpu display: msb display / msb run --display (macOS)#1482ya-luotao wants to merge 6 commits into
ya-luotao wants to merge 6 commits into
Conversation
…nout) Enable msb_krun's gpu feature and attach a virtio-gpu device when MSB_GPU=1 (2D, VIRGL_RENDERER_NO_VIRGL) or MSB_GPU=venus (adds Venus). One scanout, sized by MSB_GPU_DISPLAY (default 1920x1080), via a gpu_display builder method that lives in a local msb_krun 0.1.32 patch (path override in the workspace Cargo.toml) until it is upstreamed. Verified on HVF/Apple Silicon: guest gets /dev/dri/card0 + renderD128, KMS enabled, connector Virtual-1 with EDID; modetest -s sets 1920x1080. Host-side 2D commands are rejected by virglrenderer without virgl, so scanout content does not reach the host yet. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A2DMienRTQjgR5CF3uQ2AZ
Use the local msb_krun_devices patch that runs the virtio-gpu on rutabaga's 2D component when virgl is off, so guest scanouts reach the host on macOS. MSB_GPU_DUMP=<dir> installs a display backend that keeps the latest frame of each scanout in <dir>/scanout<N>.raw for verification without a window. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A2DMienRTQjgR5CF3uQ2AZ
The sandbox serves virtio-gpu scanout frames through a memory-mapped file per scanout and a JSON-lines socket (display.sock next to agent.sock); the new `msb display <sandbox>` command (macOS: winit + softbuffer, run on the main thread before Tokio) maps the frames into a native window and sends keyboard and absolute-pointer events back, which reach the guest as two virtio-input devices. Sandbox cleanup now removes display.sock as well. Needs the local msb_krun (input_device builder), msb_krun_devices (2D-only gpu) and msb_krun_utils (macOS eventfd non-blocking flag) patches. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A2DMienRTQjgR5CF3uQ2AZ
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A2DMienRTQjgR5CF3uQ2AZ
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A2DMienRTQjgR5CF3uQ2AZ
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A2DMienRTQjgR5CF3uQ2AZ
|
Too many files changed for review (196 files, 100 file limit). Bypass the limit by tagging |
This was referenced Aug 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft: shows the whole path end to end, but it depends on three
msb_krunchanges that are not published yet (superradcompany/libkrun#116, #117, #118), vendored here underthird_party/with[patch.crates-io]. Once those land and 0.1.33 is out thethird_party/commit goes away. It also overlaps with #1194's--gpuplumbing: this branch gates the device with anMSB_GPUenvironment variable for now and should be rebased onto that option (SandboxRuntimeOptions.gpu) rather than keep its own switch.What it does
msb run --display …(ormsb display <sandbox>on a running one) opens the guest's virtio-gpu scanout in a native macOS window with keyboard and pointer. Demo: Omarchy (Hyprland + quickshell) on Arch Linux ARM in a microVM — https://github.com/ya-luotao/msb-omarchy.How
crates/runtime/lib/gpu_display/): akrun_displaybackend copies each presented frame into a 2-slot memory-mapped file per scanout under the sandbox runtime dir and announcesconfigure/frame{slot,seq,rect}/disableas JSON lines ondisplay.sock(next toagent.sock); the viewer's evdev-style input comes back on the same socket and is queued into two virtio-input devices (keyboard; absolute pointer shaped like QEMU's tablet).present_framenever waits for a viewer (200 ms write timeout, then the viewer is dropped), so a stalled window cannot stall the guest's FLUSH.crates/cli/lib/commands/display.rs, macOS-only depswinit+softbuffer): runs the event loop on the main thread before Tokio starts, likemsb sandbox; BGRX frames are a straight copy into softbuffer's 0RGB buffer. The sandbox process cannot own the window becauseVm::enter()takes its main thread.MSB_GPU_DUMP=<dir>installs a frame-dump backend instead (debugging without a window);MSB_GPU_DISPLAY=WxHsizes the scanout (default 1920x1080).ipc.rs) also removesdisplay.sock.Findings worth knowing
msb_krun'sinputfeature never delivered an event on macOS because of an eventfd flag bug (libkrun#116).LIBGL_ALWAYS_SOFTWARE=1: aquamarine then finds no DRM EGL device. Mesa 26 falls back to llvmpipe on its own (kms_swrast for the compositor, swrast for clients).Not done / open questions
MSB_GPUenv instead of Add --gpu: virtio-gpu Venus (Vulkan) device for sandboxes #1194's option; no Linux viewer (the runtime side is portable, the viewer is macOS-only bycfg).cargo test -p microsandbox-runtimepasses; the display path itself has no unit tests yet.🤖 Generated with Claude Code
https://claude.ai/code/session_01A2DMienRTQjgR5CF3uQ2AZ