38 lines
1.3 KiB
Diff
38 lines
1.3 KiB
Diff
|
|
From 4e5de00fb124d82f9c4ce2ac433ed3d691783c01 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Jinhua Cao <caojinhua1@huawei.com>
|
||
|
|
Date: Wed, 9 Feb 2022 19:58:21 +0800
|
||
|
|
Subject: [PATCH] virtio-scsi: bugfix: fix qemu crash for hotplug scsi disk
|
||
|
|
with dataplane
|
||
|
|
|
||
|
|
The vm will trigger a disk sweep operation after plugging
|
||
|
|
a controller who's io type is iothread. If attach a scsi
|
||
|
|
disk immediately, the sg_inqury request in vm will trigger
|
||
|
|
the assert in virtio_scsi_ctx_check(), which is called by
|
||
|
|
virtio_scsi_handle_cmd_req_prepare().
|
||
|
|
|
||
|
|
Add judgment in virtio_scsi_handle_cmd_req_prepare() and
|
||
|
|
return IO Error directly if the device has not been
|
||
|
|
initialized.
|
||
|
|
|
||
|
|
Signed-off-by: Jinhua Cao <caojinhua1@huawei.com>
|
||
|
|
---
|
||
|
|
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 9c751bf296..bc7feb404a 100644
|
||
|
|
--- a/hw/scsi/virtio-scsi.c
|
||
|
|
+++ b/hw/scsi/virtio-scsi.c
|
||
|
|
@@ -781,7 +781,7 @@ static int virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *req)
|
||
|
|
req->req.cmd.tag, req->req.cmd.cdb[0]);
|
||
|
|
|
||
|
|
d = virtio_scsi_device_get(s, req->req.cmd.lun);
|
||
|
|
- if (!d) {
|
||
|
|
+ if (!d || !d->qdev.realized) {
|
||
|
|
req->resp.cmd.response = VIRTIO_SCSI_S_BAD_TARGET;
|
||
|
|
virtio_scsi_complete_cmd_req(req);
|
||
|
|
return -ENOENT;
|
||
|
|
--
|
||
|
|
2.27.0
|
||
|
|
|