summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Refactor cgclear to use new recursive deletedevel/cgdeleteJan Safranek2009-07-291-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. Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* Add cgdelete toolJan Safranek2009-07-292-1/+147
| | | | | | | | The cgdelete command line tool removes given control groups. Usage: cgdelete [-r] <controllers>:<group> [...] Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* Add recursive cgroup_delete_cgroup_ext.Jan Safranek2009-07-293-25/+155
| | | | | | | | | | | | | | 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>
* Split cgroup removal to separate functions.Jan Safranek2009-07-291-49/+149
| | | | | | | | | | | | | | | | | | | 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>
* Export cgroup_find_parent and add testing code for itJan Safranek2009-07-284-1/+96
| | | | | | | | | This patch does not necessarily need to be accepted, it just provides testing facility for new cgroup_find_parent. Especially note the ugly dependence on ../src/tools/tools-common.c :) Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* RFC: Fix cgroup_find_parent functionJan Safranek2009-07-281-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>
* 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>
* 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>
* Cleanup: Clarify the number meanings of string length.Ken'ichi Ohmichi2009-06-291-4/+4
| | | | | | | | | | | | | | | | Hi, This patch clarifies the number meanings of string length in the function cgroup_get_uid_gid_from_procfs(). This is recreated based on Igawa-san's patch for the latest code. * Reference Igawa-san's patch http://sourceforge.net/mailarchive/message.php?msg_name=20090515.085922.109268324.igawa%40mxs.nes.nec.co.jp Signed-off-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>
* Add a new test command "proctest".Ken'ichi Ohmichi2009-06-292-1/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v6: ================ * New patch. This patch adds a new test command "proctest" for testing both cgroup_get_uid_gid_from_procfs() and cgroup_get_procname_from_procfs(). # sleep 100 & [1] 28558 # ./tests/proctest $$ 28558 Pid | Process name | Uid | Gid -------+----------------------------------+-------+------- 27219 | /bin/bash | 0 | 0 28558 | /bin/sleep | 0 | 0 # The functions get a process information from /proc fs, and they are fragile because the content of /proc fs is not stable. If changing /proc fs in future, this test command will be useful for catching the change. 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 description about a new rule.Ken'ichi Ohmichi2009-06-292-6/+29
| | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v6: ================ * No change. Changelog of v5: ================ * New patch. Description: ============ This patch add the description about a new rule to both the manpage of cgrules.conf and the sample of cgrules.conf. 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 'cgclassify' command.Ken'ichi Ohmichi2009-06-292-14/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-293-9/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add the library function cgroup_register_unchanged_process().Ken'ichi Ohmichi2009-06-293-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v6: ================ * No change. Changelog of v5: ================ * Rebase the patch to the latest code. Changelog of v4: ================ * No change. Changelog of v3: ================ * No change. Changelog of v2: ================ * New patch. Description: ============ This patch adds the library function cgroup_register_unchanged_process() for notifying cgrulesengd daemon of the unchanged process. 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 handler of unchanged process to cgrulesengd daemon.Ken'ichi Ohmichi2009-06-292-5/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v6: ================ * No change. Changelog of v5: ================ * No change. Changelog of v4: ================ * Add the comment "FIXME: Change the temporary file to configurable one." * Define the number of allocation. Changelog of v3: ================ * Set the value 0x1 to CGROUP_DAEMON_UNCHANGE_CHILDREN flag. Changelog of v2: ================ * New patch. Description: ============ This patch adds the handler of unchanged process to the cgrulesengd daemon. By this patch, the daemon does not change a process which is executed by 'cgexec' command, because it is possible to notify the unchanged process to the daemon by using "unix domain socket". 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>
* Cleanup: Separate the netlink method to cgre_receive_netlink_msg().Ken'ichi Ohmichi2009-06-291-37/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v6: ================ * No change. Changelog of v5: ================ * No change. Changelog of v4: ================ * Remove unused parameter "cn_hdr" from cgre_receive_netlink_msg(). Changelog of v3: ================ * No change. Changelog of v2: ================ * New patch. Description: ============ This patch separates the netlink method for the readability, because the later patch [PATCH 6/9] adds "unix domain socket" handling method around the netlink method. 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 a exec event to the event handler of cgrulesengd daemon.Ken'ichi Ohmichi2009-06-291-9/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v6: ================ * Change the cgroup_get_procname_from_procfs() calling for the returning value's change. Changelog of v5: ================ * No change. Changelog of v4: ================ * No change. Changelog of v3: ================ * No change. Changelog of v2: ================ * No change. Description: ============ A process name is changed when execve(2), so a new rule based on process name should be applied when execve(2) happens. Then this patch adds an EXEC event to the event handler. 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 key "process name" to find a matching rule.Ken'ichi Ohmichi2009-06-293-59/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v6: ================ * No change. Changelog of v5.1: ================== * BUGFIX: Clear the flags meaning "found a matching rule" when a process name does not match. There was a problem that cgexec and cgclassify didn't work correctly if a user executes cgexec/cgclassify based on /etc/cgrules.conf. For example, if a root user executes `cgclassify $$` on the following /etc/cgrules.conf, the process ($$) should be moved to users/root on cpuset and memory subsystems. But the process was moved to users/root/cp on memory subsystem only. Example of /etc/cgrules.conf: ============================= root:cp cpuset users/root/cp % memory users/root/cp root cpuset users/root % memory users/root The cause is why the flags meaning "found a matching rule" (uid, gid, and matched) is not cleared when a process name does not match. This problem is fixed on this patch. Changelog of v5: ================ * Rebase the patch to the latest code. Changelog of v4: ================ * No change. Changelog of v3: ================ * BUGFIX: Fix the handling of '%' in /etc/cgrules.conf. Changelog of v2: ================ * Use strcmp() instead of strncmp() for checking a process name strictly. * Some cleanups. Description: ============ This patch adds the key "process name" to find a matching 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>
* Add the parser of process name in /etc/cgrules.conf.Ken'ichi Ohmichi2009-06-294-12/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v6: ================ * The definations of CGROUP_RULE_MAXKEY and CGROUP_RULE_MAXLINE are moved to libcgroup-internal.h since no one from outside should be using them. Changelog of v5: ================ * Rebase the patch to the latest code. Changelog of v4: ================ * Use more safety length of a user name for the buffer "username". * Move the macros min()/max() to src/libcgroup-internal.h for using in src/api.c also. Changelog of v3: ================ * Fix unclear buffer of user by memset(). Changelog of v2: ================ * Remove unnecessary memset(). * Some cleanups. Description: ============ This patch adds the parser of process name in /etc/cgrules.conf. A new rule based on process name is as the following, and the process name is stored into the member "procname" in struct cgroup_rule. <user>:<process name> <controllers> <destination> 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 cgroup_get_procname_from_procfs() for getting a process name.Ken'ichi Ohmichi2009-06-293-0/+190
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v6: ================ * Change the returning values of *_get_procname_from_proc*() to integer from charactor pointer. * Clarify the number meaning of string length in cg_get_procname_from_ ~proc_status() Changelog of v5: ================ * Rebase the patch to the latest code. Changelog of v4: ================ * Add the error handling for strdup()'s error. * Reduce strlen() calls. * Make the check code of a process name simple. Changelog of v3: ================ * Move cgroup_get_procname_from_procfs() to libcgroup-internal.h. * Fix unclear buffer of buf_cwd by memset(). * Get a real path of script file by realpath(). Changelog of v2: ================ * It is possible to handle a process, which name length is over than 16 characters, also. Description: ============ This patch adds a new function cgroup_get_procname_from_procfs() for getting a process name. This function allocates the memory for a process name, and writes the name to the memory, and returns the pointer of the memory. So a caller should free the memory if unusing it. The process name, which is wrotten by this function, depends on the specified process: If a command process) the full path of command. If a shell script process) the full path of shell script. If a kernel thread) the process name of kernel thread. 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: Add get_mount_point test caseDhaval Giani2009-06-261-0/+49
| | | | | | The test case to test the new mount point API. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* libcgroup: Introduce an API to get the mount point of a specific subsystemDhaval Giani2009-06-264-1/+40
| | | | | | | | | Introduce an API which will query the mount table and return the mount point of a specific subsystem. This is needed in the case when the user knows which subsystem he wants the details of, which would make the use of the get_controller* APIs cumbersome. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix some warnings.Ken'ichi Ohmichi2009-06-251-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | Hi, The latest source (commit: 5ea9a7819b717a83af03aa2ea234f105ed717589) outputs some following warnings: $ make [snip] api.c: In function 'cgroup_walk_tree_begin': api.c:2350: warning: passing argument 3 of 'cg_walk_node' makes integer from pointer without a cast api.c:2315: warning: unused variable 'fts' [snip] $ This patch fixes them. 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>
* libcgroup: Fix a missing goto in clean cgroups APIDhaval Giani2009-06-221-0/+1
| | | | | | | Jan pointed out that there was a goto missing in the error handling paths. Fix that bug. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* libcgroup: Introduce a unload cgroups APIDhaval Giani2009-06-225-1/+216
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* libcgroup: Introduce get_controller APIDhaval Giani2009-06-185-1/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | This set of APIs will allow the caller to query the mount table and find out what controller is mounted at what path. Test program has been included in the patch. Running the test program results in [dhaval@gondor tests]$ ../libtool --mode=execute ./get_controller Controller cpu is mounted at /cgroup Controller cpuacct is mounted at /cgroup Controller memory is mounted at /cgroup1 [dhaval@gondor tests]$ Which is the setup on this system. Changes from v2 1. Remove the incorrect comments as pointed out by Bharata Changes from v1 1. Use a new structure as mentioned by bharata to return the values. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Cc: Jan Safranek <jsafrane@redhat.com> Acked-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
* libcgroup: Use double pointers everywhere in the get_task APIsDhaval Giani2009-06-183-9/+8
| | | | | | | | As Jan Safranek pointed out, it is better to have double pointers everywhere in the get_task API to keep consistency. Do the same. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* libcgroup: Introduce post order walkDhaval Giani2009-06-183-4/+41
| | | | | | | | | | With the introduction of the flags, we now actually make use of them. This patch adds a post mode and modifies the test case to also do a post order walk. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> Acked-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
* libcgroup: Add flags to the walk_tree handleDhaval Giani2009-06-183-10/+69
| | | | | | | | | | | | | | Introduce a cgroup_tree_handle structure so that we can track flags for the walk_tree operation. In a number of cases we would prefer to walk the tree in postorder as opposed to pre-order which is the current default. This patch does the addition. Changes since V1: 1. Added checks for !handle as suggested by Bharata Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> Acked-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
* cgconfigparser: Change mkdir in cgroup_config_mount_fs to mkdir -pDhaval Giani2009-06-183-7/+5
| | | | | | | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=502687 mentioned that the directory was not getting created when a cgconfig start was being run. This is was because we failed the mkdir. The mkdir for directories at depth was not succeeding. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* Adds cgset man pageIvana Varekova2009-06-182-1/+28
| | | | | | | This patch adds cgset man page - it includes Makefile changes Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@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>
* Prevent to add multiple versions of the same controller to mount_tableIvana Varekova2009-06-181-0/+18
| | | | | | | | | | | | This patche add a test to cgroup_init function, which prevent to add multiple records for the same controller (this is a problem eg. in cgroup_get_cgroup function - which looks to mount table and add all relevant controllers using cgroup_add_controller function and when the function calls cgroup_add_cgroup function twice on the same controller, it returns error so the result is cgroup_get_cgroup failed). 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-086-140/+68
| | | | | | | | | | | | | | 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>
* Cleanup: Remove unnecessary 'err' value.Ken'ichi Ohmichi2009-06-081-3/+1
| | | | | | | | | | | | | | | Hi, CHANGELOG of v2: ================ * New patch. Thanks Ken'ichi Ohmichi 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>
* Cleanup: Rename "name" to "username" in struct cgroup_rule.Ken'ichi Ohmichi2009-06-082-9/+10
| | | | | | | | | | | | | | | | | | Hi, CHANGELOG of v2: ================ * No change. To add the member "procname" to struct cgroup_rule by later patch, this patch renames the member "name" to "username" for the clarification. Thanks Ken'ichi Ohmichi 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>
* Cleanup: Add cg_skip_unused_charactors_in_rule().Ken'ichi Ohmichi2009-06-081-16/+29
| | | | | | | | | | | | | | | | | | | Hi, CHANGELOG of v2: ================ * No change. The loop in cgroup_parse_rules() is a little long now, and it is not easy to read the loop. Then, This patch shortens the loop for the readability. Thanks Ken'ichi Ohmichi 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>
* Cleanup: Use sizeof() in memset().Ken'ichi Ohmichi2009-06-081-23/+5
| | | | | | | | | | | | | Changelog of v3: ================ * Remove unnecessary memset(). fgets()/sscanf() does not care what is in the buffer, and it is unnecessary to clear the buffer before. 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>
* Cleanup: Remove unnecessary strlen() in strncpy().Ken'ichi Ohmichi2009-06-081-2/+3
| | | | | | | | | | | | | | | | Hi, CHANGELOG of v2: ================ * Specify the buffer size of 'user' instead of strlen(). It actually walks through 'user' twice, once to compute length by strlen() and then this patch specifies the buffer size of 'user' instead. Reported-by: Jan Safranek <jsafrane@redhat.com> 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>
* Adds cgcreate man pageIvana Varekova2009-06-032-1/+44
| | | | | | This patch adds cgcreate man page - it includes Makefile.in changes Signed-off-by: Ivana Varekova <varekova@redhat.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>