Re: How to properly turn off guest VM on server shutdown?

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

 



Michael Tokarev wrote:
> Jernej Simončič wrote:
>> On Sunday, January 24, 2010, 19:28:47, Jean-Philippe Menil wrote:
>>
>>> Maybe the same can be done with windows guest.
>> Should work with any Windows, and verified to work with Vista x64
>> guest.
> 
> The only problem is that windows does not want to shut down when you
> need it.
> 
> All versions of windows server requires enabling something in the
> registry - to notice the "power down" events to start with.
> 
> If a windows machine is used by someone else (open files, logged in
> user etc), it brings a dialog box in response to "power down" event
> asking if you _really_ want to shut down since this machine is
> used over network.
> 
> And finally, quite often during screensaver "work" windows notices
> the "power down" event only after some other event such as mouse
> move or a keypress.
> 
> In order to shut down my windows guests I come to this version:
> 
>   {
>     # moving mouse helps windows (xp) to notice the powerdown event
>     echo mouse_move 1 1
>     sleep .1
>     echo system_powerdown
>     sleep 1
>     # also for windows, if it asks "ok to shutdown if in use?"
>     echo sendkey ret
>     sleep .1
>   } | \
>     nc -U -w2 -q2 $run/$name/mon > /dev/null
> 
> 
> That's netcat connecting to the guest's monitor which is a unix socket.
> 
> The script performs similar task for all guests in first cycle,
> next it repeats the procedure but now waits for $max_guest_waittime,
> which should be sufficient for any guest to shut down.  If the guest
> did not shut down in time, the script simple kills the guest.
> 
> Note that "sleep 1" in the above is not necessary sufficient, as
> (windows) guest might be in swap and might need some time to
> draw the dialog box.

A cleaner alternative might be emulating the monitoring interface of
some standard UPS. It's somehow the same scenario: The virtual power is
about to vanish, let's inform the guest to shut down properly. And when
choosing a serial link, that should even be possible without modifying QEMU.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux