Skip to content

Commit

Permalink
# This is a combination of 2 commits.
Browse files Browse the repository at this point in the history
# 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
  • Loading branch information
YuheiTakagawa committed Sep 26, 2018
1 parent f56bd1c commit 80bb1e9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libcontainer/container_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
Expand Down Expand Up @@ -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,
}
}
Expand Down
5 changes: 5 additions & 0 deletions libcontainer/factory_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path/filepath"

"github.com/opencontainers/runc/libcontainer/cgroups/rctl"
"github.com/opencontainers/runc/libcontainer/configs"
)

Expand Down Expand Up @@ -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}
Expand Down
6 changes: 5 additions & 1 deletion libcontainer/process_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"os"
"os/exec"
"syscall"

"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/system"
)

type initProcess struct {
cmd *exec.Cmd
container *freebsdContainer
config *initConfig
manager cgroups.Manager
fds []string
process *Process
}
Expand All @@ -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
}

Expand Down

0 comments on commit 80bb1e9

Please sign in to comment.