Skip to contentSkip to conversation

virtio-scsi: Report BAD_TARGET if device is not available

PATCH New Fam Zheng 1 participant 1 message Sep 12, 2016

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 virtio-scsi: Report BAD_TARGET if device is not available

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.

---
 hw/scsi/virtio-scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/virtio-scsi.c +1 -1
index ce57ef6..5376e46 100644
@@ -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;
Signature · 1 line
2.7.4