From 0389c9f9e06cc3a9933b525b7c68fc1225a93c39 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Mon, 1 Apr 2019 00:11:56 +0200 Subject: [PATCH] vhost/scsi: don't send hotremove sense codes after session restart Always unset the VHOST_SCSI_DEV_REMOVED status on session stop, so that we won't send hotremove SCSI sense codes after e.g. a VM gets rebooted. The VM should generally enumerate the SCSI devices again in such case. We already unset the REMOVED status for devices which were still attached at the time of the session stop, but the devices hotremoved before the session stop retained their REMOVED status, giving us inconsistent behavior. Change-Id: I7c5876e29f4bdc99cc060f1d891e24ac57051f37 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449709 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu --- lib/vhost/vhost_scsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/vhost/vhost_scsi.c b/lib/vhost/vhost_scsi.c index 8808c8988..f8e24e45c 100644 --- a/lib/vhost/vhost_scsi.c +++ b/lib/vhost/vhost_scsi.c @@ -1416,14 +1416,15 @@ destroy_session_poller_cb(void *arg) enum spdk_scsi_dev_vhost_status prev_status; state = &svsession->scsi_dev_state[i]; + /* clear the REMOVED status so that we won't send hotremove events anymore */ + prev_status = state->status; + state->status = VHOST_SCSI_DEV_EMPTY; if (state->dev == NULL) { continue; } spdk_scsi_dev_free_io_channels(state->dev); - prev_status = state->status; - state->status = VHOST_SCSI_DEV_EMPTY; state->dev = NULL; if (prev_status == VHOST_SCSI_DEV_REMOVING) {