Skip to content

Commit c171e65

Browse files
authored
Merge pull request #1419 from elezar/make-nvsandbox-utils-opt-in
Allow nvcdi feature flags to be set for the `jit-cdi` mode
2 parents 754cfa7 + a37bab4 commit c171e65

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

internal/config/runtime.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package config
1818

19+
import "github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi"
20+
1921
// RuntimeConfig stores the config options for the NVIDIA Container Runtime
2022
type RuntimeConfig struct {
2123
DebugFilePath string `toml:"debug"`
@@ -31,6 +33,7 @@ type RuntimeConfig struct {
3133
type modesConfig struct {
3234
CSV csvModeConfig `toml:"csv"`
3335
CDI cdiModeConfig `toml:"cdi"`
36+
JitCDI jitCDIModeConfig `toml:"jit-cdi,omitempty"`
3437
Legacy legacyModeConfig `toml:"legacy"`
3538
}
3639

@@ -43,6 +46,11 @@ type cdiModeConfig struct {
4346
AnnotationPrefixes []string `toml:"annotation-prefixes"`
4447
}
4548

49+
type jitCDIModeConfig struct {
50+
// NVCDIFeatureFlags sets a list of nvcdi features explicitly.
51+
NVCDIFeatureFlags []nvcdi.FeatureFlag `toml:"nvcdi-feature-flags,omitempty"`
52+
}
53+
4654
type csvModeConfig struct {
4755
MountSpecPath string `toml:"mount-spec-path"`
4856
}

internal/modifier/cdi.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ func newAutomaticCDISpecModifier(logger logger.Interface, cfg *config.Config, de
192192
nvcdi.WithVendor(automaticDeviceVendor),
193193
nvcdi.WithClass(perModeDeviceClass[mode]),
194194
nvcdi.WithMode(mode),
195+
nvcdi.WithFeatureFlags(cfg.NVIDIAContainerRuntimeConfig.Modes.JitCDI.NVCDIFeatureFlags...),
195196
)
196197
if err != nil {
197198
return nil, fmt.Errorf("failed to construct CDI library for mode %q: %w", mode, err)

pkg/nvcdi/api.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ const (
8080
// FeatureEnableExplicitDriverLibraries enables the inclusion of a list of
8181
// explicit driver libraries.
8282
FeatureEnableExplicitDriverLibraries = FeatureFlag("enable-explicit-driver-libraries")
83+
8384
// FeatureDisableNvsandboxUtils disables the use of nvsandboxutils when
8485
// querying devices.
85-
FeatureDisableNvsandboxUtils = FeatureFlag("disable-nvsandbox-utils")
86+
FeatureDisableNvsandboxUtils = FeatureFlag("disable-nvsandboxutils")
87+
8688
// FeatureEnableCoherentAnnotations enables the addition of annotations
8789
// coherent or non-coherent devices.
8890
FeatureEnableCoherentAnnotations = FeatureFlag("enable-coherent-annotations")

pkg/nvcdi/options.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ func WithFeatureFlags[T string | FeatureFlag](featureFlags ...T) Option {
183183
o.featureFlags = make(map[FeatureFlag]bool)
184184
}
185185
for _, featureFlag := range featureFlags {
186+
// The initial release of the FeatureDisableNvsandboxUtils feature
187+
// flag included a typo which we handle here.
188+
if string(featureFlag) == "disable-nvsandbox-utils" {
189+
featureFlag = T(FeatureDisableNvsandboxUtils)
190+
}
186191
o.featureFlags[FeatureFlag(featureFlag)] = true
187192
}
188193
}

0 commit comments

Comments
 (0)