diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a99ee2f..9b8d41b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## v1.12.0-rc.6 +* Rename `nvidia cdi generate` `--root` flag to `--driver-root` to better indicate intent * [libnvidia-container] Add nvcubins.bin to DriverStore components under WSL2 ## v1.12.0-rc.5 diff --git a/cmd/nvidia-ctk/cdi/generate/common.go b/cmd/nvidia-ctk/cdi/generate/common.go index 212c483f..136e1264 100644 --- a/cmd/nvidia-ctk/cdi/generate/common.go +++ b/cmd/nvidia-ctk/cdi/generate/common.go @@ -27,14 +27,14 @@ import ( // NewCommonDiscoverer returns a discoverer for entities that are not associated with a specific CDI device. // This includes driver libraries and meta devices, for example. -func NewCommonDiscoverer(logger *logrus.Logger, root string, nvidiaCTKPath string, nvmllib nvml.Interface) (discover.Discover, error) { +func NewCommonDiscoverer(logger *logrus.Logger, driverRoot string, nvidiaCTKPath string, nvmllib nvml.Interface) (discover.Discover, error) { metaDevices := discover.NewDeviceDiscoverer( logger, lookup.NewCharDeviceLocator( lookup.WithLogger(logger), - lookup.WithRoot(root), + lookup.WithRoot(driverRoot), ), - root, + driverRoot, []string{ "/dev/nvidia-modeset", "/dev/nvidia-uvm-tools", @@ -43,12 +43,12 @@ func NewCommonDiscoverer(logger *logrus.Logger, root string, nvidiaCTKPath strin }, ) - graphicsMounts, err := discover.NewGraphicsMountsDiscoverer(logger, root) + graphicsMounts, err := discover.NewGraphicsMountsDiscoverer(logger, driverRoot) if err != nil { return nil, fmt.Errorf("error constructing discoverer for graphics mounts: %v", err) } - driverFiles, err := NewDriverDiscoverer(logger, root, nvidiaCTKPath, nvmllib) + driverFiles, err := NewDriverDiscoverer(logger, driverRoot, nvidiaCTKPath, nvmllib) if err != nil { return nil, fmt.Errorf("failed to create discoverer for driver files: %v", err) } diff --git a/cmd/nvidia-ctk/cdi/generate/device-folder-permissions.go b/cmd/nvidia-ctk/cdi/generate/device-folder-permissions.go index d4602544..418a4a3d 100644 --- a/cmd/nvidia-ctk/cdi/generate/device-folder-permissions.go +++ b/cmd/nvidia-ctk/cdi/generate/device-folder-permissions.go @@ -26,7 +26,7 @@ import ( type deviceFolderPermissions struct { logger *logrus.Logger - root string + driverRoot string nvidiaCTKPath string folders []string } @@ -39,7 +39,7 @@ var _ discover.Discover = (*deviceFolderPermissions)(nil) // The nested devices that are applicable to the NVIDIA GPU devices are: // - DRM devices at /dev/dri/* // - NVIDIA Caps devices at /dev/nvidia-caps/* -func NewDeviceFolderPermissionHookDiscoverer(logger *logrus.Logger, root string, nvidiaCTKPath string, deviceSpecs []specs.Device) (discover.Discover, error) { +func NewDeviceFolderPermissionHookDiscoverer(logger *logrus.Logger, driverRoot string, nvidiaCTKPath string, deviceSpecs []specs.Device) (discover.Discover, error) { var folders []string seen := make(map[string]bool) for _, device := range deviceSpecs { @@ -66,7 +66,7 @@ func NewDeviceFolderPermissionHookDiscoverer(logger *logrus.Logger, root string, d := &deviceFolderPermissions{ logger: logger, - root: root, + driverRoot: driverRoot, nvidiaCTKPath: nvidiaCTKPath, folders: folders, } diff --git a/cmd/nvidia-ctk/cdi/generate/driver.go b/cmd/nvidia-ctk/cdi/generate/driver.go index bea3068c..97f1506a 100644 --- a/cmd/nvidia-ctk/cdi/generate/driver.go +++ b/cmd/nvidia-ctk/cdi/generate/driver.go @@ -30,20 +30,20 @@ import ( // NewDriverDiscoverer creates a discoverer for the libraries and binaries associated with a driver installation. // The supplied NVML Library is used to query the expected driver version. -func NewDriverDiscoverer(logger *logrus.Logger, root string, nvidiaCTKPath string, nvmllib nvml.Interface) (discover.Discover, error) { +func NewDriverDiscoverer(logger *logrus.Logger, driverRoot string, nvidiaCTKPath string, nvmllib nvml.Interface) (discover.Discover, error) { version, r := nvmllib.SystemGetDriverVersion() if r != nvml.SUCCESS { return nil, fmt.Errorf("failed to determine driver version: %v", r) } - libraries, err := NewDriverLibraryDiscoverer(logger, root, nvidiaCTKPath, version) + libraries, err := NewDriverLibraryDiscoverer(logger, driverRoot, nvidiaCTKPath, version) if err != nil { return nil, fmt.Errorf("failed to create discoverer for driver libraries: %v", err) } - firmwares := NewDriverFirmwareDiscoverer(logger, root, version) + firmwares := NewDriverFirmwareDiscoverer(logger, driverRoot, version) - binaries := NewDriverBinariesDiscoverer(logger, root) + binaries := NewDriverBinariesDiscoverer(logger, driverRoot) d := discover.Merge( libraries, @@ -55,8 +55,8 @@ func NewDriverDiscoverer(logger *logrus.Logger, root string, nvidiaCTKPath strin } // NewDriverLibraryDiscoverer creates a discoverer for the libraries associated with the specified driver version. -func NewDriverLibraryDiscoverer(logger *logrus.Logger, root string, nvidiaCTKPath string, version string) (discover.Discover, error) { - libraryPaths, err := getVersionLibs(logger, root, version) +func NewDriverLibraryDiscoverer(logger *logrus.Logger, driverRoot string, nvidiaCTKPath string, version string) (discover.Discover, error) { + libraryPaths, err := getVersionLibs(logger, driverRoot, version) if err != nil { return nil, fmt.Errorf("failed to get libraries for driver version: %v", err) } @@ -65,14 +65,14 @@ func NewDriverLibraryDiscoverer(logger *logrus.Logger, root string, nvidiaCTKPat logger, lookup.NewFileLocator( lookup.WithLogger(logger), - lookup.WithRoot(root), + lookup.WithRoot(driverRoot), ), - root, + driverRoot, libraryPaths, ) cfg := &discover.Config{ - Root: root, + DriverRoot: driverRoot, NvidiaCTKPath: nvidiaCTKPath, } hooks, _ := discover.NewLDCacheUpdateHook(logger, libraries, cfg) @@ -86,25 +86,25 @@ func NewDriverLibraryDiscoverer(logger *logrus.Logger, root string, nvidiaCTKPat } // NewDriverFirmwareDiscoverer creates a discoverer for GSP firmware associated with the specified driver version. -func NewDriverFirmwareDiscoverer(logger *logrus.Logger, root string, version string) discover.Discover { +func NewDriverFirmwareDiscoverer(logger *logrus.Logger, driverRoot string, version string) discover.Discover { gspFirmwarePath := filepath.Join("/lib/firmware/nvidia", version, "gsp.bin") return discover.NewMounts( logger, lookup.NewFileLocator( lookup.WithLogger(logger), - lookup.WithRoot(root), + lookup.WithRoot(driverRoot), ), - root, + driverRoot, []string{gspFirmwarePath}, ) } // NewDriverBinariesDiscoverer creates a discoverer for GSP firmware associated with the GPU driver. -func NewDriverBinariesDiscoverer(logger *logrus.Logger, root string) discover.Discover { +func NewDriverBinariesDiscoverer(logger *logrus.Logger, driverRoot string) discover.Discover { return discover.NewMounts( logger, - lookup.NewExecutableLocator(logger, root), - root, + lookup.NewExecutableLocator(logger, driverRoot), + driverRoot, []string{ "nvidia-smi", /* System management interface */ "nvidia-debugdump", /* GPU coredump utility */ @@ -116,12 +116,12 @@ func NewDriverBinariesDiscoverer(logger *logrus.Logger, root string) discover.Di } // getVersionLibs checks the LDCache for libraries ending in the specified driver version. -// Although the ldcache at the specified root is queried, the paths are returned relative to this root. +// Although the ldcache at the specified driverRoot is queried, the paths are returned relative to this driverRoot. // This allows the standard mount location logic to be used for resolving the mounts. -func getVersionLibs(logger *logrus.Logger, root string, version string) ([]string, error) { +func getVersionLibs(logger *logrus.Logger, driverRoot string, version string) ([]string, error) { logger.Infof("Using driver version %v", version) - cache, err := ldcache.New(logger, root) + cache, err := ldcache.New(logger, driverRoot) if err != nil { return nil, fmt.Errorf("failed to load ldcache: %v", err) } @@ -143,13 +143,13 @@ func getVersionLibs(logger *logrus.Logger, root string, version string) ([]strin } } - if root == "/" || root == "" { + if driverRoot == "/" || driverRoot == "" { return libs, nil } var relative []string for _, l := range libs { - relative = append(relative, strings.TrimPrefix(l, root)) + relative = append(relative, strings.TrimPrefix(l, driverRoot)) } return relative, nil diff --git a/cmd/nvidia-ctk/cdi/generate/full-gpu.go b/cmd/nvidia-ctk/cdi/generate/full-gpu.go index 7b19f246..52039eaa 100644 --- a/cmd/nvidia-ctk/cdi/generate/full-gpu.go +++ b/cmd/nvidia-ctk/cdi/generate/full-gpu.go @@ -32,7 +32,7 @@ import ( // byPathHookDiscoverer discovers the entities required for injecting by-path DRM device links type byPathHookDiscoverer struct { logger *logrus.Logger - root string + driverRoot string nvidiaCTKPath string pciBusID string } @@ -40,7 +40,7 @@ type byPathHookDiscoverer struct { var _ discover.Discover = (*byPathHookDiscoverer)(nil) // NewFullGPUDiscoverer creates a discoverer for the full GPU defined by the specified device. -func NewFullGPUDiscoverer(logger *logrus.Logger, root string, nvidiaCTKPath string, d device.Device) (discover.Discover, error) { +func NewFullGPUDiscoverer(logger *logrus.Logger, driverRoot string, nvidiaCTKPath string, d device.Device) (discover.Discover, error) { // TODO: The functionality to get device paths should be integrated into the go-nvlib/pkg/device.Device interface. // This will allow reuse here and in other code where the paths are queried such as the NVIDIA device plugin. minor, ret := d.GetMinorNumber() @@ -65,12 +65,12 @@ func NewFullGPUDiscoverer(logger *logrus.Logger, root string, nvidiaCTKPath stri deviceNodes := discover.NewCharDeviceDiscoverer( logger, deviceNodePaths, - root, + driverRoot, ) byPathHooks := &byPathHookDiscoverer{ logger: logger, - root: root, + driverRoot: driverRoot, nvidiaCTKPath: nvidiaCTKPath, pciBusID: pciBusID, } @@ -127,7 +127,7 @@ func (d *byPathHookDiscoverer) deviceNodeLinks() ([]string, error) { var links []string for _, c := range candidates { - linkPath := filepath.Join(d.root, c) + linkPath := filepath.Join(d.driverRoot, c) device, err := os.Readlink(linkPath) if err != nil { d.logger.Warningf("Failed to evaluate symlink %v; ignoring", linkPath) diff --git a/cmd/nvidia-ctk/cdi/generate/generate.go b/cmd/nvidia-ctk/cdi/generate/generate.go index 23bd17c9..66fc32dd 100644 --- a/cmd/nvidia-ctk/cdi/generate/generate.go +++ b/cmd/nvidia-ctk/cdi/generate/generate.go @@ -47,7 +47,7 @@ type config struct { output string format string deviceNameStrategy string - root string + driverRoot string nvidiaCTKPath string } @@ -94,9 +94,9 @@ func (m command) build() *cli.Command { Destination: &cfg.deviceNameStrategy, }, &cli.StringFlag{ - Name: "root", - Usage: "Specify the root to use when discovering the entities that should be included in the CDI specification.", - Destination: &cfg.root, + Name: "driver-root", + Usage: "Specify the NVIDIA GPU driver root to use when discovering the entities that should be included in the CDI specification.", + Destination: &cfg.driverRoot, }, &cli.StringFlag{ Name: "nvidia-ctk-path", @@ -132,7 +132,7 @@ func (m command) run(c *cli.Context, cfg *config) error { } spec, err := m.generateSpec( - cfg.root, + cfg.driverRoot, discover.FindNvidiaCTK(m.logger, cfg.nvidiaCTKPath), deviceNamer, ) @@ -214,7 +214,7 @@ func writeToOutput(format string, data []byte, output io.Writer) error { return nil } -func (m command) generateSpec(root string, nvidiaCTKPath string, namer deviceNamer) (*specs.Spec, error) { +func (m command) generateSpec(driverRoot string, nvidiaCTKPath string, namer deviceNamer) (*specs.Spec, error) { nvmllib := nvml.New() if r := nvmllib.Init(); r != nvml.SUCCESS { return nil, r @@ -223,7 +223,7 @@ func (m command) generateSpec(root string, nvidiaCTKPath string, namer deviceNam devicelib := device.New(device.WithNvml(nvmllib)) - deviceSpecs, err := m.generateDeviceSpecs(devicelib, root, nvidiaCTKPath, namer) + deviceSpecs, err := m.generateDeviceSpecs(devicelib, driverRoot, nvidiaCTKPath, namer) if err != nil { return nil, fmt.Errorf("failed to create device CDI specs: %v", err) } @@ -234,7 +234,7 @@ func (m command) generateSpec(root string, nvidiaCTKPath string, namer deviceNam allEdits := edits.NewContainerEdits() - ipcs, err := NewIPCDiscoverer(m.logger, root) + ipcs, err := NewIPCDiscoverer(m.logger, driverRoot) if err != nil { return nil, fmt.Errorf("failed to create discoverer for IPC sockets: %v", err) } @@ -250,12 +250,12 @@ func (m command) generateSpec(root string, nvidiaCTKPath string, namer deviceNam allEdits.Append(ipcEdits) - common, err := NewCommonDiscoverer(m.logger, root, nvidiaCTKPath, nvmllib) + common, err := NewCommonDiscoverer(m.logger, driverRoot, nvidiaCTKPath, nvmllib) if err != nil { return nil, fmt.Errorf("failed to create discoverer for common entities: %v", err) } - deviceFolderPermissionHooks, err := NewDeviceFolderPermissionHookDiscoverer(m.logger, root, nvidiaCTKPath, deviceSpecs) + deviceFolderPermissionHooks, err := NewDeviceFolderPermissionHookDiscoverer(m.logger, driverRoot, nvidiaCTKPath, deviceSpecs) if err != nil { return nil, fmt.Errorf("failed to generated permission hooks for device nodes: %v", err) } @@ -286,7 +286,7 @@ func (m command) generateSpec(root string, nvidiaCTKPath string, namer deviceNam return &spec, nil } -func (m command) generateDeviceSpecs(devicelib device.Interface, root string, nvidiaCTKPath string, namer deviceNamer) ([]specs.Device, error) { +func (m command) generateDeviceSpecs(devicelib device.Interface, driverRoot string, nvidiaCTKPath string, namer deviceNamer) ([]specs.Device, error) { var deviceSpecs []specs.Device err := devicelib.VisitDevices(func(i int, d device.Device) error { @@ -297,7 +297,7 @@ func (m command) generateDeviceSpecs(devicelib device.Interface, root string, nv if isMigEnabled { return nil } - device, err := NewFullGPUDiscoverer(m.logger, root, nvidiaCTKPath, d) + device, err := NewFullGPUDiscoverer(m.logger, driverRoot, nvidiaCTKPath, d) if err != nil { return fmt.Errorf("failed to create device: %v", err) } diff --git a/cmd/nvidia-ctk/cdi/generate/ipc.go b/cmd/nvidia-ctk/cdi/generate/ipc.go index e7c940b1..3cd96ed8 100644 --- a/cmd/nvidia-ctk/cdi/generate/ipc.go +++ b/cmd/nvidia-ctk/cdi/generate/ipc.go @@ -23,14 +23,14 @@ import ( ) // NewIPCDiscoverer creats a discoverer for NVIDIA IPC sockets. -func NewIPCDiscoverer(logger *logrus.Logger, root string) (discover.Discover, error) { +func NewIPCDiscoverer(logger *logrus.Logger, driverRoot string) (discover.Discover, error) { d := discover.NewMounts( logger, lookup.NewFileLocator( lookup.WithLogger(logger), - lookup.WithRoot(root), + lookup.WithRoot(driverRoot), ), - root, + driverRoot, []string{ "/var/run/nvidia-persistenced/socket", "/var/run/nvidia-fabricmanager/socket", diff --git a/cmd/nvidia-ctk/cdi/generate/mig-device.go b/cmd/nvidia-ctk/cdi/generate/mig-device.go index f90ea413..ad18e6ad 100644 --- a/cmd/nvidia-ctk/cdi/generate/mig-device.go +++ b/cmd/nvidia-ctk/cdi/generate/mig-device.go @@ -27,7 +27,7 @@ import ( ) // NewMigDeviceDiscoverer creates a discoverer for the specified mig device and its parent. -func NewMigDeviceDiscoverer(logger *logrus.Logger, root string, parent device.Device, d device.MigDevice) (discover.Discover, error) { +func NewMigDeviceDiscoverer(logger *logrus.Logger, driverRoot string, parent device.Device, d device.MigDevice) (discover.Discover, error) { minor, ret := parent.GetMinorNumber() if ret != nvml.SUCCESS { return nil, fmt.Errorf("error getting GPU device minor number: %v", ret) @@ -68,7 +68,7 @@ func NewMigDeviceDiscoverer(logger *logrus.Logger, root string, parent device.De giCapDevicePath, ciCapDevicePath, }, - root, + driverRoot, ) return deviceNodes, nil diff --git a/internal/discover/csv.go b/internal/discover/csv.go index efd01e5a..3af4a850 100644 --- a/internal/discover/csv.go +++ b/internal/discover/csv.go @@ -27,16 +27,16 @@ import ( // NewFromCSVFiles creates a discoverer for the specified CSV files. A logger is also supplied. // The constructed discoverer is comprised of a list, with each element in the list being associated with a // single CSV files. -func NewFromCSVFiles(logger *logrus.Logger, files []string, root string) (Discover, error) { +func NewFromCSVFiles(logger *logrus.Logger, files []string, driverRoot string) (Discover, error) { if len(files) == 0 { logger.Warnf("No CSV files specified") return None{}, nil } - symlinkLocator := lookup.NewSymlinkLocator(logger, root) + symlinkLocator := lookup.NewSymlinkLocator(logger, driverRoot) locators := map[csv.MountSpecType]lookup.Locator{ - csv.MountSpecDev: lookup.NewCharDeviceLocator(lookup.WithLogger(logger), lookup.WithRoot(root)), - csv.MountSpecDir: lookup.NewDirectoryLocator(logger, root), + csv.MountSpecDev: lookup.NewCharDeviceLocator(lookup.WithLogger(logger), lookup.WithRoot(driverRoot)), + csv.MountSpecDir: lookup.NewDirectoryLocator(logger, driverRoot), // Libraries and symlinks are handled in the same way csv.MountSpecLib: symlinkLocator, csv.MountSpecSym: symlinkLocator, @@ -52,7 +52,7 @@ func NewFromCSVFiles(logger *logrus.Logger, files []string, root string) (Discov mountSpecs = append(mountSpecs, targets...) } - return newFromMountSpecs(logger, locators, root, mountSpecs) + return newFromMountSpecs(logger, locators, driverRoot, mountSpecs) } // loadCSVFile loads the specified CSV file and returns the list of mount specs @@ -71,7 +71,7 @@ func loadCSVFile(logger *logrus.Logger, filename string) ([]*csv.MountSpec, erro // newFromMountSpecs creates a discoverer for the CSV file. A logger is also supplied. // A list of csvDiscoverers is returned, with each being associated with a single MountSpecType. -func newFromMountSpecs(logger *logrus.Logger, locators map[csv.MountSpecType]lookup.Locator, root string, targets []*csv.MountSpec) (Discover, error) { +func newFromMountSpecs(logger *logrus.Logger, locators map[csv.MountSpecType]lookup.Locator, driverRoot string, targets []*csv.MountSpec) (Discover, error) { if len(targets) == 0 { return &None{}, nil } @@ -95,9 +95,9 @@ func newFromMountSpecs(logger *logrus.Logger, locators map[csv.MountSpecType]loo var m Discover switch t { case csv.MountSpecDev: - m = NewDeviceDiscoverer(logger, locator, root, candidatesByType[t]) + m = NewDeviceDiscoverer(logger, locator, driverRoot, candidatesByType[t]) default: - m = NewMounts(logger, locator, root, candidatesByType[t]) + m = NewMounts(logger, locator, driverRoot, candidatesByType[t]) } discoverers = append(discoverers, m) diff --git a/internal/discover/discover.go b/internal/discover/discover.go index 23dc4c13..94e610ec 100644 --- a/internal/discover/discover.go +++ b/internal/discover/discover.go @@ -18,7 +18,7 @@ package discover // Config represents the configuration options for discovery type Config struct { - Root string + DriverRoot string NvidiaCTKPath string } diff --git a/internal/discover/graphics.go b/internal/discover/graphics.go index b0a6690e..acba35bf 100644 --- a/internal/discover/graphics.go +++ b/internal/discover/graphics.go @@ -30,14 +30,14 @@ import ( // NewGraphicsDiscoverer returns the discoverer for graphics tools such as Vulkan. func NewGraphicsDiscoverer(logger *logrus.Logger, devices image.VisibleDevices, cfg *Config) (Discover, error) { - root := cfg.Root + driverRoot := cfg.DriverRoot - mounts, err := NewGraphicsMountsDiscoverer(logger, root) + mounts, err := NewGraphicsMountsDiscoverer(logger, driverRoot) if err != nil { return nil, fmt.Errorf("failed to create mounts discoverer: %v", err) } - drmDeviceNodes, err := newDRMDeviceDiscoverer(logger, devices, root) + drmDeviceNodes, err := newDRMDeviceDiscoverer(logger, devices, driverRoot) if err != nil { return nil, fmt.Errorf("failed to create DRM device discoverer: %v", err) } @@ -53,15 +53,15 @@ func NewGraphicsDiscoverer(logger *logrus.Logger, devices image.VisibleDevices, } // NewGraphicsMountsDiscoverer creates a discoverer for the mounts required by graphics tools such as vulkan. -func NewGraphicsMountsDiscoverer(logger *logrus.Logger, root string) (Discover, error) { - locator, err := lookup.NewLibraryLocator(logger, root) +func NewGraphicsMountsDiscoverer(logger *logrus.Logger, driverRoot string) (Discover, error) { + locator, err := lookup.NewLibraryLocator(logger, driverRoot) if err != nil { return nil, fmt.Errorf("failed to construct library locator: %v", err) } libraries := NewMounts( logger, locator, - root, + driverRoot, []string{ "libnvidia-egl-gbm.so", }, @@ -71,10 +71,10 @@ func NewGraphicsMountsDiscoverer(logger *logrus.Logger, root string) (Discover, logger, lookup.NewFileLocator( lookup.WithLogger(logger), - lookup.WithRoot(root), + lookup.WithRoot(driverRoot), lookup.WithSearchPaths("/etc", "/usr/share"), ), - root, + driverRoot, []string{ "glvnd/egl_vendor.d/10_nvidia.json", "vulkan/icd.d/nvidia_icd.json", @@ -96,7 +96,7 @@ type drmDevicesByPath struct { None logger *logrus.Logger nvidiaCTKPath string - root string + driverRoot string devicesFrom Discover } @@ -105,7 +105,7 @@ func newCreateDRMByPathSymlinks(logger *logrus.Logger, devices Discover, cfg *Co d := drmDevicesByPath{ logger: logger, nvidiaCTKPath: FindNvidiaCTK(logger, cfg.NvidiaCTKPath), - root: cfg.Root, + driverRoot: cfg.DriverRoot, devicesFrom: devices, } @@ -152,7 +152,7 @@ func (d drmDevicesByPath) getSpecificLinkArgs(devices []Device) ([]string, error linkLocator := lookup.NewFileLocator( lookup.WithLogger(d.logger), - lookup.WithRoot(d.root), + lookup.WithRoot(d.driverRoot), ) candidates, err := linkLocator.Locate("/dev/dri/by-path/pci-*-*") if err != nil { @@ -178,21 +178,21 @@ func (d drmDevicesByPath) getSpecificLinkArgs(devices []Device) ([]string, error } // newDRMDeviceDiscoverer creates a discoverer for the DRM devices associated with the requested devices. -func newDRMDeviceDiscoverer(logger *logrus.Logger, devices image.VisibleDevices, root string) (Discover, error) { +func newDRMDeviceDiscoverer(logger *logrus.Logger, devices image.VisibleDevices, driverRoot string) (Discover, error) { allDevices := NewDeviceDiscoverer( logger, lookup.NewCharDeviceLocator( lookup.WithLogger(logger), - lookup.WithRoot(root), + lookup.WithRoot(driverRoot), ), - root, + driverRoot, []string{ "/dev/dri/card*", "/dev/dri/renderD*", }, ) - filter, err := newDRMDeviceFilter(logger, devices, root) + filter, err := newDRMDeviceFilter(logger, devices, driverRoot) if err != nil { return nil, fmt.Errorf("failed to construct DRM device filter: %v", err) } @@ -208,8 +208,8 @@ func newDRMDeviceDiscoverer(logger *logrus.Logger, devices image.VisibleDevices, } // newDRMDeviceFilter creates a filter that matches DRM devices nodes for the visible devices. -func newDRMDeviceFilter(logger *logrus.Logger, devices image.VisibleDevices, root string) (Filter, error) { - gpuInformationPaths, err := proc.GetInformationFilePaths(root) +func newDRMDeviceFilter(logger *logrus.Logger, devices image.VisibleDevices, driverRoot string) (Filter, error) { + gpuInformationPaths, err := proc.GetInformationFilePaths(driverRoot) if err != nil { return nil, fmt.Errorf("failed to read GPU information: %v", err) } diff --git a/internal/discover/ldconfig_test.go b/internal/discover/ldconfig_test.go index daf5465c..4b3c11a1 100644 --- a/internal/discover/ldconfig_test.go +++ b/internal/discover/ldconfig_test.go @@ -32,7 +32,7 @@ func TestLDCacheUpdateHook(t *testing.T) { logger, _ := testlog.NewNullLogger() cfg := Config{ - Root: "/", + DriverRoot: "/", NvidiaCTKPath: testNvidiaCTKPath, } diff --git a/internal/modifier/csv.go b/internal/modifier/csv.go index b8217def..e0f8582e 100644 --- a/internal/modifier/csv.go +++ b/internal/modifier/csv.go @@ -62,7 +62,7 @@ func NewCSVModifier(logger *logrus.Logger, cfg *config.Config, ociSpec oci.Spec) logger.Infof("Constructing modifier from config: %+v", *cfg) config := &discover.Config{ - Root: cfg.NVIDIAContainerCLIConfig.Root, + DriverRoot: cfg.NVIDIAContainerCLIConfig.Root, NvidiaCTKPath: cfg.NVIDIACTKConfig.Path, } @@ -79,7 +79,7 @@ func NewCSVModifier(logger *logrus.Logger, cfg *config.Config, ociSpec oci.Spec) csvFiles = csv.BaseFilesOnly(csvFiles) } - csvDiscoverer, err := discover.NewFromCSVFiles(logger, csvFiles, config.Root) + csvDiscoverer, err := discover.NewFromCSVFiles(logger, csvFiles, config.DriverRoot) if err != nil { return nil, fmt.Errorf("failed to create CSV discoverer: %v", err) } diff --git a/internal/modifier/graphics.go b/internal/modifier/graphics.go index 22e236de..7e4fa8d1 100644 --- a/internal/modifier/graphics.go +++ b/internal/modifier/graphics.go @@ -45,7 +45,7 @@ func NewGraphicsModifier(logger *logrus.Logger, cfg *config.Config, ociSpec oci. } config := &discover.Config{ - Root: cfg.NVIDIAContainerCLIConfig.Root, + DriverRoot: cfg.NVIDIAContainerCLIConfig.Root, NvidiaCTKPath: cfg.NVIDIACTKConfig.Path, } d, err := discover.NewGraphicsDiscoverer(