From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 07BD1558D for ; Thu, 12 Jan 2017 02:42:59 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 11 Jan 2017 17:42:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,347,1477983600"; d="scan'208";a="807846540" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by FMSMGA003.fm.intel.com with ESMTP; 11 Jan 2017 17:42:58 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 11 Jan 2017 17:42:57 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.20]) by shsmsx102.ccr.corp.intel.com ([169.254.2.88]) with mapi id 14.03.0248.002; Thu, 12 Jan 2017 09:42:53 +0800 From: "Liu, Yong" To: "Tu, LijuanX A" , "dts@dpdk.org" CC: "Tu, LijuanX A" Thread-Topic: [dts] [PATCH V1] framework: add kill qemu script. If vm not quit normally, VF will not released. and this will cause next testsuite failed. Thread-Index: AQHSaj5P0qNXu07yokKVSNKiT9XQAaE0EktA Date: Thu, 12 Jan 2017 01:42:53 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62D42F71@SHSMSX103.ccr.corp.intel.com> References: <1483941920-33564-1-git-send-email-lijuanx.a.tu@intel.com> In-Reply-To: <1483941920-33564-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-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 V1] framework: add kill qemu script. If vm not quit normally, VF will not released. and this will cause next testsuite failed. 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: Thu, 12 Jan 2017 01:43:00 -0000 Lijuan, Some comments below. Please make the email subject more compact and add de= tail description in your git comment. > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Lijuan Tu > Sent: Monday, January 09, 2017 2:05 PM > To: dts@dpdk.org > Cc: Tu, LijuanX A > Subject: [dts] [PATCH V1] framework: add kill qemu script. If vm not quit > normally, VF will not released. and this will cause next testsuite failed= . >=20 > Signed-off-by: Lijuan Tu > --- > framework/dut.py | 24 ++++++++++++++++++++++++ > framework/qemu_kvm.py | 30 ++++++++++++++++++++++++++++++ > framework/test_case.py | 6 ++++++ > 3 files changed, 60 insertions(+) >=20 > diff --git a/framework/dut.py b/framework/dut.py index 1d4a383..9500107 > 100644 > --- a/framework/dut.py > +++ b/framework/dut.py > @@ -73,6 +73,8 @@ class Dut(Crb): > self.conf =3D PortConf() > self.ports_map =3D [] > self.virt_pool =3D None > + # hypervisor pid list, used for cleanup > + self.virt_pids =3D [] >=20 > def init_host_session(self): > if self.host_init_flag: > @@ -816,6 +818,17 @@ class Dut(Crb): > pci =3D self.ports_info[port_id]['pci'] > self.virt_pool.del_vf_on_pf(pf_pci=3Dpci, vflist=3Dvflist) >=20 > + def destroy_all_sriov_vfs(self): > + > + if self.ports_info =3D=3D None: > + return > + for port_id in (0,len(self.ports_info)-1): Not satisfy with pep8 rule, please check first. Parameter port_id in destroy_sriov_vfs_by_port mean port index, the functio= n here only destroy devices of the first and last port. You need use code like "range(len(self.ports_info))" to loop on all ports. > + print port_id Need remove this debug code. > + self.destroy_sriov_vfs_by_port(port_id) > + # know issue: nic up I can't understand this comment, please add more description. > + intf =3D self.ports_info[port_id]['intf'] > + self.send_expect("ethtool -s %s autoneg on" % intf, "# ") > + Do not known why need to enable autoneg on PF device.=20 > def get_vm_core_list(self): > return VMCORELIST[self.crb['VM CoreList']] >=20 > @@ -966,6 +979,17 @@ class Dut(Crb): > if self.host_init_flag: > self.host_session.close() >=20 > + def virt_exit(self): > + """ > + Stop all unstopped hypervisors process > + """ > + # try to kill all hypervisor process > + for pid in self.virt_pids: > + print "kill %d" % pid Please remove debug code here. > + self.send_expect("kill -s SIGTERM %d" % pid, "# ", alt_sessi= on=3DTrue) > + time.sleep(3) > + self.virt_pids =3D [] > + > def crb_exit(self): > """ > Recover all resource before crb exit diff --git a/framework/qemu= _kvm.py > b/framework/qemu_kvm.py index e9d29cc..79e8417 100644 > --- a/framework/qemu_kvm.py > +++ b/framework/qemu_kvm.py > @@ -105,6 +105,7 @@ class QEMUKvm(VirtBase): > def set_vm_default(self): > self.set_vm_name(self.vm_name) > self.set_vm_enable_kvm() > + self.set_vm_pid_file() > self.set_vm_qga() > self.set_vm_daemon() > self.set_vm_monitor() > @@ -244,6 +245,25 @@ class QEMUKvm(VirtBase): > enable_kvm_boot_line =3D '-enable-kvm' > self.__add_boot_line(enable_kvm_boot_line) >=20 > + def set_vm_pid_file(self): > + """ > + Set VM pidfile option for manage qemu process > + """ > + self.__pid_file =3D '/tmp/.%s.pid' % self.vm_name > + index =3D self.find_option_index('pid_file') > + if index: > + self.params[index] =3D {'pid_file': [{'name': '%s' % self.__= pid_file}]} > + else: > + self.params.append({'pid_file': [{'name': '%s' % > + self.__pid_file}]}) > + > + def add_vm_pid_file(self, **options): > + """ > + 'name' : '/tmp/.qemu_vm0.pid' > + """ > + if 'name' in options.keys(): > + self.__add_boot_line('-pidfile %s' % options['name']) > + > + > def set_vm_name(self, vm_name): > """ > Set VM name. > @@ -1155,6 +1175,16 @@ class QEMUKvm(VirtBase): > else: > self.vm_status =3D ST_UNKNOWN >=20 > + info =3D self.host_session.send_expect('cat %s' % self.__pid_fil= e, "# ") > + try: > + pid =3D int(info) > + # save pid into dut structure > + self.host_dut.virt_pids.append(pid) > + except: > + self.host_logger.info("Failed to capture pid!!!") > + > + > + > def __strip_guest_pci(self): > """ > Strip all pci-passthrough device information, based on qemu moni= tor diff -- > git a/framework/test_case.py b/framework/test_case.py index > 85fdb70..270f7b9 100644 > --- a/framework/test_case.py > +++ b/framework/test_case.py > @@ -335,6 +335,12 @@ class TestCase(object): > dutobj.kill_all() > self.tester.kill_all() >=20 > + for dutobj in self.duts: > + dutobj.virt_exit() > + # destroy all vfs > + dutobj.destroy_all_sriov_vfs() > + > + > def wirespeed(self, nic, frame_size, num_ports): > """ > Calculate bit rate. It is depended for NICs > -- > 1.9.3