diff --git a/lib/vhost/rte_vhost_user.c b/lib/vhost/rte_vhost_user.c index f6413a06c..a9a7df327 100644 --- a/lib/vhost/rte_vhost_user.c +++ b/lib/vhost/rte_vhost_user.c @@ -1777,9 +1777,9 @@ vhost_user_dev_register(struct spdk_vhost_dev *vdev, const char *name, struct sp return -EIO; } - vdev->registered = true; user_dev->user_backend = user_backend; user_dev->vdev = vdev; + user_dev->registered = true; TAILQ_INIT(&user_dev->vsessions); vhost_user_dev_set_coalescing(user_dev, SPDK_VHOST_COALESCING_DELAY_BASE_US, @@ -1810,12 +1810,10 @@ vhost_user_dev_unregister(struct spdk_vhost_dev *vdev) return -EBUSY; } - if (vdev->registered && vhost_driver_unregister(vdev->path) != 0) { - SPDK_ERRLOG("Could not unregister controller %s with vhost library\n" - "Check if domain socket %s still exists\n", - vdev->name, vdev->path); - return -EIO; - } + /* There are no valid connections now, and it's not an error if the domain + * socket was already removed by shutdown thread. + */ + vhost_driver_unregister(vdev->path); spdk_thread_send_msg(vdev->thread, vhost_dev_thread_exit, NULL); free(user_dev); @@ -1880,7 +1878,6 @@ vhost_user_session_shutdown(void *vhost_cb) } spdk_vhost_unlock(); vhost_driver_unregister(vdev->path); - vdev->registered = false; } SPDK_INFOLOG(vhost, "Exiting\n"); diff --git a/lib/vhost/vhost_internal.h b/lib/vhost/vhost_internal.h index bc9a56538..12115eccb 100644 --- a/lib/vhost/vhost_internal.h +++ b/lib/vhost/vhost_internal.h @@ -154,6 +154,8 @@ struct spdk_vhost_user_dev { uint32_t coalescing_delay_us; uint32_t coalescing_iops_threshold; + bool registered; + /* Current connections to the device */ TAILQ_HEAD(, spdk_vhost_session) vsessions; @@ -172,7 +174,6 @@ struct spdk_vhost_dev { char *path; struct spdk_thread *thread; - bool registered; uint64_t virtio_features; uint64_t disabled_features;