]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
update documentation to reflect the changes regarding templates
authorIvana Hutarova Varekova <varekova@redhat.com>
Mon, 28 Jan 2013 13:45:55 +0000 (14:45 +0100)
committerIvana Hutarova Varekova <varekova@redhat.com>
Mon, 28 Jan 2013 13:45:55 +0000 (14:45 +0100)
    cgrules.conf(5): add information about templates setting in rules
    cgconfig.conf(5): add information about templates setting + example
    cgrulesengd(8): add information about SIGUSR1 signal which call reloads
the templates configuration
    README_daemon: the same change as in cgrulesengd(8)

    CHANGELOG:
    * cgrules.conf - incorporate Jan's feedback

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek<jsafrane@redhat.com>
README_daemon
doc/man/cgconfig.conf.5
doc/man/cgexec.1
doc/man/cgrules.conf.5
doc/man/cgrulesengd.8
include/libcgroup/tasks.h
src/api.c

index 17e4ea8b30eeeede79e602b7f6d247cd0558baaa..25f0d55075d3fac3a3625d412371af948a626673 100644 (file)
@@ -64,10 +64,14 @@ currently supported:
        --config [FILE] Read rules configuration from FILE instead of
                        /etc/cgrules.conf
 
-You can ask the daemon to reload the configuration by sending it SIGUSR2.  The
-easiest way to do this is with the 'kill' command:
+You can ask the daemon to reload the rules configuration by sending it SIGUSR2.
+The easiest way to do this is with the 'kill' command:
        kill -s SIGUSR2 [PID]
 
+You can ask the daemon to reload the templates configuration by sending it
+SIGUSR1. The easiest way to do this is with the 'kill' command:
+       kill -s SIGUSR1 [PID]
+
 TESTING
 =======
 The program setuid (found in tests/setuid.c) can help you test the daemon.  By
index fbcc978ca81e1c8830f32141c20648ce33d02550..be80e4e988f90250ca5e6ccf94d7bee9eabc1cca 100644 (file)
@@ -239,6 +239,18 @@ their permissions in their
 .I group
 section.
 
+.I template
+section has the same structure as
+.B group
+section. Template name uses the same templates string as
+.B cgrules.conf
+destination tag (see (\fBcgrules.conf\fR (5)).
+Template definition is used as a control group definition for rules in
+\fBcgrules.conf\fR (5) with the same destination name.
+Templates does not use
+.B default
+section settings.
+
 .\"********************************************"
 .SH EXAMPLES
 .LP
@@ -710,6 +722,48 @@ control group, but they can not move the process out of the group. Only the
 .I operator
 or root can do that.
 
+.SS Example 7
+.LP
+The configuration file:
+
+.LP
+.RS
+.nf
+mount {
+.RS
+cpu = /mnt/cgroups/cpu;
+cpuacct = /mnt/cgroups/cpuacct;
+.RE
+}
+
+group students {
+.RS
+cpuacct{
+}
+cpu {
+}
+.RE
+}
+
+template students/%u {
+.RS
+cpuacct{
+}
+cpu {
+}
+.RE
+}
+
+mkdir /mnt/cgroups/cpu/daemons
+mkdir /mnt/cgroups/cpuacct/daemons
+.fi
+.RE
+
+The situation is the similar as in Example 4. The only difference is template,
+which is used if some rule uses "/students/%u" as a destination.
+
+
+
 .SH RECOMMENDATIONS
 .SS Keep hierarchies separated
 Having multiple hierarchies is perfectly valid and can be useful
index fa131ce194a89b4ac17cc5edc6155c0c01ff90ba..3834a02e74bef471a3335bc74aaf61b633a0f643 100644 (file)
@@ -31,6 +31,14 @@ If this option is not used,
 \fBcgexec\fR will automatically place the task in the right
 cgroup based on \fB/etc/cgrules.conf\fR.
 
+If \fB/etc/cgrules.conf\fR configuration file is used, there can be used
+template names. Then the control group name contains
+a template in destination tag (see \fBcgrules.conf\fR (5))
+and if the cgroup does not exist in execution time,
+it is created, based on \fB/etc/cgconfig.conf\fR specification.
+If the specifications are not present the group is created with the default
+kernel values.
+
 .TP
 .B -h, --help
 Display this help and exit.
index 676f0cc6a61433cbe088c0a56f3b2f924d2b0e31..7a89fb5277faccb0a54b0ca2e823dc65d483b961 100644 (file)
@@ -56,7 +56,7 @@ can be:
 can be:
 .nf
     - path relative to the controller hierarchy (ex. pgrp1/gid1/uid1)
-    - following strings will get expanded
+    - following strings called "\fBtemplates\fR" and will get expanded
 
           %u     username, uid if name resolving fails
           %U     uid
@@ -67,13 +67,25 @@ can be:
 
           '\\' can be used to escape '%'
 .fi
-
 First rule which matches the criteria will be executed.
 
-
 Any text starting with '#' is considered as a start of comment line and is
 ignored.
 
+If the
+.I destination
+contains
+.B template
+string, the control group can be created on-fly. In time when some process wants
+to use the template rule which leads to control group (see
+\fBcgexec\fR (1)) and the control group does not exist, the group is created. The
+template control group parameters can be specified in
+.B cgconfig.conf
+configuration file. See (\fBcgconfig.conf\fR (5)).
+If the template definition is not found there created group have default
+kernel setting.
+
+
 
 .SH EXAMPLES
 .nf
@@ -110,6 +122,13 @@ the earliest matched rule is applied, it makes sense to have this line
 at the end of the list. It will put a task which was not mentioned in the
 previous rules to default/ control group.
 
+.nf
+@students      cpu,cpuacct     students/%u
+.fi
+Processes in cpu and cpuacct subsystems started by anybody from students group
+belong to group students/name. Where "name" is user name of owner of the
+process.
+
 
 
 .SH FILES
index 9093ea7cbf0a9062630e3295ffebb9e6a18fd41e..69be57f15ab00f760aa0458ebd8ccba53d5897bf 100644 (file)
@@ -15,6 +15,7 @@ the appropriate control group.
 
 The list of rules is read during the daemon startup is are cached in the daemon's memory.
 The daemon reloads the list of rules when it receives SIGUSR2 signal.
+The daemon reloads the list of templates when it receives SIGUSR1 signal.
 
 The daemon opens a standard unix socket to receive 'sticky' requests from \fBcgexec\fR.
 
index 7e5089cf0a59a58c24fd096688168bf99b471bd9..0f79220ff5431983ec58eb9611c78fe11c0ed199 100644 (file)
@@ -128,6 +128,8 @@ void cgroup_print_rules_config(FILE *fp);
  *
  * The flags can alter the behavior of this function:
  *     CGFLAG_USECACHE: Use cached rules instead of parsing the config file
+ *      CGFLAG_USE_TEMPLATE_CACHE: Use cached templates instead of
+ * parsing the config file
  *
  * This function may NOT be thread safe.
  * @param uid The UID to match.
index 0314a5eeb199a3a2d455a2930164ac9d23bf819d..11cd1b45651d94c7d0475cb26885916d29c012e0 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -2791,14 +2791,10 @@ static int cgroup_create_template_group(char *orig_group_name,
                                /* the prefix cgroup without template */
                                ret = cgroup_create_cgroup(template_group, 0);
                        } else {
-                               /* TODO: this will be a function which use
-                                * template to create relevant cgroup
-                                * now cgroup_create_cgroup is used
+                               /* use template to create relevant cgroup */
                                ret = cgroup_config_create_template_group(
                                        template_group, template_name,
-                                       0, flags);
-                                */
-                               ret = cgroup_create_cgroup(template_group, 0);
+                                       flags);
                        }
 
                        if (ret != 0) {