From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id D4A7B32A5 for ; Sun, 13 Mar 2016 13:55:53 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 13 Mar 2016 05:54:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,331,1455004800"; d="scan'208";a="909187368" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 13 Mar 2016 05:54:32 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 13 Mar 2016 05:54:32 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 13 Mar 2016 05:54:31 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.24]) by shsmsx102.ccr.corp.intel.com ([169.254.2.232]) with mapi id 14.03.0248.002; Sun, 13 Mar 2016 20:54:30 +0800 From: "Liu, Yong" To: "Tu, LijuanX A" , "dts@dpdk.org" Thread-Topic: [dts][PATCH]framework: Delete NetDevice object after virtual machine shutdown Thread-Index: AQHRe3aU4RxvjjBhvUyUR3ZUoRVRXJ9XVuwA Date: Sun, 13 Mar 2016 12:54:29 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E14EC290D@SHSMSX103.ccr.corp.intel.com> References: <1457687076-86691-1-git-send-email-lijuanx.a.tu@intel.com> In-Reply-To: <1457687076-86691-1-git-send-email-lijuanx.a.tu@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzIwNzIyZmQtMzc2My00MmM0LWEzOGItZDY3ZmY3ZDJlZmJiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkI5U3NEaWFcL0ErcDE3RHo5bnhEK3JtWGZXd1FEa3gzRkptSmNQckxzSXJrPSJ9 x-ctpclassification: CTP_IC 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: [dts] [PATCH]framework: Delete NetDevice object after virtual machine shutdown X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Mar 2016 12:55:57 -0000 Hi Lijuan, > -----Original Message----- > From: Tu, LijuanX A > Sent: Friday, March 11, 2016 5:05 PM > To: dts@dpdk.org; Liu, Yong > Cc: Tu, LijuanX A > Subject: [dts][PATCH]framework: Delete NetDevice object after virtual > machine shutdown >=20 > Signed-off-by: Lijuan Tu > --- > framework/virt_dut.py | 16 ++++++++++++++++ > nics/net_device.py | 15 +++++++++++++++ > 2 files changed, 31 insertions(+) >=20 > diff --git a/framework/virt_dut.py b/framework/virt_dut.py > index 9bf75dc..019a9f2 100644 > --- a/framework/virt_dut.py > +++ b/framework/virt_dut.py > @@ -39,6 +39,7 @@ from settings import NICS, LOG_NAME_SEP, get_netdev > from project_dpdk import DPDKdut > from dut import Dut > from net_device import GetNicObj > +from net_device import RemoveNicObj >=20 >=20 > class VirtDut(DPDKdut): > @@ -75,10 +76,25 @@ class VirtDut(DPDKdut): > self.logger.config_suite(self.host_dut.test_classname, 'virtdut'= ) >=20 > def close(self): > + # Close ssh session > if self.session: > self.session.close() > + self.session =3D None > if self.alt_session: > self.alt_session.close() > + self.alt_session =3D None > + > + # Remove Network object > + vf_ports =3D self.get_vf_net_divce() > + RemoveNicObj(self, vf_ports) > + RemoveNicObj remove all network objects from crb, there's no need to genera= te VF list. Just call RemoveNicObjs(self) is enough. > + def get_vf_net_divce(self): > + vf_port =3D [] > + for port_info in self.host_dut.ports_info: > + if 'vfs_port' in port_info.keys(): > + for port in port_info['vfs_port']: > + vf_port.append(port) > + return vf_port >=20 > def set_nic_type(self, nic_type): > """ > diff --git a/nics/net_device.py b/nics/net_device.py > index 73750f5..8c967ae 100644 > --- a/nics/net_device.py > +++ b/nics/net_device.py > @@ -830,6 +830,14 @@ def get_from_list(host, bus_id, devfun_id): > return nic['port'] > return None >=20 > +def remove_from_list(host, obj): > + """ > + Remove network device object from global structure > + Parameter will by host ip, netdevice object > + """ > + for nic in NICS_LIST: > + if host =3D=3D nic['host']: > + NICS_LIST.remove(nic) >=20 In this function, parameter obj is useless. If only intend to remove all ne= twork objects of crb, only need one parameter. > def GetNicObj(crb, bus_id, devfun_id): > """ > @@ -862,3 +870,10 @@ def GetNicObj(crb, bus_id, devfun_id): >=20 > add_to_list(crb.crb['My IP'], obj) > return obj > + > +def RemoveNicObj(crb, objs): > + """ > + Remove network device object. > + """ > + for obj in objs: > + remove_from_list(crb.crb['My IP'], obj) > -- > 2.5.0