コード例 #1
0
    def run_pre_cmds(self):
        for cmd in self.pre_cmds:
            if cmd['type'] == 'vm':
                print utils.RED("Can't run vm command when vm not ready")
            elif cmd['type'] == 'host':
                crb = self.host_dut
            elif cmd['type'] == 'tester':
                crb = self.tester
            else:
                crb = self.host_dut

            if 'expect' not in cmd.keys():
                expect = "# "
            else:
                expect = cmd['expect']

            if 'verify' not in cmd.keys():
                verify = False
            else:
                verify = cmd['verify']

            if 'timeout' not in cmd.keys():
                timeout = 5
            else:
                timeout = cmd['timeout']

            ret = crb.send_expect(cmd['command'],
                                  expect,
                                  timeout=timeout,
                                  verify=verify)

            if type(ret) is int and ret != 0:
                print utils.RED("Failed to run command %s" % cmd['command'])
                raise VirtVmOperationException
コード例 #2
0
    def start(self, load_config=True, set_target=True, cpu_topo=''):
        """
        Start VM and instantiate the VM with VirtDut.
        """
        try:
            if load_config is True:
                self.load_config()
            # compose boot command for different hypervisors
            self.compose_boot_param()

            # start virutal machine
            self._start_vm()

            if self.vm_status is ST_RUNNING:
                # connect vm dut and init running environment
                vm_dut = self.instantiate_vm_dut(set_target, cpu_topo)
            else:
                vm_dut = None

        except Exception as vm_except:
            if self.handle_exception(vm_except):
                print utils.RED("Handled expection " + str(type(vm_except)))
            else:
                print utils.RED("Unhandled expection " + str(type(vm_except)))

            if callable(self.callback):
                self.callback()

            return None
        return vm_dut
コード例 #3
0
    def add_vm_device(self, **options):
        """
        options:
            pf_idx: device index of pass-through device
            guestpci: assigned pci address in vm
        """
        devices = self.domain.find('devices')
        hostdevice = ET.SubElement(devices, 'hostdev', {
            'mode': 'subsystem',
            'type': 'pci',
            'managed': 'yes'
        })

        if 'pf_idx' not in options.keys():
            print utils.RED("Missing device index for device option!!!")
            return False

        pf = int(options['pf_idx'])
        if pf > len(self.host_dut.ports_info):
            print utils.RED("PF device index over size!!!")
            return False

        pci_addr = self.host_dut.ports_info[pf]['pci']

        pci = self.__parse_pci(pci_addr)
        if pci is None:
            return False
        bus, slot, func = pci

        source = ET.SubElement(hostdevice, 'source')
        ET.SubElement(
            source, 'address', {
                'domain': '0x0',
                'bus': '0x%s' % bus,
                'slot': '0x%s' % slot,
                'function': '0x%s' % func
            })
        if 'guestpci' in options.keys():
            pci = self.__parse_pci(options['guestpci'])
            if pci is None:
                return False
            bus, slot, func = pci
            ET.SubElement(
                hostdevice, 'address', {
                    'type': 'pci',
                    'domain': '0x0',
                    'bus': '0x%s' % bus,
                    'slot': '0x%s' % slot,
                    'function': '0x%s' % func
                })
            # save host and guest pci address mapping
            pci_map = {}
            pci_map['hostpci'] = pci_addr
            pci_map['guestpci'] = options['guestpci']
            self.pci_maps.append(pci_map)
        else:
            print utils.RED('Host device pass-through need guestpci option!!!')
コード例 #4
0
    def add_vm_device(self, **options):
        """
        options:
            pf_idx: device index of pass-through device
            guestpci: assigned pci address in vm
        """
        devices = self.domain.find('devices')
        hostdevice = ET.SubElement(devices, 'hostdev', {
            'mode': 'subsystem',
            'type': 'pci',
            'managed': 'yes'
        })

        if 'opt_host' in options.keys():
            pci_addr = options['opt_host']
        else:
            print utils.RED("Missing opt_host for device option!!!")
            return False

        pci = self.__parse_pci(pci_addr)
        if pci is None:
            return False
        bus, slot, func, dom = pci

        source = ET.SubElement(hostdevice, 'source')
        ET.SubElement(
            source, 'address', {
                'domain': '0x%s' % dom,
                'bus': '0x%s' % bus,
                'slot': '0x%s' % slot,
                'function': '0x%s' % func
            })
        if 'guestpci' in options.keys():
            guest_pci_addr = options['guestpci']
        else:
            guest_pci_addr = '0000:%s:00.0' % hex(self.pciindex)[2:]
            self.pciindex += 1
        pci = self.__parse_pci(guest_pci_addr)
        if pci is None:
            print utils.RED('Invalid guestpci for host device pass-through!!!')
            return False
        bus, slot, func, dom = pci
        ET.SubElement(
            hostdevice, 'address', {
                'type': 'pci',
                'domain': '0x%s' % dom,
                'bus': '0x%s' % bus,
                'slot': '0x%s' % slot,
                'function': '0x%s' % func
            })
        # save host and guest pci address mapping
        pci_map = {}
        pci_map['hostpci'] = pci_addr
        pci_map['guestpci'] = guest_pci_addr
        self.pci_maps.append(pci_map)
コード例 #5
0
 def add_vm_serial_port(self, **options):
     if 'enable' in options.keys():
         if options['enable'].lower() == 'yes':
             devices = self.domain.find('devices')
             if 'opt_type' in options.keys():
                 serial_type = options['opt_type']
             else:
                 serial_type = 'unix'
             if serial_type == 'pty':
                 serial = ET.SubElement(devices, 'serial',
                                        {'type': serial_type})
                 ET.SubElement(serial, 'target', {'port': '0'})
             elif serial_type == 'unix':
                 serial = ET.SubElement(devices, 'serial',
                                        {'type': serial_type})
                 self.serial_path = "/tmp/%s_serial.sock" % self.vm_name
                 ET.SubElement(serial, 'source', {
                     'mode': 'bind',
                     'path': self.serial_path
                 })
                 ET.SubElement(serial, 'target', {'port': '0'})
             else:
                 print utils.RED("Serial type %s is not supported!" %
                                 serial_type)
                 return False
             console = ET.SubElement(devices, 'console',
                                     {'type': serial_type})
             ET.SubElement(console, 'target', {
                 'type': 'serial',
                 'port': '0'
             })
コード例 #6
0
ファイル: TestSuite_ipgre.py プロジェクト: eilinge/dts
 def check_packet_transmission(self, pkt_types, layer_configs=None):
     time.sleep(1)
     for pkt_type in pkt_types.keys():
         pkt_names = pkt_types[pkt_type]
         pkt = Packet(pkt_type=pkt_type)
         if layer_configs:
             for layer in layer_configs.keys():
                 pkt.config_layer(layer, layer_configs[layer])
         inst = self.tester.tcpdump_sniff_packets(self.tester_iface,
                                                  count=1,
                                                  timeout=8)
         pkt.send_pkt(tx_port=self.tester_iface)
         out = self.dut.get_session_output(timeout=2)
         time.sleep(1)
         self.tester.load_tcpdump_sniff_packets(inst)
         if self.printFlag:  # debug output
             print out
         for pkt_layer_name in pkt_names:
             if self.printFlag:  # debug output
                 print pkt_layer_name
             if pkt_layer_name not in out:
                 print utils.RED("Fail to detect %s" % pkt_layer_name)
                 if not self.printFlag:
                     raise VerifyFailure("Failed to detect %s" %
                                         pkt_layer_name)
         else:
             print utils.GREEN("Detected %s successfully" % pkt_type)
             time.sleep(1)
コード例 #7
0
ファイル: TestSuite_shutdown_api.py プロジェクト: eilinge/dts
    def test_link_stats(self):
        """
        port link stats test
        """
        if self.kdriver == "fm10k":
            print utils.RED("RRC not support\n")
            return

        self.pmdout.start_testpmd("Default",
                                  "--portmask=%s --port-topology=loop" %
                                  utils.create_mask(self.ports),
                                  socket=self.ports_socket)
        self.dut.send_expect("set fwd mac", "testpmd>")
        self.dut.send_expect("start", "testpmd>")

        ports_num = len(self.ports)
        # link down test
        for i in range(ports_num):
            self.dut.send_expect("set link-down port %d" % i, "testpmd>")
        # leep few seconds for NIC link status update
        time.sleep(5)
        self.check_ports(status=False)

        # link up test
        for j in range(ports_num):
            self.dut.send_expect("set link-up port %d" % j, "testpmd>")
        time.sleep(5)
        self.check_ports(status=True)
        self.check_forwarding()
コード例 #8
0
 def launch_vhost_sample(self):
     #
     # Launch the vhost sample with different parameters
     #
     self.coremask = utils.create_mask(self.cores)
     self.vhostapp_testcmd = self.vhost_test % (
         self.coremask, self.memory_channel, self.jumbo, self.zero_copy,
         self.vm2vm)
     # Clean and prepare the vhost cuse modules
     self.dut.send_expect("rm -rf /dev/vhost-net", "#", 20)
     self.dut.send_expect("modprobe fuse", "#", 20)
     self.dut.send_expect("modprobe cuse", "#", 20)
     self.dut.send_expect("rmmod eventfd_link", "#", 20)
     self.dut.send_expect(
         "insmod lib/librte_vhost/eventfd_link/eventfd_link.ko", "#", 20)
     self.dut.send_expect(self.vhostapp_testcmd, "# ", 40)
     time.sleep(30)
     try:
         print "Launch vhost sample:"
         self.dut.session.copy_file_from("/root/dpdk/vhost.out")
         fp = open('./vhost.out', 'r')
         out = fp.read()
         fp.close()
         if "Error" in out:
             raise Exception("Launch vhost sample failed")
         else:
             print "Launch vhost sample finished"
     except Exception as e:
         print utils.RED("Failed to launch vhost sample: %s" % str(e))
コード例 #9
0
    def start_vms(self):
        self.vms = []
        if self.vm_type == 'kvm':
            for vm_name in self.vm_confs.keys():
                # tricky here, QEMUKvm based on suite and vm name
                # suite is virt_global, vm_name just the type
                vm = QEMUKvm(self.host_dut, self.vm_type.upper(),
                             'virt_global')
                vm.load_config()
                vm.vm_name = vm_name
                vm.set_vm_default()
                # merge default config and scene config
                scene_params = self.vm_confs[vm_name]
                # reload merged configurations
                self.merge_params(vm, scene_params)
                # get cpu topo
                topo = self.get_cputopo(scene_params)
                try:
                    vm_dut = vm.start(load_config=False,
                                      set_target=False,
                                      auto_portmap=self.auto_portmap,
                                      cpu_topo=topo)
                    if vm_dut is None:
                        raise Exception("Set up VM ENV failed!")

                    vm_info = {}
                    vm_info[vm_name] = vm
                    vm_info[vm_name + '_session'] = vm_dut
                    self.vms.append(vm_info)

                except Exception as e:
                    print utils.RED("Failure for %s" % str(e))
コード例 #10
0
    def create_bars_plot(self, image_filename, plot_title, xdata, ydata,
                         xlabel='', ylabel='', legend=[],
                         bar_colours=default_bar_colours):

        for yseries in ydata:
            if len(xdata) != len(yseries):
                print utils.RED("The number of items in X axis (%s) and Y axis (%s) does not match." % (xdata, ydata))
                return ''

        image_path = "%s/%s.%s" % (self.plots_path, image_filename,
                                   Plotting.image_format)

        pgraph = Plot2DGraph()
        pgraph.resetMe()

        # Set the number of bars, ydata contains a array per set of data
        pgraph.setNumPlots(len(ydata))
        pgraph.setNumSubplots(1)

        pgraph.setColors(bar_colours)
        pgraph.addBarYlabel(0, ylabel)
        pgraph.setBarLegends(0, legend)

        # For each value in the x axis add corresponding bar (array in ydata)
        for xvalue in xrange(len(xdata)):
            yvalues = [_[xvalue] for _ in ydata]
            pgraph.addBarData(0, xdata[xvalue], yvalues)

        # Dynamic adjustment of the bar widths for better plot appearance
        bar_width = 0.30 - 0.005 * ((len(xdata) * len(legend)) - 4)
        pgraph.setBarWidth(0, bar_width)

        pgraph.generateBar(plotName=image_path, title=plot_title)

        return image_path
コード例 #11
0
    def prepare_vxlan_sample_env(self, tep_cmd, vm_num=1):
        # remove unexpected socke
        self.dut.send_expect("rm -rf vhost-net", "# ")

        # start tep_termination first
        self.dut.send_expect(tep_cmd, "VHOST_CONFIG: bind to vhost-net")

        # start one vm
        self.vm = QEMUKvm(self.dut, 'vm0', 'vxlan_sample')

        # add two virtio user netdevices
        vm_params = {}
        vm_params['driver'] = 'vhost-user'
        vm_params['opt_path'] = './vhost-net'
        vm_params['opt_mac'] = self.def_mac
        self.vm.set_vm_device(**vm_params)
        vm_params['opt_mac'] = self.mac_address_add(1)
        self.vm.set_vm_device(**vm_params)

        try:
            self.vm_dut = self.vm.start()
            if self.vm_dut is None:
                raise Exception("Set up VM ENV failed!")
        except Exception as e:
            print utils.RED("Failure for %s" % str(e))

        # create another vm
        if vm_num == 2:
            print "not implemented now"

        return True
コード例 #12
0
    def handle_dev_destroy(self, **opts):
        if 'pf_idx' in opts.keys():
            port = int(opts['pf_idx'])

            try:
                print utils.GREEN("destroy vfs on port %d" % port)
                self.host_dut.destroy_sriov_vfs_by_port(port)
            except:
                print utils.RED("Failed to destroy vf as requested!!!")
コード例 #13
0
def send_email(sender, mailto, message, smtp_server):

    try:
        smtp = smtplib.SMTP(smtp_server)
        smtp.sendmail(sender, mailto, message.as_string())
        smtp.quit()
        print utils.GREEN("Email sent successfully.")
    except Exception, e:
        print utils.RED("Failed to send email " + str(e))
コード例 #14
0
 def compose_boot_param(self):
     """
     Compose all boot param for starting the VM.
     """
     for param in self.params:
         key = param.keys()[0]
         value = param[key]
         try:
             param_func = getattr(self, 'add_vm_' + key)
             if callable(param_func):
                 for option in value:
                     param_func(**option)
             else:
                 print utils.RED("Virt %s function not callable!!!" % key)
         except AttributeError:
             print utils.RED("Virt %s function not implemented!!!" % key)
         except Exception:
             raise exception.VirtConfigParamException(key)
コード例 #15
0
    def handle_dev_gen(self, **opts):
        if 'pf_idx' in opts.keys():
            port = int(opts['pf_idx'])
            if 'vf_num' in opts.keys():
                vf_num = int(opts['vf_num'])
            else:
                print utils.RED("No vf_num for port %d, assum one VF" % port)
                vf_num = 1
            if 'driver' in opts.keys():
                driver = opts['driver']

            try:
                print utils.GREEN("create vf %d %d %s" %
                                  (port, vf_num, driver))
                self.host_dut.generate_sriov_vfs_by_port(port, vf_num, driver)
                self.reset_pf_cmds(port)
            except:
                print utils.RED("Failed to create vf as requested!!!")
                raise VirtDeviceCreateException
コード例 #16
0
ファイル: TestSuite_etag.py プロジェクト: eilinge/dts
    def check_packet_transmission(self, pkt_types):
        time.sleep(1)
        for pkt_type in pkt_types.keys():
            intf = self.src_intf
            pkt = Packet(pkt_type=pkt_type)
            # set packet every layer's input parameters
            if 'layer_configs' in pkt_types[pkt_type].keys():
                pkt_configs = pkt_types[pkt_type]['layer_configs']
                if pkt_configs:
                    for layer in pkt_configs.keys():
                        pkt.config_layer(layer, pkt_configs[layer])
            pkt.send_pkt(tx_port=self.src_intf)

            # check vm testpmd packet received information
            if 'vm' in pkt_types[pkt_type].keys():
                out = self.vm0_testpmd.get_output(timeout=2)
                if self.printFlag:  # debug output
                    print out
                for pkt_attribute in pkt_types[pkt_type]['vm']:
                    if self.printFlag:  # debug output
                        print pkt_attribute
                    if pkt_attribute not in out:
                        print utils.RED('Fail to detect %s' % pkt_attribute)
                        if not self.printFlag:  # print out all info in debug mode
                            raise VerifyFailure('Failed to detect %s' %
                                                pkt_attribute)
                print utils.GREEN('VM detected %s successfully' % pkt_type)

            # check dut testpmd packet received information
            if 'dut' in pkt_types[pkt_type].keys():
                out = self.host_testpmd.get_output(timeout=2)
                if self.printFlag:  # debug output
                    print out
                for pkt_attribute in pkt_types[pkt_type]['dut']:
                    if self.printFlag:  # debug output
                        print pkt_attribute
                    if pkt_attribute not in out:
                        print utils.RED('Fail to detect %s' % pkt_attribute)
                        if not self.printFlag:  # print out all info in debug mode
                            raise VerifyFailure('Failed to detect %s' %
                                                pkt_attribute)
                print utils.GREEN('DUT detected %s successfully' % pkt_type)
            time.sleep(1)
コード例 #17
0
    def migrated_start(self, set_target=True, cpu_topo=''):
        """
        Instantiate the VM after migration done
        There's no need to load param and start VM because VM has been started
        """
        try:
            if self.vm_status is ST_PAUSE:
                # connect backup vm dut and it just inherited from host
                vm_dut = self.instantiate_vm_dut(set_target,
                                                 cpu_topo,
                                                 bind_dev=False)
        except Exception as vm_except:
            if self.handle_exception(vm_except):
                print utils.RED("Handled expection " + str(type(vm_except)))
            else:
                print utils.RED("Unhandled expection " + str(type(vm_except)))

            return None

        return vm_dut
コード例 #18
0
ファイル: TestSuite_shutdown_api.py プロジェクト: eilinge/dts
    def test_change_linkspeed(self):
        """
        Change Link Speed.
        """
        if self.kdriver == "fm10k":
            print utils.RED("RRC not support\n")
            return

        self.pmdout.start_testpmd("Default",
                                  "--portmask=%s --port-topology=loop" %
                                  utils.create_mask(self.ports),
                                  socket=self.ports_socket)

        out = self.tester.send_expect(
            "ethtool %s" % self.tester.get_interface(
                self.tester.get_local_port(self.ports[0])), "# ")
        if 'fortville_spirit' == self.nic:
            result_scanner = r"([0-9]+)baseSR4/([A-Za-z]+)"
        else:
            result_scanner = r"([0-9]+)baseT/([A-Za-z]+)"
        scanner = re.compile(result_scanner, re.DOTALL)
        m = scanner.findall(out)
        configs = m[:-(len(m) / 2)]
        for config in configs:
            print config
            if self.nic in ["ironpond"]:
                if config[0] != '1000' or '10000':
                    continue
            elif self.nic in ["fortville_eagle"]:
                if config[0] != '10000':
                    continue
            elif self.nic in ["sagepond"]:
                if config[0] != '1000' and '10000':
                    continue
            self.dut.send_expect("port stop all", "testpmd> ", 100)
            for port in self.ports:
                self.dut.send_expect(
                    "port config %d speed %s duplex %s" %
                    (port, config[0], config[1].lower()), "testpmd> ")
            self.dut.send_expect("set fwd mac", "testpmd>")
            self.dut.send_expect("port start all", "testpmd> ", 100)
            time.sleep(5)  # sleep few seconds for link stable

            for port in self.ports:
                out = self.tester.send_expect(
                    "ethtool %s" % self.tester.get_interface(
                        self.tester.get_local_port(port)), "# ")
                self.verify("Speed: %s" % config[0] in out,
                            "Wrong speed reported by the self.tester.")
                self.verify("Duplex: %s" % config[1] in out,
                            "Wrong link type reported by the self.tester.")
            self.dut.send_expect("start", "testpmd> ")
            self.check_forwarding()
            self.dut.send_expect("stop", "testpmd> ")
コード例 #19
0
    def test_enable_disablejumbo(self):
        """
        Enable/Disable Jumbo Frames.
        """
        if self.kdriver == "fm10k":
            print utils.RED("RRC not support\n")
            return

        jumbo_size = 2048
        self.pmdout.start_testpmd("Default",
                                  "--portmask=%s --port-topology=loop" %
                                  utils.create_mask(self.ports),
                                  socket=self.ports_socket)
        self.dut.send_expect("port stop all", "testpmd> ", 100)
        self.dut.send_expect("port config all max-pkt-len %d" % jumbo_size,
                             "testpmd> ")
        out = self.dut.send_expect("vlan set strip off all", "testpmd> ")
        if "fail" not in out:
            for port in self.ports:
                self.dut.send_expect("rx_vlan add 1 %d" % port, "testpmd> ")
            self.dut.send_expect("set fwd mac", "testpmd>")
            self.dut.send_expect("port start all", "testpmd> ", 100)
            self.dut.send_expect("start", "testpmd> ")

            if self.nic in [
                    'magnolia_park', 'niantic', 'twinpond', 'kawela_4',
                    'ironpond', 'springfountain', 'springville', 'powerville'
            ]:
                # nantic vlan length will not be calculated
                vlan_jumbo_size = jumbo_size + 4
            else:
                vlan_jumbo_size = jumbo_size

            self.check_forwarding(pktSize=vlan_jumbo_size - 1, vlan=True)
            self.check_forwarding(pktSize=vlan_jumbo_size, vlan=True)
            self.check_forwarding(pktSize=vlan_jumbo_size + 1,
                                  received=False,
                                  vlan=True)

            self.dut.send_expect("stop", "testpmd> ")

        self.dut.send_expect("port stop all", "testpmd> ", 100)
        self.dut.send_expect("port config all hw-vlan off", "testpmd> ")
        self.dut.send_expect("port start all", "testpmd> ", 100)
        self.dut.send_expect("start", "testpmd> ")
        """
        On 1G NICs, when the jubmo frame MTU set as X, the software adjust it to (X + 4).
        """
        if self.nic in ["powerville", "springville", "kawela_4"]:
            jumbo_size += 4
        self.check_forwarding(pktSize=jumbo_size - 1)
        self.check_forwarding(pktSize=jumbo_size)
        self.check_forwarding(pktSize=jumbo_size + 1, received=False)
コード例 #20
0
ファイル: virt_base.py プロジェクト: eilinge/dts
    def quick_start(self, load_config=True, set_target=True, cpu_topo=''):
        """
        Only Start VM and not do anything else, will be helpful in multiple VMs
        """
        try:
            if load_config is True:
                self.load_config()
            # compose boot command for different hypervisors
            self.compose_boot_param()

            # start virtual machine
            self._quick_start_vm()

        except Exception as vm_except:
            if self.handle_exception(vm_except):
                print utils.RED("Handled exception " + str(type(vm_except)))
            else:
                print utils.RED("Unhandled exception " + str(type(vm_except)))

            if callable(self.callback):
                self.callback()
コード例 #21
0
 def element_strip(self, out, pattern):
     """
     Strip and get queue number.
     """
     s = re.compile(pattern, re.DOTALL)
     res = s.search(out)
     if res is None:
         print utils.RED('Fail to search number.')
         return None
     else:
         result = res.group(1)
         return int(result)
コード例 #22
0
ファイル: TestSuite_uni_pkt.py プロジェクト: BAOLONGtrann/dts
 def run_test(self, pkt_types):
     time.sleep(1)
     for pkt_type in pkt_types.keys():
         pkt_names = pkt_types[pkt_type]
         pkt = Packet(pkt_type=pkt_type)
         pkt.send_pkt(tx_port=self.tester_iface)
         out = self.dut.get_session_output(timeout=2)
         for pkt_layer_name in pkt_names:
             if pkt_layer_name not in out:
                 print utils.RED("Fail to detect %s" % pkt_layer_name)
                 raise VerifyFailure("Failed to detect %s" % pkt_layer_name)            
         print utils.GREEN("Detected %s successfully" % pkt_type)
コード例 #23
0
    def prepare_host(self, **opts):
        if 'dpdk' not in opts.keys():
            print utils.RED("Scenario host parameter request dpdk option!!!")
            raise VirtConfigParamException('host')

        if 'cores' not in opts.keys():
            print utils.RED("Scenario host parameter request cores option!!!")
            raise VirtConfigParamException('host')

        if 'target' in opts.keys():
            target = opts['target']
        else:
            target = self.def_target

        self.host_dut.set_target(target, bind_dev=True)

        if opts['dpdk'] == 'testpmd':
            self.pmdout = PmdOutput(self.host_dut)
            cores = opts['cores'].split()
            out = self.pmdout.start_testpmd(cores)
            if 'Error' in out:
                raise VirtHostPrepareException()
コード例 #24
0
    def set_up_vf_to_vf_env(self, driver='default'):
        self.pf_port_for_vfs = self.dut_ports[0]
        self.dut.restore_interfaces()
        self.dut.generate_sriov_vfs_by_port(self.pf_port_for_vfs,
                                            VF_NUMS_ON_ONE_PF,
                                            driver=driver)
        self.sriov_vfs_ports = self.dut.ports_info[
            self.pf_port_for_vfs]['vfs_port']
        self.host_port_intf = self.dut.ports_info[self.pf_port_for_vfs]['intf']
        for i in range(VF_NUMS_ON_ONE_PF):
            self.dut.send_expect('ip link set dev %s vf %d mac %s' % \
                                (self.host_port_intf, i, VF_TEMP_MAC % i), '#', 10)
        try:
            for port in self.sriov_vfs_ports:
                port.bind_driver('pci-stub')
            time.sleep(1)
        except Exception as e:
            raise Exception(e)

        vf0_prop = {'opt_host': self.sriov_vfs_ports[0].pci}
        vf1_prop = {'opt_host': self.sriov_vfs_ports[1].pci}
        time.sleep(1)
        self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_to_vf_bridge')
        self.vm0.set_vm_device(driver='pci-assign', **vf0_prop)
        try:
            self.vm0_dut = self.vm0.start()
            if self.vm0_dut is None:
                raise Exception('Set up VM0 failed')
        except Exception as e:
            print utils.RED(str(e))

        self.vm1 = QEMUKvm(self.dut, 'vm1', 'vf_to_vf_bridge')
        self.vm1.set_vm_device(driver='pci-assign', **vf1_prop)
        try:
            self.vm1_dut = self.vm1.start()
            if self.vm1_dut is None:
                raise Exception('Set up VM1 failed')
        except Exception as e:
            print utils.RED(str(e))
コード例 #25
0
 def search_queue_number(self, Q_strip):
     """
     Search max queue number from configuration.
     """
     out = self.dut.send_expect("cat config/common_base", "]# ", 10)
     pattern = "(%s=)(\d*)" % Q_strip
     s = re.compile(pattern)
     res = s.search(out)
     if res is None:
         print utils.RED('Search no queue number.')
         return None
     else:
         queue = res.group(2)
         return int(queue)
コード例 #26
0
ファイル: virt_base.py プロジェクト: eilinge/dts
 def compose_boot_param(self):
     """
     Compose all boot param for starting the VM.
     """
     for param in self.params:
         key = param.keys()[0]
         value = param[key]
         try:
             param_func = getattr(self, 'add_vm_' + key)
             if callable(param_func):
                 if type(value) is list:
                     for option in value:
                         param_func(**option)
             else:
                 print utils.RED("Virt %s function not callable!!!" % key)
         except AttributeError:
             self.host_logger.error(
                 traceback.print_exception(*sys.exc_info()))
             print utils.RED("Virt %s function not implemented!!!" % key)
         except Exception:
             self.host_logger.error(
                 traceback.print_exception(*sys.exc_info()))
             raise exception.VirtConfigParamException(key)
コード例 #27
0
ファイル: TestSuite_vlan.py プロジェクト: eilinge/dts
    def test_vlan_strip_config_off(self):

        if self.kdriver == "fm10k":
            print utils.RED("fm10k not support this case\n")
            return
        self.dut.send_expect("vlan set strip off %s" % dutRxPortId, "testpmd> ", 20)
        self.dut.send_expect("rx_vlan add %d %s" % (self.vlan, dutRxPortId), "testpmd> ", 20)
        out = self.dut.send_expect("show port info %s" % dutRxPortId, "testpmd> ", 20)
        self.verify("strip off" in out, "Wrong strip:" + out)
        self.dut.send_expect("set nbport 2", "testpmd> ")
        self.dut.send_expect("start", "testpmd> ", 120)
        self.vlan_send_packet(self.vlan)
        out = self.get_tcpdump_package()
        self.verify(self.vlan in out, "Vlan not found:" + str(out))
        out = self.dut.send_expect("stop", "testpmd> ", 120)
コード例 #28
0
 def strip_ptype(self, table, hw_ptype):
     """
     Strip software packet type from packet mapping table.
     Input: packet mapping table, hardware ptype
     Out: 32 bits software ptype or none
     """
     pattern = r"\s(%s)\s0x(0*)([1-9a-f][0-9a-f]*)" % hw_ptype
     s = re.compile(pattern)
     res = s.search(table)
     if res is None:
         print utils.RED("search none ptype")
         return None
     else:
         ptype = res.group(3)
         return ptype
コード例 #29
0
ファイル: TestSuite_uni_pkt.py プロジェクト: eilinge/dts
 def run_nvgre_cope(self, pkt_nvgre):
     time.sleep(1)
     for pkts in pkt_nvgre:
         pkt = Packet()
         pkt.assign_layers(pkts[2])
         if 'inner_icmp' in pkts[2]:
             pkt.config_layers([('ipv6',{'nh':47}), ('inner_ipv6', {'nh': 58})])
         else:
             pkt.config_layers([('ipv6',{'nh':47}),('inner_ipv6', {'nh': 132})])
         pkt.send_pkt(tx_port=self.tester_iface)
         out = self.dut.get_session_output(timeout=2)
         for pkt_layer_name in pkts[1]:
             if pkt_layer_name not in out:
                 print utils.RED("Fail to detect %s" % pkt_layer_name)
                 raise VerifyFailure("Failed to detect %s" % pkt_layer_name)
         print utils.GREEN("Detected %s successfully" % pkts[0])
コード例 #30
0
    def init_core_list(self):
        self.cores = []
        cpuinfo = self.send_expect("grep --color=never \"processor\""
                                   " /proc/cpuinfo", "#", alt_session=False)
        cpuinfo = cpuinfo.split('\r\n')
        if self.cpu_topo != '':
            topo_reg = r"(\d)S/(\d)C/(\d)T"
            m = re.match(topo_reg, self.cpu_topo)
            if m:
                socks = int(m.group(1))
                cores = int(m.group(2))
                threads = int(m.group(3))
                total = socks * cores * threads
                cores_persock = cores * threads
                total_phycores = socks * cores
                # cores should match cpu_topo
                if total != len(cpuinfo):
                    print utils.RED("Core number not matched!!!")
                else:
                    for core in range(total):
                        thread = core / total_phycores
                        phy_core = core % total_phycores
                        # if this core is hyper core
                        if thread:
                            idx = core % total_phycores
                            socket = idx / cores
                        else:
                            socket = core / cores

                        # tricky here, socket must be string
                        self.cores.append({'thread': core,
                                           'socket': str(socket),
                                           'core': phy_core})
                    self.number_of_cores = len(self.cores)
                    return

        # default core map
        for line in cpuinfo:
            m = re.search("processor\t: (\d+)", line)
            if m:
                thread = m.group(1)
                socket = 0
                core = thread
            self.cores.append(
                {'thread': thread, 'socket': socket, 'core': core})

        self.number_of_cores = len(self.cores)