]> xenbits.xensource.com Git - libvirt.git/commitdiff
vircgroup: Use virCgroupMountOptsMatchController in virCgroupDetectPlacement
authorPavel Hrdina <phrdina@redhat.com>
Tue, 17 Jul 2018 11:43:55 +0000 (13:43 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 13 Aug 2018 09:53:53 +0000 (11:53 +0200)
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/util/vircgroup.c

index ec9994780a28fc1ca5ed959219ff50232cc048e2..7888dab716df52675318a2392e2cc5aa0c7139fa 100644 (file)
@@ -598,42 +598,27 @@ virCgroupDetectPlacement(virCgroupPtr group,
 
         for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
             const char *typestr = virCgroupControllerTypeToString(i);
-            int typelen = strlen(typestr);
-            char *tmp = controllers;
-
-            while (tmp) {
-                char *next = strchr(tmp, ',');
-                int len;
-                if (next) {
-                    len = next - tmp;
-                    next++;
-                } else {
-                    len = strlen(tmp);
-                }
 
+            if (virCgroupMountOptsMatchController(controllers, typestr) &&
+                group->controllers[i].mountPoint != NULL &&
+                group->controllers[i].placement == NULL) {
                 /*
                  * selfpath == "/" + path="" -> "/"
                  * selfpath == "/libvirt.service" + path == "" -> "/libvirt.service"
                  * selfpath == "/libvirt.service" + path == "foo" -> "/libvirt.service/foo"
                  */
-                if (typelen == len && STREQLEN(typestr, tmp, len) &&
-                    group->controllers[i].mountPoint != NULL &&
-                    group->controllers[i].placement == NULL) {
-                    if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) {
-                        if (VIR_STRDUP(group->controllers[i].placement,
-                                       selfpath) < 0)
-                            goto cleanup;
-                    } else {
-                        if (virAsprintf(&group->controllers[i].placement,
-                                        "%s%s%s", selfpath,
-                                        (STREQ(selfpath, "/") ||
-                                         STREQ(path, "") ? "" : "/"),
-                                        path) < 0)
-                            goto cleanup;
-                    }
+                if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) {
+                    if (VIR_STRDUP(group->controllers[i].placement,
+                                   selfpath) < 0)
+                        goto cleanup;
+                } else {
+                    if (virAsprintf(&group->controllers[i].placement,
+                                    "%s%s%s", selfpath,
+                                    (STREQ(selfpath, "/") ||
+                                     STREQ(path, "") ? "" : "/"),
+                                    path) < 0)
+                        goto cleanup;
                 }
-
-                tmp = next;
             }
         }
     }