aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio-blk.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-08-13 16:49:56 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-08-27 20:30:23 -0500
commit87b245db05aac9bcdb70a4f0af0fc5f353c5a9f8 (patch)
tree276c407258d25658da8d2ee2290a1b716825d3a7 /hw/virtio-blk.c
parent5c6c3a6c54b23caa84fb4e046e85a461612279bb (diff)
virtio-blk: handle NULL returns from bdrv_aio_{read, write}
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 <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-blk.c')
-rw-r--r--hw/virtio-blk.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index c278d2ef0a..c1602460ba 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)