From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 982E5E72 for ; Thu, 2 Jul 2015 18:04:11 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 02 Jul 2015 09:04:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,393,1432623600"; d="scan'208";a="757320746" Received: from pgsmsx106.gar.corp.intel.com ([10.221.44.98]) by orsmga002.jf.intel.com with ESMTP; 02 Jul 2015 09:04:09 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by PGSMSX106.gar.corp.intel.com (10.221.44.98) with Microsoft SMTP Server (TLS) id 14.3.224.2; Fri, 3 Jul 2015 00:04:08 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.246]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.129]) with mapi id 14.03.0224.002; Fri, 3 Jul 2015 00:04:00 +0800 From: "Xie, Huawei" To: "Ouyang, Changchun" , "dev@dpdk.org" Thread-Topic: [PATCH 3/3] vhost: call api to unregister vhost driver Thread-Index: AdC04LT2dqiDBgyIQUiz52lyO0XQNQ== Date: Thu, 2 Jul 2015 16:04:00 +0000 Message-ID: References: <1435807983-20383-1-git-send-email-changchun.ouyang@intel.com> <1435807983-20383-4-git-send-email-changchun.ouyang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [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 16:04:12 -0000 On 7/2/2015 11:33 AM, Ouyang, Changchun wrote:=0A= > The commit will break vhost sample when it runs in second time:=0A= > 292959c71961acde0cda6e77e737bb0a4df1559c=0A= >=0A= > It should call api to unregister vhost driver when sample exit/quit, then= =0A= > the socket file will be removed(by calling unlink), and thus make vhost s= ample=0A= > work correctly in second time startup.=0A= >=0A= > Signed-off-by: Changchun Ouyang =0A= > ---=0A= > examples/vhost/main.c | 18 ++++++++++++++++++=0A= > 1 file changed, 18 insertions(+)=0A= >=0A= > diff --git a/examples/vhost/main.c b/examples/vhost/main.c=0A= > index 72c4773..90666b3 100644=0A= > --- a/examples/vhost/main.c=0A= > +++ b/examples/vhost/main.c=0A= > @@ -2871,6 +2871,16 @@ setup_mempool_tbl(int socket, uint32_t index, char= *pool_name,=0A= > }=0A= > }=0A= > =0A= > +/* When we receive a HUP signal, unregister vhost driver */=0A= > +static void=0A= > +sighup_handler(__rte_unused int signum)=0A= > +{=0A= > + /* Unregister vhost driver. */=0A= > + int ret =3D rte_vhost_driver_unregister((char *)&dev_basename);=0A= > + if (ret !=3D 0)=0A= > + rte_exit(EXIT_FAILURE, "vhost driver unregister failure.\n");=0A= > + exit(0);=0A= > +}=0A= > =0A= > /*=0A= > * Main function, does initialisation and calls the per-lcore functions.= The CUSE=0A= > @@ -2887,6 +2897,8 @@ main(int argc, char *argv[])=0A= > uint16_t queue_id;=0A= > static pthread_t tid;=0A= > =0A= > + signal(SIGINT, sighup_handler);=0A= > +=0A= =0A= ignor if duplciated.=0A= sighup->sigint=0A= =0A= > /* init EAL */=0A= > ret =3D rte_eal_init(argc, argv);=0A= > if (ret < 0)=0A= > @@ -3060,6 +3072,12 @@ main(int argc, char *argv[])=0A= > =0A= > /* Start CUSE session. */=0A= > rte_vhost_driver_session_start();=0A= > +=0A= > + /* Unregister vhost driver. */=0A= > + ret =3D rte_vhost_driver_unregister((char *)&dev_basename);=0A= > + if (ret !=3D 0)=0A= > + rte_exit(EXIT_FAILURE,"vhost driver unregister failure.\n");=0A= > +=0A= > return 0;=0A= > =0A= > }=0A= =0A=