All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/5] QMP: BLOCK_IO_ERROR event handling
  2010-02-02 21:10 [Qemu-devel] [PATCH v0 0/5]: " Luiz Capitulino
@ 2010-02-02 21:10 ` Luiz Capitulino
  0 siblings, 0 replies; 8+ messages in thread
From: Luiz Capitulino @ 2010-02-02 21:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

This commit adds the basic definitions for the BLOCK_IO_ERROR
event, but actual event emission will be introduced by the
next commits.

NOTE: Adding a small reference in QMP/qmp-events.txt, but this
file is wrong and will be replaced by proper documentation shortly.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 QMP/qmp-events.txt |    7 +++++++
 monitor.c          |    3 +++
 monitor.h          |    1 +
 3 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt
index dc48ccc..7886192 100644
--- a/QMP/qmp-events.txt
+++ b/QMP/qmp-events.txt
@@ -43,3 +43,10 @@ Data: 'server' and 'client' keys with the same keys as 'query-vnc'.
 
 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
+----------------
+
+Description: Issued when a disk I/O error occurs
+Data: 'device' (device name), 'action' (action to be taken),
+      'operation' ("read" or "write")
diff --git a/monitor.c b/monitor.c
index fb7c572..6e688ac 100644
--- a/monitor.c
+++ b/monitor.c
@@ -378,6 +378,9 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)
         case QEVENT_VNC_DISCONNECTED:
             event_name = "VNC_DISCONNECTED";
             break;
+        case QEVENT_BLOCK_IO_ERROR:
+            event_name = "BLOCK_IO_ERROR";
+            break;
         default:
             abort();
             break;
diff --git a/monitor.h b/monitor.h
index b0f9270..e35f1e4 100644
--- a/monitor.h
+++ b/monitor.h
@@ -23,6 +23,7 @@ typedef enum MonitorEvent {
     QEVENT_VNC_CONNECTED,
     QEVENT_VNC_INITIALIZED,
     QEVENT_VNC_DISCONNECTED,
+    QEVENT_BLOCK_IO_ERROR,
     QEVENT_MAX,
 } MonitorEvent;
 
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v1 0/5]: BLOCK_IO_ERROR QMP event
@ 2010-02-03 14:40 Luiz Capitulino
  2010-02-03 14:41 ` [Qemu-devel] [PATCH 1/5] QMP: BLOCK_IO_ERROR event handling Luiz Capitulino
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Luiz Capitulino @ 2010-02-03 14:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

 Hi,

 This series adds the BLOCK_IO_ERROR event libvirt guys have requested.

changelog
---------

v0 -> v1

- Improve event documentation

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 1/5] QMP: BLOCK_IO_ERROR event handling
  2010-02-03 14:40 [Qemu-devel] [PATCH v1 0/5]: BLOCK_IO_ERROR QMP event Luiz Capitulino
@ 2010-02-03 14:41 ` Luiz Capitulino
  2010-02-10 18:32   ` Anthony Liguori
  2010-02-03 14:41 ` [Qemu-devel] [PATCH 2/5] block: BLOCK_IO_ERROR QMP event Luiz Capitulino
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Luiz Capitulino @ 2010-02-03 14:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

This commit adds the basic definitions for the BLOCK_IO_ERROR
event, but actual event emission will be introduced by the
next commits.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 QMP/qmp-events.txt |   21 +++++++++++++++++++++
 monitor.c          |    3 +++
 monitor.h          |    1 +
 3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt
index dc48ccc..d585a8d 100644
--- a/QMP/qmp-events.txt
+++ b/QMP/qmp-events.txt
@@ -43,3 +43,24 @@ Data: 'server' and 'client' keys with the same keys as 'query-vnc'.
 
 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
+----------------
+
+Description: Issued 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:
+    "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 } }
diff --git a/monitor.c b/monitor.c
index fb7c572..6e688ac 100644
--- a/monitor.c
+++ b/monitor.c
@@ -378,6 +378,9 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)
         case QEVENT_VNC_DISCONNECTED:
             event_name = "VNC_DISCONNECTED";
             break;
+        case QEVENT_BLOCK_IO_ERROR:
+            event_name = "BLOCK_IO_ERROR";
+            break;
         default:
             abort();
             break;
diff --git a/monitor.h b/monitor.h
index b0f9270..e35f1e4 100644
--- a/monitor.h
+++ b/monitor.h
@@ -23,6 +23,7 @@ typedef enum MonitorEvent {
     QEVENT_VNC_CONNECTED,
     QEVENT_VNC_INITIALIZED,
     QEVENT_VNC_DISCONNECTED,
+    QEVENT_BLOCK_IO_ERROR,
     QEVENT_MAX,
 } MonitorEvent;
 
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 2/5] block: BLOCK_IO_ERROR QMP event
  2010-02-03 14:40 [Qemu-devel] [PATCH v1 0/5]: BLOCK_IO_ERROR QMP event Luiz Capitulino
  2010-02-03 14:41 ` [Qemu-devel] [PATCH 1/5] QMP: BLOCK_IO_ERROR event handling Luiz Capitulino
@ 2010-02-03 14:41 ` Luiz Capitulino
  2010-02-03 14:41 ` [Qemu-devel] [PATCH 3/5] ide: Generate " Luiz Capitulino
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Luiz Capitulino @ 2010-02-03 14:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

This commit introduces the bdrv_mon_event() function, which
should be called by block subsystems (eg. IDE) when a I/O
error occurs, so that an QMP event is emitted.

The following information is currently provided in the event:

- device name
- operation (ie. "read" or "write")
- action taken (eg. "stop")

Event example:

{ "event": "BLOCK_IO_ERROR",
    "data": { "device": "ide0-hd1",
              "operation": "write",
              "action": "stop" },
    "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 block.c |   29 +++++++++++++++++++++++++++++
 block.h |    6 ++++++
 2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/block.c b/block.c
index 1919d19..2913124 100644
--- a/block.c
+++ b/block.c
@@ -1164,6 +1164,35 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
     return bs->drv->bdrv_is_allocated(bs, sector_num, nb_sectors, pnum);
 }
 
+void bdrv_mon_event(const BlockDriverState *bdrv,
+                    BlockMonEventAction action, int is_read)
+{
+    QObject *data;
+    const char *action_str;
+
+    switch (action) {
+    case BDRV_ACTION_REPORT:
+        action_str = "report";
+        break;
+    case BDRV_ACTION_IGNORE:
+        action_str = "ignore";
+        break;
+    case BDRV_ACTION_STOP:
+        action_str = "stop";
+        break;
+    default:
+        abort();
+    }
+
+    data = qobject_from_jsonf("{ 'device': %s, 'action': %s, 'operation': %s }",
+                              bdrv->device_name,
+                              action_str,
+                              is_read ? "read" : "write");
+    monitor_protocol_event(QEVENT_BLOCK_IO_ERROR, data);
+
+    qobject_decref(data);
+}
+
 static void bdrv_print_dict(QObject *obj, void *opaque)
 {
     QDict *bs_dict;
diff --git a/block.h b/block.h
index ecf66c5..a834300 100644
--- a/block.h
+++ b/block.h
@@ -44,6 +44,12 @@ typedef struct QEMUSnapshotInfo {
 #define BDRV_SECTOR_SIZE   (1 << BDRV_SECTOR_BITS)
 #define BDRV_SECTOR_MASK   ~(BDRV_SECTOR_SIZE - 1);
 
+typedef enum {
+    BDRV_ACTION_REPORT, BDRV_ACTION_IGNORE, BDRV_ACTION_STOP
+} BlockMonEventAction;
+
+void bdrv_mon_event(const BlockDriverState *bdrv,
+                    BlockMonEventAction action, int is_read);
 void bdrv_info_print(Monitor *mon, const QObject *data);
 void bdrv_info(Monitor *mon, QObject **ret_data);
 void bdrv_stats_print(Monitor *mon, const QObject *data);
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 3/5] ide: Generate BLOCK_IO_ERROR QMP event
  2010-02-03 14:40 [Qemu-devel] [PATCH v1 0/5]: BLOCK_IO_ERROR QMP event Luiz Capitulino
  2010-02-03 14:41 ` [Qemu-devel] [PATCH 1/5] QMP: BLOCK_IO_ERROR event handling Luiz Capitulino
  2010-02-03 14:41 ` [Qemu-devel] [PATCH 2/5] block: BLOCK_IO_ERROR QMP event Luiz Capitulino
@ 2010-02-03 14:41 ` Luiz Capitulino
  2010-02-03 14:41 ` [Qemu-devel] [PATCH 4/5] scsi: " Luiz Capitulino
  2010-02-03 14:41 ` [Qemu-devel] [PATCH 5/5] virtio-blk: " Luiz Capitulino
  4 siblings, 0 replies; 8+ messages in thread
From: Luiz Capitulino @ 2010-02-03 14:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

Just call bdrv_mon_event() in the right place.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 hw/ide/core.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/hw/ide/core.c b/hw/ide/core.c
index b6643e8..603e537 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -480,14 +480,17 @@ static int ide_handle_rw_error(IDEState *s, int error, int op)
     int is_read = (op & BM_STATUS_RETRY_READ);
     BlockInterfaceErrorAction action = drive_get_on_error(s->bs, is_read);
 
-    if (action == BLOCK_ERR_IGNORE)
+    if (action == BLOCK_ERR_IGNORE) {
+        bdrv_mon_event(s->bs, BDRV_ACTION_IGNORE, is_read);
         return 0;
+    }
 
     if ((error == ENOSPC && action == BLOCK_ERR_STOP_ENOSPC)
             || 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);
     } else {
         if (op & BM_STATUS_DMA_RETRY) {
             dma_buf_commit(s, 0);
@@ -495,6 +498,7 @@ static int ide_handle_rw_error(IDEState *s, int error, int op)
         } else {
             ide_rw_error(s);
         }
+        bdrv_mon_event(s->bs, BDRV_ACTION_REPORT, is_read);
     }
 
     return 1;
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 4/5] scsi: Generate BLOCK_IO_ERROR QMP event
  2010-02-03 14:40 [Qemu-devel] [PATCH v1 0/5]: BLOCK_IO_ERROR QMP event Luiz Capitulino
                   ` (2 preceding siblings ...)
  2010-02-03 14:41 ` [Qemu-devel] [PATCH 3/5] ide: Generate " Luiz Capitulino
@ 2010-02-03 14:41 ` Luiz Capitulino
  2010-02-03 14:41 ` [Qemu-devel] [PATCH 5/5] virtio-blk: " Luiz Capitulino
  4 siblings, 0 replies; 8+ messages in thread
From: Luiz Capitulino @ 2010-02-03 14:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

Just call bdrv_mon_event() in the right place.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 hw/scsi-disk.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index b34fbaa..1285122 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -182,16 +182,20 @@ static int scsi_handle_write_error(SCSIDiskReq *r, int error)
     BlockInterfaceErrorAction action =
         drive_get_on_error(s->qdev.dinfo->bdrv, 0);
 
-    if (action == BLOCK_ERR_IGNORE)
+    if (action == BLOCK_ERR_IGNORE) {
+        bdrv_mon_event(s->qdev.dinfo->bdrv, BDRV_ACTION_IGNORE, 0);
         return 0;
+    }
 
     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->qdev.dinfo->bdrv, BDRV_ACTION_STOP, 0);
     } else {
         scsi_command_complete(r, CHECK_CONDITION,
                 HARDWARE_ERROR);
+        bdrv_mon_event(s->qdev.dinfo->bdrv, BDRV_ACTION_REPORT, 0);
     }
 
     return 1;
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 5/5] virtio-blk: Generate BLOCK_IO_ERROR QMP event
  2010-02-03 14:40 [Qemu-devel] [PATCH v1 0/5]: BLOCK_IO_ERROR QMP event Luiz Capitulino
                   ` (3 preceding siblings ...)
  2010-02-03 14:41 ` [Qemu-devel] [PATCH 4/5] scsi: " Luiz Capitulino
@ 2010-02-03 14:41 ` Luiz Capitulino
  4 siblings, 0 replies; 8+ messages in thread
From: Luiz Capitulino @ 2010-02-03 14:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

Just call bdrv_mon_event() in the right place.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 hw/virtio-blk.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 037a79c..75adbec 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -105,16 +105,20 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,
         drive_get_on_error(req->dev->bs, is_read);
     VirtIOBlock *s = req->dev;
 
-    if (action == BLOCK_ERR_IGNORE)
+    if (action == BLOCK_ERR_IGNORE) {
+        bdrv_mon_event(req->dev->bs, BDRV_ACTION_IGNORE, is_read);
         return 0;
+    }
 
     if ((error == ENOSPC && action == BLOCK_ERR_STOP_ENOSPC)
             || 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);
     } else {
         virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
+        bdrv_mon_event(req->dev->bs, BDRV_ACTION_REPORT, is_read);
     }
 
     return 1;
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 1/5] QMP: BLOCK_IO_ERROR event handling
  2010-02-03 14:41 ` [Qemu-devel] [PATCH 1/5] QMP: BLOCK_IO_ERROR event handling Luiz Capitulino
@ 2010-02-10 18:32   ` Anthony Liguori
  0 siblings, 0 replies; 8+ messages in thread
From: Anthony Liguori @ 2010-02-10 18:32 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: kwolf, qemu-devel

On 02/03/2010 08:41 AM, Luiz Capitulino wrote:
> This commit adds the basic definitions for the BLOCK_IO_ERROR
> event, but actual event emission will be introduced by the
> next commits.
>
> Signed-off-by: Luiz Capitulino<lcapitulino@redhat.com>
>    

Applied all.  Thanks.

Regards,

Anthony Liguori
> ---
>   QMP/qmp-events.txt |   21 +++++++++++++++++++++
>   monitor.c          |    3 +++
>   monitor.h          |    1 +
>   3 files changed, 25 insertions(+), 0 deletions(-)
>
> diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt
> index dc48ccc..d585a8d 100644
> --- a/QMP/qmp-events.txt
> +++ b/QMP/qmp-events.txt
> @@ -43,3 +43,24 @@ Data: 'server' and 'client' keys with the same keys as 'query-vnc'.
>
>   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
> +----------------
> +
> +Description: Issued 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:
> +    "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 } }
> diff --git a/monitor.c b/monitor.c
> index fb7c572..6e688ac 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -378,6 +378,9 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)
>           case QEVENT_VNC_DISCONNECTED:
>               event_name = "VNC_DISCONNECTED";
>               break;
> +        case QEVENT_BLOCK_IO_ERROR:
> +            event_name = "BLOCK_IO_ERROR";
> +            break;
>           default:
>               abort();
>               break;
> diff --git a/monitor.h b/monitor.h
> index b0f9270..e35f1e4 100644
> --- a/monitor.h
> +++ b/monitor.h
> @@ -23,6 +23,7 @@ typedef enum MonitorEvent {
>       QEVENT_VNC_CONNECTED,
>       QEVENT_VNC_INITIALIZED,
>       QEVENT_VNC_DISCONNECTED,
> +    QEVENT_BLOCK_IO_ERROR,
>       QEVENT_MAX,
>   } MonitorEvent;
>
>    

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-02-10 18:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-03 14:40 [Qemu-devel] [PATCH v1 0/5]: BLOCK_IO_ERROR QMP event Luiz Capitulino
2010-02-03 14:41 ` [Qemu-devel] [PATCH 1/5] QMP: BLOCK_IO_ERROR event handling Luiz Capitulino
2010-02-10 18:32   ` Anthony Liguori
2010-02-03 14:41 ` [Qemu-devel] [PATCH 2/5] block: BLOCK_IO_ERROR QMP event Luiz Capitulino
2010-02-03 14:41 ` [Qemu-devel] [PATCH 3/5] ide: Generate " Luiz Capitulino
2010-02-03 14:41 ` [Qemu-devel] [PATCH 4/5] scsi: " Luiz Capitulino
2010-02-03 14:41 ` [Qemu-devel] [PATCH 5/5] virtio-blk: " Luiz Capitulino
  -- strict thread matches above, loose matches on Subject: below --
2010-02-02 21:10 [Qemu-devel] [PATCH v0 0/5]: " Luiz Capitulino
2010-02-02 21:10 ` [Qemu-devel] [PATCH 1/5] QMP: BLOCK_IO_ERROR event handling Luiz Capitulino

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.