(sysfs: SysfsRoot, state_dir: &Path)
| 25 | |
| 26 | impl GpuInventory { |
| 27 | pub fn new(sysfs: SysfsRoot, state_dir: &Path) -> Self { |
| 28 | let state_path = state_dir.join("gpu-bindings.json"); |
| 29 | |
| 30 | let restored = reconcile_stale_bindings(&sysfs, &state_path); |
| 31 | for bdf in &restored { |
| 32 | tracing::info!(bdf = %bdf, "restored stale GPU binding from previous crash"); |
| 33 | } |
| 34 | |
| 35 | let gpus = probe_host_nvidia_vfio_readiness(&sysfs); |
| 36 | let slots = gpus |
| 37 | .into_iter() |
| 38 | .map(|info| GpuSlot { |
| 39 | info, |
| 40 | assigned_to: None, |
| 41 | bind_guard: None, |
| 42 | }) |
| 43 | .collect(); |
| 44 | |
| 45 | Self { |
| 46 | slots, |
| 47 | sysfs, |
| 48 | state_path, |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | pub fn gpu_count(&self) -> u32 { |
| 53 | u32::try_from(self.slots.len()).unwrap_or(u32::MAX) |
nothing calls this directly
no test coverage detected