Skip to content

Commit 82535bf

Browse files
change logic to filter MIG GPUs
fixed method comments
1 parent 5417cee commit 82535bf

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pkg/util/common/common.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,29 @@ import (
99
)
1010

1111
const (
12-
defaultTotalVFFile = "sriov_totalvfs"
1312
defaultConfiguredVFFile = "sriov_numvfs"
13+
defaultVFCheckFile = "sriov_vf_device"
1414
)
1515

16-
// IsDeviceSRIOVCapable checks for existence of `sriov_totalvfs` file in the pcidevice tree
16+
// IsDeviceSRIOVCapable checks for existence of `sriov_vf_device` file in the pcidevice tree
1717
func IsDeviceSRIOVCapable(devicePath string) (bool, error) {
18-
_, err := os.Stat(filepath.Join(devicePath, defaultTotalVFFile))
18+
vfCheckFilePath := filepath.Join(devicePath, defaultVFCheckFile)
19+
_, err := os.Stat(vfCheckFilePath)
1920
if err != nil {
2021
if os.IsNotExist(err) {
2122
return false, nil
2223
}
2324
return false, err
2425
}
2526

27+
contents, err := os.ReadFile(vfCheckFilePath)
28+
if err != nil {
29+
return false, err
30+
}
31+
32+
if strings.TrimSuffix(string(contents), "\n") == "0" {
33+
return false, nil
34+
}
2635
return true, nil
2736
}
2837

0 commit comments

Comments
 (0)