Allow inclusion of persistenced socket in CDI specification

This change adds an include-persistenced-socket flag to the
nvidia-ctk cdi generate command that ensures that a generated
specification includes the nvidia-persistenced socket if present on
the host.

Note that for mangement mode, these sockets are always included
if detected.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2024-09-16 11:27:57 +02:00
parent a4bfccc3fe
commit 70da6cfa50
2 changed files with 11 additions and 0 deletions

View File

@ -60,6 +60,8 @@ type options struct {
files cli.StringSlice files cli.StringSlice
ignorePatterns cli.StringSlice ignorePatterns cli.StringSlice
} }
includePersistencedSocket bool
} }
// NewCommand constructs a generate-cdi command with the specified logger // NewCommand constructs a generate-cdi command with the specified logger
@ -169,6 +171,11 @@ func (m command) build() *cli.Command {
Usage: "Specify a pattern the CSV mount specifications.", Usage: "Specify a pattern the CSV mount specifications.",
Destination: &opts.csv.ignorePatterns, Destination: &opts.csv.ignorePatterns,
}, },
&cli.BoolFlag{
Name: "include-persistenced-socket",
Usage: "Include the nvidia-persistenced socket in the generated CDI specification.",
Destination: &opts.includePersistencedSocket,
},
} }
return &c return &c
@ -273,6 +280,7 @@ func (m command) generateSpec(opts *options) (spec.Interface, error) {
nvcdi.WithLibrarySearchPaths(opts.librarySearchPaths.Value()), nvcdi.WithLibrarySearchPaths(opts.librarySearchPaths.Value()),
nvcdi.WithCSVFiles(opts.csv.files.Value()), nvcdi.WithCSVFiles(opts.csv.files.Value()),
nvcdi.WithCSVIgnorePatterns(opts.csv.ignorePatterns.Value()), nvcdi.WithCSVIgnorePatterns(opts.csv.ignorePatterns.Value()),
nvcdi.WithOptInFeature("include-persistenced-socket", opts.includePersistencedSocket),
) )
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to create CDI library: %v", err) return nil, fmt.Errorf("failed to create CDI library: %v", err)

View File

@ -132,6 +132,9 @@ func New(opts ...Option) (Interface, error) {
if l.vendor == "" { if l.vendor == "" {
l.vendor = "management.nvidia.com" l.vendor = "management.nvidia.com"
} }
// For management specifications we always allow the fabricmanager and
// persistenced sockets.
WithOptInFeature("include-persistenced-socket", true)(l)
lib = (*managementlib)(l) lib = (*managementlib)(l)
case ModeNvml: case ModeNvml:
lib = (*nvmllib)(l) lib = (*nvmllib)(l)