[libvirt] [PATCH] util: change the return value of virCgroupRemove if failed

Michal Privoznik mprivozn at redhat.com
Fri Jul 19 13:45:20 UTC 2019


On 7/19/19 5:19 AM, Wang Yechao wrote:
> virCgroupRemove return -1 when removing cgroup failed.
> But there are retry code to remove cgroup in QemuProcessStop:
> 
>   retry:
>      if ((ret = qemuRemoveCgroup(vm)) < 0) {
>          if (ret == -EBUSY && (retries++ < 5)) {
>              usleep(200*1000);
>              goto retry;
>          }
>          VIR_WARN("Failed to remove cgroup for %s",
>                   vm->def->name);
>      }
> 
> The return value of qemuRemoveCgroup will never be equal to "-EBUSY",
> so change the return value of virCgroupRemove if failed.
> 
> Signed-off-by: Wang Yechao <wang.yechao255 at zte.com.cn>
> ---
>   src/util/vircgroup.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
> index 268e401..260ed2d 100644
> --- a/src/util/vircgroup.c
> +++ b/src/util/vircgroup.c
> @@ -2399,11 +2399,13 @@ int
>   virCgroupRemove(virCgroupPtr group)
>   {
>       size_t i;
> +    int ret = 0;
>   
>       for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
> -        if (group->backends[i] &&
> -            group->backends[i]->remove(group) < 0) {
> -            return -1;
> +        if (group->backends[i])
> +            ret = group->backends[i]->remove(group);
> +            if (ret < 0)
> +                return ret;
>           }
>       }
>   
> 

Ah, good catch. I'm fixin the missig curly brace, moving the @ret 
definition inside the if() and renaming it to rc.

ACKed and pushed.

Michal




More information about the libvir-list mailing list