[dpdk-dev,v2,3/3] vhost: call api to unregister vhost driver
Commit Message
The following commit broke vhost sample when it runs in second time:
292959c71961acde0cda6e77e737bb0a4df1559c
It should call api to unregister vhost driver when sample exit/quit, then
the socket file will be removed(by calling unlink), and thus make vhost sample
work correctly in the second time startup.
Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
---
examples/vhost/main.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
change in v2:
- refine the signal handler name
@@ -2871,6 +2871,16 @@ setup_mempool_tbl(int socket, uint32_t index, char *pool_name,
}
}
+/* When we receive a INT signal, unregister vhost driver */
+static void
+sigint_handler(__rte_unused int signum)
+{
+ /* Unregister vhost driver. */
+ int ret = rte_vhost_driver_unregister((char *)&dev_basename);
+ if (ret != 0)
+ rte_exit(EXIT_FAILURE, "vhost driver unregister failure.\n");
+ exit(0);
+}
/*
* Main function, does initialisation and calls the per-lcore functions. The CUSE
@@ -2887,6 +2897,8 @@ main(int argc, char *argv[])
uint16_t queue_id;
static pthread_t tid;
+ signal(SIGINT, sigint_handler);
+
/* init EAL */
ret = rte_eal_init(argc, argv);
if (ret < 0)