From: Guido Guenther Subject: Re: [PATCH] system_powerdown via acpi power button Date: Thu, 24 Jan 2008 13:37:31 +0100 Message-ID: <20080124123730.GA4527@bogon.ms20.nix> References: <20080103181132.GA1077@bogon.ms20.nix> <4795C134.7030400@siemens.com> <20080122114955.GA28335@bogon.ms20.nix> <4795DD9C.3040804@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, Avi Kivity To: Jan Kiszka Return-path: Content-Disposition: inline In-Reply-To: <4795DD9C.3040804-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org On Tue, Jan 22, 2008 at 01:12:12PM +0100, Jan Kiszka wrote: > Guido Guenther wrote: > > On Tue, Jan 22, 2008 at 11:11:00AM +0100, Jan Kiszka wrote: > >> #if defined(TARGET_I386) > >> void qemu_system_powerdown(void) > >> { > >> + if (!pm_state) > >> + exit(0); > >> if(pm_state->pmen & PWRBTN_EN) { > >> pm_state->pmsts |= PWRBTN_EN; > >> pm_update_sci(pm_state); > > This totally defeats the "clean shutdown" purpose of system_powerdown. > > Think of it like: > > system_powerdown: hint the system to shutdown cleanly > > SIGTERM: kill the vm > > This is how things are wired up in libvirt at the moment. > > So how to signal a "clean shutdown" to the guest if there is no channel > for this? It isn't. It's about what system_powerdown should mean. IMHO it should be "signal the guest to shut down cleanly". If the guest can't do that, it simply can't. You can then SIGTERM the guest after a timeout. Note that even an acpi system might not be able to shut down since it hangs on a network unmount or it ignores the ACPI interrupt via kernel commandline or whatever. You can't ever expect a system to shutdown cleanly, so you need the SIGTERM failsave anyway. Have a look at e.g. domainShutdown() vs. domainDestroy() in libvirt. Cheers, -- Guido ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/