generalize crate for multi-device PCIe passthrough - #1573
Merged
drew merged 4 commits intoMay 29, 2026
Conversation
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
Generalize
openshell-vfiobeyond GPU-only / single-device passthrough so it can serve as the binding/validation primitive layer the VM driver needs to implement RFC-0004'sresource_requirementsmodel. Adds atomic IOMMU-group binding, dry-run validation forValidateSandboxCreate-style paths, class-agnostic device enumeration, and a correctness fix for partially-failed binds. Purely additive plus one bug fix; consumer crates are unchanged.Related Issue
Foundational for RFC-0004 sandbox resource requirements (#1360). Unblocks multi-device-per-sandbox passthrough that the existing single-device API could not express when devices shared an IOMMU group (consumer GPUs + HDA + USB-C, multi-PF NICs, devices behind ACS-deficient PCIe switches).
Changes
prepare_pci_group_for_passthrough/release_pci_group_from_passthroughfor atomic bind/release of multiple PCIe devices sharing one IOMMU group. Rollback only restores devices newly bound by the call, so it does not steal bindings owned by other guards.validate_pci_for_passthrough/validate_pci_group_for_passthroughas dry-run pre-flight checks forValidateSandboxCreate-style paths. Performs every structural and IOMMU-peer check without touchingdriver_overrideor any other kernel state.prepare_*now delegates to its validate counterpart to keep the two in lockstep.probe_host_vfio_candidates(sysfs, vendor_filter)for vendor-filtered, class-agnostic enumeration of passthrough-eligible PCI devices so consumers can advertiseDeviceClassCapabilityfor arbitrary classes (GPUs, NICs, VFs) instead of being limited toprobe_host_nvidia_vfio_readiness.PciBindGuard::companion_bdfs()accessor for consumer-side persistence of grouped bindings (crash-recovery state, status reporting).VfioError::GroupMismatchandVfioError::EmptyGroupfor typed validation responses.bind_device_to_vfioto cleardriver_overrideand re-probe the host driver ondrivers_probefailure and on post-probe polling timeout. Previously a failed bind could leave the device wedged withdriver_override="vfio-pci"pinned on disk, causing the next probe event to silently re-bind to vfio-pci.Testing
mise run pre-commitpassescargo test -p openshell-vfiopasses (52/52, up from 32)cargo clippy -p openshell-vfio --all-targets -- -D warningscleancargo check -p openshell-driver-vmclean (consumer crate compiles unchanged)Checklist
docs/coversopenshell-vfiotoday