[Devel] [PATCH libvzctl 1/2] Make SYSTEMD_CTID_x be plain veids for restore convenience

Cyrill Gorcunov gorcunov at openvz.org
Sat Jan 23 08:16:41 PST 2016


When we restore containers we rewrite their roots
based on format from CT id. It's more convenient
when whole cgroup hierarchy shares same toplevel
cgroup. Thus lets nested systemd to be the same.
It doesn't cause any problems so far. Otherwise
the restore procedure will fail due to generation
of new controllers subset which is prohibited for
containers in our configurations for security
reason.

https://jira.sw.ru/browse/PSBM-43256

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 lib/systemd.c |  2 +-
 lib/vztypes.h | 18 ++++++++++++++++--
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/lib/systemd.c b/lib/systemd.c
index 4b803be..826f45e 100644
--- a/lib/systemd.c
+++ b/lib/systemd.c
@@ -115,7 +115,7 @@ int systemd_start_ve_scope(struct vzctl_env_handle *h, pid_t pid)
 	int ret = -1;
 
 	logger(3, 0, "Start CT slice");
-	snprintf(unit_name, sizeof(unit_name), "%s.scope", EID(h));
+	snprintf(unit_name, sizeof(unit_name), SYSTEMD_CTID_UNIT_FMT, EID(h));
 	snprintf(desc, sizeof(desc), "Container %s", EID(h));
 
 	msg = dbus_message_new_method_call("org.freedesktop.systemd1",
diff --git a/lib/vztypes.h b/lib/vztypes.h
index 353cfcb..55e5901 100644
--- a/lib/vztypes.h
+++ b/lib/vztypes.h
@@ -107,8 +107,22 @@
 #define DEL	1
 
 #define STR_UNLIMITED	"unlimited"
-#define SYSTEMD_CTID_FMT	"ve-%s"
-#define SYSTEMD_CTID_SCOPE_FMT	SYSTEMD_CTID_FMT".scope"
+
+/*
+ * Traditional namings for systemd cgroups
+ * are "scope" and "slices" but in criu we
+ * might be rewritting global roots. So lets
+ * simply name these cgroups from VEIDs. It
+ * is more convenient to work with and don't
+ * cause problems so far.
+ *
+ * #define SYSTEMD_CTID_FMT		"ve-%s"
+ * #define SYSTEMD_CTID_SCOPE_FMT	SYSTEMD_CTID_FMT".scope"
+ * #define SYSTEMD_CTID_UNIT_FMT	"%s.scope"
+ */
+#define SYSTEMD_CTID_FMT	"%s"
+#define SYSTEMD_CTID_SCOPE_FMT	"%s"
+#define SYSTEMD_CTID_UNIT_FMT	"%s"
 
 #define NETNS_RUN_DIR   "/var/run/netns"
 
-- 
2.5.0



More information about the Devel mailing list