Add --cdi-enabled option to control generating CDI spec

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar
2023-03-13 18:18:54 +02:00
parent 92ea8be309
commit 08ef242afb
4 changed files with 12 additions and 3 deletions

View File

@@ -56,6 +56,7 @@ type options struct {
ContainerCLIDebug string
toolkitRoot string
cdiEnabled bool
cdiOutputDir string
cdiKind string
cdiVendor string
@@ -171,6 +172,13 @@ func main() {
Destination: &opts.toolkitRoot,
EnvVars: []string{"TOOLKIT_ROOT"},
},
&cli.BoolFlag{
Name: "cdi-enabled",
Aliases: []string{"enable-cdi"},
Usage: "enable the generation of a CDI specification",
Destination: &opts.cdiEnabled,
EnvVars: []string{"CDI_ENABLED", "ENABLE_CDI"},
},
&cli.StringFlag{
Name: "cdi-output-dir",
Usage: "the directory where the CDI output files are to be written. If this is set to '', no CDI specification is generated.",
@@ -592,6 +600,9 @@ func createDirectories(dir ...string) error {
// generateCDISpec generates a CDI spec for use in managemnt containers
func generateCDISpec(opts *options, nvidiaCTKPath string) error {
if !opts.cdiEnabled {
return nil
}
if opts.cdiOutputDir == "" {
log.Info("Skipping CDI spec generation (no output directory specified)")
return nil