mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-03-31 15:47:13 +00:00
Add runtime config option for CDI spec dirs
This change adds an nvidia-container-runtime.modes.cdi.spec-dirs config option that allows the default spec dirs to be overridden. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
a4258277e1
commit
83743e3613
@ -44,6 +44,12 @@ type RuntimeConfig struct {
|
|||||||
// modesConfig defines (optional) per-mode configs
|
// modesConfig defines (optional) per-mode configs
|
||||||
type modesConfig struct {
|
type modesConfig struct {
|
||||||
CSV csvModeConfig `toml:"csv"`
|
CSV csvModeConfig `toml:"csv"`
|
||||||
|
CDI cdiModeConfig `toml:"cdi"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type cdiModeConfig struct {
|
||||||
|
// SpecDirs allows for the default spec dirs for CDI to be overridden
|
||||||
|
SpecDirs []string `toml:"spec-dirs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type csvModeConfig struct {
|
type csvModeConfig struct {
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
|
|
||||||
type cdiModifier struct {
|
type cdiModifier struct {
|
||||||
logger *logrus.Logger
|
logger *logrus.Logger
|
||||||
|
specDirs []string
|
||||||
devices []string
|
devices []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,8 +47,14 @@ func NewCDIModifier(logger *logrus.Logger, cfg *config.Config, ociSpec oci.Spec)
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
specDirs := cdi.DefaultSpecDirs
|
||||||
|
if len(cfg.NVIDIAContainerRuntimeConfig.Modes.CDI.SpecDirs) > 0 {
|
||||||
|
specDirs = cfg.NVIDIAContainerRuntimeConfig.Modes.CDI.SpecDirs
|
||||||
|
}
|
||||||
|
|
||||||
m := cdiModifier{
|
m := cdiModifier{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
|
specDirs: specDirs,
|
||||||
devices: devices,
|
devices: devices,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +98,7 @@ func getDevicesFromSpec(ociSpec oci.Spec) ([]string, error) {
|
|||||||
// Modify loads the CDI registry and injects the specified CDI devices into the OCI runtime specification.
|
// Modify loads the CDI registry and injects the specified CDI devices into the OCI runtime specification.
|
||||||
func (m cdiModifier) Modify(spec *specs.Spec) error {
|
func (m cdiModifier) Modify(spec *specs.Spec) error {
|
||||||
registry := cdi.GetRegistry(
|
registry := cdi.GetRegistry(
|
||||||
|
cdi.WithSpecDirs(m.specDirs...),
|
||||||
cdi.WithAutoRefresh(false),
|
cdi.WithAutoRefresh(false),
|
||||||
)
|
)
|
||||||
if errs := registry.GetErrors(); len(errs) > 0 {
|
if errs := registry.GetErrors(); len(errs) > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user