diff --git a/pkg/adaptation/result.go b/pkg/adaptation/result.go index da84110a..6a44906f 100644 --- a/pkg/adaptation/result.go +++ b/pkg/adaptation/result.go @@ -693,6 +693,11 @@ func (r *result) adjustResources(resources *LinuxResources, plugin string) error reply.HugepageLimits = append(reply.HugepageLimits, l) } + for _, d := range resources.Devices { + container.Devices = append(container.Devices, d) + reply.Devices = append(reply.Devices, d) + } + if len(resources.Unified) != 0 { for k, v := range resources.Unified { if err := r.owners.claimUnified(id, k, plugin); err != nil { diff --git a/pkg/api/resources.go b/pkg/api/resources.go index cf3c9e9d..d208bd97 100644 --- a/pkg/api/resources.go +++ b/pkg/api/resources.go @@ -189,6 +189,15 @@ func (r *LinuxResources) Copy() *LinuxResources { } o.BlockioClass = String(r.BlockioClass) o.RdtClass = String(r.RdtClass) + for _, d := range r.Devices { + o.Devices = append(o.Devices, &LinuxDeviceCgroup{ + Allow: d.Allow, + Type: d.Type, + Access: d.Access, + Major: Int64(d.Major), + Minor: Int64(d.Minor), + }) + } return o } diff --git a/pkg/runtime-tools/generate/generate.go b/pkg/runtime-tools/generate/generate.go index debb7387..9a6a70a8 100644 --- a/pkg/runtime-tools/generate/generate.go +++ b/pkg/runtime-tools/generate/generate.go @@ -276,6 +276,9 @@ func (g *Generator) AdjustResources(r *nri.LinuxResources) error { if v := r.GetPids(); v != nil { g.SetLinuxResourcesPidsLimit(v.GetLimit()) } + for _, d := range r.Devices { + g.AddLinuxResourcesDevice(d.Allow, d.Type, d.Major.Get(), d.Minor.Get(), d.Access) + } if g.checkResources != nil { if err := g.checkResources(g.Config.Linux.Resources); err != nil { return fmt.Errorf("failed to adjust resources in OCI Spec: %w", err)