diff --git a/cmd/nvidia-ctk/cdi/generate/generate.go b/cmd/nvidia-ctk/cdi/generate/generate.go index 9edd8598f..d112e51e9 100644 --- a/cmd/nvidia-ctk/cdi/generate/generate.go +++ b/cmd/nvidia-ctk/cdi/generate/generate.go @@ -73,6 +73,8 @@ type options struct { ignorePatterns []string } + noAllDevice bool + // the following are used for dependency injection during spec generation. nvmllib nvml.Interface } @@ -232,6 +234,12 @@ func (m command) build() *cli.Command { Destination: &opts.featureFlags, Sources: cli.EnvVars("NVIDIA_CTK_CDI_GENERATE_FEATURE_FLAGS"), }, + &cli.BoolFlag{ + Name: "no-all-device", + Usage: "Don't generate an `all` device for the resultant spec", + Destination: &opts.noAllDevice, + Sources: cli.EnvVars("NVIDIA_CTK_CDI_GENERATE_NO_ALL_DEVICE"), + }, }, } @@ -387,13 +395,18 @@ func (m command) generateSpecs(opts *options) ([]generatedSpecs, error) { spec.WithVendor(opts.vendor), spec.WithEdits(*commonEdits.ContainerEdits), spec.WithFormat(opts.format), - spec.WithMergedDeviceOptions( - transform.WithName(allDeviceName), - transform.WithSkipIfExists(true), - ), spec.WithPermissions(0644), } + if !opts.noAllDevice { + commonSpecOptions = append(commonSpecOptions, + spec.WithMergedDeviceOptions( + transform.WithName(allDeviceName), + transform.WithSkipIfExists(true), + ), + ) + } + fullSpec, err := spec.New( append(commonSpecOptions, spec.WithClass(opts.class),