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

Function cleanup_partial_bind

crates/openshell-vfio/src/bind.rs:125–138  ·  view source on GitHub ↗

Best-effort rollback of partial bind state. Clears `driver_override` and re-probes so the kernel re-attaches the host driver. Used on failure paths in [`bind_device_to_vfio`] after `driver_override` has been pinned to `vfio-pci` but the bind did not complete; without this the device is left with `driver_override=vfio-pci` and would silently re-bind to vfio-pci on the next probe event.

(sysfs: &SysfsRoot, bdf: &str)

Source from the content-addressed store, hash-verified

123/// with `driver_override=vfio-pci` and would silently re-bind to vfio-pci on
124/// the next probe event.
125fn cleanup_partial_bind(sysfs: &SysfsRoot, bdf: &str) {
126 let device = sysfs.pci_device_ref(bdf);
127 if device.driver_override_path().exists()
128 && let Err(err) = device.clear_driver_override()
129 {
130 tracing::warn!(bdf, %err, "failed to clear driver_override during bind rollback");
131 }
132 let probe = sysfs.drivers_probe();
133 if probe.exists()
134 && let Err(err) = write_sysfs(&probe, bdf)
135 {
136 tracing::warn!(bdf, %err, "failed to re-probe during bind rollback");
137 }
138}
139
140/// Bind a single PCI device to `vfio-pci`. Skips devices already bound.
141pub(crate) fn bind_device_to_vfio(sysfs: &SysfsRoot, bdf: &str) -> Result<bool, VfioError> {

Callers 1

bind_device_to_vfioFunction · 0.85

Calls 6

write_sysfsFunction · 0.85
pci_device_refMethod · 0.80
existsMethod · 0.80
driver_override_pathMethod · 0.80
clear_driver_overrideMethod · 0.80
drivers_probeMethod · 0.80

Tested by

no test coverage detected