]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
Fixed cgconfigparser to allow configs with no 'mount' section
authorJan Safranek <jsafrane@redhat.com>
Fri, 20 May 2011 13:52:58 +0000 (15:52 +0200)
committerJan Safranek <jsafrane@redhat.com>
Mon, 30 May 2011 14:25:45 +0000 (16:25 +0200)
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@redhat.com>
doc/man/cgconfig.conf.5
src/config.c

index d57fb44528bc1a06b63c3439901969b6312530f7..4a82b95bdc1b5a10e181ada2f47ca423814ac8a2 100644 (file)
@@ -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 a comment line and is ignored.
+sections. These sections can be in arbitrary order and both are optional.
+Any line starting with '#' is considered a comment line and is ignored.
 .LP
 .I mount
 section has this form:
@@ -53,6 +53,11 @@ controller shall be mounted. The directory is created
 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
@@ -174,6 +179,10 @@ created. If it is enclosed in double quotes `"', it can contain spaces
 and other special characters.
 .RE
 
+If no
+.I group
+section is specified, no groups are created.
+
 .\"********************************************"
 .SH EXAMPLES
 .LP
index f1873eaf8134c477f9193c03321e32b54f5cf2e9..0dd70d849ae1d8a6bf665acdb81ee09e31c4c446 100644 (file)
@@ -723,24 +723,25 @@ int cgroup_config_load_config(const char *pathname)
        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;