Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions internal/nvcaps/nvcaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,15 @@ func (m MigCap) isValid() bool {
var gpu int
var gi int
var ci int
// Look for a CI access file
// Look for a CI access file. Sscanf stops at the first mismatch, so the
// reconstructed name has to be the whole token.
n, _ := fmt.Sscanf(cap, "gpu%d/gi%d/ci%d/access", &gpu, &gi, &ci)
if n == 3 {
if n == 3 && cap == fmt.Sprintf("gpu%d/gi%d/ci%d/access", gpu, gi, ci) {
return true
}
// Look for a GI access file
n, _ = fmt.Sscanf(cap, "gpu%d/gi%d/access %d", &gpu, &gi)
if n == 2 {
n, _ = fmt.Sscanf(cap, "gpu%d/gi%d/access", &gpu, &gi)
if n == 2 && cap == fmt.Sprintf("gpu%d/gi%d/access", gpu, gi) {
return true
}
}
Expand Down
2 changes: 2 additions & 0 deletions internal/nvcaps/nvcaps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func TestProcessMigMinorsLine(t *testing.T) {
{"monitor 2", "monitor", 2, false},
{"gpu0/gi0/access 3", "gpu0/gi0/access", 3, false},
{"gpu0/gi0/ci0/access 4", "gpu0/gi0/ci0/access", 4, false},
{"gpu0/gi0/accessEXTRA 3", "", 0, true},
{"gpu0/gi0/ci0/accessEXTRA 4", "", 0, true},
{"notconfig 99", "", 0, true},
{"config notanint", "", 0, true},
{"", "", 0, true},
Expand Down