app/testpmd: fix exit for virtio-user
authorZhiyong Yang <zhiyong.yang@intel.com>
Fri, 18 May 2018 09:59:37 +0000 (17:59 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 22 May 2018 22:35:00 +0000 (00:35 +0200)
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 <zhiyong.yang@intel.com>
Tested-by: Lei Yao <lei.a.yao@intel.com>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
app/test-pmd/testpmd.c

index 017cc61..c3990d6 100644 (file)
@@ -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);
                }
        }