From 124909d7e1bf299c959b58c2db7c5fbd7abbb7c0 Mon Sep 17 00:00:00 2001 From: Zhiyong Yang Date: Fri, 18 May 2018 17:59:37 +0800 Subject: [PATCH] app/testpmd: fix exit for virtio-user For vdev, just calling rte_eth_dev_close() isn't enough to free all the resources allocated during device probe, e.g. for virtio-user, virtio_user_pmd_remove(), i.e. the remove() method of a vdev driver, needs to be called to unlink the socket file created during device probe. So this patch calls the rte_eth_dev_detach() for vdev when quitting testpmd. vdevs detach on testpmd exit implemented as workaround to fix a virtio-user issue. The issue was virtio-user cleanup is not called and existing socket file not cleaned up which will fail next run. Added a comment that this workaround should be converted to a proper cleanup, not something specific to virtio-user, and not something specific to vdev and testpmd. Fixes: af75078fece3 ("first public release") Fixes: bd8f50a45d0f ("net/virtio-user: support server mode") Cc: stable@dpdk.org Signed-off-by: Zhiyong Yang Tested-by: Lei Yao Acked-by: Bernard Iremonger --- app/test-pmd/testpmd.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 017cc618fa..c3990d6937 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2014,6 +2014,7 @@ detach_port(portid_t port_id) void pmd_test_exit(void) { + struct rte_device *device; portid_t pt_id; int ret; @@ -2027,6 +2028,18 @@ pmd_test_exit(void) fflush(stdout); stop_port(pt_id); close_port(pt_id); + + /* + * This is a workaround to fix a virtio-user issue that + * requires to call clean-up routine to remove existing + * socket. + * This workaround valid only for testpmd, needs a fix + * valid for all applications. + * TODO: Implement proper resource cleanup + */ + device = rte_eth_devices[pt_id].device; + if (device && !strcmp(device->driver->name, "net_virtio_user")) + detach_port(pt_id); } } -- 2.20.1