Skip to content

Commit

Permalink
Allow inclusion of sockets in CDI specification
Browse files Browse the repository at this point in the history
This change adds with-fabricmanager and with-persistenced
flags to the nvidia-ctk cdi generate command that ensures that
a generated specification includes these sockets 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>
  • Loading branch information
elezar committed Sep 16, 2024
1 parent 4d9924d commit f44e31f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/nvidia-ctk/cdi/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ type options struct {
files cli.StringSlice
ignorePatterns cli.StringSlice
}

withFabricmanager bool
withPersistenced bool
}

// NewCommand constructs a generate-cdi command with the specified logger
Expand Down Expand Up @@ -169,6 +172,16 @@ func (m command) build() *cli.Command {
Usage: "Specify a pattern the CSV mount specifications.",
Destination: &opts.csv.ignorePatterns,
},
&cli.BoolFlag{
Name: "with-fabricmanager",
Usage: "Include the nvidia-fabricmanager socket in the generated CDI specification.",
Destination: &opts.withFabricmanager,
},
&cli.BoolFlag{
Name: "with-persistenced",
Usage: "Include the nvidia-persistenced socket in the generated CDI specification.",
Destination: &opts.withPersistenced,
},
}

return &c
Expand Down Expand Up @@ -273,6 +286,8 @@ func (m command) generateSpec(opts *options) (spec.Interface, error) {
nvcdi.WithLibrarySearchPaths(opts.librarySearchPaths.Value()),
nvcdi.WithCSVFiles(opts.csv.files.Value()),
nvcdi.WithCSVIgnorePatterns(opts.csv.ignorePatterns.Value()),
nvcdi.WithOptInFeature("allow-fabricmanager", opts.withFabricmanager),
nvcdi.WithOptInFeature("allow-persistenced", opts.withPersistenced),
)
if err != nil {
return nil, fmt.Errorf("failed to create CDI library: %v", err)
Expand Down
4 changes: 4 additions & 0 deletions pkg/nvcdi/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ func New(opts ...Option) (Interface, error) {
if l.vendor == "" {
l.vendor = "management.nvidia.com"
}
// For management specifications we always allow the fabricmanager and
// persistenced sockets.
WithOptInFeature("allow-fabricmanager", true)(l)
WithOptInFeature("allow-persistenced", true)(l)
lib = (*managementlib)(l)
case ModeNvml:
lib = (*nvmllib)(l)
Expand Down

0 comments on commit f44e31f

Please sign in to comment.