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)
| 123 | /// with `driver_override=vfio-pci` and would silently re-bind to vfio-pci on |
| 124 | /// the next probe event. |
| 125 | fn 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. |
| 141 | pub(crate) fn bind_device_to_vfio(sysfs: &SysfsRoot, bdf: &str) -> Result<bool, VfioError> { |
no test coverage detected