From: Weng Meiling Date: Tue, 23 Jul 2013 12:30:33 +0000 (+0200) Subject: when we use cgsnapshot with the given controller, the result always X-Git-Tag: v0.41~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=baafbef76670f0bd9bf0269648cf3c3565d53d4d;p=thirdparty%2Flibcgroup.git when we use cgsnapshot with the given controller, the result always displays the last mounted controller which is not specified, so fix it. Example: # lssubsys -m cpuset /cgroup/cpuset cpu /cgroup/cpu # lscgroup cpu:/ cpu:/test cpuset:/ cpuset:/test before the patch: # cgsnapshot -s cpu # Configuration file generated by cgsnapshot mount { cpuset = /cgroup/cpuset; cpu = /cgroup/cpu; } group test { cpu { cpu.rt_period_us="1000000"; cpu.rt_runtime_us="0"; cpu.shares="1024"; } } group test { cpuset { cpuset.memory_spread_slab="0"; cpuset.memory_spread_page="0"; cpuset.memory_migrate="0"; cpuset.sched_relax_domain_level="-1"; cpuset.sched_load_balance="1"; cpuset.mem_hardwall="0"; cpuset.mem_exclusive="0"; cpuset.cpu_exclusive="0"; cpuset.mems=""; cpuset.cpus=""; } } after the patch: # cgsnapshot -s cpu # Configuration file generated by cgsnapshot mount { cpuset = /cgroup/cpuset; cpu = /cgroup/cpu; } group test { cpu { cpu.rt_period_us="1000000"; cpu.rt_runtime_us="0"; cpu.shares="1024"; } } Signed-off-by: Weng Meiling --- diff --git a/src/tools/cgsnapshot.c b/src/tools/cgsnapshot.c index 8217798f..046c70a1 100644 --- a/src/tools/cgsnapshot.c +++ b/src/tools/cgsnapshot.c @@ -582,7 +582,9 @@ static int parse_controllers(cont_name_t cont_names[CG_CONTROLLER_MAX], ret = cgroup_get_controller_next(&handle, &controller); } - if (max != 0) { + if ((!(flags & FL_LIST) || + (is_ctlr_on_list(controllers, cont_names))) + && (max != 0)) { (controllers[max])[0] = '\0'; ret = display_controller_data( controllers, program_name);