* [dts] [PATCH V1] framework: add kill qemu script. If vm not quit normally, VF will not released. and this will cause next testsuite failed. @ 2017-01-09 6:05 Lijuan Tu 2017-01-12 1:42 ` Liu, Yong 0 siblings, 1 reply; 3+ messages in thread From: Lijuan Tu @ 2017-01-09 6:05 UTC (permalink / raw) To: dts; +Cc: Lijuan Tu Signed-off-by: Lijuan Tu <lijuanx.a.tu@intel.com> --- framework/dut.py | 24 ++++++++++++++++++++++++ framework/qemu_kvm.py | 30 ++++++++++++++++++++++++++++++ framework/test_case.py | 6 ++++++ 3 files changed, 60 insertions(+) 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 = PortConf() self.ports_map = [] self.virt_pool = None + # hypervisor pid list, used for cleanup + self.virt_pids = [] def init_host_session(self): if self.host_init_flag: @@ -816,6 +818,17 @@ class Dut(Crb): pci = self.ports_info[port_id]['pci'] self.virt_pool.del_vf_on_pf(pf_pci=pci, vflist=vflist) + def destroy_all_sriov_vfs(self): + + if self.ports_info == None: + return + for port_id in (0,len(self.ports_info)-1): + print port_id + self.destroy_sriov_vfs_by_port(port_id) + # know issue: nic up + intf = self.ports_info[port_id]['intf'] + self.send_expect("ethtool -s %s autoneg on" % intf, "# ") + def get_vm_core_list(self): return VMCORELIST[self.crb['VM CoreList']] @@ -966,6 +979,17 @@ class Dut(Crb): if self.host_init_flag: self.host_session.close() + 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 + self.send_expect("kill -s SIGTERM %d" % pid, "# ", alt_session=True) + time.sleep(3) + self.virt_pids = [] + 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 = '-enable-kvm' self.__add_boot_line(enable_kvm_boot_line) + def set_vm_pid_file(self): + """ + Set VM pidfile option for manage qemu process + """ + self.__pid_file = '/tmp/.%s.pid' % self.vm_name + index = self.find_option_index('pid_file') + if index: + self.params[index] = {'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 = ST_UNKNOWN + info = self.host_session.send_expect('cat %s' % self.__pid_file, "# ") + try: + pid = 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 monitor 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() + 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* 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. 2017-01-09 6:05 [dts] [PATCH V1] framework: add kill qemu script. If vm not quit normally, VF will not released. and this will cause next testsuite failed Lijuan Tu @ 2017-01-12 1:42 ` Liu, Yong 2017-01-12 3:16 ` Tu, LijuanX A 0 siblings, 1 reply; 3+ messages in thread From: Liu, Yong @ 2017-01-12 1:42 UTC (permalink / raw) To: Tu, LijuanX A, dts; +Cc: Tu, LijuanX A Lijuan, Some comments below. Please make the email subject more compact and add detail 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 <lijuanx.a.tu@intel.com> > 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. > > Signed-off-by: Lijuan Tu <lijuanx.a.tu@intel.com> > --- > framework/dut.py | 24 ++++++++++++++++++++++++ > framework/qemu_kvm.py | 30 ++++++++++++++++++++++++++++++ > framework/test_case.py | 6 ++++++ > 3 files changed, 60 insertions(+) > > 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 = PortConf() > self.ports_map = [] > self.virt_pool = None > + # hypervisor pid list, used for cleanup > + self.virt_pids = [] > > def init_host_session(self): > if self.host_init_flag: > @@ -816,6 +818,17 @@ class Dut(Crb): > pci = self.ports_info[port_id]['pci'] > self.virt_pool.del_vf_on_pf(pf_pci=pci, vflist=vflist) > > + def destroy_all_sriov_vfs(self): > + > + if self.ports_info == 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 function 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 = 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. > def get_vm_core_list(self): > return VMCORELIST[self.crb['VM CoreList']] > > @@ -966,6 +979,17 @@ class Dut(Crb): > if self.host_init_flag: > self.host_session.close() > > + 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_session=True) > + time.sleep(3) > + self.virt_pids = [] > + > 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 = '-enable-kvm' > self.__add_boot_line(enable_kvm_boot_line) > > + def set_vm_pid_file(self): > + """ > + Set VM pidfile option for manage qemu process > + """ > + self.__pid_file = '/tmp/.%s.pid' % self.vm_name > + index = self.find_option_index('pid_file') > + if index: > + self.params[index] = {'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 = ST_UNKNOWN > > + info = self.host_session.send_expect('cat %s' % self.__pid_file, "# ") > + try: > + pid = 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 monitor 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() > > + 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* 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. 2017-01-12 1:42 ` Liu, Yong @ 2017-01-12 3:16 ` Tu, LijuanX A 0 siblings, 0 replies; 3+ messages in thread From: Tu, LijuanX A @ 2017-01-12 3:16 UTC (permalink / raw) To: Liu, Yong, dts Hi yong I have got your comments, will sent v2 as soon as possible. > Do not known why need to enable autoneg on PF device. [lijuan] I will remove this ,it's not related with the function, though it's know issue, refer to DPDK-1754 > -----Original Message----- > From: Liu, Yong > Sent: Thursday, January 12, 2017 9:43 AM > To: Tu, LijuanX A; dts@dpdk.org > Cc: Tu, LijuanX A > 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. > > Lijuan, > Some comments below. Please make the email subject more compact and add > detail 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 <lijuanx.a.tu@intel.com> > > 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. > > > > Signed-off-by: Lijuan Tu <lijuanx.a.tu@intel.com> > > --- > > framework/dut.py | 24 ++++++++++++++++++++++++ > > framework/qemu_kvm.py | 30 ++++++++++++++++++++++++++++++ > > framework/test_case.py | 6 ++++++ > > 3 files changed, 60 insertions(+) > > > > 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 = PortConf() > > self.ports_map = [] > > self.virt_pool = None > > + # hypervisor pid list, used for cleanup > > + self.virt_pids = [] > > > > def init_host_session(self): > > if self.host_init_flag: > > @@ -816,6 +818,17 @@ class Dut(Crb): > > pci = self.ports_info[port_id]['pci'] > > self.virt_pool.del_vf_on_pf(pf_pci=pci, vflist=vflist) > > > > + def destroy_all_sriov_vfs(self): > > + > > + if self.ports_info == 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 function > 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 = 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. [lijuan] I will remove this ,it's not related with the function, though it's know issue, refer to DPDK-1754 > > > def get_vm_core_list(self): > > return VMCORELIST[self.crb['VM CoreList']] > > > > @@ -966,6 +979,17 @@ class Dut(Crb): > > if self.host_init_flag: > > self.host_session.close() > > > > + 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_session=True) > > + time.sleep(3) > > + self.virt_pids = [] > > + > > 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 = '-enable-kvm' > > self.__add_boot_line(enable_kvm_boot_line) > > > > + def set_vm_pid_file(self): > > + """ > > + Set VM pidfile option for manage qemu process > > + """ > > + self.__pid_file = '/tmp/.%s.pid' % self.vm_name > > + index = self.find_option_index('pid_file') > > + if index: > > + self.params[index] = {'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 = ST_UNKNOWN > > > > + info = self.host_session.send_expect('cat %s' % self.__pid_file, > "# ") > > + try: > > + pid = 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 > > monitor 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() > > > > + 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-12 3:16 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-01-09 6:05 [dts] [PATCH V1] framework: add kill qemu script. If vm not quit normally, VF will not released. and this will cause next testsuite failed Lijuan Tu 2017-01-12 1:42 ` Liu, Yong 2017-01-12 3:16 ` Tu, LijuanX A
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).