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 6F2E89577 for ; Thu, 7 Jan 2016 03:59:59 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 06 Jan 2016 18:59:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,531,1444719600"; d="scan'208";a="629246402" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jan 2016 18:59:58 -0800 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 6 Jan 2016 18:59:57 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 6 Jan 2016 18:59:57 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.133]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.201]) with mapi id 14.03.0248.002; Thu, 7 Jan 2016 10:59:55 +0800 From: "Xu, Qian Q" To: "Fu, JingguoX" , "dts@dpdk.org" Thread-Topic: [DTS][PATCH 4/4] virt: add dpdk vhost virtio iperf test cases Thread-Index: AQHRPWlhO+7WKvy9q0mkh9etIrEjW57vcS3w Date: Thu, 7 Jan 2016 02:59:54 +0000 Message-ID: <82F45D86ADE5454A95A89742C8D1410E031A93EC@shsmsx102.ccr.corp.intel.com> References: <1450865062-4730-1-git-send-email-jingguox.fu@intel.com> <1450865062-4730-4-git-send-email-jingguox.fu@intel.com> In-Reply-To: <1450865062-4730-4-git-send-email-jingguox.fu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjQyZWJiZGYtZDY1ZC00ZGVlLWE5OWMtYjExMzMxOTFkYjVjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjQuMTAuMTkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiVkJBUDZONXJcL3lkSjl0QUlXeXVMNWExWHdWOWF3aFVrc3JkQUpvODJ6dnc9In0= 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] [DTS][PATCH 4/4] virt: add dpdk vhost virtio iperf test cases 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, 07 Jan 2016 03:00:00 -0000 See my comments below, thx.=20 Thanks Qian -----Original Message----- From: Fu, JingguoX=20 Sent: Wednesday, December 23, 2015 6:04 PM To: dts@dpdk.org Cc: Liu, Yong; Xu, Qian Q; Pei, Yulong; Fu, JingguoX Subject: [DTS][PATCH 4/4] virt: add dpdk vhost virtio iperf test cases [QIAN] need add some description for the patch content.=20 Signed-off-by: Jingguo Fu --- tests/TestSuite_virtio_iperf.py | 300 ++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 300 insertions(+) create mode 100644 tests/TestSuite_virtio_iperf.py diff --git a/tests/TestSuite_virtio_iperf.py b/tests/TestSuite_virtio_iperf= .py new file mode 100644 index 0000000..2b7991a --- /dev/null +++ b/tests/TestSuite_virtio_iperf.py @@ -0,0 +1,300 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without #=20 +modification, are permitted provided that the following conditions #=20 +are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS #=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR #=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT #=20 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, #=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT #=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, #=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY #=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT #=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +""" +DPDK Test suite +Test DPDK vhost + virtio scenarios +""" +import re +import dts +import time + +from test_case import TestCase +from qemu_kvm import QEMUKvm + +class TestVirtioIperf(TestCase): + def set_up_all(self): + self.vhost_legacy_virtio_cmdline=3D"csum=3Doff,gso=3Doff,guest_csu= m=3Doff,guest_tso4=3Doff,guest_tso6=3Doff,guest_ecn=3Doff" + self.vhost_cuse_virtio_cmdline=3D"csum=3Doff,gso=3Doff,guest_csum= =3Doff,guest_tso4=3Doff,guest_tso6=3Doff,guest_ecn=3Doff" + self.vhost_user_virtio_cmdline=3D"" + self.virtio_mac =3D ["52:54:00:00:00:01", "52:54:00:00:00:02"] + self.virtio_ip =3D ["1.1.1.2", "1.1.1.3"] + self.vm =3D [] + self.vm_dut =3D [] + + self.dut_ports =3D self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >=3D 1, 'Insufficient ports for=20 + test') + =20 + self.phy_function =3D self.dut_ports[0] + netdev =3D self.dut.ports_info[self.phy_function]['port'] + self.socket =3D netdev.get_nic_socket() + self.cores =3D self.dut.get_core_list("1S/3C/1T", socket=3Dself.so= cket) + self.coremask =3D dts.create_mask(self.cores) + =20 + def set_up(self): + pass + =20 + def dut_execut_cmd(self, cmdline, ex=3D'#', timout=3D30): + return self.dut.send_expect(cmdline, ex, timout) + =20 + def build_vhost_lib(self, vhost=3D'user'): + self.dut_execut_cmd('git clean -x -d -f') + self.dut_execut_cmd('git checkout *') + if vhost =3D=3D 'cuse': + self.dut_execut_cmd( + "sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST_USER=3D.*$/CONFIG_RT= E_LIBRTE" + + "_VHOST_USER=3Dn/' ./config/common_linuxapp") + else: + self.dut_execut_cmd( + "sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST_USER=3D.*$/CONFIG_RT= E_LIBRTE" + + "_VHOST_USER=3Dy/' ./config/common_linuxapp") + self.dut.build_install_dpdk(self.target) + self.dut_execut_cmd("cd ./lib/librte_vhost") + out =3D self.dut_execut_cmd("make") + self.verify('Error' not in out, 'bulid err: build lib vhost failed= ') + self.dut_execut_cmd("cd ./eventfd_link") + out =3D self.dut_execut_cmd("make") + self.verify('Error' not in out, 'bulid err: build eventfd_link fai= led') + self.dut_execut_cmd("cd ~/dpdk") + =20 + def build_vhost_app(self): + self.dut_execut_cmd( + "sed -i -e 's/define MAX_QUEUES 512/define MAX_QUEUES 128/' " = + + "./examples/vhost/main.c") [QIAN] if change to 128, then it works for Niantic but not FVL, so= how about FVL support?=20 + out =3D self.dut_execut_cmd("make -C ./examples/vhost") + self.verify("Error" not in out, "compilation error") + self.verify("No such file" not in out, "Not found file error") + =20 + def launch_vhost_switch(self, coremask, channel, jumbo, scenario): + self.vhost_switch =3D "./examples/vhost/build/vhost-switch" + self.vhost_switch_cmd =3D self.vhost_switch + \ + " -c %s -n %d --socket-mem 2048,2048 -- -p 0x1" + \ + " --mergeable %d --zero-copy 0 --vm2vm %d > ./vhost.out &" + self.dut_execut_cmd(self.vhost_switch_cmd % (coremask, channel, ju= mbo, scenario)) + time.sleep(20) + self.dut.session.copy_file_from('/root/dpdk/vhost.out') + time.sleep(5) + fp =3D open('./vhost.out') + fmsg =3D fp.read() + fp.close() + if 'Error' or 'error' in fmsg: + print 'launch vhost sample failed' + return False + else: + return True + + def iperf_result_verify(self, vm_client): + ''' + vm_client.session.copy_file_from("/root/dpdk/iperf_client.log") + self.tester.send_expect('scp -P') + ''' + vm_client.session.copy_file_from("/root/dpdk/iperf_client.log") + fp =3D open("./iperf_client.log") + fmsg =3D fp.read() + iperfdata =3D re.compile('[\d+]*.[\d+] [M|G]bits/sec').findall(fms= g) + dts.results_table_add_header(['Data', 'Unit']) + for data in iperfdata: + dts.results_table_add_row([data.split()[0], data.split()[1]]) + dts.results_table_print() + import os + os.popen("rm -rf ./iperf_client.log") + =20 + def test_perf_vhost_legacy_virtio_iperf(self): + pass + =20 + def test_perf_vhost_cuse_virtio_iperf(self): + """ + vhost cuse as back end, legacy virtio dirver as front end + """ + self.build_vhost_lib(vhost=3D'cuse') + self.build_vhost_app() + self.dut_execut_cmd('rm -rf /dev/vhost-net') + self.dut_execut_cmd('rmmod igb_uio -f') + self.dut_execut_cmd('rmmod eventfd_link') + self.dut_execut_cmd('modprobe uio') + self.dut_execut_cmd('modprobe fuse') + self.dut_execut_cmd('modprobe cuse') + self.dut_execut_cmd('insmod ./x86_64-native-linuxapp-gcc/kmod/igb_= uio.ko') + self.dut_execut_cmd('insmod ./lib/librte_vhost/eventfd_link/eventf= d_link.ko') + self.dut.bind_interfaces_linux(dts.drivername) + self.launch_vhost_switch(self.coremask, 4, 0, 1) + + self.vm1 =3D QEMUKvm(self.dut, 'vm0', 'virtio_iperf') + vm1_params =3D {} + vm1_params['driver'] =3D 'vhost-cuse' + vm1_params['opt_tap'] =3D 'vhost0' + vm1_params['opt_mac'] =3D self.virtio_mac[0] + vm1_params['opt_settings'] =3D self.vhost_cuse_virtio_cmdline + self.vm1.set_vm_device(**vm1_params) + try: + self.vm1_dut =3D self.vm1.start(auto_portmap=3DFalse) + time.sleep(10) + if self.vm1_dut is None: + raise Exception('VM1 start failed') + except Exception as e0: + print dts.RED('VM1 already exist, powerdown it first') + self.vm1_dut.restore_interfaces() + =20 + self.vm2 =3D QEMUKvm(self.dut, 'vm1', 'virtio_iperf') + vm2_params =3D {} + vm2_params['driver'] =3D 'vhost-cuse' + vm2_params['opt_tap'] =3D 'vhost1' + vm2_params['opt_mac'] =3D self.virtio_mac[1] + vm2_params['opt_settings'] =3D self.vhost_cuse_virtio_cmdline + self.vm2.set_vm_device(**vm2_params) + try: + self.vm2_dut =3D self.vm2.start(auto_portmap=3DFalse) + time.sleep(10) + if self.vm2_dut is None: + raise Exception('VM2 start failed') + except Exception as e1: + print dts.RED('VM2 already exist, powerdown it first') + self.vm2_dut.restore_interfaces() + =20 + #self.start_iperf_server() + vm1_vport =3D self.vm1_dut.send_expect('ifconfig -a', '#', 30) + print 'vm net port:' + print vm1_vport + intfs =3D re.compile('eth\d').findall(vm1_vport) + for intf in intfs: + outmac =3D self.vm1_dut.send_expect('ifconfig %s' % intf, '#',= 30) + if self.virtio_mac[0] in outmac: + self.vm1_intf =3D intf + self.vm1_dut.send_expect('ifconfig %s %s' % (self.vm1_intf, self.v= irtio_ip[0]), '#', 10) + self.vm1_dut.send_expect('ifconfig %s up' % self.vm1_intf, '#', 10= ) + self.vm1_dut.send_expect('arp -s %s %s' % (self.virtio_ip[1], self= .virtio_mac[1]), '#', 10) + self.vm1_dut.send_expect('iperf -s -p 12345 -i 1 -M >=20 + iperf_server.log &', '', 10) [QIAN] the command can be changed to "iperf -s -p 12345 -I 1", rem= ove -M=20 + =20 + #self.start_iperf_client() + vm2_vport =3D self.vm2_dut.send_expect('ifconfig -a', '#', 30) + print 'vm net port:' + print vm2_vport + intfs =3D re.compile('eth\d').findall(vm2_vport) + for intf in intfs: + outmac =3D self.vm2_dut.send_expect('ifconfig %s' % intf, '#',= 30) + if self.virtio_mac[1] in outmac: + self.vm2_intf =3D intf + self.vm2_dut.send_expect('ifconfig %s %s' % (self.vm2_intf, self.v= irtio_ip[1]), '#', 10) + self.vm2_dut.send_expect('ifconfig %s up' % self.vm2_intf, '#', 10= ) + self.vm2_dut.send_expect('arp -s %s %s' % (self.virtio_ip[0], self= .virtio_mac[0]), '#', 10) + self.vm2_dut.send_expect('iperf -c %s -p 12345 -i 1 -t 20 > iperf_= client.log &' % self.virtio_ip[0], '', 10) [QIAN] the time can be a little longer, such as 60s, -t 60 + time.sleep(30) + self.vm1_dut.send_expect("killall -s INT iperf", '', 10) + self.iperf_result_verify(self.vm2_dut) + =20 + def test_perf_vhost_user_virtio_iperf(self): + """ + vhost user as back end, legacy virtio dirver as front end + """ + self.build_vhost_lib(vhost=3D'user') + self.build_vhost_app() + #self.dut_execut_cmd('rm -rf /dev/vhost-net') + self.dut_execut_cmd('rmmod igb_uio -f') + self.dut_execut_cmd('rmmod eventfd_link') + self.dut_execut_cmd('modprobe uio') + #self.dut_execut_cmd('modprobe fuse') + #self.dut_execut_cmd('modprobe cuse') + self.dut_execut_cmd('insmod ./x86_64-native-linuxapp-gcc/kmod/igb_= uio.ko') + self.dut_execut_cmd('insmod ./lib/librte_vhost/eventfd_link/eventf= d_link.ko') + self.dut.bind_interfaces_linux(dts.drivername) + self.launch_vhost_switch(self.coremask, 4, 0, 1) + =20 + self.vm1 =3D QEMUKvm(self.dut, 'vm0', 'virtio_iperf') + vm1_params =3D {} + vm1_params['driver'] =3D 'vhost-user' + vm1_params['opt_path'] =3D './vhost-net' + vm1_params['opt_mac'] =3D self.virtio_mac[0] + self.vm1.set_vm_device(**vm1_params) + try: + self.vm1_dut =3D self.vm1.start(auto_portmap=3DFalse) + if self.vm1_dut is None: + raise Exception('VM1 start failed') + except Exception as e0: + print dts.RED('VM1 already exist, powerdown it first') + self.vm1_dut.restore_interfaces() + + self.vm2 =3D QEMUKvm(self.dut, 'vm1', 'virtio_iperf') + vm2_params =3D {} + vm2_params['driver'] =3D 'vhost-user' + vm2_params['opt_path'] =3D './vhost-net' + vm2_params['opt_mac'] =3D self.virtio_mac[1] + self.vm2.set_vm_device(**vm2_params) + try: + self.vm2_dut =3D self.vm2.start(auto_portmap=3DFalse) + if self.vm2_dut is None: + raise Exception('VM2 start failed') + except Exception as e1: + print dts.RED('VM2 already exist, powerdown it first') + =20 + self.vm2_dut.restore_interfaces() + =20 + #self.start_iperf_server() + vm1_vport =3D self.vm1_dut.send_expect('ifconfig -a', '#', 30) + print 'vm net port:' + print vm1_vport + intfs =3D re.compile('eth\d').findall(vm1_vport) + for intf in intfs: + outmac =3D self.vm1_dut.send_expect('ifconfig %s' % intf, '#',= 30) + if self.virtio_mac[0] in outmac: + self.vm1_intf =3D intf + self.vm1_dut.send_expect('ifconfig %s %s' % (self.vm1_intf, self.v= irtio_ip[0]), '#', 10) + self.vm1_dut.send_expect('ifconfig %s up' % self.vm1_intf, '#', 10= ) + self.vm1_dut.send_expect('arp -s %s %s' % (self.virtio_ip[1], self= .virtio_mac[1]), '#', 10) + self.vm1_dut.send_expect('iperf -s -p 12345 -i 1 -M >=20 + iperf_server.log &', '', 10) + [QIAN] Same as above, remove "-M" + #self.start_iperf_client() + vm2_vport =3D self.vm2_dut.send_expect('ifconfig -a', '#', 30) + print 'vm net port:' + print vm2_vport + intfs =3D re.compile('eth\d').findall(vm2_vport) + for intf in intfs: + outmac =3D self.vm2_dut.send_expect('ifconfig %s' % intf, '#',= 30) + if self.virtio_mac[1] in outmac: + self.vm2_intf =3D intf + self.vm2_dut.send_expect('ifconfig %s %s' % (self.vm2_intf, self.v= irtio_ip[1]), '#', 10) + self.vm2_dut.send_expect('ifconfig %s up' % self.vm2_intf, '#', 10= ) + self.vm2_dut.send_expect('arp -s %s %s' % (self.virtio_ip[0], self= .virtio_mac[0]), '#', 10) + self.vm2_dut.send_expect('iperf -c %s -p 12345 -i 1 -t 20 > iperf_= client.log &' % self.virtio_ip[0], '', 10) + time.sleep(30) + [QIAN] Same as above, change the time to 60s + self.vm1_dut.session.send_expect('killall -s INT iperf', '#', 10) + self.iperf_result_verify(self.vm2_dut) + =20 + def tear_down(self): + if self.vm2: + self.vm2.stop() + self.vm2 =3D None + if self.vm1: + self.vm1.stop() + self.vm1 =3D None + self.dut.send_expect("killall -s INT vhost-switch", "#") + + def tear_down_all(self): + pass -- 2.1.0