public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] system_powerdown via acpi power button
@ 2008-01-03 18:11 Guido Guenther
       [not found] ` <20080103181132.GA1077-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
  0 siblings, 1 reply; 36+ messages in thread
From: Guido Guenther @ 2008-01-03 18:11 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hi,
in order to be able to shutdown kvm cleanly with libvirt (currently
libvirt simply sends a SIGTERM) I implemented system_powerdown() to
simulate the pressing of a fixed feature acpi power button. The patch
has one issue though, it currently needs --no-kvm-irqchip (see my other
mail). Please apply if appropriate.

diff --git a/bios/rombios32.c b/bios/rombios32.c
index 314df94..7a96ece 100755
--- a/bios/rombios32.c
+++ b/bios/rombios32.c
@@ -1318,8 +1318,8 @@ void acpi_bios_init(void)
     fadt->pm_tmr_len = 4;
     fadt->plvl2_lat = cpu_to_le16(0x0fff); // C2 state not supported
     fadt->plvl3_lat = cpu_to_le16(0x0fff); // C3 state not supported
-    /* WBINVD + PROC_C1 + PWR_BUTTON + SLP_BUTTON + FIX_RTC */
-    fadt->flags = cpu_to_le32((1 << 0) | (1 << 2) | (1 << 4) | (1 << 5) | (1 << 6));
+    /* WBINVD + PROC_C1 + SLP_BUTTON + FIX_RTC */
+    fadt->flags = cpu_to_le32((1 << 0) | (1 << 2) | (1 << 5) | (1 << 6));
     acpi_build_table_header((struct acpi_table_header *)fadt, "FACP", 
                             sizeof(*fadt));
 
diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c
index a2efd9c..fa78b81 100644
--- a/qemu/hw/acpi.c
+++ b/qemu/hw/acpi.c
@@ -71,6 +71,8 @@ typedef struct PIIX4PMState {
 #define SMBHSTDAT1 0x06
 #define SMBBLKDAT 0x07
 
+PIIX4PMState *pm_state;
+
 static uint32_t get_pmtmr(PIIX4PMState *s)
 {
     uint32_t d;
@@ -475,6 +477,7 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base)
     s = (PIIX4PMState *)pci_register_device(bus,
                                          "PM", sizeof(PIIX4PMState),
                                          devfn, NULL, pm_write_config);
+    pm_state = s;
     pci_conf = s->dev.config;
     pci_conf[0x00] = 0x86;
     pci_conf[0x01] = 0x80;
@@ -516,3 +519,13 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base)
     s->smbus = i2c_init_bus();
     return s->smbus;
 }
+
+#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
diff --git a/qemu/pc-bios/bios.bin b/qemu/pc-bios/bios.bin
index d2729cd..fb3a72b 100644
Binary files a/qemu/pc-bios/bios.bin and b/qemu/pc-bios/bios.bin differ
diff --git a/qemu/sysemu.h b/qemu/sysemu.h
index c8478ec..5fd7fc2 100644
--- a/qemu/sysemu.h
+++ b/qemu/sysemu.h
@@ -33,7 +33,7 @@ void qemu_system_powerdown_request(void);
 int qemu_shutdown_requested(void);
 int qemu_reset_requested(void);
 int qemu_powerdown_requested(void);
-#if !defined(TARGET_SPARC)
+#if !defined(TARGET_SPARC) && !defined(TARGET_I386)
 // Please implement a power failure function to signal the OS
 #define qemu_system_powerdown() do{}while(0)
 #else

Cheers,
 -- Guido

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

^ permalink raw reply related	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2008-01-24 12:54 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-03 18:11 [PATCH] system_powerdown via acpi power button Guido Guenther
     [not found] ` <20080103181132.GA1077-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-03 18:14   ` acpi sci polarity Guido Guenther
     [not found]     ` <20080103181415.GB1077-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-03 21:17       ` Avi Kivity
     [not found]         ` <477D50FE.4040104-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-04 18:31           ` Guido Guenther
     [not found]             ` <20080104183158.GA14002-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-06  9:08               ` Avi Kivity
     [not found]                 ` <47809A8F.5090803-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-07 11:59                   ` Guido Guenther
     [not found]                     ` <20080107115916.GA24050-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-07 12:02                       ` [PATCH] add acpi powerbutton support Guido Guenther
     [not found]                         ` <20080107120223.GB24050-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-07 12:44                           ` Avi Kivity
     [not found]                             ` <47821EC8.4020308-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-08  4:34                               ` Jun Koi
     [not found]                                 ` <fdaac4d50801072034p7f047495jd4be276c20623be3-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-01-08  8:09                                   ` Guido Guenther
     [not found]                                     ` <20080108080928.GA9823-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-19 15:40                                       ` Jan Kiszka
     [not found]                                         ` <479219D6.1000707-S0/GAf8tV78@public.gmane.org>
2008-01-20 11:56                                           ` Guido Guenther
     [not found]                                             ` <20080120115617.GA31618-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-21 10:00                                               ` Jan Kiszka
     [not found]                                                 ` <47946D4A.5000808-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
2008-01-21 10:47                                                   ` Avi Kivity
     [not found]                                                     ` <47947857.4020004-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-21 11:35                                                       ` Jan Kiszka
     [not found]                                                         ` <47948376.9000105-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
2008-01-21 12:52                                                           ` Avi Kivity
2008-01-22  9:48                                                       ` Gerd Hoffmann
     [not found]                                                         ` <4795BBE3.5060609-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-01-22 10:06                                                           ` Jan Kiszka
2008-01-08  8:50                                   ` Avi Kivity
     [not found]                                     ` <47833938.1020609-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-09 18:00                                       ` Guido Guenther
     [not found]                                         ` <20080109180001.GA11240-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-13  9:35                                           ` Avi Kivity
     [not found]                                             ` <4789DB74.5070901-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-13 13:48                                               ` Avi Kivity
     [not found]                                                 ` <478A1694.1010307-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-14 10:23                                                   ` Guido Guenther
     [not found]                                                     ` <20080114102326.GB8987-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-14 17:34                                                       ` Avi Kivity
2008-01-18 22:20                                                   ` Avi Kivity
     [not found]                                                     ` <47912648.4030101-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-19 14:04                                                       ` Guido Guenther
2008-01-14 10:21                                               ` Guido Guenther
2008-01-14 12:41                         ` Alexey Eremenko
     [not found]                           ` <64F9B87B6B770947A9F8391472E032160C95C641-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/H7NteoWH0uzbU5w@public.gmane.org>
2008-01-14 13:30                             ` Guido Guenther
2008-01-22 10:11   ` [PATCH] system_powerdown via acpi power button Jan Kiszka
     [not found]     ` <4795C134.7030400-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
2008-01-22 11:49       ` Guido Guenther
     [not found]         ` <20080122114955.GA28335-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-22 12:12           ` Jan Kiszka
     [not found]             ` <4795DD9C.3040804-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
2008-01-24 12:37               ` Guido Guenther
     [not found]                 ` <20080124123730.GA4527-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-24 12:41                   ` Avi Kivity
     [not found]                     ` <47988797.8040208-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-24 12:50                       ` Gerd Hoffmann
     [not found]                         ` <479889B1.6030403-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-01-24 12:54                           ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox