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 834BBF976 for ; Mon, 16 Jan 2017 03:12:32 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 15 Jan 2017 18:12:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,236,1477983600"; d="scan'208";a="1113178993" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga002.fm.intel.com with ESMTP; 15 Jan 2017 18:12:30 -0800 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 15 Jan 2017 18:12:30 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 15 Jan 2017 18:12:30 -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; Mon, 16 Jan 2017 10:12:26 +0800 From: "Liu, Yong" To: "Tu, LijuanX A" , "dts@dpdk.org" CC: "Tu, LijuanX A" Thread-Topic: [dts] [PATCH v2] framework: add kill qemu script. Thread-Index: AQHSbV8yYqn4OpgVuEWlnZAX7hgvgKE6YQVw Date: Mon, 16 Jan 2017 02:12:25 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62D47832@SHSMSX103.ccr.corp.intel.com> References: <1484285906-44003-1-git-send-email-lijuanx.a.tu@intel.com> In-Reply-To: <1484285906-44003-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 v2] framework: add kill qemu script. 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: Mon, 16 Jan 2017 02:12:33 -0000 Thanks, applied into master branch with modified subject and comment. > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Lijuan Tu > Sent: Friday, January 13, 2017 1:38 PM > To: dts@dpdk.org > Cc: Tu, LijuanX A > Subject: [dts] [PATCH v2] framework: add kill qemu script. >=20 > 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 | 19 +++++++++++++++++++ > framework/qemu_kvm.py | 30 ++++++++++++++++++++++++++++++ > framework/test_case.py | 6 ++++++ > 3 files changed, 55 insertions(+) >=20 > diff --git a/framework/dut.py b/framework/dut.py index 1d4a383..9cbdaf7 > 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,13 @@ 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 range(len(self.ports_info)): > + self.destroy_sriov_vfs_by_port(port_id) > + > def get_vm_core_list(self): > return VMCORELIST[self.crb['VM CoreList']] >=20 > @@ -966,6 +975,16 @@ 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: > + 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