From cbc7958818536f62f7de8f0f8fd5b40d050dac00 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: <933ebfcd0e18f4ed2c68553cf4bc257652872678.1429739396.git.jen@redhat.com> References: <933ebfcd0e18f4ed2c68553cf4bc257652872678.1429739396.git.jen@redhat.com> From: Fam Zheng Date: Wed, 11 Mar 2015 02:44:58 -0500 Subject: [CHANGE 02/11] virtio-blk: Check return value of blk_aio_ioctl To: rhvirt-patches@redhat.com, jen@redhat.com RH-Author: Fam Zheng Message-id: <1426041898-24877-3-git-send-email-famz@redhat.com> Patchwork-id: 64265 O-Subject: [RHEL-6.7 qemu-kvm PATCH v2 2/2] virtio-blk: Check return value of blk_aio_ioctl Bugzilla: 1006871 RH-Acked-by: Paolo Bonzini RH-Acked-by: Kevin Wolf RH-Acked-by: Stefan Hajnoczi Since commit 1dc936aa84 (virtio-blk: Use blk_aio_ioctl) we silently lose the request if blk_aio_ioctl returns NULL (not implemented). Fix it by directly returning VIRTIO_BLK_S_UNSUPP as we used to do. Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi [ kwolf: Fixed build error on win32 ] Signed-off-by: Kevin Wolf (cherry picked from commit a209f4615c6853a226e847810b6c607c71b6a046) Signed-off-by: Fam Zheng Signed-off-by: Jeff E. Nelson Conflicts: hw/block/virtio-blk.c Downstream file is hw/virtio-blk.c, applied manually. --- hw/virtio-blk.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) Signed-off-by: Jeff E. Nelson --- hw/virtio-blk.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 2e01ceb..999deef 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -199,6 +199,7 @@ static void virtio_blk_handle_scsi(VirtIOBlockReq *req) int size = 0; int i; VirtIOBlockIoctlReq *ioctl_req; + BlockDriverAIOCB *acb; VirtQueueElement *elem = &req->elem; if ((req->dev->vdev.guest_features & (1 << VIRTIO_BLK_F_SCSI)) == 0) { @@ -278,8 +279,13 @@ static void virtio_blk_handle_scsi(VirtIOBlockReq *req) ioctl_req->hdr.sbp = req->elem.in_sg[req->elem.in_num - 3].iov_base; ioctl_req->hdr.mx_sb_len = req->elem.in_sg[req->elem.in_num - 3].iov_len; - bdrv_aio_ioctl(req->dev->bs, SG_IO, &ioctl_req->hdr, - virtio_blk_ioctl_complete, ioctl_req); + acb = bdrv_aio_ioctl(req->dev->bs, SG_IO, &ioctl_req->hdr, + virtio_blk_ioctl_complete, ioctl_req); + if (!acb) { + g_free(ioctl_req); + virtio_blk_req_complete(req, VIRTIO_BLK_S_UNSUPP); + qemu_free(req); + } } #else static void virtio_blk_handle_scsi(VirtIOBlockReq *req) -- 2.1.0