Skip to content

Commit 1682d72

Browse files
committed
updated isVFIOEnabled
1 parent 29b3788 commit 1682d72

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

pkg/vgpu/config.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,23 +191,15 @@ func (m *nvlibVGPUConfigManager) getVGPUTypeNumberforVFIO(filePath string, vgpuT
191191
}
192192

193193
func (m *nvlibVGPUConfigManager) IsVFIOEnabled() (bool, error) {
194-
vfioDistributions := map[string]string{
195-
"ubuntu": "24.04",
196-
"rhel": "10",
197-
}
198-
// Read from the host's /etc/os-release (mounted at /host in the container)
199-
data, err := os.ReadFile("/host/etc/os-release")
194+
// Check if mdev_bus exists and has entries
195+
mdevBusPath := "/sys/class/mdev_bus"
196+
197+
entries, err := os.ReadDir(mdevBusPath)
200198
if err != nil {
201-
return false, fmt.Errorf("unable to read host OS release info: %v", err)
199+
return false, fmt.Errorf("unable to read mdev_bus directory: %v", err)
202200
}
203201

204-
content := string(data)
205-
for distribution, version := range vfioDistributions {
206-
if strings.Contains(content, distribution) && strings.Contains(content, version) {
207-
return true, nil
208-
}
209-
}
210-
return false, nil
202+
return len(entries) == 0, nil
211203
}
212204

213205
// GetVGPUConfig gets the 'VGPUConfig' currently applied to a GPU at a particular index

0 commit comments

Comments
 (0)