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

Method adopt

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

Adopt ownership of a `PCIe` device that is already bound to `vfio-pci`. This is the restart-reconciliation counterpart to [`prepare_pci_for_passthrough`]. It validates that the device exists, that all IOMMU peers are already on `vfio-pci`, and that the primary BDF is currently bound to `vfio-pci`, then returns a guard that will restore the device on drop. It does not write `driver_override`, `new

(sysfs: &SysfsRoot, bdf: &str)

Source from the content-addressed store, hash-verified

61 /// the device on drop. It does not write `driver_override`, `new_id`, or
62 /// `drivers_probe`.
63 pub fn adopt(sysfs: &SysfsRoot, bdf: &str) -> Result<Self, VfioError> {
64 validate_pci_for_passthrough(sysfs, bdf)?;
65 ensure_bound_to_vfio(sysfs, bdf)?;
66
67 let vfio_id = crate::bind::vfio_id_string(sysfs, bdf);
68
69 Ok(Self::new_armed(
70 bdf.to_string(),
71 Vec::new(),
72 sysfs.clone(),
73 vfio_id,
74 ))
75 }
76
77 /// Adopt ownership of a complete IOMMU group already bound to `vfio-pci`.
78 ///

Callers

nothing calls this directly

Calls 3

ensure_bound_to_vfioFunction · 0.85
vfio_id_stringFunction · 0.85

Tested by

no test coverage detected