From ab4b825f8c26ae344f1f8511949842cd5197c89a Mon Sep 17 00:00:00 2001 From: Rajasekaran Date: Sun, 23 Aug 2015 16:47:31 +0530 Subject: [PATCH] Adding rlimit in spec Signed-off-by: Rajasekaran Removing return type Signed-off-by: Rajasekaran --- spec.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec.go b/spec.go index f0e0c449..595387a2 100644 --- a/spec.go +++ b/spec.go @@ -113,6 +113,14 @@ var specCommand = cli.Command{ "KILL", "NET_BIND_SERVICE", }, + Rlimits: []specs.Rlimit{ + { + Type: syscall.RLIMIT_NOFILE, + Hard: uint64(1024), + Soft: uint64(1024), + }, + }, + Devices: []specs.Device{ { Type: 'c', @@ -268,6 +276,9 @@ func createLibcontainerConfig(cgroupName string, spec *specs.LinuxSpec) (*config if err := setupUserNamespace(spec, config); err != nil { return nil, err } + for _, rlimit := range spec.Linux.Rlimits { + config.Rlimits = append(config.Rlimits, createLibContainerRlimit(rlimit)) + } c, err := createCgroupConfig(cgroupName, spec, config.Devices) if err != nil { return nil, err @@ -409,6 +420,14 @@ func setupUserNamespace(spec *specs.LinuxSpec, config *configs.Config) error { return nil } +func createLibContainerRlimit(rlimit specs.Rlimit) configs.Rlimit { + return configs.Rlimit{ + Type: int(rlimit.Type), + Hard: uint64(rlimit.Hard), + Soft: uint64(rlimit.Soft), + } +} + // parseMountOptions parses the string and returns the flags and any mount data that // it contains. func parseMountOptions(options string) (int, string) {