[systemd-devel] Reliable way to finish system units before termination through systemd shutdown / reboot routines
Reindl Harald
h.reindl at thelounge.net
Tue Aug 15 20:15:36 UTC 2017
Am 15.08.2017 um 16:25 schrieb Reiner Wenke:
> I have running some virtualbox instances under systemd control and use vboxautostart-service
> for starting and stopping (saving). This is running on Centos7
> As long as I use systemctl stop vboxautostart-service for termination, everything is fine,
> but it takes some time for completion.
>
> If I shutdown or reboot the host system, then I get a premature kill of all running instances,
> most likely through the systemd reboot / shutdown routines .
> I tried some configuration changes, but nothing worked for me.
>
> Is there a reliable way to avoid this behavior?
you need to remember that the sequence of shutdown is the exactly verse
of startup to begin with and adjust "TimeoutStopSec" in case running
guests are suspended at shutdown
i finally throwed away anything from VMware Workstation including the
module-load stuffm dhcp and so on and solved it with own services,
tragtes and dependencies - below a part of the unit files to get an idea
[root at srv-rhsoft:~]$ cat /etc/systemd/system/vmware-guest.target
[Unit]
Description=VMware Guest Group
After=vmware.service vmware.target network-wan-bridge.service
display-manager.service
Requires=vmware.service vmware-modules.service vmware-vmnet.service
Wants=guest-arrakis.service
Wants=guest-testserver.service
Wants=display-manager.service
[Install]
WantedBy=graphical.target
____________________________________________
[root at srv-rhsoft:~]$ cat /etc/systemd/system/vmware.service
[Unit]
Description=VMware Workstation Service
Requires=vmware-modules.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/systemctl start vmware.target
ExecStop=-/scripts/vmware/vm-suspend-all.sh
ExecStop=/usr/bin/systemctl stop vmware.target
TimeoutSec=1800
TimeoutStopSec=1800
ReadOnlyDirectories=/etc
ReadOnlyDirectories=/usr
CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_WRITE CAP_SYS_ADMIN
CAP_SYS_BOOT CAP_SYS_PTRACE
[Install]
WantedBy=multi-user.target
____________________________________________
[root at srv-rhsoft:~]$ cat /etc/systemd/system/vmware.target
[Unit]
Description=VMware Service Group
Requires=vmware-modules.service vmware-vmnet.service
Wants=vmware-authentication.service
Wants=vmware-usb.service
[Install]
WantedBy=multi-user.target
More information about the systemd-devel
mailing list