From patchwork Thu Aug 9 17:30:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 176201 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EBE1C2C00F1 for ; Fri, 10 Aug 2012 03:32:47 +1000 (EST) Received: from localhost ([::1]:57976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzWbF-0002sp-Rs for incoming@patchwork.ozlabs.org; Thu, 09 Aug 2012 13:32:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzWb6-0002oj-BB for qemu-devel@nongnu.org; Thu, 09 Aug 2012 13:32:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzWb2-0007Od-1Y for qemu-devel@nongnu.org; Thu, 09 Aug 2012 13:32:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45728) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzWb1-0007OU-Nu for qemu-devel@nongnu.org; Thu, 09 Aug 2012 13:32:31 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q79HWURN014831 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 9 Aug 2012 13:32:30 -0400 Received: from doriath.home (ovpn-113-85.phx2.redhat.com [10.3.113.85]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q79HWSWM004933; Thu, 9 Aug 2012 13:32:28 -0400 Date: Thu, 9 Aug 2012 14:30:32 -0300 From: Luiz Capitulino To: qemu-devel Message-ID: <20120809143032.44b147fe@doriath.home> Organization: Red Hat Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: mkletzan@redhat.com, kraxel@redhat.com, gleb@redhat.com Subject: [Qemu-devel] [PATCH 5/5] qmp: add SUSPEND_DISK event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Emitted when the guest makes a request to enter S4 state. There are three possible ways of having this event, as described here: http://lists.gnu.org/archive/html/qemu-devel/2012-07/msg02307.html I've decided to add a new event and make it indepedent of SHUTDOWN. This means that the SHUTDOWN event will eventually follow the SUSPEND_DISK event. I've choosen this way because of two reasons: 1. Having an indepedent event makes it possible to query for its existence by using query-events 2. In the future, we may allow the user to change what QEMU should do as a result of the guest entering S4. So it's a good idea to keep both events separated Signed-off-by: Luiz Capitulino --- This is on top of: [PATCH 0/4]: qmp: WAKEUP event related fixes QMP/qmp-events.txt | 14 ++++++++++++++ hw/acpi.c | 2 ++ monitor.c | 1 + monitor.h | 1 + 4 files changed, 18 insertions(+) diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt index 2001a71..1c51bee 100644 --- a/QMP/qmp-events.txt +++ b/QMP/qmp-events.txt @@ -252,6 +252,20 @@ Example: { "event": "SUSPEND", "timestamp": { "seconds": 1344456160, "microseconds": 309119 } } +SUSPEND_DISK +------------ + +Emitted when the guest makes a request to enter S4 state. + +Data: None. + +Example: + +{ "event": "SUSPEND_DISK", + "timestamp": { "seconds": 1344456160, "microseconds": 309119 } } + +Note: QEMU shutdowns when entering S4 state. + VNC_CONNECTED ------------- diff --git a/hw/acpi.c b/hw/acpi.c index effc7ec..f7950be 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -22,6 +22,7 @@ #include "hw.h" #include "pc.h" #include "acpi.h" +#include "monitor.h" struct acpi_table_header { uint16_t _length; /* our length, not actual part of the hdr */ @@ -386,6 +387,7 @@ void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val, char s4) break; default: if (sus_typ == s4) { /* S4 request */ + monitor_protocol_event(QEVENT_SUSPEND_DISK, NULL); qemu_system_shutdown_request(); } break; diff --git a/monitor.c b/monitor.c index 49dccfe..4f3c595 100644 --- a/monitor.c +++ b/monitor.c @@ -456,6 +456,7 @@ static const char *monitor_event_names[] = { [QEVENT_BLOCK_JOB_CANCELLED] = "BLOCK_JOB_CANCELLED", [QEVENT_DEVICE_TRAY_MOVED] = "DEVICE_TRAY_MOVED", [QEVENT_SUSPEND] = "SUSPEND", + [QEVENT_SUSPEND_DISK] = "SUSPEND_DISK", [QEVENT_WAKEUP] = "WAKEUP", [QEVENT_BALLOON_CHANGE] = "BALLOON_CHANGE", }; diff --git a/monitor.h b/monitor.h index 5f4de1b..4ef9a04 100644 --- a/monitor.h +++ b/monitor.h @@ -40,6 +40,7 @@ typedef enum MonitorEvent { QEVENT_BLOCK_JOB_CANCELLED, QEVENT_DEVICE_TRAY_MOVED, QEVENT_SUSPEND, + QEVENT_SUSPEND_DISK, QEVENT_WAKEUP, QEVENT_BALLOON_CHANGE,