qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [COMMIT 87b245d] virtio-blk: handle NULL returns from bdr


From: Anthony Liguori
Subject: [Qemu-commits] [COMMIT 87b245d] virtio-blk: handle NULL returns from bdrv_aio_{read, write}
Date: Fri, 28 Aug 2009 02:20:01 -0000

From: Christoph Hellwig <address@hidden>

The bdrv_aio_{read,write} routines can return a NULL pointer when the
I/O submission fails.  Currently we ignore this and will wait forever
for an I/O completion and leading to a hang of the guest.

I can easily reproduce this using the native Linux AIO patch, but it's
also possible using normal pthreads-based AIO.

Signed-off-by: Christoph Hellwig <address@hidden>
Signed-off-by: Anthony Liguori <address@hidden>

diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index c278d2e..c160246 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -254,14 +254,24 @@ static void virtio_blk_handle_scsi(VirtIOBlockReq *req)
 
 static void virtio_blk_handle_write(VirtIOBlockReq *req)
 {
-    bdrv_aio_writev(req->dev->bs, req->out->sector, &req->qiov,
-                    req->qiov.size / 512, virtio_blk_rw_complete, req);
+    BlockDriverAIOCB *acb;
+
+    acb = bdrv_aio_writev(req->dev->bs, req->out->sector, &req->qiov,
+                          req->qiov.size / 512, virtio_blk_rw_complete, req);
+    if (!acb) {
+        virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
+    }
 }
 
 static void virtio_blk_handle_read(VirtIOBlockReq *req)
 {
-    bdrv_aio_readv(req->dev->bs, req->out->sector, &req->qiov,
-                   req->qiov.size / 512, virtio_blk_rw_complete, req);
+    BlockDriverAIOCB *acb;
+
+    acb = bdrv_aio_readv(req->dev->bs, req->out->sector, &req->qiov,
+                         req->qiov.size / 512, virtio_blk_rw_complete, req);
+    if (!acb) {
+        virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
+    }
 }
 
 static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]