Message ID | 1473644884-31378-1-git-send-email-famz@redhat.com |
---|---|
State | New |
Headers | show |
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;
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 <famz@redhat.com> --- hw/scsi/virtio-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)