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

Method new

crates/openshell-driver-vm/src/gpu.rs:27–50  ·  view source on GitHub ↗
(sysfs: SysfsRoot, state_dir: &Path)

Source from the content-addressed store, hash-verified

25
26impl 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)

Callers

nothing calls this directly

Calls 2

reconcile_stale_bindingsFunction · 0.85

Tested by

no test coverage detected