I wrote a script that suspend all my virtualbox machines, and put a line in /etc/rc.local.shutdown, but it doesn't seem to work,
su - XX -c /XX
When I'm booted next time, virtualbox tells me the machine was Aborted, so the script wasn't executed. (Launching that script manually works for me)
P.S I already enabled shutdown.target
EDIT
The problem seems complicated than I thought, in my bashrc, if it's running on tty3, it executes startx, so when systemd decide to shutdown/reboot, it whould kill VBoxSVC process and other stuff when X session dies.
I also tried to hack the source code of xfsm-shutdown-helper, make a fake systemctl that execute my script first, none of the above works.
/etc/init.d/stopvmsthat stop the VMs when passed a "stop" parameter. You then create links (symbolic or hard) to that script as say/etc/rc5.d/K01stopvmsand/etc/rc3.s/K01stopvms. (the scripts in the directories are run in order (K* when leaving a runlevel, S* when entering a runlevel)) (You should also be able to do it as "start" scripts in runlevels 0 (shutdowns) and 6 (reboots)) – Gert van den Berg Dec 31 '12 at 6:46