From 47cf47e48222c5dab73abbbc695ec107d52f4f55 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Wed, 24 Apr 2019 01:44:31 +0200 Subject: [PATCH] vhost/scsi: don't send events when eventq is unset We do technically support initiators without eventq or controlq, but the lun hotplug/hotremove path expected the eventq to be always present. This was causing vhost to randomly crash in the fuzz tests. Specifically, the crash happened if lun hotplug was handled while a VM was in the middle of switching from BIOS to OS. We fix it by checking if eventq is set before putting any event there. LUN hotplug and hotremove won't work without an eventq, but the entire session will be restarted after new queues are initialized. This will make the VM retrieve all up-to-date luns after OS initialization is complete. Change-Id: I5d28cbedad8fb2a35ede5a491aeb7fdc52faad06 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/451789 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu --- lib/vhost/vhost_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vhost/vhost_scsi.c b/lib/vhost/vhost_scsi.c index 8137286f7..99498184c 100644 --- a/lib/vhost/vhost_scsi.c +++ b/lib/vhost/vhost_scsi.c @@ -276,7 +276,7 @@ eventq_enqueue(struct spdk_vhost_scsi_session *svsession, unsigned scsi_dev_num, assert(scsi_dev_num < SPDK_VHOST_SCSI_CTRLR_MAX_DEVS); vq = &vsession->virtqueue[VIRTIO_SCSI_EVENTQ]; - if (spdk_vhost_vq_avail_ring_get(vq, &req, 1) != 1) { + if (vq->vring.desc == NULL || spdk_vhost_vq_avail_ring_get(vq, &req, 1) != 1) { SPDK_ERRLOG("Controller %s: Failed to send virtio event (no avail ring entries?).\n", vdev->name); return;