Add Relative function to Locator interface

This adds a Relative function to the Locator interface and uses
this to determine the host and container paths for located files
(and devices). This ensures that the root (e.g. the nvidia driver
root) is stripped from the container path.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar
2022-06-29 16:50:17 +02:00
parent 25fd1aaf7e
commit fd135f1a8b
9 changed files with 138 additions and 24 deletions

View File

@@ -37,6 +37,9 @@ func (d device) toEdits() *cdi.ContainerEdits {
// toSpec converts a discovered Device to a CDI Spec Device. Note
// that missing info is filled in when edits are applied by querying the Device node.
func (d device) toSpec() *specs.DeviceNode {
// NOTE: We may want to mirror what is done in cri-o w.r.t src (Host) and dst (Container) paths
// to ensure that the right permissions are included.
// https://github.com/cri-o/cri-o/blob/ca3bb80a3dda0440659fcf8da8ed6f23211de94e/internal/config/device/device.go#L93
s := specs.DeviceNode{
Path: d.Path,
}