[pve-devel] [PATCH v4 container 2/4] add new pve-container units

Fabian Gr├╝nbichler f.gruenbichler at proxmox.com
Tue Oct 10 09:17:16 CEST 2017


to replace lxc at .service.

we want our unit to only start when manually invoked (by our code), and
stop on shutdown via pve-guests or pve-ha-lrm. lxc@ units are stopped by
systemd on shutdown, because of transitive dependencies.

since all instances of template service units are by default assigned to
a new slice with DefaultDependencies=yes, we also need to introduce our
own custom slice with DefaultDependencies=no.

Signed-off-by: Fabian Gr├╝nbichler <f.gruenbichler at proxmox.com>
---
 src/Makefile                         |  2 ++
 src/pve-container at .service           | 19 +++++++++++++++++++
 "src/system-pve\\x2dcontainer.slice" |  9 +++++++++
 3 files changed, 30 insertions(+)
 create mode 100644 src/pve-container at .service
 create mode 100644 "src/system-pve\\x2dcontainer.slice"

diff --git a/src/Makefile b/src/Makefile
index 9c5fbc3..109577c 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -42,6 +42,8 @@ install: pct lxc-pve.conf lxc-pve-prestart-hook lxc-pve-autodev-hook lxc-pve-pos
 	install -m 0755 lxc-pve-reboot-trigger ${LXC_SCRIPT_DIR}
 	install -d -m0755 ${SERVICEDIR}/lxc at .service.d
 	install -m0644 pve-reboot.conf ${SERVICEDIR}/lxc at .service.d/
+	install -m0644 pve-container at .service ${SERVICEDIR}/
+	install -m0644 'system-pve\x2dcontainer.slice' ${SERVICEDIR}/
 	install -d ${LXC_HOOK_DIR}
 	install -m 0755 lxc-pve-prestart-hook ${LXC_HOOK_DIR}
 	install -m 0755 lxc-pve-autodev-hook ${LXC_HOOK_DIR}
diff --git a/src/pve-container at .service b/src/pve-container at .service
new file mode 100644
index 0000000..0644358
--- /dev/null
+++ b/src/pve-container at .service
@@ -0,0 +1,19 @@
+# based on lxc at .service, but without any dependencies because
+# starting and stopping should be initiated by PVE code, not
+# systemd.
+[Unit]
+Description=PVE LXC Container: %i
+DefaultDependencies=No
+Documentation=man:lxc-start man:lxc man:pct
+
+[Service]
+Type=forking
+KillMode=mixed
+TimeoutStopSec=120s
+ExecStart=/usr/bin/lxc-start -n %i
+ExecStop=/usr/bin/lxc-stop -n %i
+ExecStopPost=/usr/share/lxc/lxc-pve-reboot-trigger %i
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
diff --git "a/src/system-pve\\x2dcontainer.slice" "b/src/system-pve\\x2dcontainer.slice"
new file mode 100644
index 0000000..7edae2c
--- /dev/null
+++ "b/src/system-pve\\x2dcontainer.slice"
@@ -0,0 +1,9 @@
+# needed because instances of template service units automatically
+# get their own slice with DefaultDependencies=yes, regardless of
+# the DefaultDependencies value of the template unit
+#
+# see man systemd.service and pve-container at .service
+[Unit]
+Description=PVE LXC Container Slice
+DefaultDependencies=No
+Documentation=man:pct
-- 
2.14.1




More information about the pve-devel mailing list