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

Zdenek Styblik stybla at turnovfree.net
Tue Nov 2 12:28:32 UTC 2010


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?
> 
> 

Hello,

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

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 ---
#!/bin/bash

for VM in $(virsh list | grep -e 'running' | tr -s ' ' | \
awk '{print $2 }'); do
  virsh shutdown "$VM"
done
--- 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.

Regards,
Zdenek

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




More information about the virt-tools-list mailing list