summaryrefslogtreecommitdiffstats
path: root/src/tools
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* 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>
* Fix compilation outside of source directoryJan Safranek2009-12-161-1/+1
| | | | | | | | | | | | | | | 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>
* 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>
* 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>
* 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 unnecessary includes from libcgroup.hJan Safranek2009-08-292-0/+2
| | | | | | | | 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>
* 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>
* removes copy_name_value_from_rules to wrapperIvana Varekova2009-08-061-56/+2
| | | | | | | | | 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>
* 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: 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>
* cgset: Add cgset_SOURCES to MakefileIvana Varekova2009-06-291-0/+2
| | | | | | | Add cgset_SOURCES to Makefile Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Apply a new rule to 'cgclassify' command.Ken'ichi Ohmichi2009-06-291-13/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v6: ================ * Change the cgroup_get_procname_from_procfs() calling for the returning value's change. Changelog of v5: ================ * Add the description of a new option "--sticky". Changelog of v4: ================ * Add a new option "--sticky" so that cgrulesengd daemon does not change the children's cgroups which is classified by 'cgclassify' command. Changelog of v3: ================ * New patch. Description: ============ This patch applies a new rule to 'cgclassify' 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>
* Apply a new rule to 'cgexec' command.Ken'ichi Ohmichi2009-06-292-8/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v6: ================ * No change. Changelog of v5: ================ * Add the description of a new option "--sticky". Changelog of v4: ================ * Add a new option "--sticky" so that cgrulesengd daemon does not change the children's cgroups which is executed by 'cgexec' command. Changelog of v3: ================ * Set a SETUID to "cgexec" command file. * An euid is changed to the executing user from a root user. Changelog of v2: ================ * New patch. Description: ============ This patch applies a new rule to 'cgexec' command. cgroup_register_unchanged_process() is called so that cgrulesengd daemon does not change the cgroup of a process, which is executed by 'cgexec' command. And cgroup_change_cgroup_flags() is called for applying a new rule. 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>
* libcgroup: Introduce a unload cgroups APIDhaval Giani2009-06-222-1/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | This API will unload the cgroups created in the cgroupfs and unmount and delete the filesystem mount point. The action is equivalent to what is done currently in service cgconfig stop. The reason for this API is to make sure we don't end up with a asymmetric library API subset. Today an application program can programatically through cgroup_config_load_config() load a configuration file, but has no means to cleanup (including all temporarily created groups). changes from v3 1. Address Jan's comments from http://article.gmane.org/gmane.comp.lib.libcg.devel/1105 changes from v2 1. Fix a leak as noted by Bharata 2. Address Balbir's review comments at http://article.gmane.org/gmane.comp.lib.libcg.devel/1080 changes from v1 1. Change the name of the function to cgroup_unload_cgroups 2. Change the name of the executatble to cgclear 3. Split out the funtions Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* This patch adds cgset toolIvana Varekova2009-06-182-1/+179
| | | | | | | | | | | | | | | | | | | | | | | | | This patch adds cgset tool, which sets parameters of controllers for given cgroup based on input name-variable pairs - the syntax is: cgset -r <name=value> <relative path to cgroup> ------------------------------------------------- EXAMPLES: $ cgcreate -g cpuset:test1 $ cgset -r cpuset.cpus=1 test $ cat ./test/cpuset.cpus 1 $ cgcreate -g cpuset:test1 -g cpuset:test2 $ cgset -r cpuset.cpus=0 test1 test2 $ cat /mnt/cgroups/cpuset/test1/cpuset.cpus 0 $ cat /mnt/cgroups/cpuset/test2/cpuset.cpus 0 Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Cleanup: Integrate similar code to cgroup_get_uid_gid_from_procfs().Ken'ichi Ohmichi2009-06-081-84/+3
| | | | | | | | | | | | | | CHANGELOG of v2.1: ================ * Rebase the patch for commit '340feae163c4797a6cb1247b3812c1ccdc52fa41'. There are some similar functions for getting process's data (uid, gid) from /proc/<pid>/status file, so this patch integrates these functions into one cgroup_get_uid_gid_from_procfs(). Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Reviewed-By: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* This patch adds cgcreate toolIvana Varekova2009-06-032-1/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds cgcreate tool, which creates cgroups based on input parameters - the syntax is: cgcreate -t <tuid>:<tgid> -a <agid>:<auid> -g <list of controllers>:<relative path to cgroup> where: -a enables user to define admin gid and uid (implicit values are the same values which are in the parent directory) -t enables user to define task gid and uid (implicit values are the same values which are in parent directory) -g sets pairs list of controllers-relative path to cgroup ------------------------------------------------- EXAMPLES: * ../../libtool --mode=execute ./cgcreate -a :varekova -g cpuacct:first * ll /mnt/cgroups/cpuacct | grep first drwxrwxr-x 2 root varekova 0 2009-06-03 09:14 first * ll /mnt/cgroups/cpuacct/first/* -rwxrwxr-x 1 root varekova 0 2009-06-03 09:14 /mnt/cgroups/cpuacct/first/cpuacct.usage -rwxrwxr-x 1 root varekova 0 2009-06-03 09:14 /mnt/cgroups/cpuacct/first/notify_on_release -rwxrwxr-x 1 root varekova 0 2009-06-03 09:14 /mnt/cgroups/cpuacct/first/tasks * ../../libtool --mode=execute ./cgcreate -a varekova:root -t varekova:varekova -g cpuacct:second * ll /mnt/cgroups/cpuacct/ | grep second drwxrwxr-x 2 varekova root 0 2009-06-03 09:13 second * ll /mnt/cgroups/cpuacct/second total 0 -rwxrwxr-x 1 varekova root 0 2009-06-03 09:13 cpuacct.usage -rwxrwxr-x 1 varekova root 0 2009-06-03 09:13 notify_on_release -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:13 tasks * ../../libtool --mode=execute ./cgcreate -a varekova:varekova -g cpuacct:third -g cpuacct:fourth * ll /mnt/cgroups/cpuacct | grep h drwxrwxr-x 2 varekova varekova 0 2009-06-03 09:18 fourth drwxrwxr-x 2 varekova varekova 0 2009-06-03 09:18 third * ll /mnt/cgroups/cpuacct/*h* /mnt/cgroups/cpuacct/fourth: total 0 -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:18 cpuacct.usage -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:18 notify_on_release -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:18 tasks /mnt/cgroups/cpuacct/third: total 0 -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:18 cpuacct.usage -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:18 notify_on_release -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:18 tasks Signed-off-by: Ivana Varekova <varekova@redhat.com>
* Add cgroup_free_group_spec procedureIvana Varekova2009-05-292-0/+32
| | | | | | | | Add cgroup_free_group_spec procedure which free cgroups_group_spec variable. Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* parse_cgroup_spec function does not initializesd allocated memoryIvana Varekova2009-05-291-1/+1
| | | | | | | | | parse_cgroup_spec function does not initializesd allocated memory this patch allocate it to zero so there is no problem with uninitialized values. Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Add options to enable/disable various build targets.Jan Safranek2009-05-251-0/+4
| | | | | | | | | | | | | By default, everything is compiled. I want to add options to ./configure, which can selectively disable tools, daemon and pam module. The library itself is mandatory component and cannot be disabled. Usage: ./configure --help ./configure --disable-tools --disable-pam --disable-daemon Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* Add fclose() calls into egid_of_pid().Ken'ichi Ohmichi2009-05-181-0/+2
| | | | | | | | | | | | | Hi, This patch adds necessary fclose() calls into egid_of_pid(). Thanks Ken'ichi Ohmichi Reported-by: Masayuki Igawa <igawa@mxs.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 of cgexec error handlingIvana Varekova2009-05-081-1/+2
| | | | | | | | | | | Fix of cgexec error handling - with this patch cgexec return the right error message - not only cg internal error value re-generated 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>
* Remove autogenerated files and update documentation. More documentationBalbir Singh2009-04-011-519/+0
| | | | | | updates will be needed and will be done in subsequent cleanups. Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* Add fclose() calls for error handlingKen'ichi Ohmichi2009-03-311-0/+2
| | | | | | | | | I reviewed the libcgroup code in the viewpoint of memory-leak and found some lacks of fclose(). This patch adds some fclose() calls for error handling. Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Rework the way how so version is definedJan Safranek2009-03-261-3/+5
| | | | | | | | | Make the shared object version a bit more usable, the notation with double colons cannot be used on different places (see next patch). Also run automake && autoconf to refresh the generated stuff. Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* Install cgconfigparser to /sbinJan Safranek2009-03-262-21/+53
| | | | | | | | | cgconfigparser can be executed only by root, so it should be installed to /sbin directory. Also run automake to update Makefile.in with this change. Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* Generate everythingautomakeJan Safranek2009-03-261-0/+486
| | | | | | Finally run autoreconf -f -i to generate all the stuff that should be generated Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* Add automake makefilesJan Safranek2009-03-261-0/+11
| | | | | | | | Add automake makefiles and prepare everything to run, but don't actually run the automake - it would generate lot of noise, where my manual changes would get lots. Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* Distribute files to various subdirectoriesJan Safranek2009-03-265-0/+557
Signed-off-by: Jan Safranek <jsafrane@redhat.com>