From 80bb1e995d048da1fc30a64b179b0a43c8fb7368 Mon Sep 17 00:00:00 2001 From: YuheiTakagawa Date: Wed, 26 Sep 2018 13:31:36 +0900 Subject: [PATCH] # This is a combination of 2 commits. # This is the 1st commit message: [add] Call cgroups(rctl) parameter setting function from FreeBSD container # The commit message #1 will be skipped: # [tmp] go fmt factory_freebsd.go --- libcontainer/container_freebsd.go | 3 +++ libcontainer/factory_freebsd.go | 5 +++++ libcontainer/process_freebsd.go | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libcontainer/container_freebsd.go b/libcontainer/container_freebsd.go index 95c5a95d999..392ff1e0901 100644 --- a/libcontainer/container_freebsd.go +++ b/libcontainer/container_freebsd.go @@ -15,6 +15,7 @@ import ( "syscall" "time" + "github.com/opencontainers/runc/libcontainer/cgroups" "github.com/opencontainers/runc/libcontainer/configs" "github.com/opencontainers/runc/libcontainer/utils" ) @@ -30,6 +31,7 @@ type freebsdContainer struct { m sync.Mutex state containerState created time.Time + cgroupManager cgroups.Manager } // State represents a running container's state @@ -649,6 +651,7 @@ func (c *freebsdContainer) newInitProcess(p *Process, cmd *exec.Cmd) *initProces cmd: cmd, container: c, config: c.newInitConfig(p), + manager: c.cgroupManager, process: p, } } diff --git a/libcontainer/factory_freebsd.go b/libcontainer/factory_freebsd.go index 98936203627..25f9e473782 100644 --- a/libcontainer/factory_freebsd.go +++ b/libcontainer/factory_freebsd.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" + "github.com/opencontainers/runc/libcontainer/cgroups/rctl" "github.com/opencontainers/runc/libcontainer/configs" ) @@ -64,6 +65,10 @@ func (l *FreeBSDFactory) Create(id string, config *configs.Config) (Container, e id: id, root: containerRoot, config: config, + cgroupManager: &rctl.Manager{ + Cgroups: config.Cgroups, + Paths: nil, + }, } c.state = &stoppedState{c: c} diff --git a/libcontainer/process_freebsd.go b/libcontainer/process_freebsd.go index cd0f64174b5..cfd8f04e987 100644 --- a/libcontainer/process_freebsd.go +++ b/libcontainer/process_freebsd.go @@ -5,7 +5,7 @@ import ( "os" "os/exec" "syscall" - + "github.com/opencontainers/runc/libcontainer/cgroups" "github.com/opencontainers/runc/libcontainer/system" ) @@ -13,6 +13,7 @@ type initProcess struct { cmd *exec.Cmd container *freebsdContainer config *initConfig + manager cgroups.Manager fds []string process *Process } @@ -30,6 +31,9 @@ func (p *initProcess) start() error { if err := setupRlimits(p.config.Rlimits); err != nil { return newSystemErrorWithCause(err, "setting rlimits for ready process") } + if err := p.manager.Set(p.config.Config); err != nil { + return newSystemErrorWithCause(err, "setting cgroup config for ready") + } return nil }