[libcgroup] - fixed cgconfig service not to unmount stuff it did not mount - added better sample cgconfig.conf f

Jan Šafránek jsafrane at fedoraproject.org
Mon May 30 14:40:07 UTC 2011


commit 198fbe43ced5904d092c1ab30008cb4535444858
Author: Jan Safranek <jsafrane at redhat.com>
Date:   Mon May 30 16:30:59 2011 +0200

    - fixed cgconfig service not to unmount stuff it did not mount
    - added better sample cgconfig.conf file to reflect systemd mounting all controllers during boot
    Resolves: #702111

 fedora-config.patch            |   18 +---
 libcgroup-0.37.1-systemd.patch |  194 ++++++++++++++++++++++++++++++++++++++++
 libcgroup.spec                 |    9 ++-
 3 files changed, 207 insertions(+), 14 deletions(-)
---
diff --git a/fedora-config.patch b/fedora-config.patch
index 940c642..5fafc32 100644
--- a/fedora-config.patch
+++ b/fedora-config.patch
@@ -3,7 +3,7 @@ Fedora specific configuration - we want to mount all controllers by default for
 diff -up libcgroup-0.34/samples/cgconfig.conf.orig libcgroup-0.34/samples/cgconfig.conf
 --- libcgroup-0.34/samples/cgconfig.conf.orig	2009-03-04 10:40:06.000000000 +0100
 +++ libcgroup-0.34/samples/cgconfig.conf	2009-10-19 10:17:37.000000000 +0200
-@@ -10,39 +10,17 @@
+@@ -10,39 +10,8 @@
  #  WITHOUT ANY WARRANTY; without even the implied warranty of
  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  #
@@ -22,7 +22,6 @@ diff -up libcgroup-0.34/samples/cgconfig.conf.orig libcgroup-0.34/samples/cgconf
 -#		cpu.shares = 1000;
 -#	}
 -#}
-+# See man cgconfig.conf for further details.
  #
 -#group daemons/ftp {
 -#	perm {
@@ -44,17 +43,10 @@ diff -up libcgroup-0.34/samples/cgconfig.conf.orig libcgroup-0.34/samples/cgconf
 -#	cpu = /mnt/cgroups/cpu;
 -#	cpuacct = /mnt/cgroups/cpuacct;
 -#}
-+# By default, mount all controllers to /cgroup/<controller>
-+
-+mount {
-+	cpuset	= /sys/fs/cgroup/cpuset;
-+	cpu	= /sys/fs/cgroup/cpu;
-+	cpuacct	= /sys/fs/cgroup/cpuacct;
-+	memory	= /sys/fs/cgroup/memory;
-+	devices	= /sys/fs/cgroup/devices;
-+	freezer	= /sys/fs/cgroup/freezer;
-+	net_cls	= /sys/fs/cgroup/net_cls;
-+}
++# By default, we expect systemd mounts everything on boot,
++# so there is not much to do.
++# See man cgconfig.conf for further details, how to create groups
++# on system boot using this file.
 +
 diff -up libcgroup-0.35.1/samples/cgconfig.sysconfig.orig libcgroup-0.35.1/samples/cgconfig.sysconfig
 --- libcgroup-0.35.1/samples/cgconfig.sysconfig.orig	2010-03-09 14:56:34.000000000 +0100
diff --git a/libcgroup-0.37.1-systemd.patch b/libcgroup-0.37.1-systemd.patch
new file mode 100644
index 0000000..8512201
--- /dev/null
+++ b/libcgroup-0.37.1-systemd.patch
@@ -0,0 +1,194 @@
+702111 - Starting LSB: start and stop the WLM configuration failed
+
+ - cgconfigparser should not unmount stuff it did not mounted
+ - cgconfigparser should accept empty config file
+ - rename the service
+
+Backported these 3 pacthes:
+
+commit 7155cc27430619be5ffcf1ddc2b6bd8cf7d6d7e0
+Author: Dhaval Giani <dhaval.giani at gmail.com>
+Date:   Fri May 27 10:36:19 2011 +0200
+
+    cgconfig: Do not touch subsystems not mounted by cgconfig
+    
+    cgconfig: Do not touch subsystems not mounted by cgconfig
+    
+    In its failure path, cgconfig should only touch the subsystems
+    it had something to do with. Currently, it unmounts all the
+    subsystems in the config file. Correct this.
+    
+    Signed-off-by: Dhaval Giani <dhaval.giani at gmail.com>
+    Signed-off-by: Jan Safranek <jsafrane at redhat.com>
+
+commit 431587f4e21b36a3f08bc595d716a70d70314e70
+Author: Jan Safranek <jsafrane at redhat.com>
+Date:   Fri May 20 15:53:05 2011 +0200
+
+    Updated cgconfig service descriptions
+    
+    Signed-off-by: Jan Safranek <jsafrane at redhat.com>
+
+commit 74e1b1e3d04c2f7999e367a20bf73396b61f9b64
+Author: Jan Safranek <jsafrane at redhat.com>
+Date:   Fri May 20 15:52:58 2011 +0200
+
+    Fixed cgconfigparser to allow configs with no 'mount' section
+    
+    cgconfig service fails when something else mounts cgroup hierarchies during
+    boot (e.g. systemd). Therefore we should allow cgconfig.conf to have no
+    'mount' section -> it's up to admin to ensure that controllers are mounted as
+    needed.
+    
+    Because 'group' section is already optional, with this patch cgconfigparser
+    will accept empty configuration file. This is probably the best default
+    config for distros with systemd.
+    
+    Changelog:
+      - fixed case with empty config file and no mounted controllers
+      - reworked the if conditions to be more clear
+    
+    Signed-off-by: Jan Safranek <jsafrane at redhat.com>
+
+diff -up libcgroup-0.37.1/doc/man/cgconfig.conf.5.systemd2 libcgroup-0.37.1/doc/man/cgconfig.conf.5
+--- libcgroup-0.37.1/doc/man/cgconfig.conf.5.systemd2	2011-03-03 09:29:41.000000000 +0100
++++ libcgroup-0.37.1/doc/man/cgconfig.conf.5	2011-05-30 15:06:45.083249011 +0200
+@@ -12,8 +12,8 @@ The file consists of
+ .I mount
+ and
+ .I group
+-sections. These sections can be in arbitrary order. Any line starting with
+-'#' is considered as a comment line and is ignored.
++sections. These sections can be in arbitrary order and both are optional.
++Any line starting with '#' is considered as a comment line and is ignored.
+ .LP
+ .I mount
+ section has this form:
+@@ -50,6 +50,11 @@ controller, shall be mounted. The direct
+ automatically on cgconfig service startup if it does not exist and
+ is deleted on service shutdown.
+ .LP
++
++If no
++.I mount
++section is specified, no controllers are mounted.
++
+ .I group
+ section has this form:
+ .RS
+@@ -171,6 +176,10 @@ created. Optionally it can be enclosed i
+ contain spaces then.
+ .RE
+ 
++If no
++.I group
++section is specified, no groups are created.
++
+ .\"********************************************"
+ .SH EXAMPLES
+ .LP
+diff -up libcgroup-0.37.1/scripts/init.d/cgconfig.in.systemd2 libcgroup-0.37.1/scripts/init.d/cgconfig.in
+--- libcgroup-0.37.1/scripts/init.d/cgconfig.in.systemd2	2011-05-30 15:00:36.269947252 +0200
++++ libcgroup-0.37.1/scripts/init.d/cgconfig.in	2011-05-30 15:00:36.284946695 +0200
+@@ -25,8 +25,8 @@
+ # Required-Stop:
+ # Should-Start:
+ # Should-Stop:
+-# Short-Description:    start and stop the WLM configuration
+-# Description:          This script allows us to create a default configuration
++# Short-Description:    Create and setup control group filesystem(s)
++# Description:          Create and setup control group filesystem(s)
+ ### END INIT INFO
+ 
+ # get correct location of binaries from configure
+diff -up libcgroup-0.37.1/src/config.c.systemd2 libcgroup-0.37.1/src/config.c
+--- libcgroup-0.37.1/src/config.c.systemd2	2011-03-03 09:29:41.000000000 +0100
++++ libcgroup-0.37.1/src/config.c	2011-05-30 15:17:08.317101247 +0200
+@@ -394,6 +394,7 @@ static int cgroup_config_mount_fs(void)
+ 	int ret;
+ 	struct stat buff;
+ 	int i;
++	int error;
+ 
+ 	for (i = 0; i < config_table_index; i++) {
+ 		struct cg_mount_table_s *curr =	&(config_mount_table[i]);
+@@ -402,26 +403,39 @@ static int cgroup_config_mount_fs(void)
+ 
+ 		if (ret < 0 && errno != ENOENT) {
+ 			last_errno = errno;
+-			return ECGOTHER;
++			error = ECGOTHER;
++			goto out_err;
+ 		}
+ 
+ 		if (errno == ENOENT) {
+ 			ret = cg_mkdir_p(curr->path);
+-			if (ret)
+-				return ret;
++			if (ret) {
++				error = ret;
++				goto out_err;
++			}
+ 		} else if (!S_ISDIR(buff.st_mode)) {
+ 			errno = ENOTDIR;
+ 			last_errno = errno;
+-			return ECGOTHER;
++			error = ECGOTHER;
++			goto out_err;
+ 		}
+ 
+ 		ret = mount(CGROUP_FILESYSTEM, curr->path, CGROUP_FILESYSTEM,
+ 								0, curr->name);
+ 
+-		if (ret < 0)
+-			return ECGMOUNTFAIL;
++		if (ret < 0) {
++			error = ECGMOUNTFAIL;
++			goto out_err;
++		}
+ 	}
+ 	return 0;
++out_err:
++	/*
++	 * If we come here, we have failed. Since we have touched only
++	 * mountpoints prior to i, we shall operate on only them now.
++	 */
++	config_table_index = 1;
++	return error;
+ }
+ 
+ /*
+@@ -681,24 +695,25 @@ int cgroup_config_load_config(const char
+ 	mount_enabled = (config_mount_table[0].name[0] != '\0');
+ 
+ 	/*
+-	 * The configuration should have either namespace or mount.
+-	 * Not both and not none.
++	 * The configuration should have namespace or mount, not both.
+ 	 */
+-	if (namespace_enabled == mount_enabled) {
++	if (namespace_enabled && mount_enabled) {
+ 		free(config_cgroup_table);
+ 		return ECGMOUNTNAMESPACE;
+ 	}
+ 
+-	/*
+-	 * We do not allow both mount and namespace sections in the
+-	 * same configuration file. So test for that
+-	 */
+-
+ 	error = cgroup_config_mount_fs();
+ 	if (error)
+ 		goto err_mnt;
+ 
+ 	error = cgroup_init();
++	if (error == ECGROUPNOTMOUNTED && cgroup_table_index == 0) {
++		/*
++		 * The config file seems to be empty.
++		 */
++		error = 0;
++		goto err_mnt;
++	}
+ 	if (error)
+ 		goto err_mnt;
+ 
diff --git a/libcgroup.spec b/libcgroup.spec
index 09f35bd..85f2e63 100644
--- a/libcgroup.spec
+++ b/libcgroup.spec
@@ -5,7 +5,7 @@ Name: libcgroup
 Summary: Library to control and monitor control groups
 Group: Development/Libraries
 Version: 0.37.1
-Release: 3%{?dist}
+Release: 4%{?dist}
 License: LGPLv2+
 URL: http://libcg.sourceforge.net/
 Source0: http://downloads.sourceforge.net/libcg/%{name}-%{version}.tar.bz2
@@ -13,6 +13,7 @@ Source1: README.Fedora
 Patch1: fedora-config.patch
 Patch2: fedora-fix-initscripts.patch
 Patch3: libcgroup-0.36.2-systemd.patch
+Patch4: libcgroup-0.37.1-systemd.patch
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: pam-devel
 BuildRequires: byacc
@@ -59,6 +60,7 @@ provide scripts to manage that configuration.
 %patch1 -p1 -b .config
 %patch2 -p1 -b .lsb
 %patch3 -p1 -b .systemd
+%patch4 -p1 -b .systemd2
 
 %build
 %configure --bindir=/bin --sbindir=/sbin --libdir=%{_libdir} --enable-initscript-install --enable-pam-module-dir=/%{_lib}/security
@@ -165,6 +167,11 @@ fi
 %doc COPYING INSTALL
 
 %changelog
+* Mon May 30 2011 Jan Safranek <jsafrane at redhat.com> 0.37.1-4
+- fixed cgconfig service not to unmount stuff it did not mount
+- added better sample cgconfig.conf file to reflect systemd
+  mounting all controllers during boot (#702111)
+
 * Wed May 25 2011 Ivana Hutarova Varekova <varekova at redhat.com> 0.37.1-3
 - split tools part from libcgroup package
 


More information about the scm-commits mailing list