I'm not sure it can be done hacking upstart job. When libvirt was a sysvinit script in ubuntu 9.10, I used this [1] script adding it in "stop" function. In Lucid, if I add the same script to /etc/init/libvirt-bin.conf with the stanza:
This works if I manually invoke a stop of libvirt-bin in a running system with:
$ sudo stop libvirt-bin
but **doesn't** work when issuing a reboot or halt. It seems there's an aggressive killing of all kvm processes **before** the pre-stop stanza is execute, and libvirt doesn't find any running guests when the shut-guests.sh is executed. it's not clear to me why and If this is an exptected behavior. For sure, kvm processes are detached from libvirt process branch.
I'm not sure it can be done hacking upstart job. When libvirt was a sysvinit script in ubuntu 9.10, I used this [1] script adding it in "stop" function. In Lucid, if I add the same script to /etc/init/ libvirt- bin.conf with the stanza:
pre-stop exec shut-guests.sh 2>&1 > /var/log/ shut-guests. log
This works if I manually invoke a stop of libvirt-bin in a running system with:
$ sudo stop libvirt-bin
but **doesn't** work when issuing a reboot or halt. It seems there's an aggressive killing of all kvm processes **before** the pre-stop stanza is execute, and libvirt doesn't find any running guests when the shut-guests.sh is executed. it's not clear to me why and If this is an exptected behavior. For sure, kvm processes are detached from libvirt process branch.
[1] http:// www.linux- kvm.com/ content/ stop-script- running- vms-using- virsh