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.

/mjt
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to