From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 8328B1DB1 for ; Thu, 2 Jul 2015 05:33:18 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 01 Jul 2015 20:33:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,389,1432623600"; d="scan'208";a="517561555" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 01 Jul 2015 20:33:16 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t623XEJd006647; Thu, 2 Jul 2015 11:33:14 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t623XB6Q020437; Thu, 2 Jul 2015 11:33:13 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t623XABR020433; Thu, 2 Jul 2015 11:33:10 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Thu, 2 Jul 2015 11:33:03 +0800 Message-Id: <1435807983-20383-4-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1435807983-20383-1-git-send-email-changchun.ouyang@intel.com> References: <1435807983-20383-1-git-send-email-changchun.ouyang@intel.com> Subject: [dpdk-dev] [PATCH 3/3] vhost: call api to unregister vhost driver X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jul 2015 03:33:19 -0000 The commit will break 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 second time startup. Signed-off-by: Changchun Ouyang --- examples/vhost/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 72c4773..90666b3 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -2871,6 +2871,16 @@ setup_mempool_tbl(int socket, uint32_t index, char *pool_name, } } +/* When we receive a HUP signal, unregister vhost driver */ +static void +sighup_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, sighup_handler); + /* init EAL */ ret = rte_eal_init(argc, argv); if (ret < 0) @@ -3060,6 +3072,12 @@ main(int argc, char *argv[]) /* Start CUSE session. */ rte_vhost_driver_session_start(); + + /* Unregister vhost driver. */ + ret = rte_vhost_driver_unregister((char *)&dev_basename); + if (ret != 0) + rte_exit(EXIT_FAILURE,"vhost driver unregister failure.\n"); + return 0; } -- 1.8.4.2