mirror of
				https://github.com/NVIDIA/nvidia-container-toolkit
				synced 2025-06-26 18:18:24 +00:00 
			
		
		
		
	Add ability to configure CDI kind with 'nvidia-ctk cdi generate'
Signed-off-by: Christopher Desiniotis <cdesiniotis@nvidia.com>
This commit is contained in:
		
							parent
							
								
									92d82ceaee
								
							
						
					
					
						commit
						7f5c9abc1e
					
				| @ -49,6 +49,9 @@ type config struct { | ||||
| 	targetDriverRoot   string | ||||
| 	nvidiaCTKPath      string | ||||
| 	mode               string | ||||
| 	kind               string | ||||
| 	vendor             string | ||||
| 	class              string | ||||
| } | ||||
| 
 | ||||
| // NewCommand constructs a generate-cdi command with the specified logger
 | ||||
| @ -116,6 +119,13 @@ func (m command) build() *cli.Command { | ||||
| 			Value:       "", | ||||
| 			Destination: &cfg.targetDriverRoot, | ||||
| 		}, | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:        "kind", | ||||
| 			Aliases:     []string{"cdi-kind"}, | ||||
| 			Usage:       "the vendor string to use for the generated CDI specification.", | ||||
| 			Value:       "nvidia.com/gpu", | ||||
| 			Destination: &cfg.kind, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	return &c | ||||
| @ -161,6 +171,16 @@ func (m command) validateFlags(c *cli.Context, cfg *config) error { | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	vendor, class := cdi.ParseQualifier(cfg.kind) | ||||
| 	if err := cdi.ValidateVendorName(vendor); err != nil { | ||||
| 		return fmt.Errorf("invalid CDI vendor name: %v", err) | ||||
| 	} | ||||
| 	if err := cdi.ValidateClassName(class); err != nil { | ||||
| 		return fmt.Errorf("invalid CDI class name: %v", err) | ||||
| 	} | ||||
| 	cfg.vendor = vendor | ||||
| 	cfg.class = class | ||||
| 
 | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| @ -236,8 +256,8 @@ func (m command) generateSpec(cfg *config) (spec.Interface, error) { | ||||
| 	} | ||||
| 
 | ||||
| 	spec, err := spec.New( | ||||
| 		spec.WithVendor("nvidia.com"), | ||||
| 		spec.WithClass("gpu"), | ||||
| 		spec.WithVendor(cfg.vendor), | ||||
| 		spec.WithClass(cfg.class), | ||||
| 		spec.WithDeviceSpecs(deviceSpecs), | ||||
| 		spec.WithEdits(*commonEdits.ContainerEdits), | ||||
| 		spec.WithFormat(cfg.format), | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user