]> git.ipfire.org Git - thirdparty/libcgroup.git/log
thirdparty/libcgroup.git
9 years agoapi.c: change cgroup of every thread of a process
Nikola Forró [Tue, 8 Dec 2015 16:09:08 +0000 (17:09 +0100)] 
api.c: change cgroup of every thread of a process

When changing cgroup of multi-threaded process, only the main threads
cgroup actually changed. Now all threads of a process are enumerated
and cgroup is changed for each of them.

9 years agoapi.c: fix infinite loop
Nikola Forró [Tue, 8 Dec 2015 15:53:41 +0000 (16:53 +0100)] 
api.c: fix infinite loop

If getgrnam or getpwuid functions failed, the program entered
an infinite loop, because the rule pointer was never advanced.
This is now fixed by updating the pointer before continuing
to the next iteration.

10 years agoapi.c: support for setting multiline values in control files
Jan Chaloupka [Mon, 15 Sep 2014 11:29:39 +0000 (13:29 +0200)] 
api.c: support for setting multiline values in control files

As of now, libcgroup does not support multiline values setting from configuration files. i.e. values in a form:

net_prio.ifpriomap="lo 7
eth0 66
eth1 5
eth2 4
eth3 3";

Thus, setting of more network interfaces can not be done from configuration file. Or

devices.allow="a *:* w
c 8:* r";

thus setting list of allow devices can not be set as well. The only way is to set it from userspace, e.g.:
# echo "lo 7" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap
# echo "eth 0" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap
# echo "eth 1" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap
# echo "eth 2" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap
# echo "eth 3" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap

This patch allows setting of multiline variables.

How this support works:
Multiline value is broken in lines and each line is set by write (man 2 write) syscall (without bufferring).
This implies change of fopen with open, fclose with close.
There is no control on multiline value, thus "eth0\n  \t\n" can be set. However, setting
of "  \t" will fail as write command returns -1. Thus administrator has to set correct
multiline values.

Tested on virtual machine with fedora and rhel with network interface lo, eth0-eth3. Configuration file:

# cat /etc/cgconfig.conf
group testGroup {
        net_prio {
                net_prio.ifpriomap="lo 7
eth0    66
eth1 5
eth2 4
eth3 3";
        }
}

net_prio has to be created before:
# modprobe netprio_cgroup
# mkdir /sys/fs/cgroup/net_prio
# mount -t cgroup -onet_prio none /sys/fs/cgroup/net_prio

Changelog:
test of success of strdup call
free str_val before return (str_val is changing in while cycle,
thus str_start_val points to the start of str_val before while)

Signed-off-by: Jan Chaloupka <jchaloup@redhat.com>
10 years agoparse.y: extending cgroup names with "default"
Jan Chaloupka [Mon, 8 Sep 2014 11:28:18 +0000 (13:28 +0200)] 
parse.y: extending cgroup names with "default"

default is used as a keyword for defining default group permissions. Having "default" as a group name (with double quotes "), parsing is successfull. Howerver, using default without double quotes, parsing fails. This patch modifies parsing rule and lex for default group name without double quotes.

Tested on:

default {
perm {
task {
uid = root;
gid = rgel6610;
fperm = 770;
}
admin {
uid = root;
gid = root;
dperm = 775;
fperm = 744;
}
}
}

group default {
        cpuset {
                cpuset.mems = 0;
                cpuset.cpus = 0;
        }
}

Signed-off-by: Jan Chaloupka <jchaloup@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
10 years agodocumentation: add examples to man pages
Ivana Hutarova Varekova [Fri, 15 Aug 2014 14:11:45 +0000 (16:11 +0200)] 
documentation: add examples to man pages

This patch add examples and missing info in file section libcgroup man pages.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Chaloupka<jchaloup@redhat.com>
11 years agocgroup_config_create_template_group: fix inverted error check.
Anton Khirnov [Thu, 31 Jul 2014 09:50:34 +0000 (11:50 +0200)] 
cgroup_config_create_template_group: fix inverted error check.

The aux_cgroup pointer will be NULL when an error occurs, but the check
is for it being non-NULL.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
11 years agocgcreate: use "*" character as a meta character for all mounted controllers
Ivana Hutarova Varekova [Thu, 31 Jul 2014 09:40:00 +0000 (11:40 +0200)] 
cgcreate: use "*" character as a meta character for all mounted controllers

This patch adds the possibility to use meta character "*" as a shortcut for all mounted controllers. This meta character can be used in "-g" option.

For example:
    $ cgcreate -g *:first  -g cpu:second
    $ lssubsys
    cpuset:/
    cpuset:/first
    cpu,cpuacct:/
    cpu,cpuacct:/first
    cpu,cpuacct:/second
    memory:/
    memory:/first
    devices:/
    devices:/first
    freezer:/
    freezer:/first
    net_cls,net_prio:/
    net_cls,net_prio:/first
    blkio:/
    blkio:/first
    perf_event:/
    perf_event:/first
    hugetlb:/
    hugetlb:/first

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Reviewed-by: Jan Chaloupka <jchaloup@redhat.com>
11 years agoapi.c: add cgroup_add_all_controllers function
Ivana Hutarova Varekova [Thu, 31 Jul 2014 09:37:26 +0000 (11:37 +0200)] 
api.c: add cgroup_add_all_controllers function

cgroup_add_all_controllers function attach all mounted controllers to a given cgroup. This function just modifies internal libcgroup structure, not the kernel control group.
 input parameter: cgroup
 output parameter: zero or error number

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Reviewed-by: Jan Chaloupka <jchaloup@redhat.com>
11 years agocgrules.d: new man page
Jan Chaloupka [Thu, 31 Jul 2014 09:23:08 +0000 (11:23 +0200)] 
cgrules.d: new man page

This patch contains new man page for cgrules.d directory and corresponding
update of existing man pages. It describes the way additional configuration
files should be created and potential conflicts resulting from an arbitrary
order or reading files in the directory.

Changelog:
* line wrapping (max to 80 characters)
* hiearchy typo corrected
* diffrent typo corrected
* succesfully typo corrected
* /etc/cgconfig.conf added into FILES section
* formulation of advice for creating rules updated. Is it enough or
  still confusing? If so, can you be more specific?
* reformulation of the first and the second paragraph

Signed-off-by: Jan Chaloupka <jchaloup@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agoapi.c: Adding support for loading configuration files from cgrules.d directory
Jan Chaloupka [Thu, 31 Jul 2014 09:21:19 +0000 (11:21 +0200)] 
api.c: Adding support for loading configuration files from cgrules.d directory

Implementation of loading rules from /etc/cgrules.d/. Explanation is in the
cover letter. New function cgroup_parse_rules_file created,
calling cgroup_parse_rules. cgroup_parse_rules is invoked only in
cgroup_change_cgroup_flags, cgroup_init_rules_cache and
cgroup_reload_cached_rules functions. For them the change in cgroup_parse_rules
implementation is transpart.

Tested with two configuration files in /etc/cgrules.d/ and all rules
in /etc/cgrules.conf commented out:

$ cat /etc/cgrules.conf
#*:ls       cpu             strom/%u
#*:sleep    memory          les/%g

$ cat /etc/cgrules.d/cgrules1.conf
*:ls       cpu             strom/%u

$ cat /etc/cgrules.d/cgrules2.conf
*:sleep    memory          les/%g

plus cgconfig.[c|d/*] files:
$ cat /etc/cgconfig.conf
mount {
        cpuset  = /cgroup/cpuset;
        cpu     = /cgroup/cpu;
        cpuacct = /cgroup/cpuacct;
        memory  = /cgroup/memory;
        devices = /cgroup/devices;
        freezer = /cgroup/freezer;
        net_cls = /cgroup/net_cls;
        blkio   = /cgroup/blkio;
}

$ cat /etc/cgconfig.d/small.conf
template strom/%u {
        cpu {}
}

group vetev {
        cpu {}
}

$ cat /etc/cgconfig.d/medium.conf
template les/%g {
        memory {}
}

group drevo/listi {
        memory {}
}

Tested to cache reload as well by sending SIGUSR2 signal to running
cgrulesengd process. After first reload I commented out all rules => no
rules match after invoking ls command. After second reload I uncommented
out ls rule => rule match after invoking ls command. After third reload
I uncommented out ls and sleep rule => debug output of cgrulesengd shows
both rules loaded in the cache

Changelog:
* CGROUP_PARSE_STATE_UNLOCK removed
* reformulation of comment to "Cannot read directory. However,
  CGRULES_CONF_FILE is succesfully parsed. Thus return as a success for
  back compatibility."
* errno = 0 removed, once it is not zero, function returns, so need to set
  it to 0 in every iteration
* fprintf replaced by cgroup_err
* added missing unlocks + new label unlock_list for all returns

This
- * finds a rule matching the given UID or GID.  It will store this rule in rl,
+ * finds a rule matching the given UID or GID.  It will store this rule in trl,
is valid correction. "It will store this rule in rl" talks about cache being
disabled. In this case, it is  stored into trl.

Signed-off-by: Jan Chaloupka <jchaloup@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agocgdelete: fix the display problem
Weng Meiling [Thu, 31 Jul 2014 08:30:51 +0000 (10:30 +0200)] 
cgdelete: fix the display problem

When multi subsystems mounted on one place like this:

$ lssubsys -m
cpu,cpuacct /cgroup/cpu

$ lscgroup
cpu,cpuacct:/
cpu,cpuacct:/test

if we delete the cgroup with the cgdelete -g, and specifying multi
controllers like this:

$ cgdelete -g cpu,cpuacct:test

or

$ cgdelete -g cpu:test -g cpuacct:test

it will report error:
cgdelete: cannot remove group 'test': No such file or directory

this patch fix the problem.

v1 -> v2
 - make cgdelete -g cpu:/test -g cpu:test failed.
v2 -> v3
 - make cgdelete -g cpu:test -g cpu:test1 ok.
v3 -> v4
 - make cgdelete -g cpuacct:test -g cpu:test -g cpuacct:test failed.
 - add some comments
 - fix the uninitialized warning
v4 -> v5 (created by Ivana Hutarova Varekova, acked by Weng Meiling)
 - make cgdelete -g cpuacct:test -g cpu:test -g cpu:test failed
 - join extended cgroup list variables to one record, do the list dynamic (static version can exceed the given limit and the safe static limit is quite high)

Signed-off-by: Weng Meiling <wengmeiling.weng@huawei.com>
Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Weng Meiling <wengmeiling.weng@huawei.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agomanpages: update of manpages for loading configuration
Jan Chaloupka [Thu, 19 Jun 2014 09:42:14 +0000 (11:42 +0200)] 
manpages: update of manpages for loading configuration

Manual pages for new functionality. Because loading files from directory is already implemented in cgconfig tool, there is nothing new. cgrulesengd reads only templates from given files. Rules for writing templates are already specified.

Signed-off-by: Jan Chaloupka <jchaloup@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agoMakefile: update for cgruleseng.d Makefiles
Jan Chaloupka [Thu, 19 Jun 2014 09:39:37 +0000 (11:39 +0200)] 
Makefile: update for cgruleseng.d Makefiles

Modification of makefiles. cgrulesengd.c uses new functions for loading files from /etc/cgconfig.d/. Thus there is a dependency on tools-common.[c|h] files. Unfortunatelly they are in ../tools directory, adding dependency on files in a diffrent directory but on the same level. Makefile.in is regenerated from Makefile.am using autoreconf -ivf.

Tested on my local machine, all files are loaded properly, cgrulesengd properly creates groups based on templates from files from /etc/cgconfig.d/.

Signed-off-by: Jan Chaloupka <jchaloup@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agocgrulesengd.c: loading of multiples files during init/reload
Jan Chaloupka [Thu, 19 Jun 2014 09:04:26 +0000 (11:04 +0200)] 
cgrulesengd.c: loading of multiples files during init/reload

This patch use new implementation. In cgrulesengd.c, static variable template_files is used to save all config files, i.e. /etc/cgconfig.conf and /etc/cgconfig.d/*. This list of files is then passed to cgroup_templates_cache_set_source_files, which saves files to template_files in config.c module. This list is accessed through invocation of cgroup_init_templates_cache_from_files and cgroup_reload_templates_cache_from_files, which can access variables only from config.c, thus presenting cgroup_templates_cache_set_source_files function. At the end, this list is set free.

Signed-off-by: Jan Chaloupka <jchaloup@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agoconfig.c: loading templates from multiple files into one template table
Jan Chaloupka [Thu, 19 Jun 2014 08:34:32 +0000 (10:34 +0200)] 
config.c: loading templates from multiple files into one template table

This patch implements loading files from /etc/cgconfig.d/. It uses already implemented functions. To hold list of files to be read for template reloading, new static variable for this list (list of template files) has been added to config.c. It is the same list as file list read with cgconfigparser (cgconfig.c file), i.e. the same functions are called. Because parser reads only one file, it is called for each file in template file list. Thus initialization, resp. template duplication has to be called before, resp. after each file parsing. Thus new functions has been presented, thus modifying config.[h|c] api and libcgroup.map. Again parsing more files for templates is analogy to parsing files for groups in cgconfig.c.

cgroup_load_cached_templates_from_file is a modification of cgroup_reload_cached_templates and cgroup_init_templates_cache. Only for loop and auxiliary variables added.

Changelog:
        Description of config.h updated. [init|reload] replaced by load
        TEMPLATE_ACTION_[INIT|RELOAD] removed
        Instead of returning error on uninitialized list of template files, CGCONFIG_CONF_FILE with old cgroup_[init|reload]_templates_cache functions is called.
        cgroup_config_create_template_group reports which template file caused unsuccesfull loading of template files

Signed-off-by: Jan Chaloupka <jchaloup@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agoThere is a situation when moving a task from child cgroup
Weng Meiling [Fri, 4 Apr 2014 07:58:20 +0000 (09:58 +0200)] 
There is a situation when moving a task from child cgroup
to parent cgroup, the task exited. This will lead to service
cgconfig start failed. So ignore the error ESRCH.

Signed-off-by: Weng Meiling <wengmeiling.weng@huawei.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agolex: add \ character into regexp for ID token
Jan Chaloupka [Mon, 10 Mar 2014 17:50:57 +0000 (18:50 +0100)] 
lex: add \ character into regexp for ID token

Having virtual machine up, group name contains \ character after
cgsnapshot output. lex.l does not consider this case. For example:
group machine.slice/machine-qemu\x2drhel6.4.scope {...}
Adding \ character into regexp for ID token resolves this problem.

Signed-off-by: Jan Chaloupka <jchaloup@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
11 years agoRelease v0.41 v0.41
Ivana Hutarova Varekova [Mon, 13 Jan 2014 14:48:09 +0000 (15:48 +0100)] 
Release v0.41

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agov0.40.rc1
Ivana Hutarova Varekova [Thu, 21 Nov 2013 17:37:40 +0000 (18:37 +0100)] 
v0.40.rc1

releasing v0.40.rc1

This is bugfixing release.

List of all patches:
Ivana Hutarova Varekova (37):
      fix permissions of logger.sh
      cgroup_get_cgroup: remove bogus comment
      fix template function to copy template groups properly
      documentation: fix cgroup_copy cgroup description
      config.c: better detect whether template group already is created
      parse: fix template parsing
      lex: suppress useless warning message during compilation
      create_cgroup_from_name_value_pairs can't deal n/v pairs from the same controller
      cgsnapshot: don't display mountpoints which are not wanted
      cgclassify: polish usage function
      cgclassify: unify help output
      cgclear: polish usage function
      cgconfig: polish usage function
      cgclear: unify help output
      cgconfig: unify the help output
      cgcreate: polish usage function
      cgdelete: polish usage function
      cgdelete: unification of usage function output
      cgexec: polish usage function
      cgexec: unify the help output
      cgget: polish usage function
      cgset: polish usage function
      cgsnapshot: polish usage function
      cgsnapshot: unify help output
      lscgroup: polish usage function
      lscgroup: unify help output
      lssubsys: polish usage function
      lssubsys: unify help output
      cgroup_init: stop mntopt parsing if there is a bug in named hierarchy
      cgroup_copy_with_slash: two typos
      cgroup_get_current_controller_path: test whether strtok_r returns NULL
      cgroup_config_create_template_group: fix strncpy limits
      cgroup_config_create_template_group: test the right variable
      cgroup_{reload|init}_cached_templates:memory leaks
      cgroup_create_cgroup: write error on fail
      cgconfig.conf: enable sign "@" in cgroup name
      bindings: remove -nostdinc compiler option

Libo Chen (8):
      log.h: add head file <stdarg.h>
      cgcreate: add err check
      cgconfig: add err check
      cgconfig: fix the excursive processing
      cgconfig: add parameter check
      cgconfig: correct freeing default_cgroup
      cgconfig: add check and nonzero
      cgconfig: change function usage behavior

Peter Schiffer (8):
      Use cache when reading /etc/passwd file
      Cgred service won't start if /etc/cgrules.conf is missing
      Typo in debug message in cgexec.c file
      Incorrect cast
      Invalid reallocation of config_table in config_insert_cgroup()
      Templates letter case is switched
      Use cache when calling cgroup_change_cgroup_flags()
      Variable procname leaks

Weng Meiling (6):
      cgsnapshot: fix the print message when use cgsnapshot with -f
      when we use cgsnapshot with the given controller, the result always     displays     the last mounted controller which is not specified, so fix it.
      It's more readable and friendly to use the enum value instead of number.
      cgclassify: use the error message instead of error number
      cgred:cgred should start when cgroup is mounted
      cgcreate: fix the wrong uid/gid set.

11 years agoRevert "'make dist' command compiles "bindings" directory content even if bindings...
Ivana Hutarova Varekova [Thu, 21 Nov 2013 13:50:25 +0000 (14:50 +0100)] 
Revert "'make dist' command compiles "bindings" directory content even if bindings are not enabled in configuration file."

This reverts commit e9b2de289163327c229f095b53b44c0767d60e38.
It is necessary becouse of binding tools can be used in some versions.

11 years ago'make dist' command compiles "bindings" directory content even if bindings are not...
Ivana Hutarova Varekova [Mon, 18 Nov 2013 10:29:27 +0000 (11:29 +0100)] 
'make dist' command compiles "bindings" directory content even if bindings are not enabled in configuration file.
This patch fix it.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agobindings: remove -nostdinc compiler option
Ivana Hutarova Varekova [Mon, 18 Nov 2013 10:25:02 +0000 (11:25 +0100)] 
bindings: remove -nostdinc compiler option

stdarg.h header file is now (libstdc++-devel-4.6.3) in libctdc++ package, thus compilation of bindings failed:
../../include/libcgroup/log.h:12:20: fatal error: stdarg.h: No such file or directory
Thus -nostdinc compiler option have to be removed.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgconfig.conf: enable sign "@" in cgroup name
Ivana Hutarova Varekova [Wed, 30 Oct 2013 13:26:42 +0000 (14:26 +0100)] 
cgconfig.conf: enable sign "@" in cgroup name

This patch enables to have "@" sign in cgroup name in cgconfig.conf as
well.
It is because of systemd, which uses sign "@" to separate the template name
from the instance identifier in its cgroup names.
For example: systemd-fsck@.service.
Without this patch, it's not possible to use these names in cgconfig.conf file.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Peter Schiffer <pschiffe@redhat.com>
11 years agocgroup_create_cgroup: write error on fail
Ivana Hutarova Varekova [Wed, 30 Oct 2013 13:21:33 +0000 (14:21 +0100)] 
cgroup_create_cgroup: write error on fail

In the current version cgroup_create_cgroup returns warning if it fails and
can't set some variable. Thus on default configuration there is no
information about the problem. This situation happens if the cgconfigparser
reads cgconfig.conf. The error message where is the problem is very useful
in this case. The patch do the message visible in standard configuration.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Peter Schiffer <pschiffe@redhat.com>
11 years agocgroup_{reload|init}_cached_templates:memory leaks
Ivana Hutarova Varekova [Wed, 30 Oct 2013 13:17:15 +0000 (14:17 +0100)] 
cgroup_{reload|init}_cached_templates:memory leaks

cgroup_{reload|init}_cached_templates does not free memory if no template
is set. This patch fix the problem.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Peter Schiffer <pschiffe@redhat.com>
11 years agoVariable procname leaks
Peter Schiffer [Fri, 25 Oct 2013 15:07:43 +0000 (17:07 +0200)] 
Variable procname leaks

Variable procname in cgroup_change_all_cgroups() function is leaking. This patch fixes the problem.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agoUse cache when calling cgroup_change_cgroup_flags()
Peter Schiffer [Mon, 14 Oct 2013 06:49:34 +0000 (08:49 +0200)] 
Use cache when calling cgroup_change_cgroup_flags()

When system contains cgrules.conf file with few thousand rules,
cgroup_change_cgroup_flags() function without CGFLAG_USECACHE flag is very
slow.

As Ivana pointed out, cgexec and cgclassify tools might have problems with
cache
reloading, so I've removed them from the patch for now.

Currently, the patch affects only cgrulesengd daemon. Testing was done with
approximately 4000 users, rules in cgrules.conf file and same amount of
entries
in cgconfig.conf. Without the CGFLAG_USECACHE the cgrulesengd is starting
for
about 15 - 20 minutes (this is because of cgroup_change_all_cgroups()
function,
which scans all running processes on cgrulesengd start).

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agoTemplates letter case is switched
Peter Schiffer [Mon, 14 Oct 2013 06:43:24 +0000 (08:43 +0200)] 
Templates letter case is switched

Man page cgrules.conf(5) says:
     %u     username, uid if name resolving fails
     %U     uid
     %g     group name, gid if name resolving fails
     %G     gid
     %p     process name, pid if name not available
     %P     pid

However, in cgroup_change_cgroup_flags() function, the letter case is switched.
This patch fixes the problem.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agoInvalid reallocation of config_table in config_insert_cgroup()
Peter Schiffer [Mon, 14 Oct 2013 04:48:06 +0000 (06:48 +0200)] 
Invalid reallocation of config_table in config_insert_cgroup()

There's invalid reallocation of config_table variable in config_insert_cgroup() function.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agoIncorrect cast
Peter Schiffer [Mon, 14 Oct 2013 04:45:10 +0000 (06:45 +0200)] 
Incorrect cast

This patch fixes incorrect cast in cgclassify.c file.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agoTypo in debug message in cgexec.c file
Peter Schiffer [Mon, 14 Oct 2013 04:41:38 +0000 (06:41 +0200)] 
Typo in debug message in cgexec.c file

This patch fixes typo in debug message.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agocgroup_config_create_template_group: test the right variable
Ivana Hutarova Varekova [Wed, 9 Oct 2013 09:43:38 +0000 (11:43 +0200)] 
cgroup_config_create_template_group: test the right variable

cgroup_config_create_template_group tests the return value of bogus
variable. This patch fix it.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
11 years agocgroup_config_create_template_group: fix strncpy limits
Ivana Hutarova Varekova [Wed, 9 Oct 2013 09:43:25 +0000 (11:43 +0200)] 
cgroup_config_create_template_group: fix strncpy limits

fix strncpy limits in cgroup_config_create_template_group function

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
11 years agocgroup_get_current_controller_path: test whether strtok_r returns NULL
Ivana Hutarova Varekova [Wed, 9 Oct 2013 09:41:22 +0000 (11:41 +0200)] 
cgroup_get_current_controller_path: test whether strtok_r returns NULL

cgroup_get_current_controller_path  should test whether strtok_r returns NULL before it continues.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
11 years agocgroup_copy_with_slash: two typos
Ivana Hutarova Varekova [Wed, 9 Oct 2013 09:39:47 +0000 (11:39 +0200)] 
cgroup_copy_with_slash: two typos

Fix a typo when the '/' character is tested on the last but one position instead of the last.
There have to be more allocated more memory in the same function.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
11 years agocgroup_init: stop mntopt parsing if there is a bug in named hierarchy
Ivana Hutarova Varekova [Wed, 9 Oct 2013 09:14:36 +0000 (11:14 +0200)] 
cgroup_init: stop mntopt parsing if there is a bug in named hierarchy

cgroup_init should stop parsing of named hierarchy if there is a bug.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
11 years agocgcreate: fix the wrong uid/gid set.
Weng Meiling [Fri, 27 Sep 2013 05:27:30 +0000 (07:27 +0200)] 
cgcreate: fix the wrong uid/gid set.

When setting the cgconfig.conf as follow:

mount {
memory = /cgroup/memory;
}

group . {
perm {
task {
gid = w00227741;
uid = w00227741;
fperm =755;
}
admin {
gid = w00227741;
uid = w00227741;
fperm =755;
dperm = 755;
}
}
memory {
}
}

and restart the cgconfig service. Then switch to the user w00227741
and cgcreate cgroup like this:

# lscgroup
memory:/

# cgcreate -g memory:test
cgcreate: can't create cgroup test: Operation not permitted

the command report the error, but the cgroup test has created:

# lscgroup
memory:/
memory:/test

this patch fix the problem.

Signed-off-by: Weng Meiling <wengmeiling.weng@huawei.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agolssubsys: unify help output
Ivana Hutarova Varekova [Fri, 27 Sep 2013 05:18:53 +0000 (07:18 +0200)] 
lssubsys: unify help output

lssubsys: unify help output
* add missing options to syntax row
* change the order of options (now in alphabetical order)

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agolssubsys: polish usage function
Ivana Hutarova Varekova [Fri, 27 Sep 2013 05:18:43 +0000 (07:18 +0200)] 
lssubsys: polish usage function

This change is suggested by Dhaval Giani <dhaval.giani@gmail.com>.
Polish "usage" function of lssubsys tool. Remove a level of indentation.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agolscgroup: unify help output
Ivana Hutarova Varekova [Fri, 27 Sep 2013 05:18:23 +0000 (07:18 +0200)] 
lscgroup: unify help output

lscgroup: unify help output
* use tabulators instead of spaces
* at first describe the functionality and then describe options
* use printf instead fprintf(stdout,..)

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agolscgroup: polish usage function
Ivana Hutarova Varekova [Fri, 27 Sep 2013 05:18:03 +0000 (07:18 +0200)] 
lscgroup: polish usage function

This change is suggested by Dhaval Giani <dhaval.giani@gmail.com>.
Polish "usage" function of lscgroup tool. Remove a level of indentation.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgsnapshot: unify help output
Ivana Hutarova Varekova [Fri, 27 Sep 2013 05:17:52 +0000 (07:17 +0200)] 
cgsnapshot: unify help output

cgsnapshot: unify help output
* use tabulators instead of spaces
* change formulation
* change fprintf(stdout,...) to printf()

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgsnapshot: polish usage function
Ivana Hutarova Varekova [Fri, 27 Sep 2013 05:17:19 +0000 (07:17 +0200)] 
cgsnapshot: polish usage function

This change is suggested by Dhaval Giani <dhaval.giani@gmail.com>.
Polish "usage" function of cgsnapshot tool. Remove a level of indentation.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgset: polish usage function
Ivana Hutarova Varekova [Fri, 27 Sep 2013 05:17:07 +0000 (07:17 +0200)] 
cgset: polish usage function

This change is suggested by Dhaval Giani <dhaval.giani@gmail.com>.
Polish "usage" function of cgset tool. Remove a level of indentation.
Use tabulators instead of spaces.
Based on Jan's comment change typo display->set in -g description

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgget: polish usage function
Ivana Hutarova Varekova [Fri, 27 Sep 2013 05:11:19 +0000 (07:11 +0200)] 
cgget: polish usage function

This change is suggested by Dhaval Giani <dhaval.giani@gmail.com>.
Polish "usage" function of cgget tool. Remove a level of indentation.
Use printf instead of fprintf(stdout,...)

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgexec: unify the help output
Ivana Hutarova Varekova [Fri, 27 Sep 2013 05:11:02 +0000 (07:11 +0200)] 
cgexec: unify the help output

cgexec: unify the help output - add -h option info

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgexec: polish usage function
Ivana Hutarova Varekova [Fri, 27 Sep 2013 05:10:21 +0000 (07:10 +0200)] 
cgexec: polish usage function

This change is suggested by Dhaval Giani <dhaval.giani@gmail.com>.
Polish "usage" function of cgexec tool. Remove a level of
indentation.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgdelete: unification of usage function output
Ivana Hutarova Varekova [Fri, 27 Sep 2013 05:09:56 +0000 (07:09 +0200)] 
cgdelete: unification of usage function output

cgdelete use spaces instead of tabulator
use printf instead of fprintf(stdout,...)

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgdelete: polish usage function
Ivana Hutarova Varekova [Thu, 26 Sep 2013 17:30:04 +0000 (19:30 +0200)] 
cgdelete: polish usage function

This change is suggested by Dhaval Giani <dhaval.giani@gmail.com>.
Polish "usage" function of cgdelete tool. Remove a level of indentation.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgcreate: polish usage function
Ivana Hutarova Varekova [Thu, 26 Sep 2013 10:00:16 +0000 (12:00 +0200)] 
cgcreate: polish usage function

This change is suggested by Dhaval Giani <dhaval.giani@gmail.com>.
Polish "usage" function of cgcreate tool. Remove a level of indentation.
use printf instead of fprintf(stderr,...)

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgconfig: unify the help output
Ivana Hutarova Varekova [Thu, 26 Sep 2013 09:59:32 +0000 (11:59 +0200)] 
cgconfig: unify the help output

Remove cgconfig input free row and change the output program name to standardize
the output with the other libcgroup tools.
sort options based on alphabetical order

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgclear: unify help output
Ivana Hutarova Varekova [Thu, 26 Sep 2013 09:58:39 +0000 (11:58 +0200)] 
cgclear: unify help output

cgclear: unify help output
put the options to chronological order

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgconfig: polish usage function
Ivana Hutarova Varekova [Thu, 26 Sep 2013 09:57:26 +0000 (11:57 +0200)] 
cgconfig: polish usage function

This change is suggested by Dhaval Giani <dhaval.giani@gmail.com>.
Polish "usage" function of cgconfig tool. Remove a level of indentation.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgclear: polish usage function
Ivana Hutarova Varekova [Thu, 26 Sep 2013 09:57:06 +0000 (11:57 +0200)] 
cgclear: polish usage function

This change is suggested by Dhaval Giani <dhaval.giani@gmail.com>.
Polish "usage" function of cgclear tool. Remove a level of indentation.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgclassify: unify help output
Ivana Hutarova Varekova [Thu, 26 Sep 2013 09:56:33 +0000 (11:56 +0200)] 
cgclassify: unify help output

cgclassify: unify help output
* -g option is optional
* use the alphabetical order
* add -h option description

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agocgclassify: polish usage function
Ivana Hutarova Varekova [Thu, 26 Sep 2013 09:53:33 +0000 (11:53 +0200)] 
cgclassify: polish usage function

This change is suggested by Dhaval Giani <dhaval.giani@gmail.com>.
Polish "usage function and remove a level of indentation.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
11 years agocgconfig: change function usage behavior
Libo Chen [Thu, 12 Sep 2013 06:38:34 +0000 (08:38 +0200)] 
cgconfig: change function usage behavior

remove exit from function usage and add a structure like usage function
in the other tools.
This is suggested by Ivana Hutarova Varekova <varekova@redhat.com>

now usage willn't exit, so we should help it in err case.

v4:
 - fix some code style reported by checkpatch.pl

Signed-off-by: Libo Chen <clbchenlibo.chen@huawei.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agocgconfig: add check and nonzero
Libo Chen [Tue, 10 Sep 2013 06:29:17 +0000 (08:29 +0200)] 
cgconfig: add check and nonzero

1. check return value of cgroup_string_list_init.
2. add nonzero for -a and -t

v4:
 - add nonzero for cgroup_new_cgroup

Signed-off-by: Libo Chen <clbchenlibo.chen@huawei.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agocgconfig: correct freeing default_cgroup
Libo Chen [Tue, 10 Sep 2013 06:27:05 +0000 (08:27 +0200)] 
cgconfig: correct freeing default_cgroup

We are freeing up default_cgroup even it has not be allocated,
there is no need to do that.

Yes, it is just a cleanup suggested
by Dhaval Giani <dhaval.giani@gmail.com>

Signed-off-by: Libo Chen <clbchenlibo.chen@huawei.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agocgconfig: add parameter check
Libo Chen [Tue, 10 Sep 2013 06:22:04 +0000 (08:22 +0200)] 
cgconfig: add parameter check

we should check invalite parameter, and then print a warning

v3:
 - usage has changed, so no need of fprintf output
v2:
 - change print info format. This is suggested
   by Dhaval Giani <dhaval.giani@gmail.com>

Signed-off-by: Libo Chen <clbchenlibo.chen@huawei.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agocgconfig: fix the excursive processing
Libo Chen [Tue, 10 Sep 2013 06:18:32 +0000 (08:18 +0200)] 
cgconfig: fix the excursive processing

error and ret should be unified

v4:
 - use error for cgroup_string_list_add_item
   goto err lable instead of exit

Signed-off-by: Libo Chen <clbchenlibo.chen@huawei.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agocgconfig: add err check
Libo Chen [Tue, 10 Sep 2013 06:13:56 +0000 (08:13 +0200)] 
cgconfig: add err check

cgroup still can be created even if giving invalid -d,-f,-s parameter.
e.g.
        cgconfigparser  -d 888 -l /etc/cgconfig.conf
        "888" is invalid, but cgroup will be created.

        So we should exit when -d,-f or -s is invalid.

v3:
 - add nonzero return value
 - use error instead of ret

Signed-off-by: Libo Chen <clbchenlibo.chen@huawei.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agocgcreate: add err check
Libo Chen [Tue, 10 Sep 2013 06:11:56 +0000 (08:11 +0200)] 
cgcreate: add err check

cgroup still can be created even if giving invalid -d,-f,-s parameter
e.g.
        cgcreate -g cpu:/test -d 888
        "888" is invalid, but test will be cgreated.

        So we should exit if -d,-f or -s is invalid

v2:
 - add nonzero return value

Signed-off-by: Libo Chen <clbchenlibo.chen@huawei.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agocgred:cgred should start when cgroup is mounted
Weng Meiling [Tue, 10 Sep 2013 06:06:20 +0000 (08:06 +0200)] 
cgred:cgred should start when cgroup is mounted

If we mount the cgroup without the name cgroup like the following:
cpu on /cgroup/cpu type cgroup (rw,cpu)

the cgred service will start failed, because it just check the name.
So changing cgred to check the mounted system's type instead of the name.

v1 -> v2
Using the right method to check cgroup filesystem. The first version
patch's method is wrong, so resend the second patch.

Signed-off-by: Weng Meiling <wengmeiling.weng@huawei.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
11 years agocgsnapshot: don't display mountpoints which are not wanted
Ivana Hutarova Varekova [Mon, 2 Sep 2013 11:49:35 +0000 (13:49 +0200)] 
cgsnapshot: don't display mountpoints which are not wanted

the first version of this patch was created by Libo Chen <clbchenlibo.chen@...>
see http://sourceforge.net/p/libcg/mailman/libcg-devel/thread/51FB6459.9000307%40huawei.com/#msg31243958

before patch:
        #lscgroup
        cpu:/
        cpuset:/

        #cgsnapshot -s cpu

        mount {
            cpuset = /cgroup/cpuacct;
            cpu = /cgroup/cpu;
        }

We just wanted to save cpu controller, so cpuset was unexpected

Changelog:
     * parse controller list only if the list is set, if there is no restriction display all hierarchies
     * parse named list as well, thus they are not output if they are not wanted
     * remove TODO comment

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Reported-by: Libo Chen <clbchenlibo.chen@...>
Acked-by: Jan Safranek <jsafrane@redhat.com>
11 years agolog.h: add head file <stdarg.h>
Libo Chen [Sun, 1 Sep 2013 12:53:11 +0000 (14:53 +0200)] 
log.h: add head file <stdarg.h>

libcg was compiled failed in suse sp2 with libc-2.11.3:
"include/libcgroup/log.h:90: error: expected declaration specifiers
or '...' before 'va_list'"

 so add #include <stdarg.h>

Signed-off-by: Libo Chen <libo.chen@huawei.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
Committer: Ivana Hutarova Varekova <varekova@redhat.com>

12 years agocreate_cgroup_from_name_value_pairs can't deal n/v pairs from the same controller
Ivana Hutarova Varekova [Tue, 30 Jul 2013 07:57:07 +0000 (09:57 +0200)] 
create_cgroup_from_name_value_pairs can't deal n/v pairs from the same controller

create_cgroup_from_name_value_pairs can't deal name/value pairs from the
same controller
E.G.
    cgset -r cpu.cfs_quota_us=400000 -r cpu.cfs_period_us=400000 cgroup
This patch fix the problem.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
12 years agocgclassify: use the error message instead of error number
Weng Meiling [Wed, 24 Jul 2013 15:46:27 +0000 (17:46 +0200)] 
cgclassify: use the error message instead of error number

It's more readable and friendly to use the detailed error
message instead of error number as other places.

Signed-off-by: Weng Meiling <wengmeiling.weng@huawei.com>
Acked-by: Ivana Hutarov Varekova <varekova@redhat.com>
12 years agoIt's more readable and friendly to use the enum value instead of number.
Weng Meiling [Tue, 23 Jul 2013 12:58:20 +0000 (14:58 +0200)] 
It's more readable and friendly to use the enum value instead of number.

Signed-off-by: Weng Meiling <wengmeiling.weng@huawei.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agowhen we use cgsnapshot with the given controller, the result always
Weng Meiling [Tue, 23 Jul 2013 12:30:33 +0000 (14:30 +0200)] 
when we use cgsnapshot with the given controller, the result always
displays
the last mounted controller which is not specified, so fix it.

Example:

# lssubsys  -m
cpuset /cgroup/cpuset
cpu /cgroup/cpu
# lscgroup
cpu:/
cpu:/test
cpuset:/
cpuset:/test

before the patch:

# cgsnapshot -s cpu
# Configuration file generated by cgsnapshot
mount {
cpuset = /cgroup/cpuset;
cpu = /cgroup/cpu;
}

group test {
cpu {
cpu.rt_period_us="1000000";
cpu.rt_runtime_us="0";
cpu.shares="1024";
}
}

group test {
cpuset {
cpuset.memory_spread_slab="0";
cpuset.memory_spread_page="0";
cpuset.memory_migrate="0";
cpuset.sched_relax_domain_level="-1";
cpuset.sched_load_balance="1";
cpuset.mem_hardwall="0";
cpuset.mem_exclusive="0";
cpuset.cpu_exclusive="0";
cpuset.mems="";
cpuset.cpus="";
}
}

after the patch:

# cgsnapshot -s cpu
# Configuration file generated by cgsnapshot
mount {
cpuset = /cgroup/cpuset;
cpu = /cgroup/cpu;
}

group test {
cpu {
cpu.rt_period_us="1000000";
cpu.rt_runtime_us="0";
cpu.shares="1024";
}
}

Signed-off-by: Weng Meiling <wengmeiling.weng@huawei.com>
12 years agolex: suppress useless warning message during compilation
Ivana Hutarova Varekova [Thu, 18 Jul 2013 10:52:53 +0000 (12:52 +0200)] 
lex: suppress useless warning message during compilation

use pragma section to suppress
error: 'yy_fatal_error'
defined but not used message

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
12 years agoparse: fix template parsing
Ivana Hutarova Varekova [Thu, 18 Jul 2013 10:51:46 +0000 (12:51 +0200)] 
parse: fix template parsing

The old version has problem with name/value pairs parsing in template
tag in parse.y. This patch fix it.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
12 years agoconfig.c: better detect whether template group already is created
Ivana Hutarova Varekova [Thu, 18 Jul 2013 10:51:41 +0000 (12:51 +0200)] 
config.c: better detect whether template group already is created

cgroup_config_create_template_group: properly detect whether template group was created

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
12 years agodocumentation: fix cgroup_copy cgroup description
Ivana Hutarova Varekova [Thu, 18 Jul 2013 10:28:55 +0000 (12:28 +0200)] 
documentation: fix cgroup_copy cgroup description

fix cgroup_copy_cgroup description. There should be obvious this function only copy the controller stuff. It does not copy permissions, name and ownership.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
12 years agofix template function to copy template groups properly
Ivana Hutarova Varekova [Thu, 18 Jul 2013 10:07:29 +0000 (12:07 +0200)] 
fix template function to copy template groups properly

This patch fixes cgroup_init_templates_cache and cgroup_reload_cached_templates functions. Their have to copy  not only
controllers and their structures but all variables (controller name, permissions and ownership) for templates.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
12 years agocgsnapshot: fix the print message when use cgsnapshot with -f
Weng Meiling [Tue, 25 Jun 2013 07:53:22 +0000 (09:53 +0200)] 
cgsnapshot: fix the print message when use cgsnapshot with -f

When use cgsnapshot with -f to save current configuration of cgroups,
the mount section is missing, this patch fix it.

the example as following:
# cgsnapshot -s -f config
        cpu = /cgroup/cpu;
# cat config
# Configuration file generated by cgsnapshot
mount {
}

group test {
        cpu {
                cpu.rt_period_us="1000000";
                cpu.rt_runtime_us="0";
                cpu.cfs_period_us="100000";
                cpu.cfs_quota_us="-1";
                cpu.shares="1024";
        }
}

Signed-off-by: Weng Meiling <wengmeiling.weng@huawei.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoCgred service won't start if /etc/cgrules.conf is missing
Peter Schiffer [Tue, 25 Jun 2013 04:47:47 +0000 (06:47 +0200)] 
Cgred service won't start if /etc/cgrules.conf is missing

By default, the /etc/cgrules.conf file contains only comments. If this is the case, the cgred service starts without problem. But if /etc/cgrules.conf file is empty or missing, the cgred service won't start, even this case is equivalent with the first one.

This patch allows the cgred service start even when the /etc/cgrules.conf files is empty, or missing.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoUse cache when reading /etc/passwd file
Peter Schiffer [Tue, 25 Jun 2013 04:37:41 +0000 (06:37 +0200)] 
Use cache when reading /etc/passwd file

Currently, libcgroup code reads /etc/passwd file once for every line in the cgrules.conf file, what can have performance impact on the login times if system contains thousands of users and cgrules.conf contains thousands of lines.

This patch adds CGFLAG_USECACHE flag to the cgroup_change_cgroup_uid_gid() function call which enables cache usage, and thus speeds up login times on those systems.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agocgroup_get_cgroup: remove bogus comment
Ivana Hutarova Varekova [Sun, 9 Jun 2013 04:47:18 +0000 (06:47 +0200)] 
cgroup_get_cgroup: remove bogus comment

cgroup_get_cgroup: remove bogus comment

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
12 years agofix permissions of logger.sh
Ivana Hutarova Varekova [Sun, 9 Jun 2013 04:46:35 +0000 (06:46 +0200)] 
fix permissions of logger.sh

change permissions to 755 to enable the file to be executed

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
12 years agoremove useless cgroup_rules_loaded
Ivana Hutarova Varekova [Sun, 9 Jun 2013 04:46:09 +0000 (06:46 +0200)] 
remove useless cgroup_rules_loaded

I don't see the reason to have cgroup_rules_loaded variable.
It is set but not used any more. Thus I'm removing it. Reply an e-mail if I'm wrong.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
12 years agov0.40.rc1
Ivana Hutarova Varekova [Tue, 21 May 2013 13:10:16 +0000 (15:10 +0200)] 
v0.40.rc1

I am releasing v0.40.rc1.

The major changes are template stuff and new logging.

List of all patches:
    Ivana Hutarova Varekova (12):
          cgrules.conf: no documentation inside config file
          cgroup_change_cgroup_flags: create template control group on the fly
          cgconfigparser: add template tag to cgconfigparser
          cgconfig.conf: parse template tag and fill relevant structures
          config.h: create function for init/reload cgconfig template cache
          api: add function for creating template control groups
          cgrulesengd: cache templates
          cgroup_change_cgroup_flags: use templates if they are in rules
          update documentation to reflect the changes regarding templates
          api.c: cgroup_create_template_group templates crashing
          templates have to be coppied in proper way to template_table structure
          remove useless include from log.h

    John Fastabend (1):
          libcg: scan running tasks at start time to classify existing pids

    Peter Schiffer (15):
          Removed cgroup_dbg from cgrulesengd
          Reworked libcgroup logging
          Enabled default logging
          Reworked logging configuration
          Added parsing of CGROUP_LOGLEVEL
          Recognize DEBUG level of CGROUP_LOGLEVEL variable in daemon
          Fixed cgrulesengd to log libcgroup log messages to syslog
          Changed log level of various messages
          Added new errors/warnings
          Enabled logging in cgconfigparser
          Added new logging to the tools
          Added a test for the new logging
          Added CGROUP_LOGLEVEL to man pages + fixed the style of 'FILES' section     where appropriate.
          Update default logging for cgrulesengd
          Make cg_mkdir_p() function compatible with read-only fs

    Robert Milasan (1):
          fix defaultcgroup detection (better description)

    Roberto Polli (1):
          support indented comments in cgconfigparser

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoremove useless include from log.h
Ivana Hutarova Varekova [Tue, 21 May 2013 09:25:59 +0000 (11:25 +0200)] 
remove useless include from log.h

stdarg.h include in log.h is useless. This patch removes it.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
12 years agoMake cg_mkdir_p() function compatible with read-only fs
Peter Schiffer [Thu, 16 May 2013 15:10:32 +0000 (17:10 +0200)] 
Make cg_mkdir_p() function compatible with read-only fs

mkdir(2) function returns EROFS error even when the path already exists on
the read only file system, so it is impossible to determine whether the path
already exists on this kind of fs only be return code from the mkdir(2). To make
cg_mkdir_p() compatible with the ro fs, the function checks whether the
path exists with stat(2) before trying to create it.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-By: Jan Safranek <jsafrane@redhat.com>
12 years agosupport indented comments in cgconfigparser
Roberto Polli [Sun, 12 May 2013 11:22:39 +0000 (13:22 +0200)] 
support indented comments in cgconfigparser

support indented comments in cgconfigparser

Signed-off-by: Roberto Polli <robipolli@gmail.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agotemplates have to be coppied in proper way to template_table structure
Ivana Hutarova Varekova [Thu, 9 May 2013 12:04:00 +0000 (14:04 +0200)] 
templates have to be coppied in proper way to template_table structure

cgroup_reload_cached_templates and cgroup_init_templates_cache functions fill structure template_table in old version the data are coppied
(memcpy function) from config_template_table.
This causes problem if both template_table and config_template_table are reloaded or if config_template_table is updated. Patch fix this problem and copy data properly (cgroup_copy_cgroup function)
    The reproducer of this bug is described in http://sourceforge.net/mailarchive/forum.php?thread_name=khtfkj%24c8l%241%40ger.gmane.org&forum_name=libcg-devel

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-By: Jan Safranek <jsafrane@redhat.com>
12 years agoapi.c: cgroup_create_template_group templates crashing
Ivana Hutarova Varekova [Thu, 9 May 2013 11:51:19 +0000 (13:51 +0200)] 
api.c: cgroup_create_template_group templates crashing

cgroup_create_template_group procedure writes to the first place of string of characters even if the varible points to NULL. As the result templates crashes.
See http://sourceforge.net/mailarchive/forum.php?thread_name=khtfkj%24c8l%241%40ger.gmane.org&forum_name=libcg-devel

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-By: Jan Safranek <jsafrane@redhat.com>
12 years agoUpdate default logging for cgrulesengd
Peter Schiffer [Tue, 2 Apr 2013 08:57:07 +0000 (10:57 +0200)] 
Update default logging for cgrulesengd

Cgrulesengd is using different default logging level than the library.
Currently
it's set to WARNING, which is not consistend with the rest of the library.
This
patch sets the default logging level to ERROR.

This patch also unifies logging levels with default logging system used in
libcg, be removing LOG_NOTICE and replacing it with LOG_INFO.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoAdded CGROUP_LOGLEVEL to man pages + fixed the style of 'FILES' section
Peter Schiffer [Tue, 2 Apr 2013 08:57:02 +0000 (10:57 +0200)] 
Added CGROUP_LOGLEVEL to man pages + fixed the style of 'FILES' section
where appropriate.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoAdded a test for the new logging
Peter Schiffer [Tue, 2 Apr 2013 08:57:01 +0000 (10:57 +0200)] 
Added a test for the new logging

New simple tests, testing
 - standard (stdout) callback
 - custom application callback
 - all loglevels
 - automatic loglevel extraction from CGROUP_LOGLEVEL

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoAdded new logging to the tools
Peter Schiffer [Tue, 2 Apr 2013 08:56:52 +0000 (10:56 +0200)] 
Added new logging to the tools

Tools should use cgroup_log now.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoEnabled logging in cgconfigparser
Peter Schiffer [Tue, 2 Apr 2013 08:56:51 +0000 (10:56 +0200)] 
Enabled logging in cgconfigparser

cgconfigparser calls cgroup_init too late, it's necessary to initialize
libcgroup logging earlier in the process, so various messages get visible
to user.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoAdded new errors/warnings
Peter Schiffer [Tue, 2 Apr 2013 08:56:45 +0000 (10:56 +0200)] 
Added new errors/warnings

I've put few errors and warnings where I find them appropriate - usually
when a function returns error and the user might be interested exactly what
file/directory is bad.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoChanged log level of various messages
Peter Schiffer [Tue, 2 Apr 2013 08:55:40 +0000 (10:55 +0200)] 
Changed log level of various messages

I went through cgroup_dbg messages and increased they log level where I
found it appropriate. I am pretty sure I missed other important ones, this
is just a first attempt. Feel free to suggest additional messages.

Changelog:
  - fixed capital letters in few log messages

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoFixed cgrulesengd to log libcgroup log messages to syslog
Peter Schiffer [Tue, 2 Apr 2013 08:55:38 +0000 (10:55 +0200)] 
Fixed cgrulesengd to log libcgroup log messages to syslog

Now we have the infrastructure, libcgroup log messages should be sent
together with cgrulesengd ones to syslog.

As side effect, all flog messages must end with '\n' to match libcgroup
standards.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoRecognize DEBUG level of CGROUP_LOGLEVEL variable in daemon
Peter Schiffer [Tue, 2 Apr 2013 08:55:33 +0000 (10:55 +0200)] 
Recognize DEBUG level of CGROUP_LOGLEVEL variable in daemon

If CGROUP_LOGLEVEL=DEBUG environment variable is set, enable --debug
verbosity
level in the cgrulesengd daemon.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoAdded parsing of CGROUP_LOGLEVEL
Peter Schiffer [Tue, 2 Apr 2013 08:55:33 +0000 (10:55 +0200)] 
Added parsing of CGROUP_LOGLEVEL

Allowed values are:
 - DEBUG, INFO, WARNING, ERROR (case insensitive)
 - integer numbers

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoReworked logging configuration
Peter Schiffer [Tue, 2 Apr 2013 08:54:58 +0000 (10:54 +0200)] 
Reworked logging configuration

Debug log messages are now automatically compiled in libcgroup unless
explicitly disabled with ./configure --disable-debug.

Please note that the messages still must be enabled in runtime by setting
appropriate log level, e.g. export CGROUP_LOGLEVEL=DEBUG.

Changelog:
  - removed --disable-debug option of configure script, removing debug
    messages we would save 'amazing' 4kB, which is IMO not worth it.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoEnabled default logging
Peter Schiffer [Tue, 2 Apr 2013 08:54:24 +0000 (10:54 +0200)] 
Enabled default logging

Default target of log messages is stdout and ERRORs are sent there by
default.

This is quite a change from the behavior of previous versions - no logging
was sent anywhere unless --enable-debug was specified at ./configure time.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
12 years agoReworked libcgroup logging
Peter Schiffer [Tue, 2 Apr 2013 08:52:59 +0000 (10:52 +0200)] 
Reworked libcgroup logging

Whole new logging with following goals is here:
 - more log levels.
 - allow applications to log somewhere else than stdout using their custom
   callback.
 - provide simple stdout logger for 'lazy' applications.

The logging is off by default, i.e. no message appears on stdout unless
application initializes the logging explicitly. But see following patches!

Internally, nothing changes, cgroup_dbg is still working. In addition,
cgroup_err, cgroup_warn and cgroup_info appeared. Description what message
should use which log level is in doxygen info, together with new public API
incl. simple example, I won't copy it here

Also the cgroup_log function is made public. I am not sure if it is the
right thing to do, but that's currently the simplest way how to use the
logging from our tools (which link only the public libcgroup API).

Changelog:
  - fixed typo in cgroup_log doxygen comment

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>