74 lines
2.2 KiB
Diff
74 lines
2.2 KiB
Diff
|
From de64230684e24deaaa33bc4b717aeccf1d76fa0b Mon Sep 17 00:00:00 2001
|
||
|
Message-Id: <de64230684e24deaaa33bc4b717aeccf1d76fa0b.1659958805.git.stefan@agner.ch>
|
||
|
In-Reply-To: <410089ea4bb8bf051a941febd087b0346b967a10.1659958805.git.stefan@agner.ch>
|
||
|
References: <410089ea4bb8bf051a941febd087b0346b967a10.1659958805.git.stefan@agner.ch>
|
||
|
From: Stefan Agner <stefan@agner.ch>
|
||
|
Date: Fri, 5 Aug 2022 17:52:26 +0200
|
||
|
Subject: [PATCH 07/11] Remove duplicated code
|
||
|
|
||
|
Signed-off-by: Stefan Agner <stefan@agner.ch>
|
||
|
---
|
||
|
libcontainer/specconv/spec_linux.go | 38 +++--------------------------
|
||
|
1 file changed, 4 insertions(+), 34 deletions(-)
|
||
|
|
||
|
diff --git a/libcontainer/specconv/spec_linux.go b/libcontainer/specconv/spec_linux.go
|
||
|
index d51ac5c5..456eafde 100644
|
||
|
--- a/libcontainer/specconv/spec_linux.go
|
||
|
+++ b/libcontainer/specconv/spec_linux.go
|
||
|
@@ -727,36 +727,6 @@ func CreateCgroupConfig(opts *CreateOpts, defaultDevs []*devices.Device) (*confi
|
||
|
if spec.Linux != nil {
|
||
|
r = spec.Linux.Resources
|
||
|
if r != nil {
|
||
|
- for i, d := range spec.Linux.Resources.Devices {
|
||
|
- var (
|
||
|
- t = "a"
|
||
|
- major = int64(-1)
|
||
|
- minor = int64(-1)
|
||
|
- )
|
||
|
- if d.Type != "" {
|
||
|
- t = d.Type
|
||
|
- }
|
||
|
- if d.Major != nil {
|
||
|
- major = *d.Major
|
||
|
- }
|
||
|
- if d.Minor != nil {
|
||
|
- minor = *d.Minor
|
||
|
- }
|
||
|
- if d.Access == "" {
|
||
|
- return nil, fmt.Errorf("device access at %d field cannot be empty", i)
|
||
|
- }
|
||
|
- dt, err := stringToCgroupDeviceRune(t)
|
||
|
- if err != nil {
|
||
|
- return nil, err
|
||
|
- }
|
||
|
- c.Resources.Devices = append(c.Resources.Devices, &devices.Rule{
|
||
|
- Type: dt,
|
||
|
- Major: major,
|
||
|
- Minor: minor,
|
||
|
- Permissions: devices.Permissions(d.Access),
|
||
|
- Allow: d.Allow,
|
||
|
- })
|
||
|
- }
|
||
|
if r.Memory != nil {
|
||
|
if r.Memory.Limit != nil {
|
||
|
c.Resources.Memory = *r.Memory.Limit
|
||
|
@@ -885,11 +855,11 @@ func CreateCgroupConfig(opts *CreateOpts, defaultDevs []*devices.Device) (*confi
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
- }
|
||
|
|
||
|
- err := CreateCgroupDeviceConfig(c.Resources, r, defaultDevs)
|
||
|
- if err != nil {
|
||
|
- return nil, err
|
||
|
+ err := CreateCgroupDeviceConfig(c.Resources, r, defaultDevs)
|
||
|
+ if err != nil {
|
||
|
+ return nil, err
|
||
|
+ }
|
||
|
}
|
||
|
|
||
|
return c, nil
|
||
|
--
|
||
|
2.37.1
|
||
|
|