Commit 9669d3c570c7a2129c6d6d4e32b856a2d155eb54

Authored by aurel32
1 parent 7b455225

x86: Fix powerdown for non-ACPI case

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 <jan.kiszka@siemens.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5130 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 4 additions and 2 deletions
hw/acpi.c
@@ -72,7 +72,7 @@ typedef struct PIIX4PMState { @@ -72,7 +72,7 @@ typedef struct PIIX4PMState {
72 #define SMBHSTDAT1 0x06 72 #define SMBHSTDAT1 0x06
73 #define SMBBLKDAT 0x07 73 #define SMBBLKDAT 0x07
74 74
75 -PIIX4PMState *pm_state; 75 +static PIIX4PMState *pm_state;
76 76
77 static uint32_t get_pmtmr(PIIX4PMState *s) 77 static uint32_t get_pmtmr(PIIX4PMState *s)
78 { 78 {
@@ -526,7 +526,9 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, @@ -526,7 +526,9 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
526 #if defined(TARGET_I386) 526 #if defined(TARGET_I386)
527 void qemu_system_powerdown(void) 527 void qemu_system_powerdown(void)
528 { 528 {
529 - if(pm_state->pmen & PWRBTN_EN) { 529 + if (!pm_state) {
  530 + qemu_system_shutdown_request();
  531 + } else if (pm_state->pmen & PWRBTN_EN) {
530 pm_state->pmsts |= PWRBTN_EN; 532 pm_state->pmsts |= PWRBTN_EN;
531 pm_update_sci(pm_state); 533 pm_update_sci(pm_state);
532 } 534 }