While there's many solutions now to shutdown VM's, here's my 2 cents. Instead of a libvirt-bin.conf script, I made a separate script (/usr/local/sbin/shutdown-libvirt-hosts.sh). This script waits 120 seconds for all VM's to shut down. Then I'm running this script from two places; in libvirt-bin.conf:
pre-stop script /usr/local/sbin/shutdown-libvirt-hosts.sh
end script
And also (as a link) from /etc/rc0.d/K10shutdown-libvirt-hosts (and from rc6.d alike)
This way, the "sendsigs" script will only run if all VMs have terminated.?field.comment=While there's many solutions now to shutdown VM's, here's my 2 cents. Instead of a libvirt-bin.conf script, I made a separate script (/usr/local/sbin/shutdown-libvirt-hosts.sh). This script waits 120 seconds for all VM's to shut down. Then I'm running this script from two places; in libvirt-bin.conf:
pre-stop script /usr/local/sbin/shutdown-libvirt-hosts.sh
end script
And also (as a link) from /etc/rc0.d/K10shutdown-libvirt-hosts (and from rc6.d alike)
With a K10shutdown-libvirt-hosts script in place, the "sendsigs" script will only run after this script has ended, which is when all VMs have terminated.
A few remarks:
- shutting down the VM's twice is not a problem; to the VM, it just looks like pressing the power button twice.
- to gracefully shut down, the VM's need the "acpid" package installed.
- if the shutdown script searches for the word "running" (like mine does, but John Morrissey's script is affected, too), it must set LANG=C at the top, otherwise virsh will run in the local language.
While there's many solutions now to shutdown VM's, here's my 2 cents. Instead of a libvirt-bin.conf script, I made a separate script (/usr/local/ sbin/shutdown- libvirt- hosts.sh) . This script waits 120 seconds for all VM's to shut down. Then I'm running this script from two places; in libvirt-bin.conf:
/usr/local/ sbin/shutdown- libvirt- hosts.sh
pre-stop script
end script
And also (as a link) from /etc/rc0. d/K10shutdown- libvirt- hosts (and from rc6.d alike)
This way, the "sendsigs" script will only run if all VMs have terminated. ?field. comment= While there's many solutions now to shutdown VM's, here's my 2 cents. Instead of a libvirt-bin.conf script, I made a separate script (/usr/local/ sbin/shutdown- libvirt- hosts.sh) . This script waits 120 seconds for all VM's to shut down. Then I'm running this script from two places; in libvirt-bin.conf:
/usr/local/ sbin/shutdown- libvirt- hosts.sh
pre-stop script
end script
And also (as a link) from /etc/rc0. d/K10shutdown- libvirt- hosts (and from rc6.d alike)
With a K10shutdown- libvirt- hosts script in place, the "sendsigs" script will only run after this script has ended, which is when all VMs have terminated.
A few remarks:
- shutting down the VM's twice is not a problem; to the VM, it just looks like pressing the power button twice.
- to gracefully shut down, the VM's need the "acpid" package installed.
- if the shutdown script searches for the word "running" (like mine does, but John Morrissey's script is affected, too), it must set LANG=C at the top, otherwise virsh will run in the local language.