Note that it could be possible to have a more simple ExecStart= by matching all the names (name of unit must exactly match the name of guest in VB, including case). I had to trick because I created my VMs long time ago, and done these units recently.

Also, the guest units can probably hard links; I did not try; would be easier to update them.

The latency is designed to accept two timing issues:- process taking long time to terminate in the guest- if we ask for a stop, just after a start, and, during guest initialisation, a small fsck is run

I could not make these latencies too long, because, we still need to terminate the guests before the UPS goes out of battery.

It's far from perfect, but considering how old the tutos are in Google, this may help some people in the future.

If yout unit file can have exactly the same name as the VirtualBox guest name, the exec lines can become more simple:

This script can be stored as wait_pid_or_kill.sh, then make a symlink from wait_pid_or_die.sh. The first one will kill the process we are waiting for; the second will return an error without killing if still alive after the timeout.

Yes, you can if you want. I was just sharing some scripts. Systemd is a bit weird at the beginning; but once you have read the whole doc, it can do wonderfull things. It's not really a clean guide-tutorial. More like a logbook.