summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDhaval Giani <dhaval@linux.vnet.ibm.com>2008-12-16 17:14:33 +0000
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2008-12-16 17:14:33 +0000
commitdcb708a93e68ef4395fe9af88275bafc91aa3fa1 (patch)
tree733976864ac9f6ab84c263f3af2a774f3706237e /scripts
parent7418f938a297167b464e4880c9c97d043c6f079e (diff)
downloadlibcg-dcb708a93e68ef4395fe9af88275bafc91aa3fa1.zip
libcg-dcb708a93e68ef4395fe9af88275bafc91aa3fa1.tar.gz
libcg-dcb708a93e68ef4395fe9af88275bafc91aa3fa1.tar.xz
libcgroup: Add default group to cgconfig
From: Balbir Singh <balbir@linux.vnet.ibm.com> As discussed in the previous thread http://article.gmane.org/gmane.comp.lib.libcg.devel/139, we don't have the concept of default groups and tasks should be able to return back to their default group when done. Here is a fix to the cgconfig script to fix the issue. Please review, comment on it. Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@236 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'scripts')
-rw-r--r--scripts/init.d/cgconfig50
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/init.d/cgconfig b/scripts/init.d/cgconfig
index 4e04fb9..58dee65 100644
--- a/scripts/init.d/cgconfig
+++ b/scripts/init.d/cgconfig
@@ -82,6 +82,56 @@ start() {
#log_progress_msg "Starting cgconfig service: "
cgconfigparser -l $CONFIG_FILE
fi
+
+ declare defaultcgroup
+
+ if [ -f /etc/cgrules.conf ]
+ then
+ read user ctrl defaultcgroup <<< \
+ `grep -m1 ^\* /etc/cgrules.conf`
+ if [[ -n $defaultcgroup && $defaultcgroup = "*" ]]
+ then
+ log_warning_msg "/etc/cgrules.conf incorrect"
+ log_warning_msg "Overriding it"
+ defaultcgroup=
+ fi
+ fi
+
+ if [ -z $defaultcgroup ]
+ then
+ defaultcgroup=sysdefault/
+ fi
+ #
+ # Create a default class for tasks to return back to
+ #
+ parse_mounts
+ for i in `seq 1 $maxindex`
+ do
+ #
+ # Ignore if directory already exists
+ #
+ mkdir ${MOUNTPOINT[$i]}/$defaultcgroup 2> /dev/null
+ chmod a+rw ${MOUNTPOINT[$i]}/$defaultcgroup/tasks
+ #
+ # special rule for cpusets
+ #
+ echo ${MOUNTOPTS[$i]} | grep -q -w cpuset
+ if [ $? -eq 0 ]
+ then
+ cat ${MOUNTPOINT[$i]}/cpuset.cpus > \
+ ${MOUNTPOINT[$i]}/$defaultcgroup/cpuset.cpus
+ cat ${MOUNTPOINT[$i]}/cpuset.mems > \
+ ${MOUNTPOINT[$i]}/$defaultcgroup/cpuset.mems
+ fi
+ #
+ # classify everything to default cgroup
+ #
+ for j in `ps --no-headers -eL o tid`
+ do
+ echo $j > ${MOUNTPOINT[$i]}/$defaultcgroup/tasks 2>/dev/null
+ done
+ done
+
[ $? == 0 ] && touch /var/lock/subsys/$servicename
return $?
}