daemon.WithDevices(): use containerd's HostDevices()

Trying to reduce the use of libcontainer/devices, as it's considered
to be an "internal" package by runc.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-12-01 12:06:59 +01:00
parent 93d560d5b3
commit 9d9b8e0cf3
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -27,7 +27,6 @@ import (
"github.com/moby/sys/mount"
"github.com/moby/sys/mountinfo"
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/devices"
"github.com/opencontainers/runc/libcontainer/user"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
@ -874,13 +873,11 @@ func WithDevices(daemon *Daemon, c *container.Container) coci.SpecOpts {
devPermissions := s.Linux.Resources.Devices
if c.HostConfig.Privileged && !userns.RunningInUserNS() {
hostDevices, err := devices.HostDevices()
hostDevices, err := coci.HostDevices()
if err != nil {
return err
}
for _, d := range hostDevices {
devs = append(devs, oci.Device(d))
}
devs = append(devs, hostDevices...)
// adding device mappings in privileged containers
for _, deviceMapping := range c.HostConfig.Devices {