MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / adopt_group

Method adopt_group

crates/openshell-vfio/src/pci.rs:85–104  ·  view source on GitHub ↗

Adopt ownership of a complete IOMMU group already bound to `vfio-pci`. This is the restart-reconciliation counterpart to [`prepare_pci_group_for_passthrough`]. It validates that `bdfs` is the complete IOMMU group, that every declared device is already bound to `vfio-pci`, and then returns a guard that restores every declared device on drop. It does not write `driver_override`, `new_id`, or `drive

(sysfs: &SysfsRoot, bdfs: &[&str])

Source from the content-addressed store, hash-verified

83 /// on drop. It does not write `driver_override`, `new_id`, or
84 /// `drivers_probe`.
85 pub fn adopt_group(sysfs: &SysfsRoot, bdfs: &[&str]) -> Result<Self, VfioError> {
86 validate_pci_group_for_passthrough(sysfs, bdfs)?;
87
88 for bdf in bdfs {
89 ensure_bound_to_vfio(sysfs, bdf)?;
90 }
91
92 let (primary, companions) = bdfs
93 .split_first()
94 .expect("validate_pci_group_for_passthrough rejects empty slices");
95 let vfio_id = crate::bind::vfio_id_string(sysfs, primary);
96 let companion_bdfs: Vec<String> = companions.iter().map(|s| (*s).to_string()).collect();
97
98 Ok(Self::new_armed(
99 (*primary).to_string(),
100 companion_bdfs,
101 sysfs.clone(),
102 vfio_id,
103 ))
104 }
105
106 pub(crate) fn new_armed(
107 bdf: String,

Callers

nothing calls this directly

Calls 3

ensure_bound_to_vfioFunction · 0.85
vfio_id_stringFunction · 0.85

Tested by

no test coverage detected