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