[RFC 3/3] vhost: improve VDUSE reconnect handler cleanup

Maxime Coquelin maxime.coquelin at redhat.com
Tue Dec 24 16:49:58 CET 2024


This patch makes use of the new FD entry cleanup callback
to close the VDUSE reconnect eventfd after its removal
from the FD set.

Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
 lib/vhost/vduse.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
index 9c10fbc684..a841da966c 100644
--- a/lib/vhost/vduse.c
+++ b/lib/vhost/vduse.c
@@ -563,16 +563,21 @@ vduse_reconnect_log_check(struct virtio_net *dev, uint64_t features, uint32_t to
 }
 
 static void
-vduse_reconnect_handler(int fd, void *arg, int *remove)
+vduse_reconnect_handler(int fd __rte_unused, void *arg, int *remove)
 {
 	struct virtio_net *dev = arg;
 
 	vduse_device_start(dev, true);
 
-	close(fd);
 	*remove = 1;
 }
 
+static void
+vduse_reconnect_handler_cleanup(int fd, void *arg __rte_unused)
+{
+	close(fd);
+}
+
 static int
 vduse_reconnect_start_device(struct virtio_net *dev)
 {
@@ -590,7 +595,8 @@ vduse_reconnect_start_device(struct virtio_net *dev)
 		goto out_err;
 	}
 
-	ret = fdset_add(vduse.fdset, fd, vduse_reconnect_handler, NULL, NULL, dev);
+	ret = fdset_add(vduse.fdset, fd, vduse_reconnect_handler, NULL,
+			vduse_reconnect_handler_cleanup, dev);
 	if (ret) {
 		VHOST_CONFIG_LOG(dev->ifname, ERR, "Failed to add reconnect efd %d to vduse fdset",
 				fd);
-- 
2.47.1



More information about the dev mailing list