From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KaBsf-0007ao-MI for qemu-devel@nongnu.org; Mon, 01 Sep 2008 12:03:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KaBse-0007aM-TA for qemu-devel@nongnu.org; Mon, 01 Sep 2008 12:03:53 -0400 Received: from [199.232.76.173] (port=56973 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KaBse-0007aA-Fv for qemu-devel@nongnu.org; Mon, 01 Sep 2008 12:03:52 -0400 Received: from lizzard.sbs.de ([194.138.37.39]:18481) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KaBsd-0006yL-Sy for qemu-devel@nongnu.org; Mon, 01 Sep 2008 12:03:52 -0400 Received: from mail1.sbs.de (localhost [127.0.0.1]) by lizzard.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id m81G3kIi013589 for ; Mon, 1 Sep 2008 18:03:47 +0200 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail1.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id m81G3kGM015325 for ; Mon, 1 Sep 2008 18:03:46 +0200 Message-ID: <48BC1262.3040201@siemens.com> Date: Mon, 01 Sep 2008 18:03:46 +0200 From: Jan Kiszka MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] x86: Fix powerdown for non-ACPI case Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Trivial fix for a corner case: system_shutdown on isapc machines causes qemu to segfaults due to accessing the uninitialized pm_state. Issue a system shutdown instead. Signed-off-by: Jan Kiszka --- hw/acpi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) Index: b/hw/acpi.c =================================================================== --- a/hw/acpi.c +++ b/hw/acpi.c @@ -72,7 +72,7 @@ typedef struct PIIX4PMState { #define SMBHSTDAT1 0x06 #define SMBBLKDAT 0x07 -PIIX4PMState *pm_state; +static PIIX4PMState *pm_state; static uint32_t get_pmtmr(PIIX4PMState *s) { @@ -526,7 +526,9 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int #if defined(TARGET_I386) void qemu_system_powerdown(void) { - if(pm_state->pmen & PWRBTN_EN) { + if (!pm_state) { + qemu_system_shutdown_request(); + } else if (pm_state->pmen & PWRBTN_EN) { pm_state->pmsts |= PWRBTN_EN; pm_update_sci(pm_state); }