|
|
397dc2 |
From a88996cc6c72a6f7fd034c0890747c54cc377484 Mon Sep 17 00:00:00 2001
|
|
|
397dc2 |
Message-Id: <a88996cc6c72a6f7fd034c0890747c54cc377484@dist-git>
|
|
|
397dc2 |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
397dc2 |
Date: Fri, 19 Feb 2021 13:33:56 +0100
|
|
|
397dc2 |
Subject: [PATCH] vircgroupv1: refactor virCgroupV1DetectPlacement
|
|
|
397dc2 |
MIME-Version: 1.0
|
|
|
397dc2 |
Content-Type: text/plain; charset=UTF-8
|
|
|
397dc2 |
Content-Transfer-Encoding: 8bit
|
|
|
397dc2 |
|
|
|
397dc2 |
Remove one level of indentation by splitting the condition.
|
|
|
397dc2 |
|
|
|
397dc2 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
397dc2 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
397dc2 |
(cherry picked from commit 5f56dd7c83493f14a471bb9e33415b04329a08bf)
|
|
|
397dc2 |
|
|
|
397dc2 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1798463
|
|
|
397dc2 |
|
|
|
397dc2 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
397dc2 |
Message-Id: <ce477880853d3a9988389789611b68c458834600.1613737828.git.phrdina@redhat.com>
|
|
|
397dc2 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
397dc2 |
---
|
|
|
397dc2 |
src/util/vircgroupv1.c | 39 ++++++++++++++++++++++-----------------
|
|
|
397dc2 |
1 file changed, 22 insertions(+), 17 deletions(-)
|
|
|
397dc2 |
|
|
|
397dc2 |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
|
397dc2 |
index 7ec8f3a316..09165ece4d 100644
|
|
|
397dc2 |
--- a/src/util/vircgroupv1.c
|
|
|
397dc2 |
+++ b/src/util/vircgroupv1.c
|
|
|
397dc2 |
@@ -339,23 +339,28 @@ virCgroupV1DetectPlacement(virCgroupPtr group,
|
|
|
397dc2 |
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
397dc2 |
const char *typestr = virCgroupV1ControllerTypeToString(i);
|
|
|
397dc2 |
|
|
|
397dc2 |
- if (virCgroupV1MountOptsMatchController(controllers, typestr) &&
|
|
|
397dc2 |
- group->legacy[i].mountPoint != NULL &&
|
|
|
397dc2 |
- group->legacy[i].placement == NULL) {
|
|
|
397dc2 |
- /*
|
|
|
397dc2 |
- * selfpath == "/" + path="" -> "/"
|
|
|
397dc2 |
- * selfpath == "/libvirt.service" + path == "" -> "/libvirt.service"
|
|
|
397dc2 |
- * selfpath == "/libvirt.service" + path == "foo" -> "/libvirt.service/foo"
|
|
|
397dc2 |
- */
|
|
|
397dc2 |
- if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) {
|
|
|
397dc2 |
- group->legacy[i].placement = g_strdup(selfpath);
|
|
|
397dc2 |
- } else {
|
|
|
397dc2 |
- bool delim = STREQ(selfpath, "/") || STREQ(path, "");
|
|
|
397dc2 |
-
|
|
|
397dc2 |
- group->legacy[i].placement = g_strdup_printf("%s%s%s", selfpath,
|
|
|
397dc2 |
- delim ? "" : "/",
|
|
|
397dc2 |
- path);
|
|
|
397dc2 |
- }
|
|
|
397dc2 |
+ if (!virCgroupV1MountOptsMatchController(controllers, typestr))
|
|
|
397dc2 |
+ continue;
|
|
|
397dc2 |
+
|
|
|
397dc2 |
+ if (!group->legacy[i].mountPoint)
|
|
|
397dc2 |
+ continue;
|
|
|
397dc2 |
+
|
|
|
397dc2 |
+ if (group->legacy[i].placement)
|
|
|
397dc2 |
+ continue;
|
|
|
397dc2 |
+
|
|
|
397dc2 |
+ /*
|
|
|
397dc2 |
+ * selfpath == "/" + path="" -> "/"
|
|
|
397dc2 |
+ * selfpath == "/libvirt.service" + path == "" -> "/libvirt.service"
|
|
|
397dc2 |
+ * selfpath == "/libvirt.service" + path == "foo" -> "/libvirt.service/foo"
|
|
|
397dc2 |
+ */
|
|
|
397dc2 |
+ if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) {
|
|
|
397dc2 |
+ group->legacy[i].placement = g_strdup(selfpath);
|
|
|
397dc2 |
+ } else {
|
|
|
397dc2 |
+ bool delim = STREQ(selfpath, "/") || STREQ(path, "");
|
|
|
397dc2 |
+
|
|
|
397dc2 |
+ group->legacy[i].placement = g_strdup_printf("%s%s%s", selfpath,
|
|
|
397dc2 |
+ delim ? "" : "/",
|
|
|
397dc2 |
+ path);
|
|
|
397dc2 |
}
|
|
|
397dc2 |
}
|
|
|
397dc2 |
|
|
|
397dc2 |
--
|
|
|
397dc2 |
2.30.0
|
|
|
397dc2 |
|