[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [virt-tools-list] shutdown / save guest state on host shutdown / reboot?

On 11/02/2010 01:11 PM, Tomasz Chmielewski wrote:
> Is it possible to shutdown or save guest state automatically on host
> shutdown / reboot?
> Right now, I see KVM processes are simply killed when the host is
> rebooted or halted, which leaves the guests in the inconsistent state.
> What are the ways to automate guest shutdown or save/resume state of the
> guests upon host shutdown/reboot?


I don't know the correct answer, but what pop-ed up in my head instantly

How about to write a shell script, which is going to be called
whatever-the-name-of-init6-script-is in your distro eg. '/etc/rc.d/rc.6',
and code like:
--- SNIP ---

for VM in $(virsh list | grep -e 'running' | tr -s ' ' | \
awk '{print $2 }'); do
  virsh shutdown "$VM"
--- SNIP ---

However, this is up-most simple version. You would like to add check if
VM has been shut down resp. some grace period before you force-kill VM.
And what if VM doesn't support ACPI/APM shutdowns etc.
It's also not going to work for VM with spaces in their names.

But as I've stated before, instant-reply to your question.


Zdenek Styblik
Net/Linux admin
OS TurnovFree.net
email: stybla turnovfree net
jabber: stybla jabber turnovfree net

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]