Blame SOURCES/libvirt-vircgroup-Use-virCgroupMountOptsMatchController-in-virCgroupDetectPlacement.patch

c313de
From dc8f41bf6bb689d86bc91d5aca7fb854a5ef847f Mon Sep 17 00:00:00 2001
c313de
Message-Id: <dc8f41bf6bb689d86bc91d5aca7fb854a5ef847f@dist-git>
c313de
From: Pavel Hrdina <phrdina@redhat.com>
c313de
Date: Mon, 1 Jul 2019 17:05:57 +0200
c313de
Subject: [PATCH] vircgroup: Use virCgroupMountOptsMatchController in
c313de
 virCgroupDetectPlacement
c313de
MIME-Version: 1.0
c313de
Content-Type: text/plain; charset=UTF-8
c313de
Content-Transfer-Encoding: 8bit
c313de
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
(cherry picked from commit 801d95d2597572612c346508446320a33aebc50d)
c313de
c313de
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
c313de
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
Message-Id: <9c2bb230e14ced391b0731bc2964155960025aa5.1561993099.git.phrdina@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
---
c313de
 src/util/vircgroup.c | 43 ++++++++++++++-----------------------------
c313de
 1 file changed, 14 insertions(+), 29 deletions(-)
c313de
c313de
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
c313de
index ec9994780a..7888dab716 100644
c313de
--- a/src/util/vircgroup.c
c313de
+++ b/src/util/vircgroup.c
c313de
@@ -598,42 +598,27 @@ virCgroupDetectPlacement(virCgroupPtr group,
c313de
 
c313de
         for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
c313de
             const char *typestr = virCgroupControllerTypeToString(i);
c313de
-            int typelen = strlen(typestr);
c313de
-            char *tmp = controllers;
c313de
-
c313de
-            while (tmp) {
c313de
-                char *next = strchr(tmp, ',');
c313de
-                int len;
c313de
-                if (next) {
c313de
-                    len = next - tmp;
c313de
-                    next++;
c313de
-                } else {
c313de
-                    len = strlen(tmp);
c313de
-                }
c313de
 
c313de
+            if (virCgroupMountOptsMatchController(controllers, typestr) &&
c313de
+                group->controllers[i].mountPoint != NULL &&
c313de
+                group->controllers[i].placement == NULL) {
c313de
                 /*
c313de
                  * selfpath == "/" + path="" -> "/"
c313de
                  * selfpath == "/libvirt.service" + path == "" -> "/libvirt.service"
c313de
                  * selfpath == "/libvirt.service" + path == "foo" -> "/libvirt.service/foo"
c313de
                  */
c313de
-                if (typelen == len && STREQLEN(typestr, tmp, len) &&
c313de
-                    group->controllers[i].mountPoint != NULL &&
c313de
-                    group->controllers[i].placement == NULL) {
c313de
-                    if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) {
c313de
-                        if (VIR_STRDUP(group->controllers[i].placement,
c313de
-                                       selfpath) < 0)
c313de
-                            goto cleanup;
c313de
-                    } else {
c313de
-                        if (virAsprintf(&group->controllers[i].placement,
c313de
-                                        "%s%s%s", selfpath,
c313de
-                                        (STREQ(selfpath, "/") ||
c313de
-                                         STREQ(path, "") ? "" : "/"),
c313de
-                                        path) < 0)
c313de
-                            goto cleanup;
c313de
-                    }
c313de
+                if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) {
c313de
+                    if (VIR_STRDUP(group->controllers[i].placement,
c313de
+                                   selfpath) < 0)
c313de
+                        goto cleanup;
c313de
+                } else {
c313de
+                    if (virAsprintf(&group->controllers[i].placement,
c313de
+                                    "%s%s%s", selfpath,
c313de
+                                    (STREQ(selfpath, "/") ||
c313de
+                                     STREQ(path, "") ? "" : "/"),
c313de
+                                    path) < 0)
c313de
+                        goto cleanup;
c313de
                 }
c313de
-
c313de
-                tmp = next;
c313de
             }
c313de
         }
c313de
     }
c313de
-- 
c313de
2.22.0
c313de