From 4f4f397502a1e29d025c81980f6a552bcc0cb22a Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Tue, 5 Sep 2017 17:13:50 +0200 Subject: [PATCH] vhost: use full path when unregistering sockets on shutdown This patch properly closes sockets on shutdown. Previous rte_vhost_driver_unregister calls were returning immediately due to inexistent sockets at given paths. Change-Id: I5e4d64f04fc8b6bef914c2eb4c4d2220be9ca9ec Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/377165 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- lib/vhost/vhost.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index bc922724d..eaa4099fa 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -712,6 +712,7 @@ static void * session_shutdown(void *arg) { struct spdk_vhost_dev *vdev = NULL; + char path[PATH_MAX]; int i; for (i = 0; i < MAX_VHOST_DEVICES; i++) { @@ -719,7 +720,15 @@ session_shutdown(void *arg) if (vdev == NULL) { continue; } - rte_vhost_driver_unregister(vdev->name); + + if (snprintf(path, sizeof(path), "%s%s", dev_dirname, vdev->name) >= (int)sizeof(path)) { + SPDK_ERRLOG("Resulting socket path for controller %s is too long: %s%s\n", vdev->name, dev_dirname, + vdev->name); + assert(false); + continue; + } + + rte_vhost_driver_unregister(path); } SPDK_NOTICELOG("Exiting\n");