feat(vmm): add HypervisorProbe for post-failure VM diagnostics#430
Merged
Conversation
macOS Hypervisor.framework returns HV_NO_RESOURCES (0xfae94005) when the 128 VM address space limit is exhausted, but libkrun discards the specific error code and collapses all failures to EINVAL (-22). Add a HypervisorProbe trait that provides platform-abstracted post-failure diagnostics. On macOS, when krun_start_enter() fails, the HvfProbe calls hv_vm_create() directly to reproduce and identify the exact HVF error: - HV_NO_RESOURCES → ResourceExhausted with actionable message - HV_SUCCESS → not HVF-related, return original error - HV_BUSY → VM created but failed post-creation - HV_DENIED → missing entitlement This is zero-cost on the happy path — the probe only runs after failure. Changes: - Add ResourceExhausted error variant to BoxliteError - Add HypervisorProbe trait with HvfProbe (macOS) and KvmProbe (Linux) - Wire probe into KrunVmmInstance::enter() failure path - Improve EINVAL message in check_status() to list both causes - Add ResourceExhausted to FFI error codes
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.
Summary
HypervisorProbetrait for platform-abstracted hypervisor validation withstartup_check()anddiagnose_create_failure()methodskrun_start_enter()fails,HvfProbecallshv_vm_create()directly to get the exact HVF error code that libkrun discards (collapses all to EINVAL)HV_NO_RESOURCES→ResourceExhaustedwith actionable message (address space limit),HV_DENIED→ entitlement error,HV_BUSY→ post-creation failureContext
macOS Hypervisor.framework has a hard limit of 128 VM address spaces (
kern.hv.max_address_spaces). When exhausted,hv_vm_create()returnsHV_NO_RESOURCES(0xfae94005), but libkrun discards the code athvf/src/lib.rs:260and returns generic-EINVAL(-22). Users see a misleading "rootfs" error.Changes
src/shared/src/errors.rsResourceExhausted(String)variantsrc/boxlite/src/system_check.rsHypervisorProbetrait,HvfProbe(macOS),KvmProbe(Linux), HVF FFIsrc/boxlite/src/vmm/krun/engine.rsenter()failure pathsrc/boxlite/src/vmm/krun/mod.rscheck_status()src/ffi/src/error.rsResourceExhausted = 20to FFI error codessdks/c/include/boxlite.hTest plan
cargo clippy -p boxlite -p boxlite-shared --tests -- -D warnings(clean)cargo test -p boxlite --lib(614 passed, 0 failed)cargo test -p boxlite-shared(1 passed)hvf_ffi_constants)hvf_probe_startup_check)system_check_runs)