WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] hvm: add ACPI power button for HVM

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] hvm: add ACPI power button for HVM
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 07 Apr 2009 23:03:03 -0700
Delivery-date: Tue, 07 Apr 2009 23:07:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1238672409 -3600
# Node ID 567d312e80ad41454e232ed78e16bd3ad8763d07
# Parent  cb5b609c4164da83a21e857e51e59b5ff7826b75
hvm: add ACPI power button for HVM

This patch adds the ACPI fixed hardware power button for HVM.
It enables a graceful shutdown of a guest OS by direction of Dom0.
(if a proper action for the power button is set inside the guest)

usage:
  xm trigger <Domain> power

Signed-off-by: Kouya Shimura <kouya@xxxxxxxxxxxxxx>
---
 tools/firmware/hvmloader/acpi/static_tables.c |    2 +-
 tools/python/xen/xend/XendConstants.py        |    6 ++++--
 tools/python/xen/xm/main.py                   |    2 +-
 xen/arch/x86/domctl.c                         |   13 +++++++++++++
 xen/arch/x86/hvm/pmtimer.c                    |   24 +++++++++++++++---------
 xen/include/public/domctl.h                   |    1 +
 6 files changed, 35 insertions(+), 13 deletions(-)

diff -r cb5b609c4164 -r 567d312e80ad 
tools/firmware/hvmloader/acpi/static_tables.c
--- a/tools/firmware/hvmloader/acpi/static_tables.c     Thu Apr 02 11:48:32 
2009 +0100
+++ b/tools/firmware/hvmloader/acpi/static_tables.c     Thu Apr 02 12:40:09 
2009 +0100
@@ -69,7 +69,7 @@ struct acpi_20_fadt Fadt = {
     .p_lvl3_lat = 0x0fff, /* >1000, means we do not support C3 state */
     .iapc_boot_arch = ACPI_8042,
     .flags = (ACPI_PROC_C1 | ACPI_SLP_BUTTON |
-              ACPI_WBINVD | ACPI_PWR_BUTTON |
+              ACPI_WBINVD |
               ACPI_FIX_RTC | ACPI_TMR_VAL_EXT),
 
     .reset_reg = {
diff -r cb5b609c4164 -r 567d312e80ad tools/python/xen/xend/XendConstants.py
--- a/tools/python/xen/xend/XendConstants.py    Thu Apr 02 11:48:32 2009 +0100
+++ b/tools/python/xen/xend/XendConstants.py    Thu Apr 02 12:40:09 2009 +0100
@@ -105,13 +105,15 @@ TRIGGER_NMI   = 0
 TRIGGER_NMI   = 0
 TRIGGER_RESET = 1
 TRIGGER_INIT  = 2
-TRIGGER_S3RESUME = 3
+TRIGGER_POWER = 3
+TRIGGER_S3RESUME = 4
 
 TRIGGER_TYPE = {
     "nmi"   : TRIGGER_NMI,
     "reset" : TRIGGER_RESET,
     "init"  : TRIGGER_INIT,
-    "s3resume": TRIGGER_S3RESUME
+    "s3resume": TRIGGER_S3RESUME,
+    "power": TRIGGER_POWER
 }
 
 #
diff -r cb5b609c4164 -r 567d312e80ad tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Thu Apr 02 11:48:32 2009 +0100
+++ b/tools/python/xen/xm/main.py       Thu Apr 02 12:40:09 2009 +0100
@@ -151,7 +151,7 @@ SUBCOMMAND_HELP = {
                      'Get/set credit scheduler parameters.'),
     'sysrq'       : ('<Domain> <letter>', 'Send a sysrq to a domain.'),
     'debug-keys'  : ('<Keys>', 'Send debug keys to Xen.'),
-    'trigger'     : ('<Domain> <nmi|reset|init|s3resume> [<VCPU>]',
+    'trigger'     : ('<Domain> <nmi|reset|init|s3resume|power> [<VCPU>]',
                      'Send a trigger to a domain.'),
     'vcpu-list'   : ('[Domain, ...]',
                      'List the VCPUs for all/some domains.'),
diff -r cb5b609c4164 -r 567d312e80ad xen/arch/x86/domctl.c
--- a/xen/arch/x86/domctl.c     Thu Apr 02 11:48:32 2009 +0100
+++ b/xen/arch/x86/domctl.c     Thu Apr 02 12:40:09 2009 +0100
@@ -587,6 +587,19 @@ long arch_do_domctl(
         }
         break;
 
+        case XEN_DOMCTL_SENDTRIGGER_POWER:
+        {
+            extern void hvm_acpi_power_button(struct domain *d);
+
+            ret = -EINVAL;
+            if ( is_hvm_domain(d) ) 
+            {
+                ret = 0;
+                hvm_acpi_power_button(d);
+            }
+        }
+        break;
+
         default:
             ret = -ENOSYS;
         }
diff -r cb5b609c4164 -r 567d312e80ad xen/arch/x86/hvm/pmtimer.c
--- a/xen/arch/x86/hvm/pmtimer.c        Thu Apr 02 11:48:32 2009 +0100
+++ b/xen/arch/x86/hvm/pmtimer.c        Thu Apr 02 12:40:09 2009 +0100
@@ -29,18 +29,15 @@
 
 /* The interesting bits of the PM1a_STS register */
 #define TMR_STS    (1 << 0)
-#define PWRBTN_STS (1 << 5)
-#define GBL_STS    (1 << 8)
+#define GBL_STS    (1 << 5)
+#define PWRBTN_STS (1 << 8)
 
 /* The same in PM1a_EN */
 #define TMR_EN     (1 << 0)
-#define PWRBTN_EN  (1 << 5)
-#define GBL_EN     (1 << 8)
-
-/* Mask of bits in PM1a_STS that can generate an SCI.  Although the ACPI
- * spec lists other bits, the PIIX4, which we are emulating, only
- * supports these three.  For now, we only use TMR_STS; in future we
- * will let qemu set the other bits */
+#define GBL_EN     (1 << 5)
+#define PWRBTN_EN  (1 << 8)
+
+/* Mask of bits in PM1a_STS that can generate an SCI. */
 #define SCI_MASK (TMR_STS|PWRBTN_STS|GBL_STS) 
 
 /* SCI IRQ number (must match SCI_INT number in ACPI FADT in hvmloader) */
@@ -59,6 +56,15 @@ static void pmt_update_sci(PMTState *s)
         hvm_isa_irq_assert(s->vcpu->domain, SCI_IRQ);
     else
         hvm_isa_irq_deassert(s->vcpu->domain, SCI_IRQ);
+}
+
+void hvm_acpi_power_button(struct domain *d)
+{
+    PMTState *s = &d->arch.hvm_domain.pl_time.vpmt;
+    spin_lock(&s->lock);
+    s->pm.pm1a_sts |= PWRBTN_STS;
+    pmt_update_sci(s);
+    spin_unlock(&s->lock);
 }
 
 /* Set the correct value in the timer, accounting for time elapsed
diff -r cb5b609c4164 -r 567d312e80ad xen/include/public/domctl.h
--- a/xen/include/public/domctl.h       Thu Apr 02 11:48:32 2009 +0100
+++ b/xen/include/public/domctl.h       Thu Apr 02 12:40:09 2009 +0100
@@ -433,6 +433,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_real_
 #define XEN_DOMCTL_SENDTRIGGER_NMI    0
 #define XEN_DOMCTL_SENDTRIGGER_RESET  1
 #define XEN_DOMCTL_SENDTRIGGER_INIT   2
+#define XEN_DOMCTL_SENDTRIGGER_POWER  3
 struct xen_domctl_sendtrigger {
     uint32_t  trigger;  /* IN */
     uint32_t  vcpu;     /* IN */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] hvm: add ACPI power button for HVM, Xen patchbot-unstable <=