[dts] [PATCH v2 05/19] Add a module to instantiate the VM

Jiajia, SunX sunx.jiajia at intel.com
Mon May 25 11:14:53 CEST 2015


Hi Michael,

Please see the comments below.

> -----Original Message-----
> From: Qiu, Michael
> Sent: Monday, May 25, 2015 2:11 PM
> To: Jiajia, SunX; dts at dpdk.org
> Subject: Re: [dts] [PATCH v2 05/19] Add a module to instantiate the VM
> 
> On 5/22/2015 5:04 PM, Jiajia, Sun wrote:
> > From: sjiajiax <sunx.jiajia at intel.com>
> >
> > Added module: virt_dut.py
> >
> > Signed-off-by: sjiajiax <sunx.jiajia at intel.com>
> > ---
> >  framework/virt_dut.py | 202
> ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 202 insertions(+)
> >  create mode 100644 framework/virt_dut.py
> >
> > diff --git a/framework/virt_dut.py b/framework/virt_dut.py
> > new file mode 100644
> > index 0000000..273b29e
> > --- /dev/null
> > +++ b/framework/virt_dut.py
> > @@ -0,0 +1,202 @@
> > +# BSD LICENSE
> > +#
> > +# Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
> > +# All rights reserved.
> > +#
> > +# Redistribution and use in source and binary forms, with or without
> > +# modification, are permitted provided that the following conditions
> > +# 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
> > +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> > +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> FOR
> > +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> COPYRIGHT
> > +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
> INCIDENTAL,
> > +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> > +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> USE,
> > +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> ANY
> > +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
> TORT
> > +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
> USE
> > +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
> DAMAGE.
> > +
> > +import os
> > +import re
> > +import time
> > +import dts
> > +import settings
> > +from config import PortConf
> > +from settings import NICS, LOG_NAME_SEP
> > +from ssh_connection import SSHConnection
> > +from project_dpdk import DPDKdut
> > +from dut import Dut
> > +from net_device import NetDevice
> > +from logger import getLogger
> > +
> > +
> > +class VirtDut(DPDKdut):
> > +
> > +    """
> > +    A connection to the CRB under test.
> > +    This class sends commands to the CRB and validates the responses.
> It is
> > +    implemented using either ssh for linuxapp or the terminal server
> for
> > +    baremetal.
> > +    All operations are in fact delegated to an instance of either
> CRBLinuxApp
> > +    or CRBBareMetal.
> > +    """
> > +
> > +    def __init__(self, crb, serializer, vm_name, suite):
> > +        super(Dut, self).__init__(crb, serializer)
> > +        self.vm_ip = self.get_ip_address()
> > +        self.NAME = 'virtdut' + LOG_NAME_SEP + '%s' % self.vm_ip
> > +        # load port config from suite cfg
> > +        self.suite = suite
> > +        self.logger = getLogger(self.NAME)
> > +        self.logger.config_execution('vmdut')
> > +        self.session = SSHConnection(self.vm_ip, self.NAME,
> > +                                     self.get_password())
> > +        self.session.init_log(self.logger)
> > +
> > +        # if redirect ssh port, there's only one session enabled
> > +        self.alt_session = SSHConnection(self.vm_ip, self.NAME +
> '_alt',
> > +                                         self.get_password())
> > +        self.alt_session.init_log(self.logger)
> > +
> > +        self.number_of_cores = 0
> > +        self.tester = None
> > +        self.cores = []
> > +        self.architecture = None
> > +        self.ports_info = None
> > +        self.ports_map = []
> > +
> > +    def set_nic_type(self, nic_type):
> > +        """
> > +        Set CRB NICS ready to validated.
> > +        """
> > +        self.nic_type = nic_type
> > +        # vm_dut config will load from vm configuration file
> > +
> > +    def load_portconf(self):
> > +        """
> > +        Load port config for this virtual machine
> > +        """
> > +        return
> > +
> > +    def set_target(self, target):
> > +        """
> > +        Set env variable, these have to be setup all the time. Some
> tests
> > +        need to compile example apps by themselves and will fail
> otherwise.
> > +        Set hugepage on DUT and install modules required by DPDK.
> > +        Configure default ixgbe PMD function.
> > +        """
> > +        self.set_toolchain(target)
> > +
> > +        # set env variable
> > +        # These have to be setup all the time. Some tests need to
> compile
> > +        # example apps by themselves and will fail otherwise.
> > +        self.send_expect("export RTE_TARGET=" + target, "#")
> > +        self.send_expect("export RTE_SDK=`pwd`", "#")
> 
> Could "RTE_SDK" be configed in config file?

Now it cannot be configured in the configure file, but I think if it is
needed, doing some changes will be okay.

> 
> > +
> > +        if not self.skip_setup:
> > +            self.build_install_dpdk(target)
> > +
> > +        self.setup_memory(hugepages=512)
> > +        self.setup_modules(target)
> > +
> > +        self.bind_interfaces_linux('igb_uio')
> > +
> > +    def prerequisites(self, pkgName, patch):
> > +        """
> > +        Prerequest function should be called before execute any test
> case.
> > +        Will call function to scan all lcore's information which on
> DUT.
> > +        Then call pci scan function to collect nic device
> information.
> > +        At last setup DUT' environment for validation.
> > +        """
> > +        self.prepare_package(pkgName, patch)
> > +
> > +        self.send_expect("cd %s" % self.base_dir, "# ")
> > +        self.host_session.send_expect("cd %s" % self.base_dir, "# ")
> > +        self.send_expect("alias ls='ls --color=none'", "#")
> > +
> > +        self.init_core_list()
> > +        self.pci_devices_information()
> > +
> > +        # scan ports before restore interface
> > +        self.scan_ports()
> > +        # restore dut ports to kernel
> > +        self.restore_interfaces()
> > +        # rescan ports after interface up
> > +        self.rescan_ports()
> > +
> > +        # no need to rescan ports for guest os just bootup
> > +        # load port infor from config file
> > +        self.load_portconf()
> > +
> > +        # enable tester port ipv6
> > +        self.host_dut.enable_tester_ipv6()
> > +        self.mount_procfs()
> > +        # auto detect network topology
> > +        self.map_available_ports()
> > +        # disable tester port ipv6
> > +        self.host_dut.disable_tester_ipv6()
> > +
> > +        # print latest ports_info
> > +        for port_info in self.ports_info:
> > +            self.logger.info(port_info)
> > +
> > +    def pci_devices_information(self):
> > +        self.pci_devices_information_uncached()
> > +
> > +    def get_memory_channels(self):
> > +        """
> > +        Virtual machine has no memory channel concept, so always
> return 1
> > +        """
> > +        return 1
> > +
> > +    def check_ports_available(self, pci_bus, pci_id):
> > +        """
> > +        Check that whether auto scanned ports ready to use
> > +        """
> > +        pci_addr = "%s:%s" % (pci_bus, pci_id)
> > +        if pci_id == "8086:100e":
> > +            return False
> 
> Why here return false? better to give some comments.
> 
> Also pci_id here should be pci_addr I think.

Because the e1000 network is commonly the control port for tester,
So it will be ignored defaultly.

> 
> > +        return True
> > +
> > +    def scan_ports(self):
> > +        """
> > +        Scan ports information, for vm will always scan
> > +        """
> > +        self.scan_ports_uncached()
> > +
> > +    def scan_ports_uncached(self):
> > +        """
> > +        Scan ports and collect port's pci id, mac adress, ipv6
> address.
> > +        """
> > +        scan_ports_uncached = getattr(
> > +            self, 'scan_ports_uncached_%s' % self.get_os_type())
> > +        return scan_ports_uncached()
> > +
> > +    def map_available_ports(self):
> > +        """
> > +        Load or generate network connection mapping list.
> > +        """
> > +        self.map_available_ports_uncached()
> > +        self.logger.warning("DUT PORT MAP: " + str(self.ports_map))
> > +
> > +    def send_ping6(self, localPort, ipv6, mac=''):
> > +        """
> > +        Send ping6 packet from local port with destination ipv6
> address.
> > +        """
> > +        if self.ports_info[localPort]['type'] == 'ixia':
> > +            pass
> > +        else:
> > +            return self.send_expect("ping6 -w 1 -c 1 -A -I %s %s" %
> (self.ports_info[localPort]['intf'], ipv6), "# ", 10)



More information about the dts mailing list