Skip to content

Commit c69b4e4

Browse files
committed
Disable nvsandboxutils by default
This change disables the use of nvsandboxuitls for CDI spec generation by default. This prevents issues with specific (end-of-life) driver versions where consecutive calls would cause a cgo segmentation violation that could not be recovered from. The EnableNvsandboxutils feature flag can be specified when generating CDI specs (or instantiating the nvcdi API) to explicitly opt-in to using the nvsandboxutils library. Signed-off-by: Evan Lezar <[email protected]>
1 parent 4091718 commit c69b4e4

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

pkg/nvcdi/api.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,23 @@ 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.
86+
//
87+
// Deprecated: nvsandboxutils is now disabled by default. To opt-in use the
88+
// FeatureEnableNvsandboxutils instead.
8589
FeatureDisableNvsandboxUtils = FeatureFlag("disable-nvsandbox-utils")
90+
91+
// FeatureEnableNvsandboxutils explicitly enables the use of nvsandboxutils
92+
// when querying devices.
93+
// Specifying this overrides the FeatureDisableNvsandboxUtils feature if
94+
// also specified.
95+
// This is explicitly opt-in due to issue in the 565 driver.
96+
// Once this driver is no longer common, the default behaviour could be
97+
// changed.
98+
FeatureEnableNvsandboxutils = FeatureFlag("enable-nvsandboxutils")
99+
86100
// FeatureEnableCoherentAnnotations enables the addition of annotations
87101
// coherent or non-coherent devices.
88102
FeatureEnableCoherentAnnotations = FeatureFlag("enable-coherent-annotations")

pkg/nvcdi/lib.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func (l *nvcdilib) getNvmlLib() nvml.Interface {
239239
// getNvsandboxUtilsLib returns the nvsandboxutilslib to use for CDI spec
240240
// generation.
241241
func (l *nvcdilib) getNvsandboxUtilsLib() nvsandboxutils.Interface {
242-
if l.featureFlags[FeatureDisableNvsandboxUtils] {
242+
if !l.featureFlags[FeatureEnableNvsandboxutils] {
243243
return nil
244244
}
245245
if l.nvsandboxutilslib != nil {

pkg/nvcdi/options.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ func WithFeatureFlags[T string | FeatureFlag](featureFlags ...T) Option {
184184
}
185185
for _, featureFlag := range featureFlags {
186186
o.featureFlags[FeatureFlag(featureFlag)] = true
187+
// If FeatureEnableNvsandboxutils is specified, we explcitly set
188+
// FeatureDisableNvsandboxUtils to false so that to have consistency.
189+
// Note that it is not needed to set FeatureEnableNvsandboxutils to
190+
// false if FeatureDisableNvsandboxUtils is specified since this is
191+
// the default behaviour -- unless a user explicitly opts-in.
192+
if featureFlag == T(FeatureEnableNvsandboxutils) {
193+
o.featureFlags[FeatureDisableNvsandboxUtils] = false
194+
}
187195
}
188196
}
189197
}

0 commit comments

Comments
 (0)