summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* libcgroup: Dont assign values to variables inside if conditionsDhaval Giani2010-03-261-2/+4
| | | | Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
* libcgroup: Fix coding style issues in api.cDhaval Giani2010-03-261-55/+57
| | | | | | | | | | | | Pre this patch total: 16 errors, 40 warnings, 3321 lines checked Post this patch total: 2 errors, 5 warnings, 3323 lines checked The remaining errors will cause a code change, and so go in a separate patch. Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
* don't export functions that should not be exportedLennart Poettering2010-03-269-36/+36
| | | | | | 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>
* cgget: properly use binary & instead of boolean && when checking for flagsLennart Poettering2010-03-261-2/+2
| | | | | | 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>
* config: don't implicitly import cgroup_config_cleanup_namespace_table(), ↵Lennart Poettering2010-03-261-0/+1
| | | | | | | | this is not K&R C anymore... 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>
* api: don't keep one copy of the mount table per .c fileLennart Poettering2010-03-262-2/+5
| | | | | | | | | | The mount table variables need to be declared in the header file and defined in the .c file. If we don't do that every .o file will end up with its own copy of those variables. 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>
* unexport a couple of variables that don't need to be exportedLennart Poettering2010-03-262-2/+2
| | | | | | 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>
* api: bzero is obsolete BSD, use memset insteadLennart Poettering2010-03-261-1/+1
| | | | | | 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>
* config: pass struct as const call-by-ref instead of call-by-value, to ↵Lennart Poettering2010-03-261-5/+5
| | | | | | | | 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>
* config: use macros instead of arrays for const stringsLennart Poettering2010-03-261-2/+2
| | | | | | 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>
* make functions without arguments proper C99 functionsLennart Poettering2010-03-262-9/+9
| | | | | | 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>
* add a couple of FIXMEs to broken codeLennart Poettering2010-03-261-0/+9
| | | | | | 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>
* add const where applicable, drop const where unnecessaryLennart Poettering2010-03-264-31/+31
| | | | | | | | | | | | | | | 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>
* git: hide all generated files from gitLennart Poettering2010-03-243-0/+14
| | | | | | | 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>
* Fix typo in wrapper.c (cgroup_get_uid_gid)Balbir Singh2010-03-241-1/+1
| | | | | | | | | 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>
* Split header file IIIJan Safranek2010-03-212-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Move private definitions to private headerJan Safranek2010-03-213-0/+21
| | | | | | | | | 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>
* Use memset to initialize sigaction structJon Bernard2010-03-121-2/+1
| | | | | | | | | | 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>
* Make the error stings constJan Safranek2010-03-081-2/+2
| | | | | | | 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>
* Remove last_errno from public headerJan Safranek2010-03-081-0/+4
| | | | | | | 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>
* Remove GNU_SOURCE from public headersJan Safranek2010-03-081-1/+8
| | | | | | | | 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>
* fix cgroup_get_value_string problem with *.stat outputIvana Hutarova Varekova2010-02-101-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* This patch adds to cgget option -a:Ivana Hutarova Varekova2010-02-101-14/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* adds new option -g to cgget commandIvana Hutarova Varekova2010-02-101-42/+152
| | | | | | | | | | | | | | | | | | | 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>
* api for generating the list of variables of given controllerIvana Hutarova Varekova2010-02-102-0/+26
| | | | | | | | | | | | | | | 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>
* [PATCH-v2] Add the write error handling to cg_set_control_value().Ken'ichi Ohmichi2010-01-281-2/+9
| | | | | | | | | | | | | | 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>
* libcgroup: Modify the APIs to use the namespaceDhaval Giani2010-01-071-1/+7
| | | | | | | | | | | 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>
* libcgroup: Setup the namespace datastructuresDhaval Giani2010-01-073-3/+212
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* libcgroup: Introduce the new namespace keywordDhaval Giani2010-01-074-7/+79
| | | | | | | | | | | | | | | 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>
* libcgroup: Remove assert in cgroup_strerror()Dhaval Giani2010-01-041-1/+1
| | | | | | | 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>
* 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>
* 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-164-5/+5
| | | | | | | | | | | | | | | 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>
* 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-161-6/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix a cgconfig behavior of wrong /etc/cgconfig.conf.Ken'ichi Ohmichi2009-11-112-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-111-2/+2
| | | | | | | | | | | | | | | 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>
* 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>
* 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>
* 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>