diff --git a/internal/config/config_test.go b/internal/config/config_test.go index f4501bf3..12683ae2 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -69,6 +69,9 @@ func TestGetConfig(t *testing.T) { CSV: csvModeConfig{ MountSpecPath: "/etc/nvidia-container-runtime/host-files-for-container.d", }, + CDI: cdiModeConfig{ + DefaultKind: "nvidia.com/gpu", + }, }, }, NVIDIACTKConfig: CTKConfig{ @@ -86,6 +89,7 @@ func TestGetConfig(t *testing.T) { "nvidia-container-runtime.log-level = \"debug\"", "nvidia-container-runtime.runtimes = [\"/some/runtime\",]", "nvidia-container-runtime.mode = \"not-auto\"", + "nvidia-container-runtime.modes.cdi.default-kind = \"example.vendor.com/device\"", "nvidia-container-runtime.modes.csv.mount-spec-path = \"/not/etc/nvidia-container-runtime/host-files-for-container.d\"", "nvidia-ctk.path = \"/foo/bar/nvidia-ctk\"", }, @@ -102,6 +106,9 @@ func TestGetConfig(t *testing.T) { CSV: csvModeConfig{ MountSpecPath: "/not/etc/nvidia-container-runtime/host-files-for-container.d", }, + CDI: cdiModeConfig{ + DefaultKind: "example.vendor.com/device", + }, }, }, NVIDIACTKConfig: CTKConfig{ @@ -121,6 +128,8 @@ func TestGetConfig(t *testing.T) { "log-level = \"debug\"", "runtimes = [\"/some/runtime\",]", "mode = \"not-auto\"", + "[nvidia-container-runtime.modes.cdi]", + "default-kind = \"example.vendor.com/device\"", "[nvidia-container-runtime.modes.csv]", "mount-spec-path = \"/not/etc/nvidia-container-runtime/host-files-for-container.d\"", "[nvidia-ctk]", @@ -139,6 +148,9 @@ func TestGetConfig(t *testing.T) { CSV: csvModeConfig{ MountSpecPath: "/not/etc/nvidia-container-runtime/host-files-for-container.d", }, + CDI: cdiModeConfig{ + DefaultKind: "example.vendor.com/device", + }, }, }, NVIDIACTKConfig: CTKConfig{ diff --git a/internal/config/runtime.go b/internal/config/runtime.go index a4a79d38..0248754e 100644 --- a/internal/config/runtime.go +++ b/internal/config/runtime.go @@ -50,6 +50,8 @@ type modesConfig struct { type cdiModeConfig struct { // SpecDirs allows for the default spec dirs for CDI to be overridden SpecDirs []string `toml:"spec-dirs"` + // DefaultKind sets the default kind to be used when constructing fully-qualified CDI device names + DefaultKind string `toml:"default-kind"` } type csvModeConfig struct { @@ -94,6 +96,9 @@ func GetDefaultRuntimeConfig() *RuntimeConfig { CSV: csvModeConfig{ MountSpecPath: "/etc/nvidia-container-runtime/host-files-for-container.d", }, + CDI: cdiModeConfig{ + DefaultKind: "nvidia.com/gpu", + }, }, }