Skip to contentSkip to conversation

: QMP: some event fixes

PATCH Applied Luiz Capitulino 3 participants 8 messages Feb 25, 2010 – Mar 9, 2010

lore
Share & tools
lore
#0 lore raw

cover : QMP: some event fixes

The most important fix is wrt the STOP event, which is not being currently
emitted. The doc revamp is also important. The other patches are small fixes.

Thanks.

#1 lore raw

PATCH 1/5 block: Emit BLOCK_IO_ERROR before vm_stop() call

The next commit will move the STOP event into do_vm_stop(), to have the expected event sequence we need to emit the I/O error event before calling vm_stop().

The expected sequence is:

{ "event": "BLOCK_IO_ERROR" [...] }
{ "event": "STOP" }

---
 hw/ide/core.c   |    2 +-
 hw/scsi-disk.c  |    2 +-
 hw/virtio-blk.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
hw/ide/core.c +1 -1
index 2e0971d..67480bb 100644
@@ -491,8 +491,8 @@ static int ide_handle_rw_error(IDEState *s, int error, int op)
             || action == BLOCK_ERR_STOP_ANY) {
         s->bus->bmdma->unit = s->unit;
         s->bus->bmdma->status |= op;
-        vm_stop(0);
         bdrv_mon_event(s->bs, BDRV_ACTION_STOP, is_read);
+        vm_stop(0);
     } else {
         if (op & BM_STATUS_DMA_RETRY) {
             dma_buf_commit(s, 0);
hw/scsi-disk.c +1 -1
index b2f61fe..7bb9c6c 100644
@@ -190,8 +190,8 @@ static int scsi_handle_write_error(SCSIDiskReq *r, int error)
     if ((error == ENOSPC && action == BLOCK_ERR_STOP_ENOSPC)
             || action == BLOCK_ERR_STOP_ANY) {
         r->status |= SCSI_REQ_STATUS_RETRY;
-        vm_stop(0);
         bdrv_mon_event(s->bs, BDRV_ACTION_STOP, 0);
+        vm_stop(0);
     } else {
         scsi_command_complete(r, CHECK_CONDITION,
                 HARDWARE_ERROR);
hw/virtio-blk.c +1 -1
index b80402d..8939bb2 100644
@@ -72,8 +72,8 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,
             || action == BLOCK_ERR_STOP_ANY) {
         req->next = s->rq;
         s->rq = req;
-        vm_stop(0);
         bdrv_mon_event(req->dev->bs, BDRV_ACTION_STOP, is_read);
+        vm_stop(0);
     } else {
         virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
         bdrv_mon_event(req->dev->bs, BDRV_ACTION_REPORT, is_read);
Signature · 1 line
1.7.0.GIT
#2 lore raw

Re: [Qemu-devel] [PATCH 1/5] block: Emit BLOCK_IO_ERROR before vm_stop() call

Quoted 11 lines · Luiz Capitulino

The next commit will move the STOP event into do_vm_stop(), to have the expected event sequence we need to emit the I/O error event before calling vm_stop().

The expected sequence is:

{ "event": "BLOCK_IO_ERROR" [...] }
{ "event": "STOP" }

Applied all. Thanks.

Regards,

Anthony Liguori

Quoted 49 lines
---
  hw/ide/core.c   |    2 +-
  hw/scsi-disk.c  |    2 +-
  hw/virtio-blk.c |    2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)
hw/ide/core.c +1 -1
index 2e0971d..67480bb 100644
@@ -491,8 +491,8 @@ static int ide_handle_rw_error(IDEState *s, int error, int op)
              || action == BLOCK_ERR_STOP_ANY) {
          s->bus->bmdma->unit = s->unit;
          s->bus->bmdma->status |= op;
-        vm_stop(0);
          bdrv_mon_event(s->bs, BDRV_ACTION_STOP, is_read);
+        vm_stop(0);
      } else {
          if (op&  BM_STATUS_DMA_RETRY) {
              dma_buf_commit(s, 0);
hw/scsi-disk.c +1 -1
index b2f61fe..7bb9c6c 100644
@@ -190,8 +190,8 @@ static int scsi_handle_write_error(SCSIDiskReq *r, int error)
      if ((error == ENOSPC&&  action == BLOCK_ERR_STOP_ENOSPC)
              || action == BLOCK_ERR_STOP_ANY) {
          r->status |= SCSI_REQ_STATUS_RETRY;
-        vm_stop(0);
          bdrv_mon_event(s->bs, BDRV_ACTION_STOP, 0);
+        vm_stop(0);
      } else {
          scsi_command_complete(r, CHECK_CONDITION,
                  HARDWARE_ERROR);
hw/virtio-blk.c +1 -1
index b80402d..8939bb2 100644
@@ -72,8 +72,8 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,
              || action == BLOCK_ERR_STOP_ANY) {
          req->next = s->rq;
          s->rq = req;
-        vm_stop(0);
          bdrv_mon_event(req->dev->bs, BDRV_ACTION_STOP, is_read);
+        vm_stop(0);
      } else {
          virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
          bdrv_mon_event(req->dev->bs, BDRV_ACTION_REPORT, is_read);
#3 lore raw

PATCH 2/5 QMP: Move STOP event into do_vm_stop()

In reply to Luiz Capitulino

I've introduced the STOP event in the main loop, this is wrong as it will be only emitted if the io thread is enabled.

This fixes that by moving the STOP event to do_vm_stop().

---
 vl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
vl.c +1 -1
index db7a178..1735dd2 100644
@@ -3106,6 +3106,7 @@ static void do_vm_stop(int reason)
         vm_running = 0;
         pause_all_vcpus();
         vm_state_notify(0, reason);
+        monitor_protocol_event(QEVENT_STOP, NULL);
     }
 }
 
@@ -4073,7 +4074,6 @@ static void main_loop(void)
             qemu_irq_raise(qemu_system_powerdown);
         }
         if ((r = qemu_vmstop_requested())) {
-            monitor_protocol_event(QEVENT_STOP, NULL);
             vm_stop(r);
         }
     }
Signature · 1 line
1.7.0.GIT
#4 lore raw

PATCH 3/5 QMP: Move RESET event into qemu_system_reset()

In reply to Luiz Capitulino

Nothing will change as that function is currently only called by the main loop code, but it's the right place for the RESET event, as it's where the reset is actually performed.

---
 vl.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
vl.c +2 -1
index 1735dd2..2c766c4 100644
@@ -3140,6 +3140,8 @@ void qemu_system_reset(void)
     QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) {
         re->func(re->opaque);
     }
+
+    monitor_protocol_event(QEVENT_RESET, NULL);
 }
 
 void qemu_system_reset_request(void)
@@ -4064,7 +4066,6 @@ static void main_loop(void)
                 break;
         }
         if (qemu_reset_requested()) {
-            monitor_protocol_event(QEVENT_RESET, NULL);
             pause_all_vcpus();
             qemu_system_reset();
             resume_all_vcpus();
Signature · 1 line
1.7.0.GIT
#5 lore raw

PATCH 4/5 QMP: Drop DEBUG event

In reply to Luiz Capitulino

This event has been introduced in the first round of QMP commits, turns out that it's based on the usage of the EXCP_DEBUG macro, which has discussable semantics when exposed through QMP.

As libvirt doesn't use this, let's just drop it.

---
 QMP/qmp-events.txt |    6 ------
 monitor.c          |    3 ---
 monitor.h          |    1 -
 vl.c               |    1 -
 4 files changed, 0 insertions(+), 11 deletions(-)
QMP/qmp-events.txt +0 -6
index d585a8d..9bf14d0 100644
@@ -19,12 +19,6 @@ Data: None.
 Description: Issued when the Virtual Machine is stopped.
 Data: None.
 
-4 DEBUG
--------
-
-Description: Issued when the Virtual Machine enters debug mode.
-Data: None.
-
 4 VNC_CONNECTED
 ---------------
 
monitor.c +0 -3
index 19470d1..b2f5842 100644
@@ -399,9 +399,6 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)
     assert(event < QEVENT_MAX);
 
     switch (event) {
-        case QEVENT_DEBUG:
-            event_name = "DEBUG";
-            break;
         case QEVENT_SHUTDOWN:
             event_name = "SHUTDOWN";
             break;
monitor.h +0 -1
index fc09505..8cc21f5 100644
@@ -15,7 +15,6 @@ extern Monitor *cur_mon;
 
 /* QMP events */
 typedef enum MonitorEvent {
-    QEVENT_DEBUG,
     QEVENT_SHUTDOWN,
     QEVENT_RESET,
     QEVENT_POWERDOWN,
vl.c +0 -1
index 2c766c4..3f580f5 100644
@@ -4054,7 +4054,6 @@ static void main_loop(void)
         } while (vm_can_run());
 
         if (qemu_debug_requested()) {
-            monitor_protocol_event(QEVENT_DEBUG, NULL);
             vm_stop(EXCP_DEBUG);
         }
         if (qemu_shutdown_requested()) {
Signature · 1 line
1.7.0.GIT
#6 lore raw

PATCH 5/5 QMP: Revamp the qmp-events.txt file

In reply to Luiz Capitulino

Now we can say it's useful, the following changes have been made:

- Put events in alphabetical order
- Add examples to all events
- Document all 'data' members
- Small corrections and cleanups

---
 QMP/qmp-events.txt |  170 ++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 133 insertions(+), 37 deletions(-)
QMP/qmp-events.txt +133 -37
index 9bf14d0..5ab5750 100644
@@ -1,60 +1,156 @@
-                   QEMU Monitor Protocol: Events
-                   =============================
+                   QEMU Monitor Protocol Events
+                   ============================
 
-1 SHUTDOWN
------------
+BLOCK_IO_ERROR
+--------------
+
+Emitted when a disk I/O error occurs.
+
+Data:
+
+- "device": device name (json-string)
+- "operation": I/O operation (json-string, "read" or "write")
+- "action": action that has been taken, it's one of the following (json-string):
+    "ignore": error has been ignored
+    "report": error has been reported to the device
+    "stop": error caused VM to be stopped
+
+Example:
+
+{ "event": "BLOCK_IO_ERROR",
+    "data": { "device": "ide0-hd1",
+              "operation": "write",
+              "action": "stop" },
+    "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
+
+Note: If action is "stop", a STOP event will eventually follow the
+BLOCK_IO_ERROR event.
+
+RESET
+-----
+
+Emitted when the Virtual Machine is reseted.
 
-Description: Issued when the Virtual Machine is powered down.
 Data: None.
 
-2 RESET
--------
+Example:
+
+{ "event": "RESET",
+    "timestamp": { "seconds": 1267041653, "microseconds": 9518 } }
+
+SHUTDOWN
+--------
+
+Emitted when the Virtual Machine is powered down.
 
-Description: Issued when the Virtual Machine is reseted.
 Data: None.
 
-3 STOP
-------
+Example:
+
+{ "event": "SHUTDOWN",
+    "timestamp": { "seconds": 1267040730, "microseconds": 682951 } }
+
+Note: If the command-line option "-no-shutdown" has been specified, a STOP
+event will eventually follow the SHUTDOWN event.
+
+STOP
+----
+
+Emitted when the Virtual Machine is stopped.
 
-Description: Issued when the Virtual Machine is stopped.
 Data: None.
 
-4 VNC_CONNECTED
----------------
+Example:
 
-Description: Issued when a VNC client establishes a connection.
-Data: 'server' and 'client' keys with the same keys as 'query-vnc',
-except that authentication ID is not provided.
+{ "event": "SHUTDOWN",
+    "timestamp": { "seconds": 1267041730, "microseconds": 281295 } }
 
-5 VNC_DISCONNECTED
-------------------
+VNC_CONNECTED
+-------------
 
-Description: Issued when the conection is closed.
-Data: 'server' and 'client' keys with the same keys as 'query-vnc'.
+Emitted when a VNC client establishes a connection.
+
+Data:
+
+- "server": Server information (json-object)
+  - "host": IP address (json-string)
+  - "service": port number (json-string)
+  - "family": address family (json-string, "ipv4" or "ipv6")
+  - "auth": authentication method (json-string, optional)
+- "client": Client information (json-object)
+  - "host": IP address (json-string)
+  - "service": port number (json-string)
+  - "family": address family (json-string, "ipv4" or "ipv6")
+
+Example:
 
-6 VNC_INITIALIZED
------------------
+{ "event": "VNC_CONNECTED",
+    "data": {
+        "server": { "auth": "sasl", "family": "ipv4",
+                    "service": "5901", "host": "0.0.0.0" },
+        "client": { "family": "ipv4", "service": "58425",
+                    "host": "127.0.0.1" } },
+    "timestamp": { "seconds": 1262976601, "microseconds": 975795 } }
 
-Description: Issued when the VNC session is made active.
-Data: 'server' and 'client' keys with the same keys as 'query-vnc'.
 
-7 BLOCK_IO_ERROR
+Note: This event is emitted before any authentication takes place, thus
+the authentication ID is not provided.
+
+VNC_DISCONNECTED
 ----------------
 
-Description: Issued when a disk I/O error occurs
+Emitted when the conection is closed.
+
 Data:
 
-- 'device': device name (json-string)
-- 'operation': I/O operation (json-string, "read" or "write")
-- 'action': action that has been taken, it's one of the following:
-    "ignore": error has been ignored
-    "report": error has been reported to the device
-    "stop": error caused VM to be stopped
+- "server": Server information (json-object)
+  - "host": IP address (json-string)
+  - "service": port number (json-string)
+  - "family": address family (json-string, "ipv4" or "ipv6")
+  - "auth": authentication method (json-string, optional)
+- "client": Client information (json-object)
+  - "host": IP address (json-string)
+  - "service": port number (json-string)
+  - "family": address family (json-string, "ipv4" or "ipv6")
+  - "x509_dname": TLS dname (json-string, optional)
+  - "sasl_username": SASL username (json-string, optional)
 
 Example:
 
-{ "event": "BLOCK_IO_ERROR",
-    "data": { "device": "ide0-hd1",
-              "operation": "write",
-              "action": "stop" },
-    "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
+{ "event": "VNC_DISCONNECTED",
+    "data": {
+        "server": { "auth": "sasl", "family": "ipv4",
+                    "service": "5901", "host": "0.0.0.0" },
+        "client": { "family": "ipv4", "service": "58425",
+                    "host": "127.0.0.1", "sasl_username": "luiz" } },
+    "timestamp": { "seconds": 1262976601, "microseconds": 975795 } }
+
+VNC_INITIALIZED
+---------------
+
+Emitted after authentication takes place (if any) and the VNC session is
+made active.
+
+Data:
+
+- "server": Server information (json-object)
+  - "host": IP address (json-string)
+  - "service": port number (json-string)
+  - "family": address family (json-string, "ipv4" or "ipv6")
+  - "auth": authentication method (json-string, optional)
+- "client": Client information (json-object)
+  - "host": IP address (json-string)
+  - "service": port number (json-string)
+  - "family": address family (json-string, "ipv4" or "ipv6")
+  - "x509_dname": TLS dname (json-string, optional)
+  - "sasl_username": SASL username (json-string, optional)
+
+Example:
+
+{ "event": "VNC_INITIALIZED",
+    "data": {
+        "server": { "auth": "sasl", "family": "ipv4",
+                    "service": "5901", "host": "0.0.0.0"},
+        "client": { "family": "ipv4", "service": "46089",
+                    "host": "127.0.0.1", "sasl_username": "luiz" } },
+        "timestamp": { "seconds": 1263475302, "microseconds": 150772 } }
Signature · 1 line
1.7.0.GIT