From patchwork Mon Aug 13 19:49:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 177122 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 2503A2C0093 for ; Tue, 14 Aug 2012 07:09:21 +1000 (EST) Received: from localhost ([::1]:55342 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T11t1-0004aV-0N for incoming@patchwork.ozlabs.org; Mon, 13 Aug 2012 17:09:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T10dv-00021g-Ku for qemu-devel@nongnu.org; Mon, 13 Aug 2012 15:49:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T10du-0003xK-Bv for qemu-devel@nongnu.org; Mon, 13 Aug 2012 15:49:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33513) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T10du-0003xB-2J for qemu-devel@nongnu.org; Mon, 13 Aug 2012 15:49:38 -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 q7DJnbbf027602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Aug 2012 15:49:37 -0400 Received: from localhost (ovpn-113-98.phx2.redhat.com [10.3.113.98]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q7DJnap7016565; Mon, 13 Aug 2012 15:49:36 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Mon, 13 Aug 2012 16:49:02 -0300 Message-Id: <1344887349-13041-42-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1344887349-13041-1-git-send-email-lcapitulino@redhat.com> References: <1344887349-13041-1-git-send-email-lcapitulino@redhat.com> 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: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 41/48] 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 --- 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 df190ac..2878058 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 shuts down 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 3694590..586abae 100644 --- a/monitor.c +++ b/monitor.c @@ -432,6 +432,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,