Skip to content

Commit f44e31f

Browse files
committed
Allow inclusion of sockets in CDI specification
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>
1 parent 4d9924d commit f44e31f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

cmd/nvidia-ctk/cdi/generate/generate.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ type options struct {
6060
files cli.StringSlice
6161
ignorePatterns cli.StringSlice
6262
}
63+
64+
withFabricmanager bool
65+
withPersistenced bool
6366
}
6467

6568
// NewCommand constructs a generate-cdi command with the specified logger
@@ -169,6 +172,16 @@ func (m command) build() *cli.Command {
169172
Usage: "Specify a pattern the CSV mount specifications.",
170173
Destination: &opts.csv.ignorePatterns,
171174
},
175+
&cli.BoolFlag{
176+
Name: "with-fabricmanager",
177+
Usage: "Include the nvidia-fabricmanager socket in the generated CDI specification.",
178+
Destination: &opts.withFabricmanager,
179+
},
180+
&cli.BoolFlag{
181+
Name: "with-persistenced",
182+
Usage: "Include the nvidia-persistenced socket in the generated CDI specification.",
183+
Destination: &opts.withPersistenced,
184+
},
172185
}
173186

174187
return &c
@@ -273,6 +286,8 @@ func (m command) generateSpec(opts *options) (spec.Interface, error) {
273286
nvcdi.WithLibrarySearchPaths(opts.librarySearchPaths.Value()),
274287
nvcdi.WithCSVFiles(opts.csv.files.Value()),
275288
nvcdi.WithCSVIgnorePatterns(opts.csv.ignorePatterns.Value()),
289+
nvcdi.WithOptInFeature("allow-fabricmanager", opts.withFabricmanager),
290+
nvcdi.WithOptInFeature("allow-persistenced", opts.withPersistenced),
276291
)
277292
if err != nil {
278293
return nil, fmt.Errorf("failed to create CDI library: %v", err)

pkg/nvcdi/lib.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ func New(opts ...Option) (Interface, error) {
132132
if l.vendor == "" {
133133
l.vendor = "management.nvidia.com"
134134
}
135+
// For management specifications we always allow the fabricmanager and
136+
// persistenced sockets.
137+
WithOptInFeature("allow-fabricmanager", true)(l)
138+
WithOptInFeature("allow-persistenced", true)(l)
135139
lib = (*managementlib)(l)
136140
case ModeNvml:
137141
lib = (*nvmllib)(l)

0 commit comments

Comments
 (0)