mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Add modifier to inject Tegra platform files
This change adds a modifier to that injects the tegra platform files * /etc/nv_tegra_release * /sys/devices/soc0/family allowing these files to be used for platform detection in a containerized context such as the GPU device plugin. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
e5dadf34d9
commit
ffd6ec3c54
@ -77,10 +77,16 @@ func newSpecModifier(logger *logrus.Logger, cfg *config.Config, ociSpec oci.Spec
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tegraModifier, err := modifier.NewTegraPlatformFiles(logger)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
modifiers := modifier.Merge(
|
modifiers := modifier.Merge(
|
||||||
modeModifier,
|
modeModifier,
|
||||||
gdsModifier,
|
gdsModifier,
|
||||||
mofedModifier,
|
mofedModifier,
|
||||||
|
tegraModifier,
|
||||||
)
|
)
|
||||||
return modifiers, nil
|
return modifiers, nil
|
||||||
}
|
}
|
||||||
|
45
internal/modifier/tegra.go
Normal file
45
internal/modifier/tegra.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
**/
|
||||||
|
|
||||||
|
package modifier
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/discover"
|
||||||
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/info"
|
||||||
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/lookup"
|
||||||
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/oci"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewTegraPlatformFiles creates a modifier to inject the Tegra platform files into a container.
|
||||||
|
func NewTegraPlatformFiles(logger *logrus.Logger) (oci.SpecModifier, error) {
|
||||||
|
isTegra, _ := info.IsTegraSystem()
|
||||||
|
if !isTegra {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
tegraSystemMounts := discover.NewMounts(
|
||||||
|
logger,
|
||||||
|
lookup.NewFileLocator(logger, ""),
|
||||||
|
"",
|
||||||
|
[]string{
|
||||||
|
"/etc/nv_tegra_release",
|
||||||
|
"/sys/devices/soc0/family",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
return NewModifierFromDiscoverer(logger, tegraSystemMounts)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user