mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-21 15:57:49 +00:00
Simplify meta device discovery
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
00a712d018
commit
3a96a00362
@ -27,20 +27,13 @@ type charDevices mounts
|
||||
var _ Discover = (*charDevices)(nil)
|
||||
|
||||
// NewCharDeviceDiscoverer creates a discoverer which locates the specified set of device nodes.
|
||||
func NewCharDeviceDiscoverer(logger logger.Interface, devices []string, root string) Discover {
|
||||
func NewCharDeviceDiscoverer(logger logger.Interface, devRoot string, devices []string) Discover {
|
||||
locator := lookup.NewCharDeviceLocator(
|
||||
lookup.WithLogger(logger),
|
||||
lookup.WithRoot(root),
|
||||
lookup.WithRoot(devRoot),
|
||||
)
|
||||
|
||||
return NewDeviceDiscoverer(logger, locator, root, devices)
|
||||
}
|
||||
|
||||
// NewDeviceDiscoverer creates a discoverer which locates the specified set of device nodes using the specified locator.
|
||||
func NewDeviceDiscoverer(logger logger.Interface, locator lookup.Locator, root string, devices []string) Discover {
|
||||
m := NewMounts(logger, locator, root, devices).(*mounts)
|
||||
|
||||
return (*charDevices)(m)
|
||||
return (*charDevices)(newMounts(logger, locator, devRoot, devices))
|
||||
}
|
||||
|
||||
// Mounts returns the discovered mounts for the charDevices.
|
||||
|
@ -29,17 +29,17 @@ type gdsDeviceDiscoverer struct {
|
||||
}
|
||||
|
||||
// NewGDSDiscoverer creates a discoverer for GPUDirect Storage devices and mounts.
|
||||
func NewGDSDiscoverer(logger logger.Interface, root string) (Discover, error) {
|
||||
func NewGDSDiscoverer(logger logger.Interface, driverRoot string, devRoot string) (Discover, error) {
|
||||
devices := NewCharDeviceDiscoverer(
|
||||
logger,
|
||||
devRoot,
|
||||
[]string{"/dev/nvidia-fs*"},
|
||||
root,
|
||||
)
|
||||
|
||||
udev := NewMounts(
|
||||
logger,
|
||||
lookup.NewDirectoryLocator(lookup.WithLogger(logger), lookup.WithRoot(root)),
|
||||
root,
|
||||
lookup.NewDirectoryLocator(lookup.WithLogger(logger), lookup.WithRoot(driverRoot)),
|
||||
driverRoot,
|
||||
[]string{"/run/udev"},
|
||||
)
|
||||
|
||||
@ -47,9 +47,9 @@ func NewGDSDiscoverer(logger logger.Interface, root string) (Discover, error) {
|
||||
logger,
|
||||
lookup.NewFileLocator(
|
||||
lookup.WithLogger(logger),
|
||||
lookup.WithRoot(root),
|
||||
lookup.WithRoot(driverRoot),
|
||||
),
|
||||
root,
|
||||
driverRoot,
|
||||
[]string{"/etc/cufile.json"},
|
||||
)
|
||||
|
||||
|
@ -188,12 +188,8 @@ func (d drmDevicesByPath) getSpecificLinkArgs(devices []Device) ([]string, error
|
||||
|
||||
// newDRMDeviceDiscoverer creates a discoverer for the DRM devices associated with the requested devices.
|
||||
func newDRMDeviceDiscoverer(logger logger.Interface, devices image.VisibleDevices, devRoot string) (Discover, error) {
|
||||
allDevices := NewDeviceDiscoverer(
|
||||
allDevices := NewCharDeviceDiscoverer(
|
||||
logger,
|
||||
lookup.NewCharDeviceLocator(
|
||||
lookup.WithLogger(logger),
|
||||
lookup.WithRoot(devRoot),
|
||||
),
|
||||
devRoot,
|
||||
[]string{
|
||||
"/dev/dri/card*",
|
||||
|
@ -19,14 +19,14 @@ package discover
|
||||
import "github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
|
||||
|
||||
// NewMOFEDDiscoverer creates a discoverer for MOFED devices.
|
||||
func NewMOFEDDiscoverer(logger logger.Interface, root string) (Discover, error) {
|
||||
func NewMOFEDDiscoverer(logger logger.Interface, devRoot string) (Discover, error) {
|
||||
devices := NewCharDeviceDiscoverer(
|
||||
logger,
|
||||
devRoot,
|
||||
[]string{
|
||||
"/dev/infiniband/uverbs*",
|
||||
"/dev/infiniband/rdma_cm",
|
||||
},
|
||||
root,
|
||||
)
|
||||
|
||||
return devices, nil
|
||||
|
@ -36,9 +36,8 @@ func (o tegraOptions) newDiscovererFromCSVFiles() (discover.Discover, error) {
|
||||
|
||||
targetsByType := getTargetsFromCSVFiles(o.logger, o.csvFiles)
|
||||
|
||||
devices := discover.NewDeviceDiscoverer(
|
||||
devices := discover.NewCharDeviceDiscoverer(
|
||||
o.logger,
|
||||
lookup.NewCharDeviceLocator(lookup.WithLogger(o.logger), lookup.WithRoot(o.driverRoot)),
|
||||
o.driverRoot,
|
||||
targetsByType[csv.MountSpecDev],
|
||||
)
|
||||
|
@ -20,18 +20,13 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/discover"
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/lookup"
|
||||
)
|
||||
|
||||
// newCommonNVMLDiscoverer returns a discoverer for entities that are not associated with a specific CDI device.
|
||||
// This includes driver libraries and meta devices, for example.
|
||||
func (l *nvmllib) newCommonNVMLDiscoverer() (discover.Discover, error) {
|
||||
metaDevices := discover.NewDeviceDiscoverer(
|
||||
metaDevices := discover.NewCharDeviceDiscoverer(
|
||||
l.logger,
|
||||
lookup.NewCharDeviceLocator(
|
||||
lookup.WithLogger(l.logger),
|
||||
lookup.WithRoot(l.devRoot),
|
||||
),
|
||||
l.devRoot,
|
||||
[]string{
|
||||
"/dev/nvidia-modeset",
|
||||
|
@ -29,8 +29,8 @@ const (
|
||||
func newDXGDeviceDiscoverer(logger logger.Interface, devRoot string) discover.Discover {
|
||||
deviceNodes := discover.NewCharDeviceDiscoverer(
|
||||
logger,
|
||||
[]string{dxgDeviceNode},
|
||||
devRoot,
|
||||
[]string{dxgDeviceNode},
|
||||
)
|
||||
|
||||
return deviceNodes
|
||||
|
@ -103,8 +103,8 @@ func newFullGPUDiscoverer(logger logger.Interface, devRoot string, nvidiaCTKPath
|
||||
|
||||
deviceNodes := discover.NewCharDeviceDiscoverer(
|
||||
logger,
|
||||
deviceNodePaths,
|
||||
devRoot,
|
||||
deviceNodePaths,
|
||||
)
|
||||
|
||||
byPathHooks := &byPathHookDiscoverer{
|
||||
|
@ -109,6 +109,7 @@ type managementDiscoverer struct {
|
||||
func (m *managementlib) newManagementDeviceDiscoverer() (discover.Discover, error) {
|
||||
deviceNodes := discover.NewCharDeviceDiscoverer(
|
||||
m.logger,
|
||||
m.devRoot,
|
||||
[]string{
|
||||
"/dev/nvidia*",
|
||||
"/dev/nvidia-caps/nvidia-cap*",
|
||||
@ -117,7 +118,6 @@ func (m *managementlib) newManagementDeviceDiscoverer() (discover.Discover, erro
|
||||
"/dev/nvidia-uvm",
|
||||
"/dev/nvidiactl",
|
||||
},
|
||||
m.devRoot,
|
||||
)
|
||||
|
||||
deviceFolderPermissionHooks := newDeviceFolderPermissionHookDiscoverer(
|
||||
|
@ -112,12 +112,12 @@ func newComputeInstanceDiscoverer(logger logger.Interface, driverRoot string, gp
|
||||
|
||||
deviceNodes := discover.NewCharDeviceDiscoverer(
|
||||
logger,
|
||||
driverRoot,
|
||||
[]string{
|
||||
parentPath,
|
||||
giCapDevicePath,
|
||||
ciCapDevicePath,
|
||||
},
|
||||
driverRoot,
|
||||
)
|
||||
|
||||
return deviceNodes, nil
|
||||
|
Loading…
Reference in New Issue
Block a user