This patch adds the possibility to use meta character "*" as a shortcut for all mounted controllers. This meta character can be used in "-g" option.
For example: $ cgcreate -g *:first -g cpu:second $ lssubsys cpuset:/ cpuset:/first cpu,cpuacct:/ cpu,cpuacct:/first cpu,cpuacct:/second memory:/ memory:/first devices:/ devices:/first freezer:/ freezer:/first net_cls,net_prio:/ net_cls,net_prio:/first blkio:/ blkio:/first perf_event:/ perf_event:/first hugetlb:/ hugetlb:/first Signed-off-by: Ivana Hutarova Varekova <varek...@redhat.com> --- doc/man/cgcreate.1 | 3 ++- src/tools/cgcreate.c | 32 ++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/doc/man/cgcreate.1 b/doc/man/cgcreate.1 index 7068073..557b5ae 100644 --- a/doc/man/cgcreate.1 +++ b/doc/man/cgcreate.1 @@ -38,7 +38,8 @@ others permissions to the owners permissions). .TP .B -g <controllers>:<path> defines control groups to be added. -\fBcontrollers\fR is a list of controllers and +\fBcontrollers\fR is a list of controllers. Character "*" can be used +as a shortcut for "all mounted controllers". \fBpath\fR is the relative path to control groups in the given controllers list. This option can be specified multiple times. diff --git a/src/tools/cgcreate.c b/src/tools/cgcreate.c index 73abd91..65b188a 100644 --- a/src/tools/cgcreate.c +++ b/src/tools/cgcreate.c @@ -54,7 +54,6 @@ static void usage(int status, const char *program_name) printf(" -t <tuid>:<tgid> Owner of the tasks file\n"); } - int main(int argc, char *argv[]) { int ret = 0; @@ -195,16 +194,29 @@ int main(int argc, char *argv[]) /* add controllers to the new cgroup */ j = 0; while (cgroup_list[i]->controllers[j]) { - cgc = cgroup_add_controller(cgroup, - cgroup_list[i]->controllers[j]); - if (!cgc) { - ret = ECGINVAL; - fprintf(stderr, "%s: " - "controller %s can't be add\n", - argv[0], + if (strcmp(cgroup_list[i]->controllers[j], "*") == 0) { + /* it is meta character, add all controllers */ + ret = cgroup_add_all_controllers(cgroup); + if (ret != 0) { + ret = ECGINVAL; + fprintf(stderr, "%s: can't add ", + argv[0]); + fprintf(stderr, "all controllers\n"); + cgroup_free(&cgroup); + goto err; + } + } else { + cgc = cgroup_add_controller(cgroup, cgroup_list[i]->controllers[j]); - cgroup_free(&cgroup); - goto err; + if (!cgc) { + ret = ECGINVAL; + fprintf(stderr, "%s: ", argv[0]); + fprintf(stderr, "controller %s", + cgroup_list[i]->controllers[j]); + fprintf(stderr, "can't be add\n"); + cgroup_free(&cgroup); + goto err; + } } j++; } ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel