Received: from eggs.gnu.org ([2001:4830:134:3::10]:50515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjGM2-0004Wf-Cq for qemu-devel@nongnu.org; Sun, 11 Sep 2016 21:48:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjGLx-0003uy-CZ for qemu-devel@nongnu.org; Sun, 11 Sep 2016 21:48:13 -0400 From: Fam Zheng Date: Mon, 12 Sep 2016 09:48:04 +0800 Message-Id: <1473644884-31378-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH] virtio-scsi: Report BAD_TARGET if device is not available List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-stable@nongnu.org Ejected devices cannot complete the IO, so we can fail it early. This is also a fix to a crash for dataplane in that case, since the assert(blk_get_aio_context(d->conf.blk) == s->ctx); below won't hold because blk_get_aio_context will return qemu_aio_ctx for ejected devices, where as s->ctx is the assigned IOThread ctx. Cc: qemu-stable@nongnu.org Signed-off-by: Fam Zheng --- hw/scsi/virtio-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index ce57ef6..5376e46 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -534,7 +534,7 @@ static bool virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *req } d = virtio_scsi_device_find(s, req->req.cmd.lun); - if (!d) { + if (!d || !blk_is_available(d->conf.blk)) { req->resp.cmd.response = VIRTIO_SCSI_S_BAD_TARGET; virtio_scsi_complete_cmd_req(req); return false; -- 2.7.4