From: Gleb Natapov <gleb@redhat.com>
To: Ryan Harper <ryanh@us.ibm.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH][RESEND] Add monitor command for system_reboot
Date: Wed, 8 Jul 2009 10:56:01 +0300 [thread overview]
Message-ID: <20090708075601.GJ28046@redhat.com> (raw)
In-Reply-To: <20090707192631.GQ11590@us.ibm.com>
On Tue, Jul 07, 2009 at 02:26:31PM -0500, Ryan Harper wrote:
> 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.
OS is free to ignore ACPI shutdown request and in this case
reboot_requested will not be reset. On the next user initiated
guest power down qemu will reboot instead of exit.
>
> 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 <ryanh@us.ibm.com>
> Subject: [PATCH] Add system_reboot monitor function
> Cc: Anthony Liguori <aliguori@us.ibm.com>
>
> This patch adds a new monitor command to trigger a powerdown followed by
> system_reset.
>
> Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
> ---
> 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
>
>
--
Gleb.
next prev parent reply other threads:[~2009-07-08 7:56 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-07 19:26 [Qemu-devel] [PATCH][RESEND] Add monitor command for system_reboot Ryan Harper
2009-07-08 5:06 ` Avi Kivity
2009-07-08 13:07 ` Anthony Liguori
2009-07-08 13:11 ` Avi Kivity
2009-07-08 13:16 ` Anthony Liguori
2009-07-08 13:28 ` Avi Kivity
2009-07-08 7:56 ` Gleb Natapov [this message]
2009-07-08 13:05 ` Anthony Liguori
2009-07-08 13:26 ` Daniel P. Berrange
2009-07-08 13:47 ` Anthony Liguori
2009-07-08 13:56 ` Daniel P. Berrange
2009-07-08 13:59 ` Anthony Liguori
2009-07-08 15:43 ` Ryan Harper
2009-07-08 15:49 ` Anthony Liguori
2009-07-08 15:58 ` Ryan Harper
2009-07-08 16:02 ` Anthony Liguori
2009-07-08 16:02 ` Avi Kivity
2009-07-16 8:58 ` Amit Shah
2009-07-16 14:39 ` Jamie Lokier
2009-07-16 14:49 ` Amit Shah
2009-07-08 13:49 ` Gleb Natapov
2009-07-08 14:04 ` Avi Kivity
2009-07-08 14:10 ` Daniel P. Berrange
2009-07-08 15:16 ` Avi Kivity
2009-07-08 15:47 ` Stefano Stabellini
2009-07-08 15:54 ` Daniel P. Berrange
2009-07-08 15:59 ` Stefano Stabellini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090708075601.GJ28046@redhat.com \
--to=gleb@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=ryanh@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).