From ffe768ba41ea21bf1f97fe31c7e610f4f5335db2 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 4 Nov 2025 16:56:45 +0100 Subject: [PATCH 1/2] Allow nvcdi FeatureFlags to be configured for jit-cdi mode This change allows users the posibility to explicitly specify feature flags for using the `jit-cdi` mode. This allows, for example, for users to opt-in to use nvsandboxutils in the default mode in addition to when generating CDI specs explicitly. Signed-off-by: Evan Lezar --- internal/config/runtime.go | 8 ++++++++ internal/modifier/cdi.go | 1 + 2 files changed, 9 insertions(+) diff --git a/internal/config/runtime.go b/internal/config/runtime.go index 315f23ba5..5df04e90f 100644 --- a/internal/config/runtime.go +++ b/internal/config/runtime.go @@ -16,6 +16,8 @@ package config +import "github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi" + // RuntimeConfig stores the config options for the NVIDIA Container Runtime type RuntimeConfig struct { DebugFilePath string `toml:"debug"` @@ -31,6 +33,7 @@ type RuntimeConfig struct { type modesConfig struct { CSV csvModeConfig `toml:"csv"` CDI cdiModeConfig `toml:"cdi"` + JitCDI jitCDIModeConfig `toml:"jit-cdi,omitempty"` Legacy legacyModeConfig `toml:"legacy"` } @@ -43,6 +46,11 @@ type cdiModeConfig struct { AnnotationPrefixes []string `toml:"annotation-prefixes"` } +type jitCDIModeConfig struct { + // NVCDIFeatureFlags sets a list of nvcdi features explicitly. + NVCDIFeatureFlags []nvcdi.FeatureFlag `toml:"nvcdi-feature-flags,omitempty"` +} + type csvModeConfig struct { MountSpecPath string `toml:"mount-spec-path"` } diff --git a/internal/modifier/cdi.go b/internal/modifier/cdi.go index c7cd8c945..97f562d8c 100644 --- a/internal/modifier/cdi.go +++ b/internal/modifier/cdi.go @@ -192,6 +192,7 @@ func newAutomaticCDISpecModifier(logger logger.Interface, cfg *config.Config, de nvcdi.WithVendor(automaticDeviceVendor), nvcdi.WithClass(perModeDeviceClass[mode]), nvcdi.WithMode(mode), + nvcdi.WithFeatureFlags(cfg.NVIDIAContainerRuntimeConfig.Modes.JitCDI.NVCDIFeatureFlags...), ) if err != nil { return nil, fmt.Errorf("failed to construct CDI library for mode %q: %w", mode, err) From a37bab416241a23af7cc53e80c83e2d3dea4c280 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 4 Nov 2025 16:56:23 +0100 Subject: [PATCH 2/2] Correct typo in nvsandboxutils feature flag This original implementation of the FeatureDisableNvsandboxUtils feature flag included a dash that was not supposed to be there. This change updates the feature flag's string representation to disable-nvsandboxutils. Special handling is included for users that may still use the old string value (e.g. for the nvidia-ctk cdi generate command), but no changes are expected for users of the nvcdi API. Signed-off-by: Evan Lezar --- pkg/nvcdi/api.go | 4 +++- pkg/nvcdi/options.go | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/nvcdi/api.go b/pkg/nvcdi/api.go index 03135a0c6..fce32bc88 100644 --- a/pkg/nvcdi/api.go +++ b/pkg/nvcdi/api.go @@ -80,9 +80,11 @@ const ( // FeatureEnableExplicitDriverLibraries enables the inclusion of a list of // explicit driver libraries. FeatureEnableExplicitDriverLibraries = FeatureFlag("enable-explicit-driver-libraries") + // FeatureDisableNvsandboxUtils disables the use of nvsandboxutils when // querying devices. - FeatureDisableNvsandboxUtils = FeatureFlag("disable-nvsandbox-utils") + FeatureDisableNvsandboxUtils = FeatureFlag("disable-nvsandboxutils") + // FeatureEnableCoherentAnnotations enables the addition of annotations // coherent or non-coherent devices. FeatureEnableCoherentAnnotations = FeatureFlag("enable-coherent-annotations") diff --git a/pkg/nvcdi/options.go b/pkg/nvcdi/options.go index 550b18bad..eab27f05d 100644 --- a/pkg/nvcdi/options.go +++ b/pkg/nvcdi/options.go @@ -183,6 +183,11 @@ func WithFeatureFlags[T string | FeatureFlag](featureFlags ...T) Option { o.featureFlags = make(map[FeatureFlag]bool) } for _, featureFlag := range featureFlags { + // The initial release of the FeatureDisableNvsandboxUtils feature + // flag included a typo which we handle here. + if string(featureFlag) == "disable-nvsandbox-utils" { + featureFlag = T(FeatureDisableNvsandboxUtils) + } o.featureFlags[FeatureFlag(featureFlag)] = true } }