Skip to content

Commit ae477f1

Browse files
committed
libct/configs: move cgroup stuff to libct/cgroups
We have quite a few external users of libcontainer/cgroups packages, and they all have to depend on libcontainer/configs as well. Let's move cgroup-related configuration to libcontainer/croups. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 85c7c99 commit ae477f1

File tree

8 files changed

+38
-14
lines changed

8 files changed

+38
-14
lines changed

libcontainer/cgroups/cgroups.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package cgroups
22

33
import (
44
"errors"
5-
6-
"github.com/opencontainers/runc/libcontainer/configs"
75
)
86

97
var (
@@ -21,8 +19,8 @@ var (
2119
// [github.com/opencontainers/runc/libcontainer/cgroups/devices]
2220
// package is imported, it is set to nil, so cgroup managers can't
2321
// manage devices.
24-
DevicesSetV1 func(path string, r *configs.Resources) error
25-
DevicesSetV2 func(path string, r *configs.Resources) error
22+
DevicesSetV1 func(path string, r *Resources) error
23+
DevicesSetV2 func(path string, r *Resources) error
2624
)
2725

2826
type Manager interface {
@@ -42,7 +40,7 @@ type Manager interface {
4240
GetStats() (*Stats, error)
4341

4442
// Freeze sets the freezer cgroup to the specified state.
45-
Freeze(state configs.FreezerState) error
43+
Freeze(state FreezerState) error
4644

4745
// Destroy removes cgroup.
4846
Destroy() error
@@ -54,7 +52,7 @@ type Manager interface {
5452
// Set sets cgroup resources parameters/limits. If the argument is nil,
5553
// the resources specified during Manager creation (or the previous call
5654
// to Set) are used.
57-
Set(r *configs.Resources) error
55+
Set(r *Resources) error
5856

5957
// GetPaths returns cgroup path(s) to save in a state file in order to
6058
// restore later.
@@ -67,10 +65,10 @@ type Manager interface {
6765
GetPaths() map[string]string
6866

6967
// GetCgroups returns the cgroup data as configured.
70-
GetCgroups() (*configs.Cgroup, error)
68+
GetCgroups() (*Cgroup, error)
7169

7270
// GetFreezerState retrieves the current FreezerState of the cgroup.
73-
GetFreezerState() (configs.FreezerState, error)
71+
GetFreezerState() (FreezerState, error)
7472

7573
// Exists returns whether the cgroup path exists or not.
7674
Exists() bool

libcontainer/configs/blkio_device.go renamed to libcontainer/cgroups/config_blkio_device.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package configs
1+
package cgroups
22

33
import "fmt"
44

libcontainer/configs/hugepage_limit.go renamed to libcontainer/cgroups/config_hugepages.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package configs
1+
package cgroups
22

33
type HugepageLimit struct {
44
// which type of hugepage to limit.

libcontainer/configs/interface_priority_map.go renamed to libcontainer/cgroups/config_ifprio_map.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package configs
1+
package cgroups
22

33
import (
44
"fmt"

libcontainer/configs/cgroup_linux.go renamed to libcontainer/cgroups/config_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package configs
1+
package cgroups
22

33
import (
44
systemdDbus "github.com/coreos/go-systemd/v22/dbus"

libcontainer/configs/rdma.go renamed to libcontainer/cgroups/config_rdma.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package configs
1+
package cgroups
22

33
// LinuxRdma for Linux cgroup 'rdma' resource management (Linux 4.11)
44
type LinuxRdma struct {

libcontainer/configs/cgroup_unsupported.go renamed to libcontainer/cgroups/config_unsupported.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//go:build !linux
22

3-
package configs
3+
package cgroups
44

55
// Cgroup holds properties of a cgroup on Linux
66
// TODO Windows: This can ultimately be entirely factored out on Windows as
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package configs // Deprecated: use [github.com/opencontainers/runc/libcontainer/cgroups].
2+
3+
import "github.com/opencontainers/runc/libcontainer/cgroups"
4+
5+
type (
6+
Cgroup = cgroups.Cgroup
7+
Resources = cgroups.Resources
8+
FreezerState = cgroups.FreezerState
9+
LinuxRdma = cgroups.LinuxRdma
10+
BlockIODevice = cgroups.BlockIODevice
11+
WeightDevice = cgroups.WeightDevice
12+
ThrottleDevice = cgroups.ThrottleDevice
13+
HugepageLimit = cgroups.HugepageLimit
14+
IfPrioMap = cgroups.IfPrioMap
15+
)
16+
17+
const (
18+
Undefined = cgroups.Undefined
19+
Frozen = cgroups.Frozen
20+
Thawed = cgroups.Thawed
21+
)
22+
23+
var (
24+
NewWeightDevice = cgroups.NewWeightDevice
25+
NewThrottleDevice = cgroups.NewThrottleDevice
26+
)

0 commit comments

Comments
 (0)