From a7648e78fbcbc4dfcb56a2aa824362a0393a935a Mon Sep 17 00:00:00 2001
From: Bob Lantz <rlantz@cs.stanford.edu>
Date: Sun, 8 Apr 2012 17:22:01 -0700
Subject: [PATCH] Add mountCgroups() and tweak/correct fixLimits()

---
 mininet/util.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/mininet/util.py b/mininet/util.py
index 04a91cba..8fe3f368 100644
--- a/mininet/util.py
+++ b/mininet/util.py
@@ -305,8 +305,19 @@ def makeNumeric( s ):
 
 def fixLimits():
     "Fix ridiculously small resource limits."
-    setrlimit( RLIMIT_NPROC, ( 4096, 8192 ) )
-    setrlimit( RLIMIT_NOFILE, ( 16384, 32768 ) )
+    setrlimit( RLIMIT_NPROC, ( 8192, 8192 ) )
+    setrlimit( RLIMIT_NOFILE, ( 16384, 16384 ) )
+
+def mountCgroups():
+    "Make sure cgroups file system is mounted"
+    mounts = quietRun( 'mount' )
+    cgdir = '/sys/fs/cgroup'
+    csdir = cgdir + '/cpuset'
+    if 'cgroups on %s' % cgdir not in mounts:
+        raise Exception( "cgroups not mounted on " + cgdir )
+    if 'cpuset on %s' % csdir not in mounts:
+        errRun( 'mkdir -p', csdir )
+        errRun( 'mount -t cgroup -ocpuset cpuset', csdir )
 
 def natural( text ):
     "To sort sanely/alphabetically: sorted( l, key=natural )"
-- 
GitLab