[libvirt] [PATCH 2/5] vircgroup: Try harder to kill cgroup

Erik Skultety eskultet at redhat.com
Wed Feb 6 12:28:24 UTC 2019


On Fri, Jan 25, 2019 at 02:31:46PM +0100, Michal Privoznik wrote:
> Prior to rewrite of cgroup code we only had one backend to try.
> After the rewrite the virCgroupBackendGetAll() returns both
> backends (for v1 and v2). However, not both have to really be
> present on the system which results in killRecursive callback
> failing which in turn might mean we won't try the other backend.
>
> At the same time, this function reports no error as it should.
>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/util/vircgroup.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
> index 3ebb3b0a0f..b8b56f1263 100644
> --- a/src/util/vircgroup.c
> +++ b/src/util/vircgroup.c
> @@ -2606,6 +2606,7 @@ virCgroupKillRecursive(virCgroupPtr group, int signum)
>      int ret = 0;
>      int rc;
>      size_t i;
> +    bool backendAvailable = false;
>      virCgroupBackendPtr *backends = virCgroupBackendGetAll();
>      virHashTablePtr pids = virHashCreateFull(100,
>                                               NULL,
> @@ -2616,13 +2617,9 @@ virCgroupKillRecursive(virCgroupPtr group, int signum)
>
>      VIR_DEBUG("group=%p path=%s signum=%d", group, group->path, signum);
>
> -    if (!backends) {
> -        ret = -1;
> -        goto cleanup;
> -    }
> -
>      for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
> -        if (backends[i]) {
> +        if (backends && backends[i] && backends[i]->available()) {
> +            backendAvailable = true;
>              rc = backends[i]->killRecursive(group, signum, pids);

Assuming that it's not possible for v2 backend to succeed with ^this and v1 to
fail with an error:

Reviewed-by: Erik Skultety <eskultet at redhat.com>




More information about the libvir-list mailing list