----- Original Message -----
> From: "Weng Meiling" <wengmeiling.w...@huawei.com>
> To: "Ivana Varekova" <varek...@redhat.com>
> Cc: "Libcg Development list" <libcg-devel@lists.sourceforge.net>, "libo chen" 
> <libo.c...@huawei.com>, "Huang Qiang"
> <h.huangqi...@huawei.com>
> Sent: Thursday, November 7, 2013 6:36:45 AM
> Subject: [PATCH v3] cgdelete:fix the display problem
> 
> 
> 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.
> 
> v1 -> v2
>  - make cgdelete -g cpu:/test -g cpu:test failed.
> v2 -> v3
>  - make cgdelete -g cpu:test -g cpu:test1 ok.
> 
Hello,
sorry for the delay, I found there is no response so I review the patch now. 
Thanks for your work.
Ivana

> Signed-off-by: Weng Meiling <wengmeiling.w...@huawei.com>
> ---
>  src/tools/cgdelete.c | 57
>  ++++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 55 insertions(+), 2 deletions(-)
> 
> diff --git a/src/tools/cgdelete.c b/src/tools/cgdelete.c
> index 190310f..f7ac7a5 100644
> --- a/src/tools/cgdelete.c
> +++ b/src/tools/cgdelete.c
> @@ -52,6 +52,41 @@ static void usage(int status, const char *program_name)
>  }
> 
> 
> +static int skip_add_controller(int counter, int *skip, int *h_list,
> +             char cg_name[][FILENAME_MAX], char cont_name[][FILENAME_MAX])
> +{
> +     int k, ret = 0;
> +     struct controller_data info;
> +     void *handle;
> +
> +     ret = cgroup_get_all_controller_begin(&handle, &info);
> +     while (ret == 0) {
> +             if (!strcmp(info.name, cont_name[counter])) {
> +                     h_list[counter] = info.hierarchy;
please could you add some comment regardin the purpose of h_list variable (it 
would be more readable)
> +                     for (k = 0; k < counter; k++)
> +                             if (h_list[k] == info.hierarchy &&
> +                                     strcmp(cont_name[k],
> +                                             cont_name[counter]))
my example is:
cgdelete -g cpuacct:test -g cpu:test -g cpuacct:test
is ok (see v1 x v2 diff) can this be error?


> +                                     if (!strcmp(cg_name[k],
> +                                             cg_name[counter]))
> +                                             *skip = 1;
> +                     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));
> +     }
> +     return ret;
> +}
> +
> +
>  int main(int argc, char *argv[])
>  {
>       int ret = 0;
> @@ -59,6 +94,10 @@ int main(int argc, char *argv[])
>       int c;
>       int flags = 0;
>       int final_ret = 0;
> +     int counter = 0, skip_add_cont;
> +     int h_list[CG_CONTROLLER_MAX] = {-1};
> +     char cg_name[CG_CONTROLLER_MAX][FILENAME_MAX];
> +     char cont_name[CG_CONTROLLER_MAX][FILENAME_MAX];
> 
>       struct cgroup_group_spec **cgroup_list = NULL;
>       struct cgroup *cgroup;
> @@ -138,8 +177,21 @@ int main(int argc, char *argv[])
>               /* add controllers to the cgroup */
>               j = 0;
>               while (cgroup_list[i]->controllers[j]) {
> -                     cgc = cgroup_add_controller(cgroup,
> -                             cgroup_list[i]->controllers[j]);
> +                     skip_add_cont = 0;
> +                     strncpy(cont_name[counter],
> +                             cgroup_list[i]->controllers[j],
> +                             FILENAME_MAX);
> +                     cont_name[counter][FILENAME_MAX - 1] = '\0';
> +                     strncpy(cg_name[counter], cgroup_list[i]->path,
> +                             FILENAME_MAX);
> +                     cg_name[counter][FILENAME_MAX - 1] = '\0';
> +                     ret = skip_add_controller(counter, &skip_add_cont,
> +                                             h_list, cg_name, cont_name);
> +                     if (ret)
> +                             goto err;
> +                     if (!skip_add_cont)
> +                             cgc = cgroup_add_controller(cgroup,
> +                                     cgroup_list[i]->controllers[j]);
>                       if (!cgc) {
compilator returns error here ^
cgdelete.c:195:7: warning: ‘cgc’ may be used uninitialized in this function 
[-Wmaybe-uninitialized]
>                               ret = ECGFAIL;
>                               fprintf(stderr, "%s: "
> @@ -149,6 +201,7 @@ int main(int argc, char *argv[])
>                               cgroup_free(&cgroup);
>                               goto err;
>                       }
> +                     counter++;
>                       j++;
>               }
> 
> --
> 1.8.3
> 
> 
> 
> 
> 

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to