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>
38 lines
1.3 KiB
Diff
38 lines
1.3 KiB
Diff
From 98cbb6d13484e79b6f9da064a40a281f2983be1d 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 51fd09522a..781a37fe89 100644
|
|
--- a/hw/scsi/virtio-scsi.c
|
|
+++ b/hw/scsi/virtio-scsi.c
|
|
@@ -638,7 +638,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
|
|
|