diff --git a/lib/vhost/vhost_scsi.c b/lib/vhost/vhost_scsi.c index 10b25847c..5c5406bf1 100644 --- a/lib/vhost/vhost_scsi.c +++ b/lib/vhost/vhost_scsi.c @@ -724,7 +724,7 @@ spdk_vhost_scsi_dev_add_dev(struct spdk_vhost_dev *vdev, unsigned scsi_dev_num, return -EINVAL; } - if (vdev->lcore != -1) { + if (vdev->lcore != -1 && !spdk_vhost_dev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) { SPDK_ERRLOG("Controller %s is in use and hotplug is not supported\n", vdev->name); return -ENOTSUP; } @@ -751,6 +751,12 @@ spdk_vhost_scsi_dev_add_dev(struct spdk_vhost_dev *vdev, unsigned scsi_dev_num, return -EINVAL; } spdk_scsi_dev_add_port(svdev->scsi_dev[scsi_dev_num], 0, "vhost"); + + if (vdev->lcore != -1) { + spdk_scsi_dev_allocate_io_channels(svdev->scsi_dev[scsi_dev_num]); + eventq_enqueue(svdev, scsi_dev_num, VIRTIO_SCSI_T_TRANSPORT_RESET, VIRTIO_SCSI_EVT_RESET_RESCAN); + } + SPDK_NOTICELOG("Controller %s: defined device '%s' using lun '%s'\n", vdev->name, dev_name, lun_name); return 0; diff --git a/test/vhost/fiotest/autotest.sh b/test/vhost/fiotest/autotest.sh index 6e92aa2db..25416522e 100755 --- a/test/vhost/fiotest/autotest.sh +++ b/test/vhost/fiotest/autotest.sh @@ -250,6 +250,26 @@ done $COMMON_DIR/vm_run.sh $x --work-dir=$TEST_DIR $used_vms vm_wait_for_boot 600 $used_vms +if [[ $test_type == "spdk_vhost_scsi" ]]; then + for vm_conf in ${vms[@]}; do + IFS=',' read -ra conf <<< "$vm_conf" + while IFS=':' read -ra disks; do + for disk in "${disks[@]}"; do + echo "INFO: Hotdetach test. Trying to remove existing device from a controller naa.$disk.${conf[0]}" + $rpc_py remove_vhost_scsi_dev naa.$disk.${conf[0]} 0 + + sleep 0.1 + + echo "INFO: Hotattach test. Re-adding device 0 to naa.$disk.${conf[0]}" + $rpc_py add_vhost_scsi_lun naa.$disk.${conf[0]} 0 $disk + done + done <<< "${conf[2]}" + unset IFS; + done +fi + +sleep 0.1 + echo "===============" echo "" echo "INFO: Testing..."