Package: libvirt / 5.0.0-4

vircgroup-Try-harder-to-kill-cgroup.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 24 Jan 2019 17:20:58 +0100
Subject: vircgroup: Try harder to kill cgroup

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@redhat.com>
Reviewed-by: Erik Skultety <eskultet@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 3ebb3b0..b8b56f1 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);
             if (rc < 0) {
                 ret = -1;
@@ -2633,6 +2630,12 @@ virCgroupKillRecursive(virCgroupPtr group, int signum)
         }
     }
 
+    if (!backends || !backendAvailable) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("no cgroup backend available"));
+        goto cleanup;
+    }
+
  cleanup:
     virHashFree(pids);
     return ret;