summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Fix a memory leak in "cgconfig" service.Ken'ichi Ohmichi2009-12-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix compilation outside of source directoryJan Safranek2009-12-165-6/+6
| | | | | | | | | | | | | | | 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>
* Remove the init script installation from .specJan Safranek2009-12-161-5/+0
| | | | | | | | 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>
* Install init scripts during 'make install'Jan Safranek2009-12-161-0/+8
| | | | | | | | | | | 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>
* Enable get_all_controller testIvana Hutarova Varekova2009-12-162-2/+3
| | | | | | | 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>
* Fix cgroup_get_all_controller_{begin, next, end} apiIvana Hutarova Varekova2009-12-161-9/+0
| | | | | | | 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>
* lssubsys: new option -a,--allIvana Hutarova Varekova2009-12-162-7/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* man page for lssubsys toolIvana Hutarova Varekova2009-11-131-0/+35
| | | | | | | 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>
* Fix a cgconfig behavior of wrong /etc/cgconfig.conf.Ken'ichi Ohmichi2009-11-113-14/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Cleanup: Define ECGRULESPARSEFAIL for the parser error of cgrules.conf.Ken'ichi Ohmichi2009-11-112-2/+4
| | | | | | | | | | | | | | | 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>
* man page for lscgroup toolIvana Hutarova Varekova2009-11-111-0/+25
| | | | | | | 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>
* Add copyright header to cgcreateIvana Hutarova Varekova2009-11-111-0/+15
| | | | | Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Add man page for cgdeleteJan Safranek2009-11-011-0/+26
| | | | | | | Add man page for cgdelete. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Allow cgcreate to create unlimited nr. of groupsJan Safranek2009-11-011-8/+17
| | | | | | | | | 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>
* Allow cgdelete to process unlimited nr. of groupsJan Safranek2009-11-011-8/+18
| | | | | | | | 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>
* Remove the CG_HIER_MAX from tools-commonJan Safranek2009-11-017-11/+22
| | | | | | | | | | | | 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>
* libcgroup: cgclear manpageDhaval Giani2009-10-282-1/+20
| | | | | | | Add a manpage for cgclear Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Reviewed-by : Ivana Hutarova Varekova <varekova@redhat.com>
* config.h.in is generated by "autoheader" and since we removed all generatedJan Safranek2009-10-271-163/+0
| | | | | | | | | | 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>
* Don't link with -lpam unless necessary IIJan Safranek2009-10-271-1/+5
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Change the libcgroup groupJan Safranek2009-10-271-1/+1
| | | | | | | | | | | | | 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>
* Distribute the PAM module in separate subpackageJan Safranek2009-10-271-1/+15
| | | | | | | | | | | 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>
* Add new executables to .spec fileJan Safranek2009-10-271-0/+8
| | | | | | | | | | | 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>
* Minor improvements and refactoring of lscgroupsBalbir Singh2009-10-231-12/+13
| | | | | | | | 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>
* adds lscgroup toolIvana Hutarova Varekova2009-10-092-1/+298
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Restrict the effective range of SIGUSR2 signal.Ken'ichi Ohmichi2009-10-041-30/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add the strings of errno to cgrulesengd daemon's message.Ken'ichi Ohmichi2009-10-041-11/+12
| | | | | | | | | | | | | | | | 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>
* adds lssubsys toolIvana Hutarova Varekova2009-08-292-1/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove VERSION macro from api.cJan Safranek2009-08-291-11/+0
| | | | | | | | | 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>
* Remove warnings from test_functions.cJan Safranek2009-08-292-3/+6
| | | | | | | | | | | | | | 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>
* Remove unnecessary includes from libcgroup.hJan Safranek2009-08-295-5/+5
| | | | | | | | 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>
* Shorten error text of ECGOTHERJan Safranek2009-08-291-4/+1
| | | | | | | | | | | | | | | 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>
* libcgroup: Use the correct data type in the get_all_controller test caseDhaval Giani2009-08-061-0/+34
| | | | | | | | | | | 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>
* libcgroup: Fix compile errorDhaval Giani2009-08-061-1/+1
| | | | | | The correct error code is ECGOTHER and not CGOTHER Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* add api for generating the list of all controllers (not only mount ones)Ivana Hutarova Varekova2009-08-063-0/+112
| | | | | | | | | | | | | | | | | | | | | | 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>
* Refactor cgclear to use new recursive deleteJan Safranek2009-08-061-92/+14
| | | | | | | | | | | | 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>
* Add cgdelete toolJan Safranek2009-08-062-1/+147
| | | | | | | | | | | | | | | | | 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>
* Add recursive cgroup_delete_cgroup_ext.Jan Safranek2009-08-063-26/+155
| | | | | | | | | | | | | | | | | | | 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>
* Split cgroup removal to separate functions.Jan Safranek2009-08-061-49/+154
| | | | | | | | | | | | | | | | | | | | | | | 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>
* RFC: Fix cgroup_find_parent functionJan Safranek2009-08-061-31/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* removes copy_name_value_from_rules to wrapperIvana Varekova2009-08-064-56/+64
| | | | | | | | | 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>
* Add a process name to the log of cgrulesengd daemon.Ken'ichi Ohmichi2009-07-071-5/+6
| | | | | | | | | | | | | | | 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>
* Reduce "Cgroup change for PID:X, UID:X, GID:X FAILED!" messages.Ken'ichi Ohmichi2009-07-071-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Configure the location of cgrulesengd socketJan Safranek2009-07-013-2/+17
| | | | | | | | | | | | | 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>
* Cleanup: find better name for CGRULE_CGRED_TEMP_FILEJan Safranek2009-07-013-6/+6
| | | | | | | | Rename CGRULE_CGRED_TEMP_FILE to CGRULE_CGRED_SOCKET_PATH to better describe the macro usage - it's not a temporary file, it's a socket. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix cgroup_find_matching_rule() call.Ken'ichi Ohmichi2009-06-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Hi, If compiling the latest code (8cc1d9743201cb9ae9a5286c898b9d47e318ed46), the following warning messages are printed. The problem is due to invalid call of cgroup_find_matching_rule_uid_gid(). Instead of this function call, cgroup_find_matching_rule() should be called as "[PATCH-v6 03/11] Add the key "process name" to find a matching rule.". $ make [snip] api.c: In function 'cgroup_change_cgroup_flags': api.c:1994: warning: passing argument 3 of 'cgroup_find_matching_rule_uid_gid' from incompatible pointer type api.c: At top level: api.c:1923: warning: 'cgroup_find_matching_rule' defined but not used [snip] $ * Reference: "[PATCH-v6 03/11] Add the key "process name" to find a matching rule." http://sourceforge.net/mailarchive/message.php?msg_name=4A44617E.9060002%40mxs.nes.nec.co.jp Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix too many program name in the usage message of "cgset" command.Ken'ichi Ohmichi2009-06-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Hi, If compiling the latest code (8cc1d9743201cb9ae9a5286c898b9d47e318ed46), the following warning messages are printed. $ make [snip] cgset.c: In function 'usage': cgset.c:123: warning: too many arguments for format [snip] $ This patch fixes too many program name in the usage message of "cgset" command. 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>
* cgset: fix the man-page -add new parametersIvana Varekova2009-06-291-2/+8
| | | | | | | This patch fixed man page and adds newly added parameters Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* cgset: Add --copy-from option to cgsetIvana Varekova2009-06-291-5/+69
| | | | | | | Add copy-from option to cgset Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* cgset: Change the handling of options, add --helpIvana Varekova2009-06-291-6/+35
| | | | | | | | | | Change the handling of options - add the possibility to use long options - add --help option - change the type of c (see man 3 getopt_long) Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* cgset: Change the generation of cgroupIvana Varekova2009-06-291-43/+74
| | | | | | | | | | | | | | | - This patch change the system of generating cgroup to 1/ create one src cgroup 2/ for each input cgroup name cgroup_copy_cgroup the name-value data from original one This method is better because the name-values pairs should not be parsed several times. And this method will be used in new coption --copy-from too (the src group will be find in option) move the part in which src is generated to separate function Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>