Add devRoot option to CDI api

A driverRoot defines both the driver library root and the
root for device nodes. In the case of preinstalled drivers or
the driver container, these are equal, but in cases such as GKE
they do not match. In this case, drivers are extracted to a folder
and devices exist at the root /.

The changes here add a devRoot option to the nvcdi API that allows the
parent of /dev to be specified explicitly.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar
2023-11-14 16:57:37 +01:00
parent f6e3593a72
commit d4e21fdd10
15 changed files with 73 additions and 44 deletions

View File

@@ -29,6 +29,7 @@ type tegraOptions struct {
logger logger.Interface
csvFiles []string
driverRoot string
devRoot string
nvidiaCTKPath string
librarySearchPaths []string
ignorePatterns ignoreMountSpecPatterns
@@ -50,6 +51,10 @@ func New(opts ...Option) (discover.Discover, error) {
opt(o)
}
if o.devRoot == "" {
o.devRoot = o.driverRoot
}
if o.symlinkLocator == nil {
o.symlinkLocator = lookup.NewSymlinkLocator(
lookup.WithLogger(o.logger),
@@ -112,6 +117,14 @@ func WithDriverRoot(driverRoot string) Option {
}
}
// WithDevRoot sets the /dev root.
// If this is unset, the driver root is assumed.
func WithDevRoot(driverRoot string) Option {
return func(o *tegraOptions) {
o.driverRoot = driverRoot
}
}
// WithCSVFiles sets the CSV files for the discoverer.
func WithCSVFiles(csvFiles []string) Option {
return func(o *tegraOptions) {