|
|
c480ed |
From 3928ca076fac13572f14c20f38bcf5fb205d7670 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <3928ca076fac13572f14c20f38bcf5fb205d7670@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:07:14 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: introduce virCgroupV2ValidateMachineGroup
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
When reconnecting to a domain we are validating the cgroup name.
|
|
|
c480ed |
In case of cgroup v2 we need to validate only the new format for host
|
|
|
c480ed |
without systemd '{machinename}.libvirt-{drivername}' or scope name
|
|
|
c480ed |
generated by systemd.
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 3a365ef697b8fedb929725c46753481a63ae3de7)
|
|
|
c480ed |
|
|
|
c480ed |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Message-Id: <97d6369bcfc2943c708fd9bfc94f71ab10e00535.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroupv2.c | 43 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
c480ed |
1 file changed, 43 insertions(+)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
|
c480ed |
index 4ab9f2b792..02dc4e4686 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv2.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv2.c
|
|
|
c480ed |
@@ -36,6 +36,7 @@
|
|
|
c480ed |
#include "virfile.h"
|
|
|
c480ed |
#include "virlog.h"
|
|
|
c480ed |
#include "virstring.h"
|
|
|
c480ed |
+#include "virsystemd.h"
|
|
|
c480ed |
|
|
|
c480ed |
VIR_LOG_INIT("util.cgroup");
|
|
|
c480ed |
|
|
|
c480ed |
@@ -90,10 +91,52 @@ virCgroupV2Available(void)
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static bool
|
|
|
c480ed |
+virCgroupV2ValidateMachineGroup(virCgroupPtr group,
|
|
|
c480ed |
+ const char *name ATTRIBUTE_UNUSED,
|
|
|
c480ed |
+ const char *drivername,
|
|
|
c480ed |
+ const char *machinename)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) partmachinename = NULL;
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) scopename = NULL;
|
|
|
c480ed |
+ char *tmp;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virAsprintf(&partmachinename, "%s.libvirt-%s", machinename,
|
|
|
c480ed |
+ drivername) < 0) {
|
|
|
c480ed |
+ return false;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virCgroupPartitionEscape(&partmachinename) < 0)
|
|
|
c480ed |
+ return false;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!(scopename = virSystemdMakeScopeName(machinename, drivername,
|
|
|
c480ed |
+ false))) {
|
|
|
c480ed |
+ return false;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virCgroupPartitionEscape(&scopename) < 0)
|
|
|
c480ed |
+ return false;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!(tmp = strrchr(group->unified.placement, '/')))
|
|
|
c480ed |
+ return false;
|
|
|
c480ed |
+ tmp++;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (STRNEQ(tmp, partmachinename) &&
|
|
|
c480ed |
+ STRNEQ(tmp, scopename)) {
|
|
|
c480ed |
+ VIR_DEBUG("Name '%s' for unified does not match '%s' or '%s'",
|
|
|
c480ed |
+ tmp, partmachinename, scopename);
|
|
|
c480ed |
+ return false;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return true;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
|
|
c480ed |
|
|
|
c480ed |
.available = virCgroupV2Available,
|
|
|
c480ed |
+ .validateMachineGroup = virCgroupV2ValidateMachineGroup,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|