]> git.ipfire.org Git - thirdparty/libcgroup.git/log
thirdparty/libcgroup.git
15 years agoapi: bzero is obsolete BSD, use memset instead
Lennart Poettering [Wed, 24 Mar 2010 20:03:56 +0000 (21:03 +0100)] 
api: bzero is obsolete BSD, use memset instead

Signed-off-by: Lennart Poettering <lennart@poettering.net>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoconfig: pass struct as const call-by-ref instead of call-by-value, to minimize copying
Lennart Poettering [Wed, 24 Mar 2010 20:03:42 +0000 (21:03 +0100)] 
config: pass struct as const call-by-ref instead of call-by-value, to minimize copying

Signed-off-by: Lennart Poettering <lennart@poettering.net>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoconfig: use macros instead of arrays for const strings
Lennart Poettering [Wed, 24 Mar 2010 20:03:24 +0000 (21:03 +0100)] 
config: use macros instead of arrays for const strings

Signed-off-by: Lennart Poettering <lennart@poettering.net>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agomake functions without arguments proper C99 functions
Lennart Poettering [Wed, 24 Mar 2010 20:03:04 +0000 (21:03 +0100)] 
make functions without arguments proper C99 functions

Signed-off-by: Lennart Poettering <lennart@poettering.net>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoadd a couple of FIXMEs to broken code
Lennart Poettering [Wed, 24 Mar 2010 19:59:42 +0000 (20:59 +0100)] 
add a couple of FIXMEs to broken code

Signed-off-by: Lennart Poettering <lennart@poettering.net>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoadd const where applicable, drop const where unnecessary
Lennart Poettering [Wed, 24 Mar 2010 18:06:49 +0000 (19:06 +0100)] 
add const where applicable, drop const where unnecessary

This patch adds the const qualifier to a number of function arguments
(mostly string arguments) so that client libraries can pass their own
const strings to the library without having to cast their const'ness
away.

This also drops a couple of consts where call-by-value is done anyway,
and which hence has no effect and just misleads the users and adds
unnecessary noise to the signal. After all this is C, not C++.

Signed-off-by: Lennart Poettering <lennart@poettering.net>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agogit: hide all generated files from git
Lennart Poettering [Wed, 24 Mar 2010 14:53:05 +0000 (15:53 +0100)] 
git: hide all generated files from git

Signed-off-by: Lennart Poettering <lennart@poettering.net>
Reviewed-By: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoinclude: refuse inclusion of seperate header files
Lennart Poettering [Wed, 24 Mar 2010 14:51:55 +0000 (15:51 +0100)] 
include: refuse inclusion of seperate header files

Later on it might make sense to move around function definitions between
header files. Hence make sure that nobody includes any header file
directly except the main one.

Signed-off-by: Lennart Poettering <lennart@poettering.net>
Reviewed-By: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agobuild-sys: add bootstrap.sh
Lennart Poettering [Wed, 24 Mar 2010 14:52:23 +0000 (15:52 +0100)] 
build-sys: add bootstrap.sh

Most projects carry a bootstrap.sh/autogen.sh file that calls the
autotools in the right order.

This bootstrap.sh also enables the default git commit hook which
enforces a strict kernel-like whitespace regime.

Signed-off-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agobuild-sys: enable silent build by default
Lennart Poettering [Wed, 24 Mar 2010 14:51:38 +0000 (15:51 +0100)] 
build-sys: enable silent build by default

Make the automake output a bit more like the kbuild output if supported.

Signed-off-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agolibcgroup: Add pkg-config data
Dhaval Giani [Thu, 18 Feb 2010 14:56:31 +0000 (15:56 +0100)] 
libcgroup: Add pkg-config data

libcgroup was not making an entry into the pkg-config database, which
makes life easier when using multiple libraries. Add the needed data
in order to be registered with the pkg-config database on installation.

Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Reviewed-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Lennart Poettering <lennnart@poettering.net>
15 years agolibcgroup: Version bump to v0.36.rc1
Dhaval Giani [Thu, 18 Feb 2010 14:56:30 +0000 (15:56 +0100)] 
libcgroup: Version bump to v0.36.rc1

We are now making changes to the specfile, which needs a version
bump. Bump up the version to v0.36.rc1.

Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoFix typo in wrapper.c (cgroup_get_uid_gid)
Balbir Singh [Wed, 24 Mar 2010 07:18:45 +0000 (12:48 +0530)] 
Fix typo in wrapper.c (cgroup_get_uid_gid)

Fix the typo in our cgroup_get_uid_gid routine
We seem to have a typo in the function, the fix is quite obvious.

Reported-by: Ciju Rajan K <ciju@linux.vnet.ibm.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoSplit header file III
Jan Safranek [Fri, 12 Mar 2010 15:50:20 +0000 (16:50 +0100)] 
Split header file III

Changelog:
 - since there are no global macros, base.h is gone
 - since there is no base.h, all headers need to include <features.h> to get
   __BEGIN_DECLS
 - new init.h with cgroup_init() and cgroup_get_subsys_mount_point()
 - new error.h with error handling enum and related stuff
 - use #ifndef _LIBCGROUP_*_H instead _LIBCG_*_H in header guards
 - fix few checkpatch complaints (long lines, whitespaces, ...)

The patch includes Makefile and .spec changes. I tested it compiles,
make dist produces tarball with all headers, so does also the rpm.
'make' should automatically catch all changes in new headers and
recompile dependent (=all) sources when any header changes.

libcgroup.h
  - does not declare anything, it just includes all the other files. In
    future, it might contain base of doxygen documentation (some
    introduction etc.)

libcgroup/error.h
  - the big enum with errors + error related functions

libcgroup/init.h
  - libcgroup_init() and cgroup_get_subsys_mount_point()

libcgroup/config.h
  - configuration reading/unloading

libcgroup/groups.h
  - group manipulation stuff (create/modify/delete/free, incl. controllers and
    get/set values) + definition of struct cgroup (=must be included by
    libcgroup/tasks.h, which needs it)

libcgroup/iterators.h
  - various walks, *_begin/next/end

libcgroup/tasks.h
  - task classification, incl. rules cache manipulation

In addition, I probably removed some #includes, which are not needed now when
looking for the minimal #include set to build the project. I also hope I did not
miss any function declaration or macro...

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoMove private definitions to private header
Jan Safranek [Fri, 12 Mar 2010 15:50:10 +0000 (16:50 +0100)] 
Move private definitions to private header

Most of the macro definitions in licgroup.h are internal, let's move them
to private header. Applications should not depend on them. The only one
really needed is CG_VALUE_MAX, which is used in struct cgroup_stat.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoAnonymize error enum
Jan Safranek [Fri, 12 Mar 2010 15:50:01 +0000 (16:50 +0100)] 
Anonymize error enum

The enum with ECG* error codes should be anonymous, as pointed out by
Lennart Poettering.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoUse memset to initialize sigaction struct
Jon Bernard [Tue, 9 Mar 2010 21:10:39 +0000 (16:10 -0500)] 
Use memset to initialize sigaction struct

The sa_restorer field is not present on some architectures, like alpha.
By using memset, the structure is initialized appropriately regardless of
struct contents.

Signed-off-by: Jon Bernard <jbernard@debian.org>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agorpm spec file misses the sysconfig/cgconfig file
Chris [Tue, 9 Mar 2010 16:09:48 +0000 (11:09 -0500)] 
rpm spec file misses the sysconfig/cgconfig file

The /etc/sysconfig/cgconfig file is never installed with the current RPM
spec file. This fixes it for me:

Signed-off-by: Chris Tasma <chris@deksai.com>
Reviewed-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoinit script can miss default group
Chris [Tue, 9 Mar 2010 16:04:46 +0000 (11:04 -0500)] 
init script can miss default group

If there is a directive like *:httpd before * in the cgconfig file, all
processes end up being moved into the wrong group on cgconfig startup, and
the default group is never made. This fixes it for me:

Signed-off-by: Chris Tasma <chris@deksai.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoMake the error stings const
Jan Safranek [Mon, 8 Mar 2010 11:46:11 +0000 (12:46 +0100)] 
Make the error stings const

Make the error stings const, just to be safe.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoRemove last_errno from public header
Jan Safranek [Mon, 8 Mar 2010 11:46:04 +0000 (12:46 +0100)] 
Remove last_errno from public header

Remove last_errno from public header, that's why we have cgroup_get_last_errno.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoRemove GNU_SOURCE from public headers
Jan Safranek [Mon, 8 Mar 2010 11:45:57 +0000 (12:45 +0100)] 
Remove GNU_SOURCE from public headers

Remove GNU_SOURCE from public headers, it has unpredictable consequences on
applications using libcgroup.h

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agolibcgroup: Add a gitignore file
Dhaval Giani [Wed, 17 Feb 2010 16:26:05 +0000 (17:26 +0100)] 
libcgroup: Add a gitignore file

Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agofix cgroup_get_value_string problem with *.stat output
Ivana Hutarova Varekova [Mon, 8 Feb 2010 12:32:41 +0000 (13:32 +0100)] 
fix cgroup_get_value_string problem with *.stat output

fix cgroup_get_value_string problem with *.stat output
the problem was in the low limit for value for the output of stat variables - now there are used the functions cgroup_read_stats_{begin/next/end} for this purpose

bogus output:
./src/tools/cgget -r memory.stat /
/:
memory.stat=cache 1024561152
rss 291270656
pgpgin 1209259
pgpgout 888011
inactive_anon 8192
active_anon 2976481

fixed output:
$ ./src/tools/cgget -r memory.stat /
/:
memory.stat=cache 1024610304
rss 291270656
pgpgin 1209271
pgpgout 888011
inactive_anon 8192
active_anon 297648128
inactive_file 619126784
active_file 399073280
unevictable 24576
hierarchical_memory_limit 9223372036854775807
hierarchical_memsw_limit 9223372036854775807
total_cache 1024610304
total_rss 291270656
total_pgpgin 1209271
total_pgpgout 888011
total_inactive_anon 8192
total_active_anon 297648128
total_inactive_file 619126784
total_active_file 399073280
total_unevictable 24576

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoThis patch adds to cgget option -a:
Ivana Hutarova Varekova [Mon, 8 Feb 2010 12:32:26 +0000 (13:32 +0100)] 
This patch adds to cgget option -a:

v2:
removed bunch of unnecessary error messages
This patch adds to cgget option -a:
-a     print the variables for all controllers which consists given cgroup

EXAMPLE:
$ ./cgget -a /daemons
/daemons:
cpuset.memory_spread_slab=0
cpuset.memory_spread_page=0
cpuset.memory_pressure=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=
cpuacct.stat=user 0
system 0
cpuacct.usage_percpu=0 0
cpuacct.usage=0

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoadds new option -g to cgget command
Ivana Hutarova Varekova [Mon, 8 Feb 2010 12:32:18 +0000 (13:32 +0100)] 
adds new option -g to cgget command

adds new option -g to cgget command
* the option has one argument - controller
* cgget -g devices / returns the values of all variables of controller
devices
* the option could be used multiple times

EXAMLES:

$ ./cgget -n -g cpu -r cpuset.mems /
cpu.rt_period_us=1000000
cpu.rt_runtime_us=950000
cpu.shares=1024
cpuset.mems=0

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoThis is the test program for listing controller variables
Ivana Hutarova Varekova [Mon, 8 Feb 2010 12:31:56 +0000 (13:31 +0100)] 
This is the test program for listing controller variables

This is the test program for new internal functions:

    int cgroup_get_value_name_count(struct cgroup_controller *controller)
    char *cgroup_get_value_name(struct cgroup_controller *controller, int     index)

The program display the variables of input controllers.

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoapi for generating the list of variables of given controller
Ivana Hutarova Varekova [Mon, 8 Feb 2010 12:31:47 +0000 (13:31 +0100)] 
api for generating the list of variables of given controller

api for generating the list of variables of given controller:
changelog - v2:
fixed the space on the end of lines

  * int cgroup_get_value_name_count(struct cgroup_controller,  *controller)
  functions return the number of variables in "controller"

  * char *cgroup_get_value_name(struct cgroup_controller *controller, int index)
  function return the "index" variable of "controller"

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoRelease procedure proposal
Jan Safranek [Mon, 8 Feb 2010 13:13:18 +0000 (14:13 +0100)] 
Release procedure proposal

this is my proposal for release procedure - it's quite simple and covers all
the technical details you need to know regarding autotools.

Changelog:
- re-diff with current master (and not my internal branch :)
- renumber the steps

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years ago[PATCH-v2] Add the write error handling to cg_set_control_value().
Ken'ichi Ohmichi [Thu, 28 Jan 2010 05:45:48 +0000 (11:15 +0530)] 
[PATCH-v2] Add the write error handling to cg_set_control_value().

Changelog since v1:
 o Use fopen/fprintf/fclose instead of open/write/close.
 o Add the error handling against fclose.

cg_set_control_value() is the function for setting a value to a file
of cgroup file system. And current function does not handle the error
of writing to a file. So we cannot know whether setting value is
enable or not. This patch add the error handling for knowing it.

Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoMerge branch 'HEAD'; commit 'v0.35.1'
Balbir Singh [Tue, 19 Jan 2010 12:11:44 +0000 (17:41 +0530)] 
Merge branch 'HEAD'; commit 'v0.35.1'

15 years agoUpdate the changelog in libcgroup.spec.in v0.35.1
Balbir Singh [Tue, 19 Jan 2010 11:46:36 +0000 (17:16 +0530)] 
Update the changelog in libcgroup.spec.in
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoFix initstripts directory.
Jan Safranek [Mon, 18 Jan 2010 12:15:16 +0000 (13:15 +0100)] 
Fix initstripts directory.

Put initscipts to /etc/rc.d/init.d, rpm's %{_initrddir} points there.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoFix bad filename in Makefile
Jan Safranek [Mon, 18 Jan 2010 12:15:09 +0000 (13:15 +0100)] 
Fix bad filename in Makefile

Fix bad filename in Makefile and make 'make dist' working again.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoDistribute cgget tool
Jan Safranek [Mon, 18 Jan 2010 12:15:02 +0000 (13:15 +0100)] 
Distribute cgget tool

Distribute cgget tool in rpms.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agov0.35 v0.35
Dhaval Giani [Mon, 18 Jan 2010 17:16:21 +0000 (18:16 +0100)] 
v0.35

Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
15 years agoAdd cgget man page.
Jan Safranek [Mon, 18 Jan 2010 11:13:48 +0000 (16:43 +0530)] 
Add cgget man page.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agolibcgroup samples: Invalid namespace configuration
Dhaval Giani [Thu, 7 Jan 2010 10:54:38 +0000 (16:24 +0530)] 
libcgroup samples: Invalid namespace configuration

An invalide namespace configuration. This configuration is invalid
because while cpu and cpuacct have been mounted at the same point,
they have different namespaces.

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agolibcgroup samples: Valid namespace based configuration
Dhaval Giani [Thu, 7 Jan 2010 10:54:37 +0000 (16:24 +0530)] 
libcgroup samples: Valid namespace based configuration

Change from v2:
1. Correct the changes made in the config file format. namespace and
mount not in the same file.

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agolibcgroup: Modify the APIs to use the namespace
Dhaval Giani [Thu, 7 Jan 2010 10:54:36 +0000 (16:24 +0530)] 
libcgroup: Modify the APIs to use the namespace

Since every API builds its patch via build_path, updating that
function should be enough.

Changes from v1:
1. Append the namespace only if it is defined. This will remove an
additional "/" which would be introduced otherwise.

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agolibcgroup: Setup the namespace datastructures
Dhaval Giani [Thu, 7 Jan 2010 10:54:35 +0000 (16:24 +0530)] 
libcgroup: Setup the namespace datastructures

This patch handles the validation of the newer configuration files.

Some of the rules to be followed
1. We cannot have more controllers in the namespcae section than
already mounted.
2. If more than one controller are mounted at the same point, then
they will have the same namespace. In case it is not explicitly
mentioned, the subsystems at the mount point will be set to the
same namespace. This does not mean that controllers mounted at different
points need to have the same namespace.

Changes from v4:
1. Changed a variable name from mount to mount_path
2. Added more comments

Changes from v3:
1. Removed most of the strdups
2. Fixed return values for errors

Changes from v2:
1. mount and namespace keyword cannot come in the same file.

Changes from v1:
1. Fix a bug where if a namespace was not defined, we were not exiting
2. Comment the validate namespace function
3. Make some of the variables more descriptive
4. Make namespace thread specific

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agolibcgroup: Introduce the new namespace keyword
Dhaval Giani [Thu, 7 Jan 2010 10:54:34 +0000 (16:24 +0530)] 
libcgroup: Introduce the new namespace keyword

This patch introduces a new keywork NAMESPACE which allow cgroups
to be created starting from a certain point as mentioned by the
administrator. This is provided via the configuration file.

Newer APIs will use this feature.

Changes from v1:
1. Attempted to fix the indentation
2. Change a variable name

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agolibcgroup: Remove assert in cgroup_strerror()
Dhaval Giani [Mon, 4 Jan 2010 12:34:42 +0000 (18:04 +0530)] 
libcgroup: Remove assert in cgroup_strerror()

Since we add new errors after ECGSENTINEL, it makes no
sense to have the assert in place. Remove the assert.

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoMerge branch 'devel/config3' of git://fedorapeople.org/~jsafrane/libcg
Dhaval Giani [Wed, 23 Dec 2009 13:04:45 +0000 (18:34 +0530)] 
Merge branch 'devel/config3' of git://fedorapeople.org/~jsafrane/libcg

* 'devel/config3' of git://fedorapeople.org/~jsafrane/libcg:
  Clean up the init script
  Use tools instead of shell scripts
  Make cgclear quiert when there is nothing to clear.
  Use cgclear on shutdown
  Add sample /etc/sysconfig/cgconfig
  Don't create sysdefault group whent it's not needed
  Move sysdefault handling to separate function
  Remove trailing space from lssubsys output
  Fix reading of empty parameter values
  Fix error text on failed reading of parameter.
  cgget tool

15 years agoClean up the init script
Jan Safranek [Tue, 22 Dec 2009 08:24:52 +0000 (09:24 +0100)] 
Clean up the init script

Some parts of the init script are not needed with the recent changes.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
15 years agoUse tools instead of shell scripts
Jan Safranek [Tue, 22 Dec 2009 08:24:25 +0000 (09:24 +0100)] 
Use tools instead of shell scripts

libcgroup now provides some tools, which can be used in the init script
instead of bash code.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoMake cgclear quiert when there is nothing to clear.
Jan Safranek [Tue, 22 Dec 2009 08:24:04 +0000 (09:24 +0100)] 
Make cgclear quiert when there is nothing to clear.

Cgclear clears and unmounts all controllers. Therefore I think it's not an
error when there is nothing to clear and unmount.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
15 years agoUse cgclear on shutdown
Jan Safranek [Tue, 22 Dec 2009 08:23:53 +0000 (09:23 +0100)] 
Use cgclear on shutdown

Use cgclear on service cgconfig stop, it's much faster than manual group
removal.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoAdd sample /etc/sysconfig/cgconfig
Jan Safranek [Tue, 22 Dec 2009 08:23:42 +0000 (09:23 +0100)] 
Add sample /etc/sysconfig/cgconfig

Feel free to rephrase it's content, I could not find any better words to
describe sysdefault group usability.

Changelog:
 - set the default to 'yes'

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
15 years agoDon't create sysdefault group whent it's not needed
Jan Safranek [Tue, 22 Dec 2009 08:23:42 +0000 (09:23 +0100)] 
Don't create sysdefault group whent it's not needed

IMHO most of users don't need sysdefault group being created during boot -
it's quite slow and at least in Fedora there is no application using it.

So, let users to configure it and allow them to turn the sysdefault off.

Whether the option should be enabled/disabled is distro-specific, we as
libcgroup turn it on.

Changelog:
 - create the sysdefault group by default

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
15 years agoMove sysdefault handling to separate function
Jan Safranek [Tue, 22 Dec 2009 08:23:42 +0000 (09:23 +0100)] 
Move sysdefault handling to separate function

Move sysdefault handling to separate function - it simplifies following
patch.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
15 years agoRemove trailing space from lssubsys output
Jan Safranek [Tue, 22 Dec 2009 08:23:39 +0000 (09:23 +0100)] 
Remove trailing space from lssubsys output

Remove trailing space from lssubsys output, it can confuse scripts.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoFix reading of empty parameter values
Jan Safranek [Tue, 22 Dec 2009 08:16:48 +0000 (09:16 +0100)] 
Fix reading of empty parameter values

When a group parameter has empty value (like uninitialized cpuset.cpus),
libcgroup does not return this parameter value - it returns
ECGROUPVALUENOTEXIST instead.

I think reading whole parameter file instead of just '%s' is the right thing
to do - it helps also with multiline values, like cpuacct.stat.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
15 years agoFix error text on failed reading of parameter.
Jan Safranek [Tue, 22 Dec 2009 08:16:45 +0000 (09:16 +0100)] 
Fix error text on failed reading of parameter.

ECGROUPVALUENOTEXIST is translated by cgroup_strerr to "Cgroup trying to set
value for control that does not exist". This is wrong, because the error
code is being returned also when *reading* non-existing value,

I propose "Cgroup, requested group parameter does not exist".

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
15 years agocgget tool
Jan Safranek [Tue, 22 Dec 2009 08:15:10 +0000 (09:15 +0100)] 
cgget tool

Add a tool to query for parameter values. The syntax is very similar to cgset,
including IMHO ugly group specification without list of controllers.

Usage:
cgget [-nv] -r <param. name> [-r <param. name>] [...] <path to group> [...]

 -n - no headers
 -v - print values only (no parameter names)

Example:

$ cgget -r cpuset.cpus / /second
/:
cpuset.cpus=0-1

/second:
cpuset.cpus=1

$ cgget -nv -r cpuset.cpus / /second
0-1
1

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
15 years agolibcgroup: trivial: Fix typo
Dhaval Giani [Wed, 16 Dec 2009 10:14:34 +0000 (15:44 +0530)] 
libcgroup: trivial: Fix typo

opened is spelled as opened and not opend

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoFix an invalid access to yytext.
Ken'ichi Ohmichi [Fri, 11 Dec 2009 03:22:19 +0000 (12:22 +0900)] 
Fix an invalid access to yytext.

Hi,

I tested "cgconfig" service with a big /etc/cgconfig.conf file, and the
service failed by signal SIGSEGV.
There are two problems. The first is that "cgconfig" service fails with
a big /etc/cgconfig.conf file. The second is that the error handling is
stopped by signal SIGSEGV.
This patch fixes the second problem.

The following is the gdb output of the problem.
You can see the problem happens in yyerror().

 # gdb cgconfigparser
 (gdb) run -l /etc/cgconfig.conf
 Starting program: /usr/local/sbin/cgconfigparser -l /etc/cgconfig.conf
 [Thread debugging using libthread_db enabled]
 [New Thread 139764254320624 (LWP 15169)]

 Program received signal SIGSEGV, Segmentation fault.
 [Switching to Thread 139764254320624 (LWP 15169)]
 0x00007f1d66bd1604 in yyerror (s=0x7f1d66bd955a "syntax error") at parse.y:30
 30              fprintf(stderr, "error at line number %d at %c:%s", line_no, *yytext,
 (gdb) bt
 #0  0x00007f1d66bd1604 in yyerror (s=0x7f1d66bd955a "syntax error")
     at parse.y:30
 #1  0x00007f1d66bd1a9e in yyparse () at parse.c:1689
 #2  0x00007f1d66bd79b5 in cgroup_config_load_config (
     pathname=<value optimized out>) at config.c:467
 #3  0x00000000004008a3 in main (argc=3, argv=0x7fffa20c8358) at cgconfig.c:60
 (gdb)

This problem is due to an invalid access to yytext, and this patch fixes it.
(If you need a big /etc/cgconfig.conf file for reproducing the problem,
please let me know it. I will send it to you without the mailing list.)

Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Acked-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoFix a memory leak in "cgconfig" service.
Ken'ichi Ohmichi [Wed, 9 Dec 2009 06:47:26 +0000 (15:47 +0900)] 
Fix a memory leak in "cgconfig" service.

Hi,

When I operated "cgconfig" service on valgrind, I found a memory leak
like the following:

  # cat /etc/cgconfig.conf
  mount {
    cpuset = /cgroup/cpuset;
    cpu    = /cgroup/cpu;
    memory = /cgroup/memory;
  }
  group user000 {
    cpuset {
        cpuset.cpus = 0;
        cpuset.mems = 0;
    }
  }
  group user000/sleep000 {
    cpuset {
        cpuset.cpus = 0;
        cpuset.mems = 0;
    }
  }

  # valgrind --tool=memcheck --leak-check=yes cgconfigparser -l /etc/cgconfig.conf
  ==13095== Memcheck, a memory error detector.
  ==13095== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
  ==13095== Using LibVEX rev 1658, a library for dynamic binary translation.
  ==13095== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
  ==13095== Using valgrind-3.2.1, a dynamic binary instrumentation framework.
  ==13095== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
  ==13095== For more details, rerun with: -v
  ==13095==
  ==13095==
  ==13095== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 1)
  ==13095== malloc/free: in use at exit: 43,062 bytes in 10 blocks.
  ==13095== malloc/free: 129 allocs, 119 frees, 85,399 bytes allocated.
  ==13095== For counts of detected errors, rerun with: -v
  ==13095== searching for pointers to 10 not-freed blocks.
  ==13095== checked 6,795,480 bytes.
  ==13095==
  ==13095== 28 bytes in 2 blocks are definitely lost in loss record 1 of 5
  ==13095==    at 0x4A0590B: realloc (vg_replace_malloc.c:306)
  ==13095==    by 0x4C0CC24: yyparse (parse.y:117)
  ==13095==    by 0x4C12914: cgroup_config_load_config (config.c:467)
  ==13095==    by 0x4008A2: main (cgconfig.c:60)
  ==13095==
  ==13095== LEAK SUMMARY:
  ==13095==    definitely lost: 28 bytes in 2 blocks.
  ==13095==      possibly lost: 0 bytes in 0 blocks.
  ==13095==    still reachable: 43,034 bytes in 8 blocks.
  ==13095==         suppressed: 0 bytes in 0 blocks.
  ==13095== Reachable blocks (those to which a pointer was found) are not shown.
  ==13095== To see them, rerun with: --show-reachable=yes
  #

This patch fixes the memory leak.

Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoFix compilation outside of source directory
Jan Safranek [Mon, 14 Dec 2009 08:22:36 +0000 (09:22 +0100)] 
Fix compilation outside of source directory

Configure script can be invoked outside of source directory, which allows
to compile sources without spoiling the source directory with compilation
artifacts (like .o files). This patch tries to fix our Makefiles to allow
this to work.

You can test it in current GIT checkout (in the root dir):
# mkdir build; cd build; ../configure; make

As result, you should see all binary files in the 'build' directory.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoRemove the init script installation from .spec
Jan Safranek [Mon, 14 Dec 2009 08:22:29 +0000 (09:22 +0100)] 
Remove the init script installation from .spec

If we have our init scripts in /etc/init.d as result of 'make install', we
don't need to install them again in the .spec file.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoInstall init scripts during 'make install'
Jan Safranek [Mon, 14 Dec 2009 08:22:22 +0000 (09:22 +0100)] 
Install init scripts during 'make install'

Install init scripts during 'make install'.

I am not sure this is right thing to do, all the other projects I
participate in do not install their init scripts, but Dhaval thinks it's
nice to have it.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoEnable get_all_controller test
Ivana Hutarova Varekova [Thu, 10 Dec 2009 12:26:11 +0000 (13:26 +0100)] 
Enable get_all_controller test

This patch enable get_all_controller test

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoFix cgroup_get_all_controller_{begin, next, end} api
Ivana Hutarova Varekova [Thu, 10 Dec 2009 12:26:00 +0000 (13:26 +0100)] 
Fix cgroup_get_all_controller_{begin, next, end} api

remove the cgroup_initialized need from all of them - not needed

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agolssubsys: new option -a,--all
Ivana Hutarova Varekova [Thu, 10 Dec 2009 12:25:21 +0000 (13:25 +0100)] 
lssubsys: new option -a,--all

This patch adds new option to lssubsys command
lssubsys with this option displays moreover controllers which are
not mounted
The patch change the behavior of lssubsys a bit - there is no
error message if controllers are not mounted and lssubsys is called.

Example:
$  ./lssubsys -a
devices
cpuset,cpuacct
ns
cpu

$  ./lssubsys -am
devices /mnt/cgroups/devices
cpuset,cpuacct /mnt/cgroups/cpuset
ns
cpu

$  ./lssubsys

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoman page for lssubsys tool
Ivana Hutarova Varekova [Thu, 12 Nov 2009 12:51:25 +0000 (13:51 +0100)] 
man page for lssubsys tool

This patch adds the man page for lssubsys tool

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoFix a cgconfig behavior of wrong /etc/cgconfig.conf.
Ken'ichi Ohmichi [Wed, 4 Nov 2009 01:54:30 +0000 (10:54 +0900)] 
Fix a cgconfig behavior of wrong /etc/cgconfig.conf.

Changelog since v2:
o Avoid breaking ABI by changing the ECGCONFIGPARSEFAIL value.

Changelog since v1:
o Change a parser error value of /etc/cgconfig.conf to ECGCONFIGPARSEFAIL.

The cgconfig service succeeds even if there are something wrong
in /etc/cgconfig.conf. For example, it succeeds even if specifying
not-existing user (nouser) as a perm.task.uid like the following:

 # cat /etc/cgconfig.conf
 mount {
        cpuset = /mnt/cgroups/cpuset;
        memory = /mnt/cgroups/memory;
 }
 group root {
        perm {
                task {
                        uid = nouser;
                        gid = root;
                }
                admin {
                        uid = root;
                        gid = root;
                }
        }
        cpuset {
                cpuset.cpus = 0;
                cpuset.mems = 0;
        }
        memory {
                memory.use_hierarchy = 1;
                memory.limit_in_bytes = 1000000000000;
        }
 }
 #
 # service cgconfig start
 Starting cgconfig service: parsing failed at line number 10
                                                           [  OK  ]
 # echo $?
 0
 #

That is not a good behavior and the cgconfig service should fail
if there are something wrong in /etc/cgconfig.conf.
This patch fixes the behavior. In the above case, the behavior is
changed like the following by this patch:

 # service cgconfig start
 Starting cgconfig service: parsing failed at line number 10
 Loading configuration file /etc/cgconfig.conf failed
 Cgroup parsing failed
 Failed to parse /etc/cgconfig.conf                         [FAILED]
 #

Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoCleanup: Define ECGRULESPARSEFAIL for the parser error of cgrules.conf.
Ken'ichi Ohmichi [Wed, 4 Nov 2009 01:51:33 +0000 (10:51 +0900)] 
Cleanup: Define ECGRULESPARSEFAIL for the parser error of cgrules.conf.

Changelog since v2:
o Define ECGRULESPARSEFAIL for avoiding breaking ABI.

Changelog since v1:
o A new patch [Cleanup: Rename ECGROUPPARSEFAIL to ECGRULESPARSEFAIL.]

Now ECGROUPPARSEFAIL is defined for a parser error of /etc/cgrules.conf and
this patch defines ECGRULESPARSEFAIL for the same value for clarifying its
meaning.

Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoman page for lscgroup tool
Ivana Hutarova Varekova [Mon, 9 Nov 2009 13:13:58 +0000 (14:13 +0100)] 
man page for lscgroup tool

This patch adds the man page for lscgroup tool

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoAdd copyright header to cgcreate
Ivana Hutarova Varekova [Mon, 9 Nov 2009 10:38:14 +0000 (11:38 +0100)] 
Add copyright header to cgcreate

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoAdd man page for cgdelete
Jan Safranek [Fri, 30 Oct 2009 11:51:01 +0000 (12:51 +0100)] 
Add man page for cgdelete

Add man page for cgdelete.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoAllow cgcreate to create unlimited nr. of groups
Jan Safranek [Thu, 29 Oct 2009 14:48:06 +0000 (15:48 +0100)] 
Allow cgcreate to create unlimited nr. of groups

Don't limit the number of groups cgcreate can create, allocate them
dynamically. The size of allocated space for the group is only aproximate, but
still should be better than hard CG_HIER_MAX.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoAllow cgdelete to process unlimited nr. of groups
Jan Safranek [Thu, 29 Oct 2009 14:47:59 +0000 (15:47 +0100)] 
Allow cgdelete to process unlimited nr. of groups

Don't limit the number of groups cgdelete can remove, allocate them
dynamically.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoRemove the CG_HIER_MAX from tools-common
Jan Safranek [Thu, 29 Oct 2009 14:47:52 +0000 (15:47 +0100)] 
Remove the CG_HIER_MAX from tools-common

Some libcgroup tools are limited to CG_HIER_MAX arguments. This hard limit
is suitable only to some of the tools, namely cgdelete and cgcreate should not
be limited to any particular numbers of groups to create/delete.

This patches removes the hard limit from tools-common.c and puts it to the
individual tools.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agolibcgroup: cgclear manpage
Dhaval Giani [Fri, 23 Oct 2009 11:20:03 +0000 (16:50 +0530)] 
libcgroup: cgclear manpage

Add a manpage for cgclear

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Reviewed-by : Ivana Hutarova Varekova <varekova@redhat.com>

15 years agoconfig.h.in is generated by "autoheader" and since we removed all generated
Jan Safranek [Tue, 27 Oct 2009 15:42:14 +0000 (21:12 +0530)] 
config.h.in is generated by "autoheader" and since we removed all generated
files, we should remove this one too. "autoreconf" creates it when needed.

I am annoyed by reverting changes in it when I post git patches - the file
seems to change quite often, especially when I play with automake/autoconf.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoDon't link with -lpam unless necessary II
Jan Safranek [Fri, 23 Oct 2009 12:10:25 +0000 (14:10 +0200)] 
Don't link with -lpam unless necessary II

Oops, I sent older working version, here is correct one. I need to rest :(.
Here is the correct one:

All binaries are compiled with '-lpam' if --enable-pam is specified (and it
is on by default). We want only the PAM module linked with it.

The autoconf manual says about AC_CHECK_LIB:
If action-if-found is not specified, the default action prepends
-llibrary to LIBS

And the action-if-found we used was '[]', i.e. empty -> -lpam was added to
LIBS -> everything links with it. Simple action-if-found overrides this
default.

Changelog:
 - use 'dnl' as comments and ':' as the 'noop' action to reflect autoconf
 coding style.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoChange the libcgroup group
Jan Safranek [Mon, 26 Oct 2009 14:28:16 +0000 (15:28 +0100)] 
Change the libcgroup group

IMHO libcgroup is not part of "Development/Libraries" group - only the devel
subpackage is. Question is, part of which group it is. Looking at
https://fedoraproject.org/wiki/RPMGroups, I like "System
Environment/Libraries" (the package provides library) or "Applications/System"
the package provides various system tools).

What is your opinion?

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoDistribute the PAM module in separate subpackage
Jan Safranek [Mon, 26 Oct 2009 14:28:09 +0000 (15:28 +0100)] 
Distribute the PAM module in separate subpackage

As discussed on IRC, it might be nice to distribute the PAM module as
separate subpackage.

Regarding the Group:, it seems to me all PAM modules are in "System
Environment/Base" group, so let's put this one there too.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoAdd new executables to .spec file
Jan Safranek [Mon, 26 Oct 2009 14:28:02 +0000 (15:28 +0100)] 
Add new executables to .spec file

We have some new tools available in /bin and /sbin and we should distribute
them.

Changelog:
 - list the files instead of using wildcard

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
15 years agoMinor improvements and refactoring of lscgroups
Balbir Singh [Fri, 9 Oct 2009 14:45:34 +0000 (20:15 +0530)] 
Minor improvements and refactoring of lscgroups

This patch removes the excess "/"'s and makes the output
more readable. Please test on your systems as well.

Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoadds lscgroup tool
Ivana Hutarova Varekova [Fri, 9 Oct 2009 09:40:04 +0000 (11:40 +0200)] 
adds lscgroup tool

Description:
create tool which shows cgroups which are on system:

Usage: lscgroup [<controllers>:<path>] [...]
list all cgroups

Changes since V1(the previous versions was not enumerated):
* fix the format of comments which have more than 1 line
* printf of help -> fprintf(stdout,...
* change the sequence of processing of cgroups on input (now
    first) and internal controller list(first in the previous version), now the
    cgroups are output in order in which they are put to input
* fix return values/error messages - now if the controller is not mount
    the tool return error - it returns 0 otherwise
Changes since V2
    * fix problem with slash characters
  ( $ lscgroup cpu:/1/2
  cpu:/1/2/
  cpu:/1/2/1
  $ lscgroup cpu:1/2
  cpu:/2/
  cpu:/2/1 )
Changes since V3
    * rename the variables (dp1 -> cgroup_dir_path, dp2 -> input_dir_path)
    * improve the coding style

Examples:
    $ lscgroup
    devices:/
    devices:/sysdefault
    cpuset,cpuacct:/
    cpuset,cpuacct:/sysdefault
    cpuset,cpuacct:/daemons
    cpuset,cpuacct:/daemons/ftp

    $ lscgroup cpuset:/
    cpuset,cpuacct:/
    cpuset,cpuacct:/sysdefault
    cpuset,cpuacct:/daemons
    cpuset,cpuacct:/daemons/ftp

    $ lscgroup cpuset:/daemons
    cpuset,cpuacct:/daemons/
    cpuset,cpuacct:/daemons/ftp

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoRestrict the effective range of SIGUSR2 signal.
Ken'ichi Ohmichi [Mon, 13 Jul 2009 03:14:29 +0000 (12:14 +0900)] 
Restrict the effective range of SIGUSR2 signal.

Hi,

If a cgrulesengd daemon receives a SIGUSR2 signal (for reloading rules
configuration) while waiting in select(), a daemon finishes incorrectly
due to an "Interrupted system call" error.
If applying a patch "Add the strings of errno to cgrulesengd daemon's
message." and running `service cgred reload`, you can see the message
"selecting error: Interrupted system call". This patch fixes the problem.

There were some problems the deadlock happens related to a SIGUSR2 signal
and they have been fixed by the followings already:

* [PATCH] Fix the deadlock of vsyslog() call.
  http://libcg.git.sourceforge.net/git/gitweb.cgi?p=libcg;a=commit;h=70111cd03653c3ceab9d907c14fa35e5881b2735
* [PATCH] Fix the deadlock of rl_lock.
  http://libcg.git.sourceforge.net/git/gitweb.cgi?p=libcg;a=commit;h=0241c6f1df5068c006f756005c8e7faa63058c27

The above two patches fixed the problems by protecting the important
codes from receiving a SIGUSR2 signal. But this way was not good, because
the protecting code will be necessary if increasing the important codes.

Instead of protecting the important codes, this patch restricts the
effective range of receiving SIGUSR2 signal. So we will not need to add
a new protecting code by this patch.

Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoAdd the strings of errno to cgrulesengd daemon's message.
Ken'ichi Ohmichi [Mon, 13 Jul 2009 03:14:00 +0000 (12:14 +0900)] 
Add the strings of errno to cgrulesengd daemon's message.

Hi,

This patch adds  the strings of errno to cgrulesengd daemon's message.

For investigating a problem that cgrulesengd daemon finishes by
`service cgred reload`, I added the strings of errno to the daemon's
message. This strings were useful for investigating.

Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoadds lssubsys tool
Ivana Hutarova Varekova [Mon, 24 Aug 2009 09:46:17 +0000 (11:46 +0200)] 
adds lssubsys tool

Description:
 Show controller, which are mounted/which are on input
 and if option -m is used shows the mount point on which are mounted:

Changes since V1(the previous versions was not enumerated):
*   fix the size of array cont_name - so no allocation and c_max variable
removed
*   change the sequence of processing of controllers list on input (now
first) and internal controller list(first in the previous version), now the
controllers are output in order in which they are put to input
*   fix return values/error messages - now if the controller is not mount
the tool return error - it returns 0 otherwise

Changes since V2
* fix the format of comments which have more than 1 line

Changes since V3
* printf of help -> fprintf(stdout,

Syntax:
 lssubsys [-m] [controller1] [controller2] [...]

 -m - show mount points

Examples:
 $lssubsys -m cpuacct
 cpuset,cpuacct /mnt/cgroups/cpuset

 $ lssubsys
 devices
 cpuset,cpuacct

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoRemove VERSION macro from api.c
Jan Safranek [Thu, 6 Aug 2009 12:03:45 +0000 (14:03 +0200)] 
Remove VERSION macro from api.c

The macro and assosicated cg_version is not used anywhere and it generates
warning:
api.c:58:1: warning: "VERSION" redefined

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoRemove warnings from test_functions.c
Jan Safranek [Thu, 6 Aug 2009 12:03:32 +0000 (14:03 +0200)] 
Remove warnings from test_functions.c

Fix following warnings:
test_functions.c: In function ‘group_modified’:
test_functions.c:435: warning: format ‘%d’ expects type ‘int *’, but argument
3 has type ‘_Bool *’
test_functions.c:440: warning: format ‘%lld’ expects type ‘long long int *’,
but argument 3 has type ‘int64_t *’
test_functions.c:445: warning: format ‘%llu’ expects type ‘long long unsigned
int *’, but argument 3 has type ‘u_int64_t *’

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoRemove unnecessary includes from libcgroup.h
Jan Safranek [Thu, 6 Aug 2009 12:03:26 +0000 (14:03 +0200)] 
Remove unnecessary includes from libcgroup.h

libcgroup.h includes some header files, which are not then used. These should
be removed, resp. moved to the source files where they are actually needed.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
15 years agoShorten error text of ECGOTHER
Jan Safranek [Thu, 6 Aug 2009 12:03:19 +0000 (14:03 +0200)] 
Shorten error text of ECGOTHER

Let's reformat cgroup_strerror output from

Cgroup generic error, error message: Device or resource busy

to shorter and clearer

Device or resource busy

The patch assumes that _GNU_SOURCE is defined.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
16 years agolibcgroup: Use the correct data type in the get_all_controller test case
Dhaval Giani [Thu, 6 Aug 2009 06:33:18 +0000 (12:03 +0530)] 
libcgroup: Use the correct data type in the get_all_controller test case

get_all_controller.c: In function ‘main’:
get_all_controller.c:18: warning: passing argument 1 of ‘cgroup_get_all_controller_begin’ from incompatible pointer type
get_all_controller.c:23: warning: passing argument 1 of ‘cgroup_get_all_controller_next’ from incompatible pointer type
get_all_controller.c:31: warning: passing argument 1 of ‘cgroup_get_all_controller_end’ from incompatible pointer type

The test case used a FILE * instead of a void *. Correct this change (The datatype is opaque to the caller)

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
16 years agolibcgroup: Fix compile error
Dhaval Giani [Thu, 6 Aug 2009 06:29:35 +0000 (11:59 +0530)] 
libcgroup: Fix compile error

The correct error code is ECGOTHER and not CGOTHER

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
16 years agoadd api for generating the list of all controllers (not only mount ones)
Ivana Hutarova Varekova [Fri, 17 Jul 2009 07:41:12 +0000 (09:41 +0200)] 
add api for generating the list of all controllers (not only mount ones)

this patch add api for generating the list of all controllers (not only mount ones)
- it uses three functions:
cgroup_get_all_controller_begin
cgroup_get_all_controller_next
cgroup_get_all_controller_end

and structure:
struct controller_data {
char name[FILENAME_MAX];
int hierarchy;
int num_cgroups;
int enabled;
};

the data are read from /proc/cgroups file

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Reviewed-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
16 years agoRefactor cgclear to use new recursive delete
Jan Safranek [Tue, 4 Aug 2009 12:28:29 +0000 (14:28 +0200)] 
Refactor cgclear to use new recursive delete

Let's rework cgroup_config_unload_controller to use the brand new recursive
removal of groups. It saves *lot of* fopen() and fclose() calls:

On my (semi-broken) Fedora 11 with 196 running processes and 3 cgroup
hierarchies, the old cgclear does 668 open("*/tasks"). With the
optimized cgclear, I can see just 22 open("*/tasks") calls.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
16 years agoAdd cgdelete tool
Jan Safranek [Tue, 4 Aug 2009 12:28:22 +0000 (14:28 +0200)] 
Add cgdelete tool

The cgdelete command line tool removes given control groups.

Usage: cgdelete [-r]  <controllers>:<group> [...]

# I have group 1 with many subgroups:
$ cgdelete cpu,freezer:1
cgdelete: cannot remove group '1': Cgroup generic error, error message:
Device or resource busy

$ cgdelete -r cpu,freezer:1
$

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
16 years agoAdd recursive cgroup_delete_cgroup_ext.
Jan Safranek [Tue, 4 Aug 2009 12:28:15 +0000 (14:28 +0200)] 
Add recursive cgroup_delete_cgroup_ext.

Changelog:
- add braces to cgroup_delete_cgroup_ext to improve readability
- use enum instead of macro to define flags

The new function allows to recursively delete whole tree of groups. There is
new infrastructure created around (cg_delete_cgroup_controller_recursive).

It has inconsistent behavior when root group removal is requested - it removes
all children (if requested), but does not remove the root itself and returns
success value. This allows simple rewrite of cgclear functions to use this
function.

Original cgroup_delete_cgroup now leads to cgroup_delete_cgroup_ext.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
16 years agoSplit cgroup removal to separate functions.
Jan Safranek [Tue, 4 Aug 2009 12:28:09 +0000 (14:28 +0200)] 
Split cgroup removal to separate functions.

Changelog:
- simplify error handling in cg_move_task_files

cgroup_delete_cgroup does all the stuff on it's own. This patch refactors
the function and moves the parts with complete error handling.

The new functions are cg_delete_cgroup_controller and cg_move_task_files.
They are not necessarily needed, but it simplifies error handling and clearly
distinguishes functionality of cgroup_delete_cgroup.

Purpose of the functions should be clearly specified in the doxygen comments.

Especially note that cg_delete_cgroup_controller wants already opened file,
where all tasks should be moved - this is optimization, which will be used in
subsequent patches. I could use cgroup_get_task_* and cgroup_attach_task, which
would look definitely nicer, but it would lead to lot of fopen() and fclose()
calls. Let me know what do you think about it.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
16 years agoRFC: Fix cgroup_find_parent function
Jan Safranek [Tue, 28 Jul 2009 14:20:25 +0000 (16:20 +0200)] 
RFC: Fix cgroup_find_parent function

There are more issues with cgroup_find_parent function:

1.
The cgroup_find_parent expects, that it's argument is group in
cg_mount_table[0] controller, which is not always the case.

IMHO the function should accept complete struct cgroup and find real parent.

2.
when checking the st_dev of the group and it's parent to prevent
"underflow" to real filesystem, actually the parent and it's parent are
checked instead of group and it's parent.

In addition, I enhanced the function to return real error code when something
goes wrong.

Open question is, if the function should return just char* as parent's
name or whole struct cgroup*. The second case is more natural - we should
work with groups and not group names, but in some cases just the name is
needed and whole cgroup creation would be unnecessary overhead (I have
prepared cgcdelete tool, which needs just parent's name).

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
16 years agoremoves copy_name_value_from_rules to wrapper
Ivana Varekova [Wed, 15 Jul 2009 08:28:56 +0000 (10:28 +0200)] 
removes copy_name_value_from_rules to wrapper

move copy_name_value_from_rules procedure to wrapper.c file and
add the header to libcgroup-internal.h

Signed-off-by: Ivana Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
16 years agoAdd a process name to the log of cgrulesengd daemon.
Ken'ichi Ohmichi [Mon, 6 Jul 2009 04:42:36 +0000 (13:42 +0900)] 
Add a process name to the log of cgrulesengd daemon.

Hi,

Current cgrulesengd daemon changes the cgroup of each process by a rule
based on uid, gid, and process name. And it is good that the log of the
daemon contains a process name with uid and gid.
This patch adds a process name to the log message.

Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
16 years agoReduce "Cgroup change for PID:X, UID:X, GID:X FAILED!" messages.
Ken'ichi Ohmichi [Mon, 6 Jul 2009 04:23:44 +0000 (13:23 +0900)] 
Reduce "Cgroup change for PID:X, UID:X, GID:X FAILED!" messages.

Hi,

Changelog since v1:
===================
 * Rebase the latest code.
 * Cleanup.

The log message "Cgroup change for PID:X, UID:X, GID:X FAILED!" is output
by cgrulesengd daemon, even if a process finished already and that is not
a problem.
This patch prevents the daemon from outputting this spam log message.

* Reference
  [PATCH 2/2] Reduce "Cgroup change for PID:X, UID:X, GID:X FAILED!" messages.
  http://sourceforge.net/mailarchive/message.php?msg_name=4A10EE7E.60403%40mxs.nes.nec.co.jp

Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
16 years agoConfigure the location of cgrulesengd socket v0.34
Jan Safranek [Tue, 30 Jun 2009 12:29:19 +0000 (14:29 +0200)] 
Configure the location of cgrulesengd socket

This patch allows users to configure location of cgrulesengd socket before
compilation:

./configure --enable-cgred-socket=/var/run/cgred.socket

In addition, /var/run/cgred.socket is now default location of the socket - this
sounds LSB compliant to me. Feel free to suggest better one.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>