瀏覽代碼

qmp: add SUSPEND_DISK event

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 <lcapitulino@redhat.com>
Luiz Capitulino 13 年之前
父節點
當前提交
25df49f6eb
共有 4 個文件被更改,包括 18 次插入0 次删除
  1. 14 0
      QMP/qmp-events.txt
  2. 2 0
      hw/acpi.c
  3. 1 0
      monitor.c
  4. 1 0
      monitor.h

+ 14 - 0
QMP/qmp-events.txt

@@ -252,6 +252,20 @@ Example:
 { "event": "SUSPEND",
 { "event": "SUSPEND",
      "timestamp": { "seconds": 1344456160, "microseconds": 309119 } }
      "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
 VNC_CONNECTED
 -------------
 -------------
 
 

+ 2 - 0
hw/acpi.c

@@ -22,6 +22,7 @@
 #include "hw.h"
 #include "hw.h"
 #include "pc.h"
 #include "pc.h"
 #include "acpi.h"
 #include "acpi.h"
+#include "monitor.h"
 
 
 struct acpi_table_header {
 struct acpi_table_header {
     uint16_t _length;         /* our length, not actual part of the hdr */
     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;
             break;
         default:
         default:
             if (sus_typ == s4) { /* S4 request */
             if (sus_typ == s4) { /* S4 request */
+                monitor_protocol_event(QEVENT_SUSPEND_DISK, NULL);
                 qemu_system_shutdown_request();
                 qemu_system_shutdown_request();
             }
             }
             break;
             break;

+ 1 - 0
monitor.c

@@ -432,6 +432,7 @@ static const char *monitor_event_names[] = {
     [QEVENT_BLOCK_JOB_CANCELLED] = "BLOCK_JOB_CANCELLED",
     [QEVENT_BLOCK_JOB_CANCELLED] = "BLOCK_JOB_CANCELLED",
     [QEVENT_DEVICE_TRAY_MOVED] = "DEVICE_TRAY_MOVED",
     [QEVENT_DEVICE_TRAY_MOVED] = "DEVICE_TRAY_MOVED",
     [QEVENT_SUSPEND] = "SUSPEND",
     [QEVENT_SUSPEND] = "SUSPEND",
+    [QEVENT_SUSPEND_DISK] = "SUSPEND_DISK",
     [QEVENT_WAKEUP] = "WAKEUP",
     [QEVENT_WAKEUP] = "WAKEUP",
     [QEVENT_BALLOON_CHANGE] = "BALLOON_CHANGE",
     [QEVENT_BALLOON_CHANGE] = "BALLOON_CHANGE",
 };
 };

+ 1 - 0
monitor.h

@@ -40,6 +40,7 @@ typedef enum MonitorEvent {
     QEVENT_BLOCK_JOB_CANCELLED,
     QEVENT_BLOCK_JOB_CANCELLED,
     QEVENT_DEVICE_TRAY_MOVED,
     QEVENT_DEVICE_TRAY_MOVED,
     QEVENT_SUSPEND,
     QEVENT_SUSPEND,
+    QEVENT_SUSPEND_DISK,
     QEVENT_WAKEUP,
     QEVENT_WAKEUP,
     QEVENT_BALLOON_CHANGE,
     QEVENT_BALLOON_CHANGE,