Use cgroups_mem_max to enable memory limits
authorJagger <robert@swiecki.net>
Sun, 19 Jun 2016 16:12:15 +0000 (18:12 +0200)
committerJagger <robert@swiecki.net>
Sun, 19 Jun 2016 16:12:15 +0000 (18:12 +0200)
cgroup.c
cmdline.c

index cb1c32230f20c9948d5b39514bc9bc1935dd36ee..6e0c0320d563ca95153e7a61bf1dbbc48c832551 100644 (file)
--- a/cgroup.c
+++ b/cgroup.c
@@ -38,7 +38,7 @@
 
 bool cgroupInitNsFromParent(struct nsjconf_t *nsjconf, pid_t pid)
 {
-       if (nsjconf->clone_newcgroup == false) {
+       if (nsjconf->cgroup_mem_max == (size_t) 0) {
                return true;
        }
 
@@ -84,7 +84,7 @@ bool cgroupInitNsFromParent(struct nsjconf_t *nsjconf, pid_t pid)
 
 void cgroupFinishFromParent(struct nsjconf_t *nsjconf, pid_t pid)
 {
-       if (nsjconf->clone_newcgroup == false) {
+       if (nsjconf->cgroup_mem_max == (size_t) 0) {
                return;
        }
 
index e9d299ce2c41c29861e2c5fc7b618a4322b65212..61bb7a38c3a5f901d79fb572f1e8d161951239c1 100644 (file)
--- a/cmdline.c
+++ b/cmdline.c
@@ -376,9 +376,9 @@ bool cmdlineParse(int argc, char *argv[], struct nsjconf_t * nsjconf)
                {{"tmpfsmount", required_argument, NULL, 'T'}, "List of mountpoints to be mounted as RW/tmpfs inside the container. Can be specified multiple times. Supports 'dest' syntax"},
                {{"tmpfs_size", required_argument, NULL, 0x0602}, "Number of bytes to allocate for tmpfsmounts (default: 4194304)"},
                {{"disable_proc", no_argument, NULL, 0x0603}, "Disable mounting /proc in the jail"},
-               {{"cgroup_mem_mount", required_argument, NULL, 0x0801}, "Where to mount memory cgroup FS (default: '/sys/fs/cgroup/memory'"},
-               {{"cgroup_mem_parent", required_argument, NULL, 0x0802}, "Which memory cgroup to use as parent (default: 'NSJAIL')"},
-               {{"cgroup_mem_max", required_argument, NULL, 0x0803}, "Maximum number of bytes to use in the group"},
+               {{"cgroup_mem_max", required_argument, NULL, 0x0801}, "Maximum number of bytes to use in the group"},
+               {{"cgroup_mem_mount", required_argument, NULL, 0x0802}, "Location of memory cgroup FS (default: '/sys/fs/cgroup/memory'"},
+               {{"cgroup_mem_parent", required_argument, NULL, 0x0803}, "Which memory cgroup to use as parent (default: 'NSJAIL')"},
                {{"iface_no_lo", no_argument, NULL, 0x700}, "Don't bring up the 'lo' interface"},
                {{"iface", required_argument, NULL, 'I'}, "Interface which will be cloned (MACVLAN) and put inside the subprocess' namespace as 'vs'"},
                {{"iface_vs_ip", required_argument, NULL, 0x701}, "IP of the 'vs' interface"},
@@ -615,13 +615,13 @@ bool cmdlineParse(int argc, char *argv[], struct nsjconf_t * nsjconf)
                        nsjconf->iface_vs_gw = optarg;
                        break;
                case 0x801:
-                       nsjconf->cgroup_mem_mount = optarg;
+                       nsjconf->cgroup_mem_max = (size_t) strtoull(optarg, NULL, 0);
                        break;
                case 0x802:
-                       nsjconf->cgroup_mem_parent = optarg;
+                       nsjconf->cgroup_mem_mount = optarg;
                        break;
                case 0x803:
-                       nsjconf->cgroup_mem_max = (size_t) strtoull(optarg, NULL, 0);
+                       nsjconf->cgroup_mem_parent = optarg;
                        break;
                default:
                        cmdlineUsage(argv[0], custom_opts);