From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] system_powerdown via acpi power button Date: Tue, 22 Jan 2008 11:11:00 +0100 Message-ID: <4795C134.7030400@siemens.com> References: <20080103181132.GA1077@bogon.ms20.nix> 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: Guido Guenther Return-path: In-Reply-To: <20080103181132.GA1077-DVvpyRRQz99DDGxTMhc9XQ@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 Guido Guenther wrote: > +#if defined(TARGET_I386) > +void qemu_system_powerdown(void) > +{ > + if(pm_state->pmen & PWRBTN_EN) { > + pm_state->pmsts |= PWRBTN_EN; > + pm_update_sci(pm_state); > + } > +} > +#endif This code should also care about !pm_state, ie. non-PCI systems. Jan --- qemu/hw/acpi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Index: kvm-userspace/qemu/hw/acpi.c =================================================================== --- kvm-userspace.orig/qemu/hw/acpi.c +++ kvm-userspace/qemu/hw/acpi.c @@ -72,7 +72,7 @@ typedef struct PIIX4PMState { #define SMBHSTDAT1 0x06 #define SMBBLKDAT 0x07 -PIIX4PMState *pm_state; +PIIX4PMState *pm_state = NULL; static uint32_t get_pmtmr(PIIX4PMState *s) { @@ -527,6 +527,8 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int #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); -- Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux ------------------------------------------------------------------------- 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/