From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MOGJU-0002K2-3H for qemu-devel@nongnu.org; Tue, 07 Jul 2009 15:26:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MOGJP-0002IA-Ii for qemu-devel@nongnu.org; Tue, 07 Jul 2009 15:26:47 -0400 Received: from [199.232.76.173] (port=36265 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MOGJP-0002I0-36 for qemu-devel@nongnu.org; Tue, 07 Jul 2009 15:26:43 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:58782) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MOGJO-0005iJ-Mc for qemu-devel@nongnu.org; Tue, 07 Jul 2009 15:26:42 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e7.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n67JDZ4d020750 for ; Tue, 7 Jul 2009 15:13:35 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n67JQYp8247646 for ; Tue, 7 Jul 2009 15:26:34 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n67JO4xv027678 for ; Tue, 7 Jul 2009 15:24:04 -0400 Date: Tue, 7 Jul 2009 14:26:31 -0500 From: Ryan Harper Message-ID: <20090707192631.GQ11590@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH][RESEND] Add monitor command for system_reboot List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori Add a new monitor command (system_reboot) for a soft reboot which uses system_powerdown to trigger ACPI shutdown in the guest and once shutdown is complete, trigger a reset instead of exiting qemu. Depends on commit a6d6552426dcbf726e5549f08b70c9318d6be14b which enabled ACPI power button support. V2: -added reset handler to lower the reboot flag on reset. Tested with: - Ubuntu 9.04 64-bit guest. - SLES 10 SP2 32-bit guest. - RHEL 5.3 32 and 64 bit guests. -- Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx ryanh@us.ibm.com diffstat output: hw/acpi.c | 15 ++++++++++++++- monitor.c | 5 +++++ qemu-monitor.hx | 8 ++++++++ sysemu.h | 2 ++ vl.c | 22 +++++++++++++++++++++- 5 files changed, 50 insertions(+), 2 deletions(-) --- From: Ryan Harper Subject: [PATCH] Add system_reboot monitor function Cc: Anthony Liguori This patch adds a new monitor command to trigger a powerdown followed by system_reset. Signed-off-by: Ryan Harper --- hw/acpi.c | 15 ++++++++++++++- monitor.c | 5 +++++ qemu-monitor.hx | 8 ++++++++ sysemu.h | 2 ++ vl.c | 21 +++++++++++++++++++++ 5 files changed, 50 insertions(+), 1 deletions(-) diff --git a/hw/acpi.c b/hw/acpi.c index 0465201..aba384c 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -151,7 +151,13 @@ static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val) sus_typ = (val >> 10) & 7; switch(sus_typ) { case 0: /* soft power off */ - qemu_system_shutdown_request(); + /* after powerdown, if on system_reboot path, call reset + instead of shutdown */ + if (qemu_reboot_requested()) { + qemu_system_reset_request(); + } else { + qemu_system_shutdown_request(); + } break; case 1: /* RSM_STS should be set on resume. Pretend that resume @@ -497,6 +503,12 @@ static void piix4_reset(void *opaque) } } +static void system_reboot_reset(void *opaque) +{ + /* clear reboot flag */ + qemu_reboot_requested(); +} + i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, qemu_irq sci_irq) { @@ -551,6 +563,7 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, s->smbus = i2c_init_bus(NULL, "i2c"); s->irq = sci_irq; qemu_register_reset(piix4_reset, s); + qemu_register_reset(system_reboot_reset, s); return s->smbus; } diff --git a/monitor.c b/monitor.c index bad79fe..346e0db 100644 --- a/monitor.c +++ b/monitor.c @@ -1223,6 +1223,11 @@ static void do_system_powerdown(Monitor *mon) qemu_system_powerdown_request(); } +static void do_system_reboot(Monitor *mon) +{ + qemu_system_reboot_request(); +} + #if defined(TARGET_I386) static void print_pte(Monitor *mon, uint32_t addr, uint32_t pte, uint32_t mask) { diff --git a/qemu-monitor.hx b/qemu-monitor.hx index dc10b75..91799d0 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -339,6 +339,14 @@ STEXI Power down the system (if supported). ETEXI + { "system_reboot", "", do_system_reboot, + "", "send system power down event, and then reset" }, +STEXI +@item system_reboot + +Power down the system (if supported), and then reset. +ETEXI + { "sum", "ii", do_sum, "addr size", "compute the checksum of a memory region" }, STEXI diff --git a/sysemu.h b/sysemu.h index 06dc4c6..056a491 100644 --- a/sysemu.h +++ b/sysemu.h @@ -40,10 +40,12 @@ void cpu_enable_ticks(void); void cpu_disable_ticks(void); void qemu_system_reset_request(void); +void qemu_system_reboot_request(void); void qemu_system_shutdown_request(void); void qemu_system_powerdown_request(void); int qemu_shutdown_requested(void); int qemu_reset_requested(void); +int qemu_reboot_requested(void); int qemu_powerdown_requested(void); #ifdef NEED_CPU_H #if !defined(TARGET_SPARC) && !defined(TARGET_I386) diff --git a/vl.c b/vl.c index 7b7489c..634d386 100644 --- a/vl.c +++ b/vl.c @@ -3618,6 +3618,7 @@ static QEMUResetEntry *first_reset_entry; static int reset_requested; static int shutdown_requested; static int powerdown_requested; +static int reboot_requested; static int debug_requested; static int vmstop_requested; @@ -3642,6 +3643,13 @@ int qemu_powerdown_requested(void) return r; } +int qemu_reboot_requested(void) +{ + int r = reboot_requested; + reboot_requested = 0; + return r; +} + static int qemu_debug_requested(void) { int r = debug_requested; @@ -3712,6 +3720,17 @@ void qemu_system_powerdown_request(void) qemu_notify_event(); } +void qemu_system_reboot_request(void) +{ + /* Raise the powerdown request to trigger system_powerdown event. + * Also raise reboot flag so powerdown handler knows to request + * a reset instead of shutdown after the powerdown. + */ + powerdown_requested = 1; + reboot_requested = 1; + qemu_notify_event(); +} + #ifdef CONFIG_IOTHREAD static void qemu_system_vmstop_request(int reason) { @@ -4461,6 +4480,8 @@ static int vm_can_run(void) { if (powerdown_requested) return 0; + if (reboot_requested) + return 0; if (reset_requested) return 0; if (shutdown_requested) -- 1.6.0.4