]> git.ipfire.org Git - thirdparty/libcgroup.git/log
thirdparty/libcgroup.git
14 years agoscripts: cgconfig, cleanup
Jiri Slaby [Wed, 12 Jan 2011 13:53:43 +0000 (14:53 +0100)] 
scripts: cgconfig, cleanup

* get rid of some unneeded bashisms
* remove unused variables

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoupdate .gitignore's
Jiri Slaby [Wed, 12 Jan 2011 13:53:42 +0000 (14:53 +0100)] 
update .gitignore's

Some files were not in .gitignore files, add them properly to not show
up in the status list.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoAllow commas for cpu sets in cgconfig.conf
James M Leddy [Wed, 23 Feb 2011 15:39:42 +0000 (10:39 -0500)] 
Allow commas for cpu sets in cgconfig.conf

We set disjoint cpu sets with the following command:

cgset -r cpuset.cpus=0,2 slot1

However, we don't allow commas that as part of the grammar when used
in the configuration file at cgconfig.conf. This patch seeks to
address that.

Signed-off-by: James M Leddy <james.leddy@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agocgrulesengd: Ignore netlink messages that don't come from the kernel.
Nelson Elhage [Fri, 18 Feb 2011 01:55:12 +0000 (20:55 -0500)] 
cgrulesengd: Ignore netlink messages that don't come from the kernel.

recvfrom() returns the address, it doesn't filter the packet based on the
sender. We need to explicitly check the received address after the call happens.

Signed-off-by: Nelson Elhage <nelhage@ksplice.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agocgrulesengd: Improve handling of out-of-memory.
Nelson Elhage [Fri, 18 Feb 2011 01:55:11 +0000 (20:55 -0500)] 
cgrulesengd: Improve handling of out-of-memory.

Don't leak the old array if the allocation fails, and don't touch num_allocation
if the allocation fails.

Signed-off-by: Nelson Elhage <nelhage@ksplice.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoMake --sticky option effective when setuid(2) and setgid(2)
Ken'ichi Ohmichi [Thu, 10 Feb 2011 04:41:58 +0000 (13:41 +0900)] 
Make --sticky option effective when setuid(2) and setgid(2)

A cgrulesengd daemon did not check whether a stickied process or when
setuid(2)/setgid(2) happens, and the daemon moved the process based on
/etc/cgrules.conf.
So --sticky option was not effective when setuid(2)/setgid(2).

This patch makes --sticky effective when setuid(2) and setgid(2) also.

Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agoAdd bindings for python
Balbir Singh [Sun, 2 Jan 2011 10:03:32 +0000 (15:33 +0530)] 
Add bindings for python

The added bindings depend on swig and hence are disabled by
default. If you know what you are doing, enable the bindings
for python. To test the bindings, ensure _libcgroup.so
is copied in the same directory as libcgroup.py. There after
libcgroup API's can be invoked from python.

Please use --enable-bindings after installing swig to compile
with the changes

Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years ago[Libcg-devel] [PATCH] BUGFIX: add missing braces
Jan Safranek [Mon, 10 Jan 2011 14:31:52 +0000 (15:31 +0100)] 
[Libcg-devel] [PATCH] BUGFIX: add missing braces

Fix cgclassify to return zero exit code when it succeeds.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years ago[PATCH 3/3] config: fix segfault in cgconfigparser
Jiri Slaby [Tue, 4 Jan 2011 16:56:40 +0000 (17:56 +0100)] 
[PATCH 3/3] config: fix segfault in cgconfigparser

We now get:
Program received signal SIGSEGV, Segmentation fault.
cgroup_add_controller (cgroup=0x7ffff7f86010, name=0x606300 "cpuacct") at wrapper.c:70
70              cgroup->controller[cgroup->index] = controller;
(gdb) where
0  cgroup_add_controller (cgroup=0x7ffff7f86010, name=0x606300 "cpuacct") at wrapper.c:70
1  0x00007ffff79806d4 in cgroup_config_parse_controller_options (controller=0x606300 "cpuacct", values=0x6085b0)
    at config.c:135
2  0x00007ffff79793ec in yyparse () at parse.y:97
3  0x00007ffff7980ee1 in cgroup_config_load_config (pathname=<value optimized out>) at config.c:667
4  0x00000000004009f4 in main (argc=3, argv=0x7fffffffdf08) at cgconfig.c:67

It's because cgroup structure is unitialized. Especially its member
index is not and later we access cgroup->controller[cgroup->index]
with cgroup->index negative and kaboom, we explode.

Use calloc and realloc+memset to avoid that.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years ago[PATCH 2/3] cgsnapshot: fix strn* lengths
Jiri Slaby [Tue, 4 Jan 2011 16:56:39 +0000 (17:56 +0100)] 
[PATCH 2/3] cgsnapshot: fix strn* lengths

The 'n' parameter in strncat stands for how much to copy from src, not
what's dest overall space. So we need to subtract full strlen we have
constructed so far.

Also fix one strncpy where we may pass too much as well as in strncpy.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years ago[PATCH 1/3] API: fix mount/namespace error message
Jiri Slaby [Tue, 4 Jan 2011 16:56:38 +0000 (17:56 +0100)] 
[PATCH 1/3] API: fix mount/namespace error message

When one passes no input to the parser, it spits out:
Cannot have mount and namespace keyword in the same configuration file
It's wrong, because we have none of them. So change it to:
Either mount or namespace keyword has to be specified in the configuration file

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agoSubstitutions in the destinations of the rules
Michal Hrusecky [Wed, 22 Dec 2010 19:39:10 +0000 (20:39 +0100)] 
Substitutions in the destinations of the rules

Rules can be written using wildcards, but destinations had to be static.
This patch adds support for following strings in destination:

   %u - uid
   %U - username, uid in case of error
   %g - gid
   %G - group name, gid in case of error
   %p - pid
   %P - proccess name, pid in case of error

More general rules can be specified using wildcards. Example rule can be:

*@users        *     %G/%U

This will put all users in their own cgroups named by their login and
group.

Signed-off-by: Michal Hrusecky <Michal@Hrusecky.net>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoFix commit 17a40d649c9dfc539b18784c644d8a45916ecd68
Balbir Singh [Wed, 15 Dec 2010 17:20:42 +0000 (22:50 +0530)] 
Fix commit 17a40d649c9dfc539b18784c644d8a45916ecd68

Commit 17a40d649c9dfc539b18784c644d8a45916ecd68 had a patch, that I failed
to push as a part of that commit (stg ref went missing). Fix it correctly
this time

Signed-off-by: Ciju Rajan K <ciju@linux.vnet.ibm.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agocgred.in: fix return value start()/stop() function's
tachibana@mxm.nes.nec.co.jp [Fri, 19 Nov 2010 08:08:21 +0000 (17:08 +0900)] 
cgred.in: fix return value start()/stop() function's

Now cgred script can't return proper value. Because
stop()/start() functions return result of if [] when failing,
and result of wrong commands when succeeding.

So fix this.

Signed-off-by: Masaki Tachibana <tachibana@mxm.nes.nec.co.jp>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoWhen we invoke cgroup_get_cgroup() to get the cgroup meta data, the
Ciju Rajan K [Wed, 15 Dec 2010 11:19:23 +0000 (16:49 +0530)] 
When we invoke cgroup_get_cgroup() to get the cgroup meta data, the
admin_id and admin_gid are not displayed correctly. This is because
cgroup_fill_cgc() does not differentiate between the cgroup control
files and tasks file. So cgroup->control_uid and cgroup->control_gid
fields are getting populated with the uid and gid of tasks file.

This patch fixes this problem by adding a check in the cgroup_fill_cgc()
function to see if the file is a 'tasks' file or not.

Changes from v1.0:

* Instead of using strstr() using pointer arithmetic to get the last six
characters of the entire path

* Fixed the problem of dealing *tasks* string as part of directory names

Signed-off-by: Ciju Rajan K <ciju@linux.vnet.ibm.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agoMerge branch 'master' of ssh://libcg.git.sf.net/gitroot/libcg/libcg
Balbir Singh [Mon, 13 Dec 2010 16:22:47 +0000 (21:52 +0530)] 
Merge branch 'master' of ssh://libcg.git.sf.net/gitroot/libcg/libcg

14 years agoRerelease v0.37 v0.37
Balbir Singh [Tue, 7 Dec 2010 17:06:11 +0000 (22:36 +0530)] 
Rerelease v0.37

14 years agoRelease v0.37
Balbir Singh [Tue, 7 Dec 2010 15:43:24 +0000 (21:13 +0530)] 
Release v0.37

Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agoThe cgrulesengd parameter to set different log file is --logfile,
Jan Safranek [Fri, 3 Dec 2010 09:39:28 +0000 (10:39 +0100)] 
The cgrulesengd parameter to set different log file is --logfile,
not --log-file.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agocgsnapshot is not much useful without a blacklist file, so let's distribute
Jan Safranek [Fri, 3 Dec 2010 09:38:41 +0000 (10:38 +0100)] 
cgsnapshot is not much useful without a blacklist file, so let's distribute
the sample we provide.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agofree the used memory correctly
Jan Safranek [Thu, 2 Dec 2010 14:00:40 +0000 (15:00 +0100)] 
free the used memory correctly

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoif a hierarchy with more controllers is parsed before hierarchy with less
Jan Safranek [Thu, 2 Dec 2010 14:00:40 +0000 (15:00 +0100)] 
if a hierarchy with more controllers is parsed before hierarchy with less
controllers as the last two hierarchies, then the output of cgsnapshot is
broken - test is missing

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoThere is a bug which causes the initialised configuration will
Jan Safranek [Thu, 2 Dec 2010 14:00:40 +0000 (15:00 +0100)] 
There is a bug which causes the initialised configuration will
be bogus or does not work at all and majority of tools does not work well.
The situation happens when multiple mount points are mounted for one hierarchy and the hierarchy
have multiple controllers:

example:

# lssubsys
cpu,cpuacct /mnt/cgroups/cpu
cpuacct /cgroup/cpu
memory /cgroup/memory

# cat /proc/mounts | grep cgroup
cpu /mnt/cgroups/cpu cgroup rw,relatime,cpuacct,cpu 0 0
cgroup /cgroup/cpu cgroup rw,relatime,cpuacct,cpu 0 0
cgroup /cgroup/memory cgroup rw,relatime,memory 0 0

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agothere is no sense to read the data for cgroup which was not found
Jan Safranek [Thu, 2 Dec 2010 14:00:40 +0000 (15:00 +0100)] 
there is no sense to read the data for cgroup which was not found

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoIn corner case there is omitted incrementation of the counter so
Jan Safranek [Thu, 2 Dec 2010 14:00:40 +0000 (15:00 +0100)] 
In corner case there is omitted incrementation of the counter so
there will be endless loop. This patch fixes the problem

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoThere is a bogus test in cgroup_get_parent_name
Jan Safranek [Thu, 2 Dec 2010 14:00:40 +0000 (15:00 +0100)] 
There is a bogus test in cgroup_get_parent_name
which returns error in situation when 0 should be return.
This causes problem e.g. when a hierarchy is mounted to two
mount points.

CHANGELOG:
- the test is not removed but moved to the else part

EXAMPLE:

$ cat aux.conf
mount {
cpu = /cgroup/cpu;
cpuacct = /cgroup/cpu;
memory = /cgroup/memory;
}
group hXAjiy/wWRq {
cpu {}
memory {}
}
$ mkdir /mnt/cgroups/cpu 2>/dev/null
$ mount -t cgroup -o cpu,cpuacct cpu /mnt/cgroups/cpu
$ time cgconfigparser -l aux.conf
$ cgclear
$ cat /proc/cgroups

OLD output
#subsys_name hierarchy num_cgroups enabled
cpuset 0 1 1
ns 0 1 1
cpu 301 1 1
cpuacct 301 1 1
memory 303 3 1
devices 0 1 1
freezer 0 1 1
net_cls 0 1 1
blkio 0 1 1

New output
#subsys_name    hierarchy   num_cgroups enabled
cpuset  0   1   1
ns  0   1   1
cpu 0   1   1
cpuacct 0   1   1
memory  0   1   1
devices 0   1   1
freezer 0   1   1
net_cls 0   1   1
blkio   0   1   1

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoMerge branch 'master' of ssh://libcg.git.sf.net/gitroot/libcg/libcg
Balbir Singh [Thu, 25 Nov 2010 09:31:26 +0000 (15:01 +0530)] 
Merge branch 'master' of ssh://libcg.git.sf.net/gitroot/libcg/libcg

14 years agoremove the perm part from cgsnapshot output if possible
Ivana Hutarova Varekova [Tue, 16 Nov 2010 11:32:47 +0000 (12:32 +0100)] 
remove the perm part from cgsnapshot output if possible

This patch removes perm part from cgsnapshot output if it
is set to the default one:

EXAMPLE:
old version:
# Configuration file generated by cgsnapshot
mount {
memory = /cgroup/cpu2;
devices = /cgroup/cpu3;
}

group CBSFxx {
perm {
admin {
uid = root;
gid = root;
}
task {
uid = root;
gid = root;
}
}
devices {
devices.deny="a *:* rwm";
devices.allow="a *:* rwm";
}
}

new version:
# Configuration file generated by cgsnapshot
mount {
memory = /cgroup/cpu2;
devices = /cgroup/cpu3;
}

group CBSFxx {
devices {
devices.deny="a *:* rwm";
devices.allow="a *:* rwm";
}
}

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-By: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agov2 [patch 6/6] api: Fix cgroup_walk_tree_begin memory leak
Dhaval Giani [Tue, 16 Nov 2010 13:29:51 +0000 (14:29 +0100)] 
v2 [patch 6/6] api: Fix cgroup_walk_tree_begin memory leak

As pointed out by Steve Grubb at
http://article.gmane.org/gmane.comp.lib.libcg.devel/2485 we leak
entry in cgroup_walk_tree_begin

When we fail fts_read, we need to ensure that entry is freed
on return. Do so.

Reported-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-By: Jan Safranek <jsafrane@redhat.com>
14 years agov2 [patch 5/6] api: Remove unnecessary check
Dhaval Giani [Tue, 16 Nov 2010 13:29:50 +0000 (14:29 +0100)] 
v2 [patch 5/6] api: Remove unnecessary check

Steve Grubb pointed out at
http://article.gmane.org/gmane.comp.lib.libcg.devel/2485
that the additional check for EOF is unneeded since EOF != 3.

Remove this check

Reported-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-By: Jan Safranek <jsafrane@redhat.com>
14 years agov2 [patch 4/6] api: Use a new counter in an inner loop
Dhaval Giani [Tue, 16 Nov 2010 13:29:49 +0000 (14:29 +0100)] 
v2 [patch 4/6] api: Use a new counter in an inner loop

The same counter is reused in an inner loop in cg_prepare_cgroup.
This is perfectly fine simply because we never exit the inner
loop to the outer loop. The only way out of the inner loop leads
to a return statement, during which there is no mention of the
outer counter.

However, this is ugly code, and hard to read and may lead to bugs
if some decides to refactor the code. So clean it all up using a
different counter.

Thanks to Steve Grubb for raising this issue at
http://article.gmane.org/gmane.comp.lib.libcg.devel/2485

Reported-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-By: Jan Safranek <jsafrane@redhat.com>
14 years agov2 [patch 3/6] libcgroup: Fix up memory leak in cgroup_basename
Dhaval Giani [Tue, 16 Nov 2010 13:29:48 +0000 (14:29 +0100)] 
v2 [patch 3/6] libcgroup: Fix up memory leak in cgroup_basename

We were not freeing up tmp_string if the strdup for basename failed.

Since we anyway need to free up tmp_string and return NULL if the
strdup failed, we don't really care about testing the return value
of the strdup, and therefore this check is not needed. Remove this
check then.

Thanks to Steve Grubb's review at
http://article.gmane.org/gmane.comp.lib.libcg.devel/2485

Reported-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-By: Jan Safranek <jsafrane@redhat.com>
14 years agoFix exit code in the event of display_controller_values failure
Jan Safranek [Tue, 16 Nov 2010 11:11:28 +0000 (12:11 +0100)] 
Fix exit code in the event of display_controller_values failure

Just store the error into 'result' on error, 'ret' is not used.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agoCorrectly process display_all_controllers return value
Jan Safranek [Tue, 16 Nov 2010 11:11:21 +0000 (12:11 +0100)] 
Correctly process display_all_controllers return value

Add missing return value assignment, as pointed out by Steve Grubb.

Changelog:
- indent the 'if (ret)' lower.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agov2 [patch 2/6] wrapper.c: correct the return types
Dhaval Giani [Tue, 16 Nov 2010 13:29:47 +0000 (14:29 +0100)] 
v2 [patch 2/6] wrapper.c: correct the return types

Steve Grubb was kind enough to do a review at
http://article.gmane.org/gmane.comp.lib.libcg.devel/2485
and pointed out that we were checking for unsigned values to be
negative. That is of course wrong, and we need to actually be
checking integers. Correct the return type so that the check
is valid once more.

Reported-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-By: Jan Safranek <jsafrane@redhat.com>
14 years agov2 [patch 1/6] wrapper.c: Fix memory leaks
Dhaval Giani [Tue, 16 Nov 2010 13:29:46 +0000 (14:29 +0100)] 
v2 [patch 1/6] wrapper.c: Fix memory leaks

Steve Grubb was kind enough to do a code review at
http://article.gmane.org/gmane.comp.lib.libcg.devel/2485
and spotted a few memory leaks. Take care of them!

Reported-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-By: Jan Safranek <jsafrane@redhat.com>
14 years agoUse setresuid/setresgid to revoke suid/sgid bit
Jan Safranek [Tue, 16 Nov 2010 11:11:35 +0000 (12:11 +0100)] 
Use setresuid/setresgid to revoke suid/sgid bit

Use setresuid/setresgid to revoke suid/sgid bit instead of seteuid/setegid
in cgexec.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agoFix memory leaks in cgreate
Jan Safranek [Tue, 16 Nov 2010 11:11:14 +0000 (12:11 +0100)] 
Fix memory leaks in cgreate

Fix few memory leaks in cgcreate tools, as pointed out by Steve Grub.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agoUpdate the spec file with new user and sgid cgexec
Jan Safranek [Mon, 15 Nov 2010 13:59:58 +0000 (14:59 +0100)] 
Update the spec file with new user and sgid cgexec

Update the spec file:
- add new cgred group
- /bin/cgexec is sgid (instead of suid, as 'make install' does

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agoUpdate initscript with new socket user and group options
Jan Safranek [Mon, 15 Nov 2010 13:59:52 +0000 (14:59 +0100)] 
Update initscript with new socket user and group options

Add a posibility to set socker owner to init scripts.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agoSet cgrulesengd socket owner
Jan Safranek [Mon, 15 Nov 2010 13:59:44 +0000 (14:59 +0100)] 
Set cgrulesengd socket owner

Currently, cgexec has suid flag and runs as root because it needs to
communicate with cgrulesengd using /var/run/cgred.socket. This is generally
frowned upon, so let's add few options to cgrulesengd to set the socket
owner to someone else - cgexec does not need to run as powerful root, but
as some new harmless user or group.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agoman-pages minor typos patch
Ivana Hutarova Varekova [Mon, 15 Nov 2010 16:06:57 +0000 (17:06 +0100)] 
man-pages minor typos patch

This patch fixes several minor problem in manual pages:
* cgconfig.conf (5) .. fix "SEE ALSO" part
* cgcreate .. fix the SYNTAX part format - add bold to -g
* cgdelete .. fix .TH tag and add space to "SEE ALSO" part
* cgcreate .. fix the SYNTAX part format - add bold to -a
* cgsnapshot .. remove newline in SYNOPSIS part
* lscgroup, lssubsys, cgrules.conf .. add space to "SEE ALSO" part

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agocgclear: Do not rmdir the mount point
Dhaval Giani [Fri, 12 Nov 2010 10:19:55 +0000 (11:19 +0100)] 
cgclear: Do not rmdir the mount point

This code is strictly not needed, and was originally only added only
because cgconfigparser can mkdir the mountpoint.

Doing it however caused a few bugs and had the possibility of
changing the system state. So, let's not do it.

Should also fix up https://bugzilla.redhat.com/show_bug.cgi?id=652583

Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Tested-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoAdd the return value fts_open check
Ivana Hutarova Varekova [Fri, 12 Nov 2010 08:06:46 +0000 (09:06 +0100)] 
Add the return value fts_open check

This patch adds return value checks to two occurrences of fts_open command calls

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agocgconfig.conf man-page fix
Ivana Hutarova Varekova [Fri, 12 Nov 2010 07:37:40 +0000 (08:37 +0100)] 
cgconfig.conf man-page fix

This patch fixes the example 4 in cgconfig conf man-page

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoUpdate cgsnapshot_blacklist.conf to 2.6.36
Ivana Hutarova Varekova [Wed, 27 Oct 2010 04:38:23 +0000 (06:38 +0200)] 
Update cgsnapshot_blacklist.conf to 2.6.36

In 2.3.36 there is new variable (memory.oom_control)
in memory controller, this variable should be blacklisted now
(cgsnapshot should have some additonal logic for it)

Signed-off-by: Ivana Hutarova Varekova<varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agoFix wrong formating in cgset man page
Ivana Hutarova Varekova [Wed, 27 Oct 2010 05:32:14 +0000 (07:32 +0200)] 
Fix wrong formating in cgset man page

This patch fixes man-page formating in cgset man page

man-page without the fix:
SYNOPSIS
       cgset [-r <name=value>] <cgroup_path> ...  cgset --copy-from <source_cgrup_path> <cgroup_path> ...

man-page with the fix:
SYNOPSIS
       cgset [-r <name=value>] <cgroup_path> ...
       cgset --copy-from <source_cgrup_path> <cgroup_path> ...

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agoMerge branch 'master' of ssh://libcg.git.sf.net/gitroot/libcg/libcg
Balbir Singh [Thu, 11 Nov 2010 16:34:54 +0000 (22:04 +0530)] 
Merge branch 'master' of ssh://libcg.git.sf.net/gitroot/libcg/libcg

14 years ago'service cgred start' should print some meaningful error message when
Jan Safranek [Wed, 10 Nov 2010 15:09:55 +0000 (16:09 +0100)] 
'service cgred start' should print some meaningful error message when
there are no cgroups on the system.

Before:
Starting CGroup Rules Engine Daemon:              [FAILED]
After:
Starting CGroup Rules Engine Daemon:
Cannot find cgroups, is cgconfig service running? [FAILED]

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agoBefore: Error: libcgroup initialization failed, 50001
Jan Safranek [Wed, 10 Nov 2010 15:09:55 +0000 (16:09 +0100)] 
Before: Error: libcgroup initialization failed, 50001
Now:    Error: libcgroup initialization failed, Cgroup is not mounted

Changelog:
  - point to /etc/cgrules/conf when loading of the rules failed
    Before: Error: libcgroup failed to initialize rulescache, No such file or
            directory
    Now:    Error: libcgroup failed to initialize rulescache from
            /etc/cgrules.conf. No such file or directory

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
14 years agoThis patch fixes init script to use -f and -d options for cgcreate when it creates
Ivana Hutarova Varekova [Wed, 10 Nov 2010 15:08:21 +0000 (16:08 +0100)] 
This patch fixes init script to use -f and -d options for cgcreate when it creates
sysdefault control groups

CHANGELOG:
* fix the permission tags (used the permission numbers which jan suggested)

Signed-off-by: Ivana Hutarova Varekova<varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoThis patch add options -f and -d to cgcreate, it cause the permission change of the...
Ivana Hutarova Varekova [Wed, 10 Nov 2010 15:08:21 +0000 (16:08 +0100)] 
This patch add options -f and -d to cgcreate, it cause the permission change of the files of the created group
-d, --dperm mode
              sets the permission mode of control groups directory.  The mode have to be set using octal numbers e.g.  -d 775.
-f, --fperm mode
              sets the permission mode of control groups files.  The mode have to be set using octal numbers e.g.  -f 775.

CHANGELOG v1:
* fix jsafrane foodback thanks for it)

EXAMPLE:
#cgcreate -f 775 -d 775 -g devices:with
#cgcreate -g devices:without
# ll /cgroup/devices/ | grep with
drwxrwxr-x. 2 root root 0 Oct 29 06:55 with
drwxr-xr-x. 2 root root 0 Oct 29 06:55 without
# ll /cgroup/devices/with
total 0
-rwxrwxr-x. 1 root root 0 Oct 29 06:55 cgroup.event_control
-rwxrwxr-x. 1 root root 0 Oct 29 06:55 cgroup.procs
-rwxrwxr-x. 1 root root 0 Oct 29 06:55 devices.allow
-rwxrwxr-x. 1 root root 0 Oct 29 06:55 devices.deny
-rwxrwxr-x. 1 root root 0 Oct 29 06:55 devices.list
-rwxrwxr-x. 1 root root 0 Oct 29 06:55 notify_on_release
-rwxrwxr-x. 1 root root 0 Oct 29 06:55 tasks
# ll /cgroup/devices/without/
total 0
--w--w--w-. 1 root root 0 Oct 29 06:55 cgroup.event_control
-r--r--r--. 1 root root 0 Oct 29 06:55 cgroup.procs
--w-------. 1 root root 0 Oct 29 06:55 devices.allow
--w-------. 1 root root 0 Oct 29 06:55 devices.deny
-r--r--r--. 1 root root 0 Oct 29 06:55 devices.list
-rw-r--r--. 1 root root 0 Oct 29 06:55 notify_on_release
-rw-r--r--. 1 root root 0 Oct 29 06:55 tasks

Signed-off-by: Ivana Hutarova Varekova<varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoThis patch adds permission change function
Ivana Hutarova Varekova [Wed, 10 Nov 2010 15:08:20 +0000 (16:08 +0100)] 
This patch adds permission change function
int cg_chmod_recursive(struct cgroup *cgroup, mode_t dir_mode,
       int dirm_change, mode_t file_mode, int filem_change);

It changes the directory and files permissions to the given values.
If dirm_change is nonzero, then directory permissions will be set to the second parameter
dir_mode.
If filem_change is nonzero, then directory permissions will be set to the second parameter
file_mode.

CHANGELOG v2:
* fix the return value check for cg_chmod_file procedure

CHANGELOG v1:
* improve the patch description and typo in comment
* fix the problems jsafrane reported

Signed-off-by: Ivana Hutarova Varekova<varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoThis patch removes the permission change from control_group_create function
Ivana Hutarova Varekova [Wed, 10 Nov 2010 15:08:20 +0000 (16:08 +0100)] 
This patch removes the permission change from control_group_create function
It should be done only if the caller needs it not by default.

EXAMPLE:
before the change:
# ./tools/cgcreate -g devices:/test1
# ll /cgroup/cpu3/test1
total 0
-rwxrwxr-x. 1 root root 0 2010-11-02 08:05 cgroup.procs
-rwxrwxr-x. 1 root root 0 2010-11-02 08:05 devices.allow
-rwxrwxr-x. 1 root root 0 2010-11-02 08:05 devices.deny
-rwxrwxr-x. 1 root root 0 2010-11-02 08:05 devices.list
-rwxrwxr-x. 1 root root 0 2010-11-02 08:05 notify_on_release
-rwxrwxr-x. 1 root root 0 2010-11-02 08:05 tasks
# ll /cgroup/cpu3/ | grep test1
drwxrwxr-x. 2 root root 0 2010-11-02 08:05 test1

after the change:
# ./tools/cgcreate -g devices:/test2
# ll /cgroup/cpu3/test2
total 0
-r--r--r--. 1 root root 0 2010-11-02 08:04 cgroup.procs
--w-------. 1 root root 0 2010-11-02 08:04 devices.allow
--w-------. 1 root root 0 2010-11-02 08:04 devices.deny
-r--r--r--. 1 root root 0 2010-11-02 08:04 devices.list
-rw-r--r--. 1 root root 0 2010-11-02 08:04 notify_on_release
-rw-r--r--. 1 root root 0 2010-11-02 08:04 tasks
# ll /cgroup/cpu3/ | grep test2
drwxr-xr-x. 2 root root 0 2010-11-02 08:04 test2

Signed-off-by: Ivana Hutarova Varekova<varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoThis patch adds help option to cgcreate tool
Ivana Hutarova Varekova [Wed, 10 Nov 2010 15:08:20 +0000 (16:08 +0100)] 
This patch adds help option to cgcreate tool
and unified the cgget error messages

CHANGELOG v1:
* fix the typo (thanks jsafrane)

Signed-off-by: Ivana Hutarova Varekova<varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoMerge branch 'master' of ssh://libcg.git.sf.net/gitroot/libcg/libcg
Balbir Singh [Wed, 10 Nov 2010 05:01:48 +0000 (10:31 +0530)] 
Merge branch 'master' of ssh://libcg.git.sf.net/gitroot/libcg/libcg

14 years agoAdd cgsnapshot to .spec file
Jan Safranek [Tue, 2 Nov 2010 11:27:01 +0000 (12:27 +0100)] 
Add cgsnapshot to .spec file

Add new cgsnapshot tool to libcgroup.spec.

14 years agov0.37.rc
Dhaval Giani [Mon, 1 Nov 2010 23:03:16 +0000 (00:03 +0100)] 
v0.37.rc

Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agoMerge branch 'master' of ssh://libcg.git.sf.net/gitroot/libcg/libcg
Balbir Singh [Tue, 26 Oct 2010 08:03:41 +0000 (13:33 +0530)] 
Merge branch 'master' of ssh://libcg.git.sf.net/gitroot/libcg/libcg

14 years agocgget output patch
Ivana Hutarova Varekova [Tue, 26 Oct 2010 06:51:57 +0000 (08:51 +0200)] 
cgget output patch

This patch fixes cgget to put newline character to the end of all lines

--------------------------------
EXAMPLE:
OLD:
$ ./cgget -g devices //CBSFxx/Zcz6
//CBSFxx/Zcz6:
devices.list: a *:* rwm
devices.deny: devices.allow:

NEW:
$ ./cgget -g devices //CBSFxx/Zcz6
//CBSFxx/Zcz6:
devices.list: a *:* rwm
devices.deny:
devices.allow:

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agocgroup_read_value_begin return value patch
Ivana Hutarova Varekova [Tue, 26 Oct 2010 06:51:39 +0000 (08:51 +0200)] 
cgroup_read_value_begin return value patch

there is a typo in cgroup_read_value_begin
return value, this patch fixes it

----------------
EXAMPLE:
OLD:
$ cgget -g devices //CBSFxx/Zcz6
//CBSFxx/Zcz6:
devices.list: a *:* rwm
devices.deny: a *:* rwm
devices.allow: a *:* rwm
$

NEW:
$ cgget -g devices //CBSFxx/Zcz6
//CBSFxx/Zcz6:
devices.list: a *:* rwm
devices.deny: devices.allow: $

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
14 years agoremove cpuacct.usage_percpu from the blacklist
Ivana Hutarova Varekova [Thu, 21 Oct 2010 12:35:36 +0000 (14:35 +0200)] 
remove cpuacct.usage_percpu from the blacklist

This patch removes cpuacct.usage_percpu from the blacklist
(the variable should not be output because it is read-only one)

Signed-off-by: Ivana Hutarova Varekova<varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agofixes the cgsnapshot problem with pfile permisssions
Ivana Hutarova Varekova [Mon, 25 Oct 2010 10:27:08 +0000 (12:27 +0200)] 
fixes the cgsnapshot problem with pfile permisssions

cgpconfigparser changes the permissions of all files. That's why to test whether the variable file is writable, there have to be used the variable file from the root group.

  CHANGELOG:
* add the information why root group is used for finding which variable is writable

Signed-off-by: Ivana Hutarova Varekova<varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoremove cpuacct.stat from the blacklist
Ivana Hutarova Varekova [Thu, 21 Oct 2010 12:35:20 +0000 (14:35 +0200)] 
remove cpuacct.stat from the blacklist

This patch removes cpuacct.stat from the blacklist
(the variable should not be output because it is read-only one)

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoadd devices controller logic to cgsnapshot tool
Ivana Hutarova Varekova [Mon, 25 Oct 2010 10:32:19 +0000 (12:32 +0200)] 
add devices controller logic to cgsnapshot tool

This patch adds devices controller logic to cgsnapshot tool
so now it is able to parse devices.

CHANGELOG:
 * incorporate Jan's feedback

EXAMPLE:
# cgget -g devices /dev
/dev:
devices.list=c 1:* wm
devices.deny=
devices.allow=

# cgsnapshot -b samples/blacklist.conf -w samples/whitelist.conf
# Configuration file generated by cgsnapshot
mount {
cpuset = /cgroup/1;
cpu = /cgroup/2;
cpuacct = /cgroup/3;
memory = /cgroup/4;
devices = /cgroup/5;
freezer = /cgroup/6;
net_cls = /cgroup/7;
}

group dev {
perm {
admin {
uid = root;
gid = root;
}
task {
uid = root;
gid = root;
}
}
devices {
devices.deny="a *:* rwm";
devices.allow="c 1:* wm";
}
}

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoMerge branch 'master' of ssh://libcg.git.sourceforge.net/gitroot/libcg/libcg
Balbir Singh [Wed, 20 Oct 2010 14:20:14 +0000 (19:50 +0530)] 
Merge branch 'master' of ssh://libcg.git.sourceforge.net/gitroot/libcg/libcg

14 years agoCHANGELOG v3
Ivana Hutarova Varekova [Wed, 20 Oct 2010 13:41:14 +0000 (19:11 +0530)] 
CHANGELOG v3
    * change the structure of blacklist to be relevant to cgsnapshot changes
 * remove =n/y part of record
 * remove =y records

CHANGELOG v2
* whitelist -> blacklist

CHANGELOG v1
* fix balbir comments: remove devices.(deny/allow)

the default cgsnapshot configuration file
contains is relevant to kernel  2.6.34

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
14 years agoCHANGELOG v3
Ivana Hutarova Varekova [Wed, 20 Oct 2010 13:41:14 +0000 (19:11 +0530)] 
CHANGELOG v3
    * change the structure of blacklist to be relevant to cgsnapshot changes
 * remove =n/y part of record
 * remove =y records

CHANGELOG v2
* whitelist -> blacklist

CHANGELOG v1
* fix balbir comments: remove devices.(deny/allow)

the default cgsnapshot configuration file
contains is relevant to kernel  2.6.34

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
14 years agoCHANGELOG v4
Ivana Hutarova Varekova [Wed, 20 Oct 2010 13:39:15 +0000 (19:09 +0530)] 
CHANGELOG v4
* fix the description of the default behavior of -w option

CHANGELOG v3
* fix the man page to show the actual cgsnapshot options

CHANGELOG v2
* incorporate dhaval?? feedback
whitelist -> blacklist

    CHANGELOG v1
* fix jsafranek comments

This patch adds cgsnapshot man page

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
14 years agoMerge branch 'master' of ssh://libcg.git.sourceforge.net/gitroot/libcg/libcg
Balbir Singh [Wed, 20 Oct 2010 14:03:42 +0000 (19:33 +0530)] 
Merge branch 'master' of ssh://libcg.git.sourceforge.net/gitroot/libcg/libcg

14 years agoCHANGELOG v3
Ivana Hutarova Varekova [Wed, 20 Oct 2010 13:41:14 +0000 (19:11 +0530)] 
CHANGELOG v3
    * change the structure of blacklist to be relevant to cgsnapshot changes
 * remove =n/y part of record
 * remove =y records

CHANGELOG v2
* whitelist -> blacklist

CHANGELOG v1
* fix balbir comments: remove devices.(deny/allow)

the default cgsnapshot configuration file
contains is relevant to kernel  2.6.34

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
14 years agoMerge branch 'master' of ssh://libcg.git.sf.net/gitroot/libcg/libcg
Balbir Singh [Wed, 20 Oct 2010 13:47:53 +0000 (19:17 +0530)] 
Merge branch 'master' of ssh://libcg.git.sf.net/gitroot/libcg/libcg

14 years agothe default cgsnapshot configuration file
Ivana Hutarova Varekova [Wed, 20 Oct 2010 13:47:11 +0000 (19:17 +0530)] 
the default cgsnapshot configuration file
    contains all variables from  2.6.34

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
14 years agoCHANGELOG v3
Ivana Hutarova Varekova [Wed, 20 Oct 2010 13:47:05 +0000 (19:17 +0530)] 
CHANGELOG v3
    * change the structure of blacklist to be relevant to cgsnapshot changes
 * remove =n/y part of record
 * remove =y records

CHANGELOG v2
* whitelist -> blacklist

CHANGELOG v1
* fix balbir comments: remove devices.(deny/allow)

the default cgsnapshot configuration file
contains is relevant to kernel  2.6.34

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
14 years agoCHANGELOG v4
Ivana Hutarova Varekova [Wed, 20 Oct 2010 13:46:45 +0000 (19:16 +0530)] 
CHANGELOG v4
* fix the description of the default behavior of -w option

CHANGELOG v3
* fix the man page to show the actual cgsnapshot options

CHANGELOG v2
* incorporate dhaval?? feedback
whitelist -> blacklist

    CHANGELOG v1
* fix jsafranek comments

This patch adds cgsnapshot man page

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
14 years agothe default cgsnapshot configuration file
Balbir Singh [Wed, 20 Oct 2010 13:41:49 +0000 (19:11 +0530)] 
the default cgsnapshot configuration file
    contains all variables from  2.6.34

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
14 years agoCHANGELOG v3
Balbir Singh [Wed, 20 Oct 2010 13:41:14 +0000 (19:11 +0530)] 
CHANGELOG v3
    * change the structure of blacklist to be relevant to cgsnapshot changes
 * remove =n/y part of record
 * remove =y records

CHANGELOG v2
* whitelist -> blacklist

CHANGELOG v1
* fix balbir comments: remove devices.(deny/allow)

the default cgsnapshot configuration file
contains is relevant to kernel  2.6.34

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
14 years agoCHANGELOG v4
Balbir Singh [Wed, 20 Oct 2010 13:39:15 +0000 (19:09 +0530)] 
CHANGELOG v4
* fix the description of the default behavior of -w option

CHANGELOG v3
* fix the man page to show the actual cgsnapshot options

CHANGELOG v2
* incorporate dhaval?? feedback
whitelist -> blacklist

    CHANGELOG v1
* fix jsafranek comments

This patch adds cgsnapshot man page

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
14 years agoThis patch adds cgsnapshot tool
Ivana Hutarova Varekova [Wed, 20 Oct 2010 13:37:52 +0000 (19:07 +0530)] 
This patch adds cgsnapshot tool

CHANGELOGS:
CHANGELOG v7
* fix the warnings, remove the root path variable at all, free the name

CHANGELOG v6
* remove the default whitelist (now default state is no whitelist is used)
* incorporate jan's feedback
 * dynamic allocation of variable names in lists
 * fix the path names and reading

CHANGELOG v5
 * add the default blacklist and  whitelist
 * -w, -b: there is options for setting both blacklist and whitelist configuration files
 * -t: add the possibility to read the whitelist strictly

CHANGELOG v4
* incorporate dhaval feedback:
* whitelist -> blacklist
* add cgroup_free_cgroup

CHANGELOG v3
* white/blacklist is cached
* incorporate jsafraneks feedback

CHANGELOG v2
* add whitelist which describe the set of variables which can be dealt by
cgsnapshot without any problem (the values which with which have cgsnapshot
the problems are there with TODO comment and the reason) without -s option
the skipped variables are output with the warning text
* add the possibility to set the whitelist file
* add the possibility to redirect the output

CHANGELOG v1
* more verbose comments
* tune the variable names/description/usage in display_controller_data
function
* remove unnecessary .stat exception

    SYNOPSIS:
cgsnapshot [-h] [-s] [-t] [-b file] [-w file] [-f output_file] [controller] [...]
Generate the configuration file from the given controllers of control groups
  -b,--blacklist file  Set the blacklist configuration file (default /etc/cgsnapshot_blacklist.conf)
  -f,--file            Redirect the output to output_file
  -h,--help            Display this help
  -s,--silent          Ignore all warnings
  -t,--strict          Don't show the variables which are not on the whitelist
  -w,--whitelist file  Set the whitelist configuration file (don't used by default)

    EXAMPLE:
    $ /home/varekova/bg/libcgroup/20100719/libcg/src/tools/cgsnapshot -n
    # Configuration file generated by cgsnapshot
    mount {
         cpuset = /cgroup/cpuset;
         cpu = /cgroup/devices;
         cpuacct = /cgroup/memoryd;
         memory = /cgroup/memory;
         devices = /cgroup/devices;
         freezer = /cgroup/freezer;
         net_cls = /cgroup/net_cls;
    }

    group daemons {
        perm {
                admin {
                        uid = root;
                        gid = root;
                }
                task {
                        uid = root;
                        gid = root;
                }
        }
        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";
        }
    }

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
14 years agoIf cgconfigparser fails, it tries to delete created groups. But if they are
Jan Safranek [Tue, 5 Oct 2010 07:51:10 +0000 (13:21 +0530)] 
If cgconfigparser fails, it tries to delete created groups. But if they are
in the config file in wrong order, it tries to remove a parent group before
its children are destroyed, resulting into error.

The roll back should use recursive delete. And in addition, it should
delete as much as possible, not to stop on first error.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Reviewed-By: Ivana Hutarova Varekova <varekova@redhat.com>
Tested-By: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agoAdd the flag CGROUP_DAEMON_CANCEL_UNCHANGE_PROCESS.
Ken'ichi Ohmichi [Thu, 16 Sep 2010 05:08:59 +0000 (14:08 +0900)] 
Add the flag CGROUP_DAEMON_CANCEL_UNCHANGE_PROCESS.

A new flag CGROUP_DAEMON_CANCEL_UNCHANGE_PROCESS cancels the unchanged process.
If specifying this flag as the argument of cgroup_register_unchanged_process,
a cgrulesengd daemon can move the specified process to right cgroup based on
/etc/cgrules.conf.

Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agoAdd the flag CGROUP_DAEMON_CANCEL_UNCHANGE_PROCESS.
Ken'ichi Ohmichi [Thu, 16 Sep 2010 05:08:59 +0000 (14:08 +0900)] 
Add the flag CGROUP_DAEMON_CANCEL_UNCHANGE_PROCESS.

Hi,

A new flag CGROUP_DAEMON_CANCEL_UNCHANGE_PROCESS cancels the unchanged process.
If specifying this flag as the argument of cgroup_register_unchanged_process,
a cgrulesengd daemon can move the specified process to right cgroup based on
/etc/cgrules.conf.

Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agoThere is a problem in cgroup_init function
Ivana Hutarova Varekova [Fri, 24 Sep 2010 05:38:12 +0000 (11:08 +0530)] 
There is a problem in cgroup_init function
   Now if the function strtok_r get at first the controller which
precedes some other controllers on the mount-point option list,
then it removes all next controllers from the list and they are omitted.
   The test which is done by strtok_r is redundant (there is already
hasmntopt test), so the patch is removing it at all.

 E.G. use commands:

$ mount -t cgroup -o cpu,memory,net_cls lab1 /cgroup/lab1
$ mount -t cgroup -o remount,cpuset,cpu,memory,net_cls lab1 /cgroup/lab1
$ lssubsys -ma

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agofix two warning problems in programs in tests section
Ivana Hutarova Varekova [Mon, 6 Sep 2010 13:15:31 +0000 (15:15 +0200)] 
fix two warning problems in programs in tests section

This patch fixes these two warnings:

setuid.c: In function ‘main’:
setuid.c:38: warning: ‘ret’ may be used uninitialized in this function

get_procs.c: In function ‘main’:
get_procs.c:15: warning: unused variable ‘test’

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoadd the long options to cgget
Ivana Hutarova Varekova [Thu, 2 Sep 2010 10:17:41 +0000 (12:17 +0200)] 
add the long options to cgget

This patch adds the long options parsing to cgget
to be consistent with the other tools

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agouse the new iterators in cgget tool
Ivana Hutarova Varekova [Thu, 2 Sep 2010 13:57:17 +0000 (15:57 +0200)] 
use the new iterators in cgget tool

changelog
 incorporate Jan's feedback
 - test the return value of cgroup_read_value_next
 - output \t character only after the whole row of the output

This patch rework cgget to use cgroup_read_vars_{begin/next/end}
iterators - it fix the problem with long variables (like e.g. devices.list)
it also fixes the bug in stat file reading (it shows the variables in root
directory all time)

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agosmall cgget tool cleanup
Ivana Hutarova Varekova [Thu, 2 Sep 2010 13:26:18 +0000 (15:26 +0200)] 
small cgget tool cleanup

changelog
- adds missing if

small cgget tool cleanup

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoadd test for empty controller/variable stack
Ivana Hutarova Varekova [Thu, 2 Sep 2010 10:17:21 +0000 (12:17 +0200)] 
add test for empty controller/variable stack

add test for empty controller/variable stack

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agonew iterator api for reading variables
Ivana Hutarova Varekova [Thu, 2 Sep 2010 10:17:14 +0000 (12:17 +0200)] 
new iterator api for reading variables

This patch adds three iterators api function
cgroup_read_vars_begin
cgroup_read_vars_next
cgroup_read_vars_end

 They read the values of the given variable for the specified
 controller and control group. The string with the maximal
 length max is returned line is returned per
 cgroup_read_stats_begin() and cgroup_read_stats_next() call.

(there already are _stat_ versions of function which can read only stat
variables)

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoAdd missing test to cgroup_read_stats_end
Ivana Hutarova Varekova [Tue, 7 Sep 2010 18:06:54 +0000 (23:36 +0530)] 
Add missing test to cgroup_read_stats_end

This patch adds the missing test to cgroup_read_stats_end
Sorry for the misstake.
Fixed the test - it should return the error

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agoRewrite cg_mkdir_p so it does not change current working directory.
Jan Safranek [Tue, 7 Sep 2010 18:04:52 +0000 (23:34 +0530)] 
Rewrite cg_mkdir_p so it does not change current working directory.

Old sequence of operations when creating e.g. /cgroup/cpu
$OLDCWD=$PWD
cd /
mkdir cgroup
cd cgroup
mkdir cpu
cd $OLDCWD

New sequence is:
mkdir /cgroup
mkdir /cgroup/cpu

Some tools, namely those used in /etc/init.d/cgconfig, might be executed with
security constrained context, which does not allow them to access certain
directories (like /var/log/audit). And when e.g. cgconfigparser is executed in
/var/log/audit as current working directory, chdir("/var/log/audit") in
cg_mkdir_p() fails. As consequence, "/etc/init.d/cgconfig start" randomly fails
or succeeds, depending on current working directory and current SELinux policy.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agoIt might be useful to allow empty values in cgconfig.conf, like:
Jan Safranek [Tue, 7 Sep 2010 15:02:56 +0000 (20:32 +0530)] 
It might be useful to allow empty values in cgconfig.conf, like:

devices {
devices.deny = "";
}

I know, it sounds weird, but Ivana is preparing cgsnapshot tool, which
saves current cgroups into a cgconfig.conf file, and empty values might
occur there.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agoChange the return value to more informative one
Ivana Hutarova Varekova [Wed, 18 Aug 2010 09:22:54 +0000 (11:22 +0200)] 
Change the return value to more informative one

Change the return value to more informative one
 the previous error message:
# /sbin/cgconfigparser -l /tmp/cgconfig.conf
can't create group "CBSFxx/Zcz6": Loading configuration file /etc/cgconfig.conf failed
Cgroup values are not equal

 the new error message
#/sbin/cgconfigparser -l /etc/cgconfig.conf
can't create group "CBSFxx/Zcz6": Loading configuration file /etc/cgconfig.conf failed
Value setting does not succeed

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoFix build breakage with --enable-debug after dict changes
Balbir Singh [Mon, 30 Aug 2010 08:00:02 +0000 (13:30 +0530)] 
Fix build breakage with --enable-debug after dict changes

The dictionary changes broke the build with --enable-debug.
Fixing all breakage under this commit. See diff for details

Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agoFix build with --enable-debug
Eric Brower [Mon, 30 Aug 2010 07:54:54 +0000 (13:24 +0530)] 
Fix build with --enable-debug

cgroup_dbg(%s) is broken in src/lex.l. This patch fixes
it to use fprintf(stderr, ...)

Signed-off-by: Eric Brower <ebrower@gmail.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
14 years agoadds option -i description to lssubsys man page
Ivana Hutarova Varekova [Fri, 13 Aug 2010 13:01:18 +0000 (15:01 +0200)] 
adds option -i description to lssubsys man page

Changelog:
- fixed the typos from Eric Brower comment

This patch adds  -i option description to lssubsys man-page
(example included too)

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoAdds option to lssubsys tool for unmount controllers in hierrachy
Ivana Hutarova Varekova [Fri, 13 Aug 2010 13:00:54 +0000 (15:00 +0200)] 
Adds option to lssubsys tool for unmount controllers in hierrachy

This patch adds option new option "-i" to lssubsys tool. This option displays for mount controllers
the number of hierarchie in which they are:

SEMANTIC:
lssubsys  [-m|--mount-points] [-i|--hierarchies] [-a|--all]

-i, --hierrachies
              Display attached hierarchy number, if the subsystem is in a hierrachy.
If the option -m is used too, then the hierarchy number is shown only for not mounted hierarchies.

EXAMPLE:
        $ lssubsys -ami
        ns
        cpuset 5
        cpu,devices 6
        cpuacct /cgroup/cpuacct
        memory /cgroup/memory
        freezer /cgroup/freezer
        net_cls /cgroup/net_cls

        $ lssubsys -ai
        ns
        cpuset 5
        cpu,devices 6
        cpuacct 7
        memory 8
        freezer 9
        net_cls 4

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoupdates lssubsys man page
Ivana Hutarova Varekova [Fri, 13 Aug 2010 13:00:39 +0000 (15:00 +0200)] 
updates lssubsys man page

Changelog from previous version
- fixed jsafranek's comments

this fix updatest the man page
- the information about -a option behavior
- added a example related to this change

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
14 years agoMerge branch 'master' of ssh://libcg.git.sourceforge.net/gitroot/libcg/libcg
Jan Safranek [Thu, 19 Aug 2010 10:27:29 +0000 (12:27 +0200)] 
Merge branch 'master' of ssh://libcg.git.sourceforge.net/gitroot/libcg/libcg

14 years agoSome parameters (like devices.allow) shall include a space in their values.
Jan Safranek [Tue, 10 Aug 2010 09:38:14 +0000 (15:08 +0530)] 
Some parameters (like devices.allow) shall include a space in their values.
This patch adds possibility to specify parameters names in double quotes,
like:
devices {
devices.allow="c 1:3 mr";
}

The double quotes are not mandatory, old  behavior is still there.

As side effect, also parameter names, group names, user names, controller names
etc. can be (optionally) in double quotes and can contain weird characters
- it's a feature, not a bug :). Of course, I could change the grammar to allow
double quotes only in param. values, that shouldn't be a problem.

There is also no advance handling of escape sequences - \", \n, \t does not work
here. That means that parameter values cannot contain newline or double quote
characters - are they required by any controllers?

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>