mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-25 21:39:10 +00:00
Rename discover.Config.Root to discover.Config.DriverRoot
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
cfa2647260
commit
daceac9117
@ -72,7 +72,7 @@ func NewDriverLibraryDiscoverer(logger *logrus.Logger, driverRoot string, nvidia
|
|||||||
)
|
)
|
||||||
|
|
||||||
cfg := &discover.Config{
|
cfg := &discover.Config{
|
||||||
Root: driverRoot,
|
DriverRoot: driverRoot,
|
||||||
NvidiaCTKPath: nvidiaCTKPath,
|
NvidiaCTKPath: nvidiaCTKPath,
|
||||||
}
|
}
|
||||||
hooks, _ := discover.NewLDCacheUpdateHook(logger, libraries, cfg)
|
hooks, _ := discover.NewLDCacheUpdateHook(logger, libraries, cfg)
|
||||||
|
@ -27,16 +27,16 @@ import (
|
|||||||
// NewFromCSVFiles creates a discoverer for the specified CSV files. A logger is also supplied.
|
// 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
|
// The constructed discoverer is comprised of a list, with each element in the list being associated with a
|
||||||
// single CSV files.
|
// 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 {
|
if len(files) == 0 {
|
||||||
logger.Warnf("No CSV files specified")
|
logger.Warnf("No CSV files specified")
|
||||||
return None{}, nil
|
return None{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
symlinkLocator := lookup.NewSymlinkLocator(logger, root)
|
symlinkLocator := lookup.NewSymlinkLocator(logger, driverRoot)
|
||||||
locators := map[csv.MountSpecType]lookup.Locator{
|
locators := map[csv.MountSpecType]lookup.Locator{
|
||||||
csv.MountSpecDev: lookup.NewCharDeviceLocator(lookup.WithLogger(logger), lookup.WithRoot(root)),
|
csv.MountSpecDev: lookup.NewCharDeviceLocator(lookup.WithLogger(logger), lookup.WithRoot(driverRoot)),
|
||||||
csv.MountSpecDir: lookup.NewDirectoryLocator(logger, root),
|
csv.MountSpecDir: lookup.NewDirectoryLocator(logger, driverRoot),
|
||||||
// Libraries and symlinks are handled in the same way
|
// Libraries and symlinks are handled in the same way
|
||||||
csv.MountSpecLib: symlinkLocator,
|
csv.MountSpecLib: symlinkLocator,
|
||||||
csv.MountSpecSym: symlinkLocator,
|
csv.MountSpecSym: symlinkLocator,
|
||||||
@ -52,7 +52,7 @@ func NewFromCSVFiles(logger *logrus.Logger, files []string, root string) (Discov
|
|||||||
mountSpecs = append(mountSpecs, targets...)
|
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
|
// 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.
|
// 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.
|
// 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 {
|
if len(targets) == 0 {
|
||||||
return &None{}, nil
|
return &None{}, nil
|
||||||
}
|
}
|
||||||
@ -95,9 +95,9 @@ func newFromMountSpecs(logger *logrus.Logger, locators map[csv.MountSpecType]loo
|
|||||||
var m Discover
|
var m Discover
|
||||||
switch t {
|
switch t {
|
||||||
case csv.MountSpecDev:
|
case csv.MountSpecDev:
|
||||||
m = NewDeviceDiscoverer(logger, locator, root, candidatesByType[t])
|
m = NewDeviceDiscoverer(logger, locator, driverRoot, candidatesByType[t])
|
||||||
default:
|
default:
|
||||||
m = NewMounts(logger, locator, root, candidatesByType[t])
|
m = NewMounts(logger, locator, driverRoot, candidatesByType[t])
|
||||||
}
|
}
|
||||||
discoverers = append(discoverers, m)
|
discoverers = append(discoverers, m)
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ package discover
|
|||||||
|
|
||||||
// Config represents the configuration options for discovery
|
// Config represents the configuration options for discovery
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Root string
|
DriverRoot string
|
||||||
NvidiaCTKPath string
|
NvidiaCTKPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,14 +30,14 @@ import (
|
|||||||
|
|
||||||
// NewGraphicsDiscoverer returns the discoverer for graphics tools such as Vulkan.
|
// NewGraphicsDiscoverer returns the discoverer for graphics tools such as Vulkan.
|
||||||
func NewGraphicsDiscoverer(logger *logrus.Logger, devices image.VisibleDevices, cfg *Config) (Discover, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create mounts discoverer: %v", err)
|
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 {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create DRM device discoverer: %v", err)
|
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.
|
// NewGraphicsMountsDiscoverer creates a discoverer for the mounts required by graphics tools such as vulkan.
|
||||||
func NewGraphicsMountsDiscoverer(logger *logrus.Logger, root string) (Discover, error) {
|
func NewGraphicsMountsDiscoverer(logger *logrus.Logger, driverRoot string) (Discover, error) {
|
||||||
locator, err := lookup.NewLibraryLocator(logger, root)
|
locator, err := lookup.NewLibraryLocator(logger, driverRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to construct library locator: %v", err)
|
return nil, fmt.Errorf("failed to construct library locator: %v", err)
|
||||||
}
|
}
|
||||||
libraries := NewMounts(
|
libraries := NewMounts(
|
||||||
logger,
|
logger,
|
||||||
locator,
|
locator,
|
||||||
root,
|
driverRoot,
|
||||||
[]string{
|
[]string{
|
||||||
"libnvidia-egl-gbm.so",
|
"libnvidia-egl-gbm.so",
|
||||||
},
|
},
|
||||||
@ -71,10 +71,10 @@ func NewGraphicsMountsDiscoverer(logger *logrus.Logger, root string) (Discover,
|
|||||||
logger,
|
logger,
|
||||||
lookup.NewFileLocator(
|
lookup.NewFileLocator(
|
||||||
lookup.WithLogger(logger),
|
lookup.WithLogger(logger),
|
||||||
lookup.WithRoot(root),
|
lookup.WithRoot(driverRoot),
|
||||||
lookup.WithSearchPaths("/etc", "/usr/share"),
|
lookup.WithSearchPaths("/etc", "/usr/share"),
|
||||||
),
|
),
|
||||||
root,
|
driverRoot,
|
||||||
[]string{
|
[]string{
|
||||||
"glvnd/egl_vendor.d/10_nvidia.json",
|
"glvnd/egl_vendor.d/10_nvidia.json",
|
||||||
"vulkan/icd.d/nvidia_icd.json",
|
"vulkan/icd.d/nvidia_icd.json",
|
||||||
@ -96,7 +96,7 @@ type drmDevicesByPath struct {
|
|||||||
None
|
None
|
||||||
logger *logrus.Logger
|
logger *logrus.Logger
|
||||||
nvidiaCTKPath string
|
nvidiaCTKPath string
|
||||||
root string
|
driverRoot string
|
||||||
devicesFrom Discover
|
devicesFrom Discover
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ func newCreateDRMByPathSymlinks(logger *logrus.Logger, devices Discover, cfg *Co
|
|||||||
d := drmDevicesByPath{
|
d := drmDevicesByPath{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
nvidiaCTKPath: FindNvidiaCTK(logger, cfg.NvidiaCTKPath),
|
nvidiaCTKPath: FindNvidiaCTK(logger, cfg.NvidiaCTKPath),
|
||||||
root: cfg.Root,
|
driverRoot: cfg.DriverRoot,
|
||||||
devicesFrom: devices,
|
devicesFrom: devices,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ func (d drmDevicesByPath) getSpecificLinkArgs(devices []Device) ([]string, error
|
|||||||
|
|
||||||
linkLocator := lookup.NewFileLocator(
|
linkLocator := lookup.NewFileLocator(
|
||||||
lookup.WithLogger(d.logger),
|
lookup.WithLogger(d.logger),
|
||||||
lookup.WithRoot(d.root),
|
lookup.WithRoot(d.driverRoot),
|
||||||
)
|
)
|
||||||
candidates, err := linkLocator.Locate("/dev/dri/by-path/pci-*-*")
|
candidates, err := linkLocator.Locate("/dev/dri/by-path/pci-*-*")
|
||||||
if err != nil {
|
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.
|
// 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(
|
allDevices := NewDeviceDiscoverer(
|
||||||
logger,
|
logger,
|
||||||
lookup.NewCharDeviceLocator(
|
lookup.NewCharDeviceLocator(
|
||||||
lookup.WithLogger(logger),
|
lookup.WithLogger(logger),
|
||||||
lookup.WithRoot(root),
|
lookup.WithRoot(driverRoot),
|
||||||
),
|
),
|
||||||
root,
|
driverRoot,
|
||||||
[]string{
|
[]string{
|
||||||
"/dev/dri/card*",
|
"/dev/dri/card*",
|
||||||
"/dev/dri/renderD*",
|
"/dev/dri/renderD*",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
filter, err := newDRMDeviceFilter(logger, devices, root)
|
filter, err := newDRMDeviceFilter(logger, devices, driverRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to construct DRM device filter: %v", err)
|
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.
|
// 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) {
|
func newDRMDeviceFilter(logger *logrus.Logger, devices image.VisibleDevices, driverRoot string) (Filter, error) {
|
||||||
gpuInformationPaths, err := proc.GetInformationFilePaths(root)
|
gpuInformationPaths, err := proc.GetInformationFilePaths(driverRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read GPU information: %v", err)
|
return nil, fmt.Errorf("failed to read GPU information: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ func TestLDCacheUpdateHook(t *testing.T) {
|
|||||||
logger, _ := testlog.NewNullLogger()
|
logger, _ := testlog.NewNullLogger()
|
||||||
|
|
||||||
cfg := Config{
|
cfg := Config{
|
||||||
Root: "/",
|
DriverRoot: "/",
|
||||||
NvidiaCTKPath: testNvidiaCTKPath,
|
NvidiaCTKPath: testNvidiaCTKPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ func NewCSVModifier(logger *logrus.Logger, cfg *config.Config, ociSpec oci.Spec)
|
|||||||
logger.Infof("Constructing modifier from config: %+v", *cfg)
|
logger.Infof("Constructing modifier from config: %+v", *cfg)
|
||||||
|
|
||||||
config := &discover.Config{
|
config := &discover.Config{
|
||||||
Root: cfg.NVIDIAContainerCLIConfig.Root,
|
DriverRoot: cfg.NVIDIAContainerCLIConfig.Root,
|
||||||
NvidiaCTKPath: cfg.NVIDIACTKConfig.Path,
|
NvidiaCTKPath: cfg.NVIDIACTKConfig.Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ func NewCSVModifier(logger *logrus.Logger, cfg *config.Config, ociSpec oci.Spec)
|
|||||||
csvFiles = csv.BaseFilesOnly(csvFiles)
|
csvFiles = csv.BaseFilesOnly(csvFiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
csvDiscoverer, err := discover.NewFromCSVFiles(logger, csvFiles, config.Root)
|
csvDiscoverer, err := discover.NewFromCSVFiles(logger, csvFiles, config.DriverRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create CSV discoverer: %v", err)
|
return nil, fmt.Errorf("failed to create CSV discoverer: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func NewGraphicsModifier(logger *logrus.Logger, cfg *config.Config, ociSpec oci.
|
|||||||
}
|
}
|
||||||
|
|
||||||
config := &discover.Config{
|
config := &discover.Config{
|
||||||
Root: cfg.NVIDIAContainerCLIConfig.Root,
|
DriverRoot: cfg.NVIDIAContainerCLIConfig.Root,
|
||||||
NvidiaCTKPath: cfg.NVIDIACTKConfig.Path,
|
NvidiaCTKPath: cfg.NVIDIACTKConfig.Path,
|
||||||
}
|
}
|
||||||
d, err := discover.NewGraphicsDiscoverer(
|
d, err := discover.NewGraphicsDiscoverer(
|
||||||
|
Loading…
Reference in New Issue
Block a user