From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: How to properly turn off guest VM on server shutdown? Date: Mon, 25 Jan 2010 20:09:25 +0100 Message-ID: <4B5DEC65.4030502@siemens.com> References: <4B5C5A31.7060807@web.de> <20100124151140.GC24932@defiant.freesoftware> <4B5C6425.7070000@redhat.com> <4B5C6744.8070006@codemonkey.ws> <4B5C915F.6060609@univ-nantes.fr> <1167509576.20100124210716@eternallybored.org> <4B5DE70A.7050709@msgid.tls.msk.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1250 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: =?windows-1250?Q?Jernej_Simon=E8i=E8?= , "Jean-Philippe Menil on [KVM]" , Jean-Philippe Menil , kvm-owner@vger.kernel.org To: Michael Tokarev Return-path: Received: from thoth.sbs.de ([192.35.17.2]:17365 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751129Ab0AYTJu (ORCPT ); Mon, 25 Jan 2010 14:09:50 -0500 In-Reply-To: <4B5DE70A.7050709@msgid.tls.msk.ru> Sender: kvm-owner@vger.kernel.org List-ID: Michael Tokarev wrote: > Jernej Simon=E8i=E8 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. >=20 > The only problem is that windows does not want to shut down when you > need it. >=20 > All versions of windows server requires enabling something in the > registry - to notice the "power down" events to start with. >=20 > 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. >=20 > 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. >=20 > In order to shut down my windows guests I come to this version: >=20 > { > # 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 >=20 >=20 > That's netcat connecting to the guest's monitor which is a unix socke= t. >=20 > 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. >=20 > 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 --=20 Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux