summaryrefslogtreecommitdiffstats
path: root/include/libcgroup.h
Commit message (Collapse)AuthorAgeFilesLines
* Add recursive cgroup_delete_cgroup_ext.Jan Safranek2009-07-291-0/+27
| | | | | | | | | | | | | | 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>
* Export cgroup_find_parent and add testing code for itJan Safranek2009-07-281-0/+12
| | | | | | | | | 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>
* Configure the location of cgrulesengd socketJan Safranek2009-07-011-2/+0
| | | | | | | | | | | | | 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-011-1/+1
| | | | | | | | 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>
* Add the library function cgroup_register_unchanged_process().Ken'ichi Ohmichi2009-06-291-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-291-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add the key "process name" to find a matching rule.Ken'ichi Ohmichi2009-06-291-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-291-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* libcgroup: Introduce an API to get the mount point of a specific subsystemDhaval Giani2009-06-261-0/+9
| | | | | | | | | 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>
* libcgroup: Introduce a unload cgroups APIDhaval Giani2009-06-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-181-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-181-1/+1
| | | | | | | | 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: Add flags to the walk_tree handleDhaval Giani2009-06-181-0/+10
| | | | | | | | | | | | | | 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>
* libcgroup: Export cgroup_get_controller APIDhaval Giani2009-06-031-0/+2
| | | | | | | | | libcgroup: Export cgroup_get_controller API This wrapper was not exposed for some reason earlier. Make it available from the library. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* libcgroup: Add new API to walk tasksDhaval Giani2009-04-221-0/+19
| | | | | | | | | Add a new API to iterate through the tasks file to get the list of all the tasks in a cgroup. 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>
* Here is the v2 of the patch which introduces APIs to read controllerBharata B Rao2009-04-011-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | specific stats. Added Makefile.am updates which I had missed in the previous post. New APIs to read controller specific statistics. This patch introduces 3 new APIs which can be used to read controller statistics iteratively. (Eg. stats from memory.stat etc) Reading of stats is initiated by cgroup_read_stats_begin() API, which returns the first stat of the requested controller in addition to returing a handle that should be used in subsequent reads. cgroup_read_stats_next() API can be used to read the remaining stats one by one. This needs the handle returned by cgroup_read_stats_begin(). cgroup_read_stats_end() API will terminate the stats reading iteration initiated by cgroup_read_stats_begin(). Changelog: v2 - Update tests/Makefile.am so that it generates appropriate rules for tests/read_stats.c in the Makefile. This is in addition to the manual updates done to the generated file tests/Makefile.in. v1 - cgroup_read_stats apis now work with relative cgroup path names instead of absolute path names. v0 - Initial post. Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* Distribute files to various subdirectoriesJan Safranek2009-03-261-0/+298
Signed-off-by: Jan Safranek <jsafrane@redhat.com>