Skip to content

feat(krun): builder methods for displays, display backends and input devices - #118

Open
ya-luotao wants to merge 1 commit into
superradcompany:krunfrom
ya-luotao:krun-display-input-builders
Open

feat(krun): builder methods for displays, display backends and input devices#118
ya-luotao wants to merge 1 commit into
superradcompany:krunfrom
ya-luotao:krun-display-input-builders

Conversation

@ya-luotao

Copy link
Copy Markdown

What

VmResources already carries displays, display_backend and input_backends, and the vmm attaches virtio-gpu scanouts and virtio-input devices from them — but the Rust API (ConsoleBuilder) only exposes gpu_virgl_flags / gpu_shm_size, so an msb_krun embedder cannot configure a scanout or attach input. This adds:

  • ConsoleBuilder::gpu_display(width, height) — one scanout per call (DisplayInfo::new, default EDID). Without any display the guest driver disables KMS and exposes a render-only node.
  • ConsoleBuilder::gpu_display_backend(DisplayBackend<'static>) — where presented frames go; NoopDisplayBackend remains the default.
  • ConsoleBuilder::input_device(InputConfigBackend<'static>, InputEventProviderBackend<'static>) (feature input) — one virtio-input device per call.
  • pub use krun_display / pub use krun_input so callers can implement the backend traits against the same crate versions.

Kept on ConsoleBuilder next to the existing gpu options rather than inventing a new builder; happy to move them if you would rather have a gpu(|g| …) builder.

Verification

Used by microsandbox's experimental display (https://github.com/ya-luotao/microsandbox/tree/gpu-m0): a 1920x1080 scanout, a shared-memory krun_display backend, and a keyboard + absolute-pointer pair of input devices, driving an Omarchy/Hyprland guest in a native macOS window (with #116 and #117). cargo check -p msb_krun --features gpu,input,blk passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01A2DMienRTQjgR5CF3uQ2AZ

…devices

ConsoleBuilder::gpu_display(width, height) adds a scanout,
gpu_display_backend installs a krun_display backend and input_device
attaches a virtio-input device from krun_input backends. The vmm
already supports all three through VmResources; the Rust API only
exposed gpu_virgl_flags and gpu_shm_size. Re-export krun_display and
krun_input so callers can implement the backends.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant