When reconnecting to a domain we are validating the cgroup name.
In case of cgroup v2 we need to validate only the new format for host
without systemd '{machinename}.libvirt-{drivername}' or scope name
generated by systemd.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/vircgroupv2.c | 43 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 83944602d6..77e7695ac5 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -35,6 +35,7 @@
#include "virfile.h"
#include "virlog.h"
#include "virstring.h"
+#include "virsystemd.h"
VIR_LOG_INIT("util.cgroup");
@@ -98,10 +99,52 @@ virCgroupV2Available(void)
}
+static bool
+virCgroupV2ValidateMachineGroup(virCgroupPtr group,
+ const char *name ATTRIBUTE_UNUSED,
+ const char *drivername,
+ const char *machinename)
+{
+ VIR_AUTOFREE(char *) partmachinename = NULL;
+ VIR_AUTOFREE(char *) scopename = NULL;
+ char *tmp;
+
+ if (virAsprintf(&partmachinename, "%s.libvirt-%s", machinename,
+ drivername) < 0) {
+ return false;
+ }
+
+ if (virCgroupPartitionEscape(&partmachinename) < 0)
+ return false;
+
+ if (!(scopename = virSystemdMakeScopeName(machinename, drivername,
+ false))) {
+ return false;
+ }
+
+ if (virCgroupPartitionEscape(&scopename) < 0)
+ return false;
+
+ if (!(tmp = strrchr(group->unified.placement, '/')))
+ return false;
+ tmp++;
+
+ if (STRNEQ(tmp, partmachinename) &&
+ STRNEQ(tmp, scopename)) {
+ VIR_DEBUG("Name '%s' for unified does not match '%s' or
'%s'",
+ tmp, partmachinename, scopename);
+ return false;
+ }
+
+ return true;
+}
+
+
virCgroupBackend virCgroupV2Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V2,
.available = virCgroupV2Available,
+ .validateMachineGroup = virCgroupV2ValidateMachineGroup,
};
--
2.17.1