forked from jaypipes/ghw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
snapshot: collect data related to GPU devices
make sure the snapshot code collects data related to GPU devices. Turns out not much was missing, most notably the `/sys/class/drm` link; nevertheless, let's make sure to collect this data, so now also the gpu package can consume snapshots. We choose to refactor the code from net devices collection more for clarity -what we collect and what we filter out is a bit more explicit now- than to avoid duplication. The PCI collection code is a bit more elaborate, because it needs to deal with PCI roots and subtrees (subforests?), so it was intentionally left out for the time being. Signed-off-by: Francesco Romani <fromani@redhat.com>
- Loading branch information
Showing
3 changed files
with
97 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Use and distribution licensed under the Apache license version 2. | ||
// | ||
// See the COPYING file in the root project directory for full text. | ||
// | ||
|
||
package snapshot | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
// ExpectedCloneGPUContent returns a slice of strings pertaining to the GPU devices ghw | ||
// cares about. We cannot use a static list because we want to grab only the first cardX data | ||
// (see comment in pkg/gpu/gpu_linux.go) | ||
// Additionally, we want to make sure to clone the backing device data. | ||
func ExpectedCloneGPUContent() []string { | ||
cardEntries := []string{ | ||
"device", | ||
} | ||
|
||
filterName := func(cardName string) bool { | ||
if !strings.HasPrefix(cardName, "card") { | ||
return false | ||
} | ||
if strings.ContainsRune(cardName, '-') { | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
return cloneContentByClass("drm", cardEntries, filterName, filterNone) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters