gpu_plugin: skip drm control node

DRM control node is deprecated and removed by latest kernel.
This will skip possible drm control node found on host.

v2: Fix lint error
v3: Fix regex string

Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
This commit is contained in:
Zhenyu Wang 2018-07-26 10:35:53 +08:00
parent 6f3543884f
commit ec632e0b38

View File

@ -36,6 +36,7 @@ const (
sysfsDrmDirectory = "/sys/class/drm"
devfsDriDirectory = "/dev/dri"
gpuDeviceRE = `^card[0-9]+$`
controlDeviceRE = `^controlD[0-9]+$`
vendorString = "0x8086"
// Device plugin settings.
@ -58,6 +59,7 @@ func newDeviceManager() *deviceManager {
// Discovers all GPU devices available on the local node by walking `/sys/class/drm` directory.
func (dm *deviceManager) discoverGPUs(sysfsDrmDir string, devfsDriDir string) error {
reg := regexp.MustCompile(gpuDeviceRE)
ctlReg := regexp.MustCompile(controlDeviceRE)
files, err := ioutil.ReadDir(sysfsDrmDir)
if err != nil {
return fmt.Errorf("Can't read sysfs folder: %v", err)
@ -79,6 +81,10 @@ func (dm *deviceManager) discoverGPUs(sysfsDrmDir string, devfsDriDir string) er
}
for _, drmFile := range drmFiles {
if ctlReg.MatchString(drmFile.Name()) {
//Skipping possible drm control node
continue
}
devPath := path.Join(devfsDriDir, drmFile.Name())
if _, err := os.Stat(devPath); err != nil {
continue