From: Weng Meiling <wengmeiling.w...@huawei.com> When multi subsystems mounted on one place like this:
# lssubsys -m cpu,cpuacct /cgroup/cpu # lscgroup cpu,cpuacct:/ cpu,cpuacct:/test if we delete the cgroup with the cgdelete -g, and specifying multi controllers like this: # cgdelete -g cpu,cpuacct:test or # cgdelete -g cpu:test -g cpuacct:test it will report error: cgdelete: cannot remove group 'test': No such file or directory this patch fix the problem. Signed-off-by: Weng Meiling <wengmeiling.w...@huawei.com> --- src/tools/cgdelete.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/tools/cgdelete.c b/src/tools/cgdelete.c index e84cd2d..a06ec75 100644 --- a/src/tools/cgdelete.c +++ b/src/tools/cgdelete.c @@ -60,6 +60,8 @@ int main(int argc, char *argv[]) int c; int flags = 0; int final_ret = 0; + int counter = 0; + int h_list[CG_CONTROLLER_MAX]; struct cgroup_group_spec **cgroup_list = NULL; struct cgroup *cgroup; @@ -139,6 +141,37 @@ int main(int argc, char *argv[]) /* add controllers to the cgroup */ j = 0; while (cgroup_list[i]->controllers[j]) { + int k; + struct controller_data info; + void *handle; + + /* determine and skip the controllers mounted on one place */ + ret = cgroup_get_all_controller_begin(&handle, &info); + while (ret == 0) { + if (!strcmp(info.name, cgroup_list[i]->controllers[j])) { + for (k = 0; k < counter; k++) + if (h_list[k] == info.hierarchy) + break; + if (k < counter) + goto skip_add; + else { + h_list[counter] = info.hierarchy; + counter++; + } + break; + } + ret = cgroup_get_all_controller_next(&handle, &info); + } + cgroup_get_all_controller_end(&handle); + if (ret == ECGEOF) + ret = 0; + if (ret) { + fprintf(stderr, + "cgroup_get_controller_begin/next failed(%s)\n", + cgroup_strerror(ret)); + goto err; + } + cgc = cgroup_add_controller(cgroup, cgroup_list[i]->controllers[j]); if (!cgc) { @@ -150,6 +183,7 @@ int main(int argc, char *argv[]) cgroup_free(&cgroup); goto err; } + skip_add: j++; } -- 1.8.2.2 ------------------------------------------------------------------------------ LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99! 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/22/13. http://pubads.g.doubleclick.net/gampad/clk?id=64545871&iu=/4140/ostg.clktrk _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel