Generate v0.4.0 CDI spec

This change generates a v0.4.0 CDI spec instead of a v0.5.0 spec.
This allows older versions of podman, for example, to be used.

This requires that the device names do not start on a numeric character
and that the HostPath for a device is unspecified.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2022-10-07 16:10:45 +02:00
parent 568896742b
commit dfa041991f
2 changed files with 3 additions and 5 deletions

View File

@ -139,7 +139,7 @@ func (m command) generateSpec() (*specs.Spec, error) {
devicelib := device.New(device.WithNvml(nvmllib))
spec := specs.Spec{
Version: specs.CurrentVersion,
Version: "0.4.0",
Kind: "nvidia.com/gpu",
ContainerEdits: specs.ContainerEdits{},
}
@ -210,8 +210,6 @@ func generateEditsForDevice(name string, d deviceInfo) (specs.Device, error) {
for _, p := range deviceNodePaths {
deviceNode := specs.DeviceNode{
Path: p,
// TODO: Set the host path dependent on the root
HostPath: p,
}
deviceNodes = append(deviceNodes, &deviceNode)
}

View File

@ -42,11 +42,11 @@ var _ deviceInfo = (*nvmlDevice)(nil)
var _ deviceInfo = (*nvmlMigDevice)(nil)
func newGPUDevice(i int, gpu device.Device) (string, nvmlDevice) {
return fmt.Sprintf("%v", i), nvmlDevice{gpu}
return fmt.Sprintf("gpu%v", i), nvmlDevice{gpu}
}
func newMigDevice(i int, j int, mig device.MigDevice) (string, nvmlMigDevice) {
return fmt.Sprintf("%v:%v", i, j), nvmlMigDevice{mig}
return fmt.Sprintf("mig%v:%v", i, j), nvmlMigDevice{mig}
}
// GetUUID returns the UUID of the device