to replace lxc@.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.gruenbich...@proxmox.com> --- src/Makefile | 2 ++ src/pve-container@.service | 19 +++++++++++++++++++ "src/system-pve\\x2dcontainer.slice" | 9 +++++++++ 3 files changed, 30 insertions(+) create mode 100644 src/pve-container@.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@.service.d install -m0644 pve-reboot.conf ${SERVICEDIR}/lxc@.service.d/ + install -m0644 pve-container@.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@.service b/src/pve-container@.service new file mode 100644 index 0000000..0644358 --- /dev/null +++ b/src/pve-container@.service @@ -0,0 +1,19 @@ +# based on lxc@.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@.service +[Unit] +Description=PVE LXC Container Slice +DefaultDependencies=No +Documentation=man:pct -- 2.14.1 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel