summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Clean up the init scriptdevel/config3Jan Safranek2009-12-221-18/+0
| | | | | | Some parts of the init script are not needed with the recent changes. Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* Use tools instead of shell scriptsJan Safranek2009-12-221-28/+27
| | | | | | | | 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>
* Make cgclear quiert when there is nothing to clear.Jan Safranek2009-12-221-0/+3
| | | | | | | 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>
* Use cgclear on shutdownJan Safranek2009-12-221-39/+1
| | | | | | | | 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>
* Add sample /etc/sysconfig/cgconfigJan Safranek2009-12-222-1/+13
| | | | | | | | | | 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>
* Don't create sysdefault group whent it's not neededJan Safranek2009-12-221-1/+9
| | | | | | | | | | | | | | | 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>
* Move sysdefault handling to separate functionJan Safranek2009-12-221-20/+24
| | | | | | | Move sysdefault handling to separate function - it simplifies following patch. Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* Remove trailing space from lssubsys outputJan Safranek2009-12-221-2/+2
| | | | | | | 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>
* Fix reading of empty parameter valuesJan Safranek2009-12-221-3/+7
| | | | | | | | | | | 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>
* Fix error text on failed reading of parameter.Jan Safranek2009-12-221-1/+1
| | | | | | | | | | 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>
* cgget toolJan Safranek2009-12-222-1/+197
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* libcgroup: trivial: Fix typoDhaval Giani2009-12-161-1/+1
| | | | | | opened is spelled as opened and not opend Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix an invalid access to yytext.Ken'ichi Ohmichi2009-12-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* 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>