diff options
author | Sebastian Jug <seb@stianj.ug> | 2021-03-29 20:21:00 -0400 |
---|---|---|
committer | Sebastian Jug <seb@stianj.ug> | 2021-04-20 09:18:52 -0400 |
commit | db7cff8c86a35a4b1971c3fbb2365eff9cc205d4 (patch) | |
tree | 3dc20b52f6a8b2de4acf8cb99ebff81776680959 /libpod/container_internal_linux.go | |
parent | cf2c3a1f13710014892804aacf855cd6b001a5ea (diff) | |
download | podman-db7cff8c86a35a4b1971c3fbb2365eff9cc205d4.tar.gz podman-db7cff8c86a35a4b1971c3fbb2365eff9cc205d4.tar.bz2 podman-db7cff8c86a35a4b1971c3fbb2365eff9cc205d4.zip |
Add support for CDI device configuration
- Persist CDIDevices in container config
- Add e2e test
- Log HasDevice error and add additional condition for safety
Signed-off-by: Sebastian Jug <seb@stianj.ug>
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r-- | libpod/container_internal_linux.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 1986f7438..f4762b5ff 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -20,6 +20,7 @@ import ( "time" metadata "github.com/checkpoint-restore/checkpointctl/lib" + cdi "github.com/container-orchestrated-devices/container-device-interface/pkg" cnitypes "github.com/containernetworking/cni/pkg/types/current" "github.com/containernetworking/plugins/pkg/ns" "github.com/containers/buildah/pkg/chrootuser" @@ -704,6 +705,13 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { } g.SetLinuxCgroupsPath(cgroupPath) + // Warning: CDI may alter g.Config in place. + if len(c.config.CDIDevices) > 0 { + if err = cdi.UpdateOCISpecForDevices(g.Config, c.config.CDIDevices); err != nil { + return nil, errors.Wrapf(err, "error setting up CDI devices") + } + } + // Mounts need to be sorted so paths will not cover other paths mounts := sortMounts(g.Mounts()) g.ClearMounts() |