From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M2TQR-000772-FS for qemu-devel@nongnu.org; Fri, 08 May 2009 12:59:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M2TQM-00074c-GK for qemu-devel@nongnu.org; Fri, 08 May 2009 12:59:54 -0400 Received: from [199.232.76.173] (port=54728 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M2TQM-00074Y-BG for qemu-devel@nongnu.org; Fri, 08 May 2009 12:59:50 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:35301) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M2TQL-0003ME-R3 for qemu-devel@nongnu.org; Fri, 08 May 2009 12:59:50 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e37.co.us.ibm.com (8.13.1/8.13.1) with ESMTP id n48GxEPq018019 for ; Fri, 8 May 2009 10:59:14 -0600 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n48Gxm3U136328 for ; Fri, 8 May 2009 10:59:48 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n48Gxmic024034 for ; Fri, 8 May 2009 10:59:48 -0600 Message-ID: <4A046503.8050209@us.ibm.com> Date: Fri, 08 May 2009 11:59:47 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1241801561-11441-1-git-send-email-ryanh@us.ibm.com> In-Reply-To: <1241801561-11441-1-git-send-email-ryanh@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] Add monitor command for system_reboot List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ryan Harper Cc: "qemu-devel@nongnu.org" 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. > > Tested with Ubuntu 9.04 64-bit guest. > > Signed-off-by: Ryan Harper > > diff --git a/hw/acpi.c b/hw/acpi.c > index dbaf18a..346d100 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; > If qemu_shutdown_requested(), then we'll immediately shutdown the system. qemu_reboot_requested() has different semantics, it's really a soft request. I think the name needs to reflect that. Also, the soft reset flag ought to get reset whenever a VM changes it's state. That is, if you do a system_reboot, then a system_reset (imagine that the reboot fails), then you do a normal powerdown in the guest, instead of shutting off like the user would expect, we'll reboot because the qemu_reboot_requested() is still true. A good way to do that would be by registering a reset handler in hw/acpi.c. In fact, I think that the whole functionality probably should live in hw/acpi.c. And I think this also needs to be stored as part of the savevm state for hw/acpi.c. If you do a system_reboot followed by an immediate live migration, without the savevm handler, the VM will shutdown completely after the migration instead of rebooting as expected. -- Regards, Anthony Liguori