Beispiel #1
0
    def check_vhostuser_guests(session1, session2):
        """
        Check the vhostuser interface in guests

        param session1: Session of original guest
        param session2: Session of original additional guest
        """
        logging.debug("iface details is %s" %
                      libvirt.get_interface_details(vm_name))
        vm1_mac = str(libvirt.get_interface_details(vm_name)[0]['mac'])
        vm2_mac = str(libvirt.get_interface_details(add_vm_name)[0]['mac'])

        utils_net.set_guest_ip_addr(session1, vm1_mac, guest1_ip)
        utils_net.set_guest_ip_addr(session2, vm2_mac, guest2_ip)
        ping_status, ping_output = utils_net.ping(dest=guest2_ip,
                                                  count='3',
                                                  timeout=5,
                                                  session=session1)
        logging.info("output:%s" % ping_output)
        if ping_status != 0:
            if ping_expect_fail:
                logging.info("Can not ping guest2 as expected")
            else:
                test.fail("Can not ping guest2 from guest1")
        else:
            if ping_expect_fail:
                test.fail("Ping guest2 successfully not expected")
            else:
                logging.info("Can ping guest2 from guest1")
Beispiel #2
0
def run(test, params, env):
    """
    SR-IOV devices sanity test:
    1) Bring up VFs by following instructions How To in Setup.
    2) Configure all VFs in host.
    3) Check whether all VFs get ip in host.
    4) Unbind PFs/VFs from host kernel driver to sr-iov driver.
    5) Bind PFs/VFs back to host kernel driver.
    6) Repeat step 4, 5.
    7) Try to boot up guest(s) with VF(s).

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """

    device_driver = params.get("device_driver", "pci-assign")
    repeat_time = int(params.get("bind_repeat_time", 1))
    configure_on_host = int(params.get("configure_on_host", 0))
    static_ip = int(params.get("static_ip", 1))
    serial_login = params.get("serial_login", "no")
    pci_assignable = test_setup.PciAssignable(
        driver=params.get("driver"),
        driver_option=params.get("driver_option"),
        host_set_flag=params.get("host_set_flag", 1),
        kvm_params=params.get("kvm_default"),
        vf_filter_re=params.get("vf_filter_re"),
        pf_filter_re=params.get("pf_filter_re"),
        device_driver=device_driver,
        pa_type=params.get("pci_assignable"),
        static_ip=static_ip,
        net_mask=params.get("net_mask"),
        start_addr_PF=params.get("start_addr_PF"))

    devices = []
    device_type = params.get("device_type", "vf")
    if device_type == "vf":
        device_num = pci_assignable.get_vfs_count()
        if device_num == 0:
            msg = " No VF device found even after running SR-IOV setup"
            test.cancel(msg)
    elif device_type == "pf":
        device_num = len(pci_assignable.get_pf_vf_info())
    else:
        msg = "Unsupport device type '%s'." % device_type
        msg += " Please set device_type to 'vf' or 'pf'."
        test.error(msg)

    for i in range(device_num):
        device = {}
        device["type"] = device_type
        if device_type == "vf":
            device['mac'] = utils_net.generate_mac_address_simple()
        if params.get("device_name"):
            device["name"] = params.get("device_name")
        devices.append(device)

    pci_assignable.devices = devices
    vf_pci_id = []
    pf_vf_dict = pci_assignable.get_pf_vf_info()
    for pf_dict in pf_vf_dict:
        vf_pci_id.extend(pf_dict["vf_ids"])

    ethname_dict = []
    ips = {}

    # Not all test environments would have a dhcp server to serve IP for
    # all mac addresses. So configure_on_host param has been
    # introduced to choose whether configure VFs on host or not
    if configure_on_host:
        msg = "Configure all VFs in host."
        error_context.context(msg, logging.info)
        for pci_id in vf_pci_id:
            ethname = utils_misc.get_interface_from_pci_id(pci_id)
            mac = utils_net.generate_mac_address_simple()
            ethname_dict.append(ethname)
            # TODO:cleanup of the network scripts
            try:
                utils_net.create_network_script(ethname, mac, "dhcp",
                                                "255.255.255.0", on_boot="yes")
            except Exception as info:
                test.error("Network script creation failed - %s" % info)

        msg = "Check whether VFs could get ip in host."
        error_context.context(msg, logging.info)
        for ethname in ethname_dict:
            utils_net.bring_down_ifname(ethname)
            _ip = check_network_interface_ip(ethname)
            if not _ip:
                msg = "Interface '%s' could not get IP." % ethname
                logging.error(msg)
            else:
                ips[ethname] = _ip
                logging.info("Interface '%s' get IP '%s'", ethname, _ip)

    for i in range(repeat_time):
        msg = "Bind/unbind device from host. Repeat %s/%s" % (i + 1,
                                                              repeat_time)
        error_context.context(msg, logging.info)
        bind_device_num = random.randint(1, device_num)
        pci_assignable.request_devs(devices[:bind_device_num])
        logging.info("Sleep 3s before releasing vf to host.")
        time.sleep(3)
        pci_assignable.release_devs()
        logging.info("Sleep 3s after releasing vf to host.")
        time.sleep(3)
        if device_type == "vf":
            post_device_num = pci_assignable.get_vfs_count()
        else:
            post_device_num = len(pci_assignable.get_pf_vf_info())
        if post_device_num != device_num:
            msg = "lspci cannot report the correct PF/VF number."
            msg += " Correct number is '%s'" % device_num
            msg += " lspci report '%s'" % post_device_num
            test.fail(msg)
    dmesg = process.system_output("dmesg")
    file_name = "host_dmesg_after_unbind_device.txt"
    logging.info("Log dmesg after bind/unbing device to '%s'.", file_name)
    if configure_on_host:
        msg = "Check whether VFs still get ip in host."
        error_context.context(msg, logging.info)
        for ethname in ips:
            utils_net.bring_up_ifname(ethname, action="up")
            _ip = utils_net.get_ip_address_by_interface(ethname, ip_ver="ipv4")
            if not _ip:
                msg = "Interface '%s' could not get IP." % ethname
                msg += "Before bind/unbind it have IP '%s'." % ips[ethname]
                logging.error(msg)
            else:
                logging.info("Interface '%s' get IP '%s'", ethname, _ip)

    msg = "Try to boot up guest(s) with VF(s)."
    error_context.context(msg, logging.info)
    regain_ip_cmd = params.get("regain_ip_cmd", None)
    timeout = int(params.get("login_timeout", 30))

    for vm_name in params["vms"].split(" "):
        params["start_vm"] = "yes"
        vm = env.get_vm(vm_name)
        # User can opt for dhcp IP or a static IP configuration for probed
        # interfaces inside guest. Added option for static IP configuration
        # below
        if static_ip:
            if 'IP_addr_VF' not in locals():
                IP_addr_VF = netaddr.IPAddress(params.get("start_addr_VF"))
                net_mask = params.get("net_mask")
            if not IP_addr_VF:
                test.fail("No IP address found, please"
                          "populate starting IP address in "
                          "configuration file")
            session = vm.wait_for_serial_login(
                timeout=int(params.get("login_timeout", 720)))
            rc, output = session.cmd_status_output(
                "ip li| grep -i 'BROADCAST'|awk '{print $2}'| sed 's/://'")
            if not rc:
                iface_probed = output.splitlines()
                logging.info("probed VF Interface(s) in guest: %s",
                             iface_probed)
                for iface in iface_probed:
                    mac = utils_net.get_linux_mac(session, iface)
                    utils_net.set_guest_ip_addr(session, mac, IP_addr_VF)
                    rc, output = utils_test.ping(
                        str(IP_addr_VF), 30, timeout=60)
                    if rc != 0:
                        test.fail("New nic failed ping test"
                                  "with output:\n %s" % output)
                    IP_addr_VF = IP_addr_VF + 1
            else:
                test.fail("Fail to locate probed interfaces"
                          "for VFs, please check on respective"
                          "drivers in guest image")
        else:
            # User has opted for DHCP IP inside guest
            vm.verify_alive()
            vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))
Beispiel #3
0
def run(test, params, env):
    """
    QEMU 'open vswitch host vlan' test

    1) Start a VM and setup netperf in it
    2) Stop NetworkManager service in host
    3) Create a new private ovs bridge, which has no physical nics inside
    4) Create 4 ovs ports and add to 2 vlans
    4) Boot 4 VMs on this bridge and add them to 2 vlans
    5) Configure ip address of all systems make sure all IPs are in same
       subnet
    6) Ping between two guests in same vlan
    7) Ping between two guests in different vlan
    8) Ping between two guests in another vlan
    9) Netperf test between two guests in same vlan
    10) Transfer file between two guests in same vlan (optional)

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    txt = "Setup netperf in guest."
    image_snapshot = params.get("image_snapshot", "yes")
    error_context.context(txt, logging.info)
    netperf_setup(test, params, env)
    params["image_snapshot"] = image_snapshot

    os_type = params.get("os_type", "linux")
    bridge_name = params.get("private_vlan_bridge", "ovs_private_br")
    login_timeout = int(params.get("login_timeout", 360))
    match_error = params.get("destination_unreachable", "")

    txt = "Stop NetworkManager service in host."
    error_context.context(txt, logging.info)
    process.system(params["stop_network_manager"],
                   timeout=120,
                   ignore_status=True)

    txt = "Create a new private ovs bridge, which has"
    txt += " no physical nics inside."
    error_context.context(txt, logging.info)
    ovs_br_create_cmd = params["ovs_br_create_cmd"]
    ovs_br_remove_cmd = params["ovs_br_remove_cmd"]
    try:
        process.system(ovs_br_create_cmd, shell=True)
    except process.CmdError:
        test.fail("Fail to create ovs bridge %s" % bridge_name)

    try:
        params["start_vm"] = "yes"
        params["netdst"] = bridge_name
        vms = params.get("vms").split()
        sessions = []
        ips = []
        txt = "Start multi vms and add them to 2 vlans."
        error_context.context(txt, logging.info)
        for vm_name in vms:
            vm_params = params.object_params(vm_name)
            env_process.preprocess_vm(test, vm_params, env, vm_name)
            vm = env.get_vm(vm_name)
            ifname = vm.virtnet[0]["ifname"]
            guest_ip = vm.virtnet[0].ip
            vlan = vm_params["ovs_port_vlan"]
            create_port_cmd = "ovs-vsctl set Port %s tag=%s" % (ifname, vlan)
            try:
                output = process.system_output(create_port_cmd,
                                               timeout=120,
                                               ignore_status=False).decode()
                process.system_output("ovs-vsctl show")
            except process.CmdError:
                err = "Fail to create ovs port %s " % ifname
                err += "on bridge %s." % bridge_name
                err += " Command: %s, " % create_port_cmd
                err += "output: %s." % output
                test.fail(err)

            session_ctl = vm.wait_for_serial_login(timeout=login_timeout)
            if os_type == "linux":
                txt = "Stop NetworkManager service in guest %s." % vm_name
                session_ctl.cmd(params["stop_network_manager"], timeout=120)

            mac = vm.get_mac_address()
            txt = "Set guest %s mac %s IP to %s" % (vm_name, mac, guest_ip)
            error_context.context(txt, logging.info)
            utils_net.set_guest_ip_addr(session_ctl,
                                        mac,
                                        guest_ip,
                                        os_type=os_type)
            utils_net.Interface(ifname).down()
            utils_net.Interface(ifname).up()
            ips.append(guest_ip)
            sessions.append(session_ctl)

        txt = "Ping between two guests in same vlan. %s -> %s" % (vms[0],
                                                                  vms[1])
        error_context.context(txt, logging.info)
        ping(test,
             os_type,
             match_error,
             ips[1],
             count=10,
             session=sessions[0],
             same_vlan=True)

        txt = "Ping between two guests in different "
        txt += "vlan. %s -> %s" % (vms[0], vms[2])
        error_context.context(txt, logging.info)
        ping(test,
             os_type,
             match_error,
             ips[2],
             count=10,
             session=sessions[0],
             same_vlan=False)

        txt = "Ping between two guests in another "
        txt += "vlan. %s -> %s" % (vms[2], vms[3])
        error_context.context(txt, logging.info)
        ping(test,
             os_type,
             match_error,
             ips[3],
             count=10,
             session=sessions[2],
             same_vlan=True)

        txt = "Netperf test between two guests in same vlan."
        txt += "%s -> %s" % (vms[0], vms[1])
        error_context.context(txt, logging.info)

        txt = "Run netserver in VM %s" % vms[0]
        error_context.context(txt, logging.info)
        shutdown_firewall_cmd = params["shutdown_firewall"]
        sessions[0].cmd_status_output(shutdown_firewall_cmd, timeout=10)
        netserver_cmd = params.get("netserver_cmd")
        netperf_path = params.get("netperf_path")
        cmd = os.path.join(netperf_path, netserver_cmd)
        status, output = sessions[0].cmd_status_output(cmd, timeout=60)
        if status != 0:
            err = "Fail to start netserver in VM."
            err += " Command output %s" % output
            test.error(err)

        txt = "Run netperf client in VM %s" % vms[1]
        error_context.context(txt, logging.info)
        sessions[1].cmd_status_output(shutdown_firewall_cmd, timeout=10)
        test_duration = int(params.get("netperf_test_duration", 60))
        test_protocol = params.get("test_protocol")
        netperf_cmd = params.get("netperf_cmd")
        netperf_cmd = os.path.join(netperf_path, netperf_cmd)
        cmd = netperf_cmd % (test_duration, ips[0])
        if test_protocol:
            cmd += " -t %s" % test_protocol
        cmd_timeout = test_duration + 20
        status, output = sessions[1].cmd_status_output(cmd,
                                                       timeout=cmd_timeout)
        if status != 0:
            err = "Fail to run netperf test between %s and %s." % (vms[0],
                                                                   vms[1])
            err += " Command output:\n%s" % output
            test.fail(err)

        if params.get("file_transfer_test", "yes") == "yes":
            filesize = int(params.get("filesize", 1024))
            file_create_timeout = int(params.get("file_create_timeout", 720))
            file_path = params.get("file_path", "/var/tmp/src_file")

            txt = "Create %s MB file %s in %s" % (filesize, file_path, vms[0])
            error_context.context(txt, logging.info)
            create_file_in_guest(test,
                                 session=sessions[0],
                                 file_path=file_path,
                                 size=filesize,
                                 os_type=os_type,
                                 timeout=file_create_timeout)

            txt = "Transfer file %s between guests in same " % file_path
            txt += "vlan. %s -> %s" % (vms[0], vms[1])
            error_context.context(txt, logging.info)
            password = params.get("password", "kvmautotest")
            username = params.get("username", "root")
            f_tmout = int(params.get("file_transfer_timeout", 1200))
            shell_port = params.get("shell_port", "22")
            data_port = params.get("nc_file_transfer_port", "9000")
            log_file = "file_transfer_from_%s_to_%s.log" % (ips[0], ips[1])
            if os_type == "linux":  # TODO, windows will be supported later
                remote.nc_copy_between_remotes(ips[0],
                                               ips[1],
                                               shell_port,
                                               password,
                                               password,
                                               username,
                                               username,
                                               file_path,
                                               file_path,
                                               d_port=data_port,
                                               timeout=2,
                                               check_sum=True,
                                               s_session=sessions[0],
                                               d_session=sessions[1],
                                               file_transfer_timeout=f_tmout)
    finally:
        process.system(ovs_br_remove_cmd, ignore_status=False, shell=True)
Beispiel #4
0
def run(test, params, env):
    """
    SR-IOV devices sanity test:
    1) Bring up VFs by following instructions How To in Setup.
    2) Configure all VFs in host.
    3) Check whether all VFs get ip in host.
    4) Unbind PFs/VFs from host kernel driver to sr-iov driver.
    5) Bind PFs/VFs back to host kernel driver.
    6) Repeat step 4, 5.
    7) Try to boot up guest(s) with VF(s).

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """

    device_driver = params.get("device_driver", "pci-assign")
    repeat_time = int(params.get("bind_repeat_time", 1))
    configure_on_host = int(params.get("configure_on_host", 0))
    static_ip = int(params.get("static_ip", 1))
    serial_login = params.get("serial_login", "no")
    pci_assignable = test_setup.PciAssignable(
        driver=params.get("driver"),
        driver_option=params.get("driver_option"),
        host_set_flag=params.get("host_set_flag", 1),
        kvm_params=params.get("kvm_default"),
        vf_filter_re=params.get("vf_filter_re"),
        pf_filter_re=params.get("pf_filter_re"),
        device_driver=device_driver,
        pa_type=params.get("pci_assignable"),
        static_ip=static_ip,
        net_mask=params.get("net_mask"),
        start_addr_PF=params.get("start_addr_PF"))

    devices = []
    device_type = params.get("device_type", "vf")
    if device_type == "vf":
        device_num = pci_assignable.get_vfs_count()
        if device_num == 0:
            msg = " No VF device found even after running SR-IOV setup"
            test.cancel(msg)
    elif device_type == "pf":
        device_num = len(pci_assignable.get_pf_vf_info())
    else:
        msg = "Unsupport device type '%s'." % device_type
        msg += " Please set device_type to 'vf' or 'pf'."
        test.error(msg)

    for i in range(device_num):
        device = {}
        device["type"] = device_type
        if device_type == "vf":
            device['mac'] = utils_net.generate_mac_address_simple()
        if params.get("device_name"):
            device["name"] = params.get("device_name")
        devices.append(device)

    pci_assignable.devices = devices
    vf_pci_id = []
    pf_vf_dict = pci_assignable.get_pf_vf_info()
    for pf_dict in pf_vf_dict:
        vf_pci_id.extend(pf_dict["vf_ids"])

    ethname_dict = []
    ips = {}

    # Not all test environments would have a dhcp server to serve IP for
    # all mac addresses. So configure_on_host param has been
    # introduced to choose whether configure VFs on host or not
    if configure_on_host:
        msg = "Configure all VFs in host."
        error_context.context(msg, logging.info)
        for pci_id in vf_pci_id:
            ethname = utils_misc.get_interface_from_pci_id(pci_id)
            mac = utils_net.generate_mac_address_simple()
            ethname_dict.append(ethname)
            # TODO:cleanup of the network scripts
            try:
                utils_net.create_network_script(ethname,
                                                mac,
                                                "dhcp",
                                                "255.255.255.0",
                                                on_boot="yes")
            except Exception as info:
                test.error("Network script creation failed - %s" % info)

        msg = "Check whether VFs could get ip in host."
        error_context.context(msg, logging.info)
        for ethname in ethname_dict:
            utils_net.bring_down_ifname(ethname)
            _ip = check_network_interface_ip(ethname)
            if not _ip:
                msg = "Interface '%s' could not get IP." % ethname
                logging.error(msg)
            else:
                ips[ethname] = _ip
                logging.info("Interface '%s' get IP '%s'", ethname, _ip)

    for i in range(repeat_time):
        msg = "Bind/unbind device from host. Repeat %s/%s" % (i + 1,
                                                              repeat_time)
        error_context.context(msg, logging.info)
        bind_device_num = random.randint(1, device_num)
        pci_assignable.request_devs(devices[:bind_device_num])
        logging.info("Sleep 3s before releasing vf to host.")
        time.sleep(3)
        pci_assignable.release_devs()
        logging.info("Sleep 3s after releasing vf to host.")
        time.sleep(3)
        if device_type == "vf":
            post_device_num = pci_assignable.get_vfs_count()
        else:
            post_device_num = len(pci_assignable.get_pf_vf_info())
        if post_device_num != device_num:
            msg = "lspci cannot report the correct PF/VF number."
            msg += " Correct number is '%s'" % device_num
            msg += " lspci report '%s'" % post_device_num
            test.fail(msg)
    dmesg = process.system_output("dmesg")
    file_name = "host_dmesg_after_unbind_device.txt"
    logging.info("Log dmesg after bind/unbing device to '%s'.", file_name)
    if configure_on_host:
        msg = "Check whether VFs still get ip in host."
        error_context.context(msg, logging.info)
        for ethname in ips:
            utils_net.bring_up_ifname(ethname, action="up")
            _ip = utils_net.get_ip_address_by_interface(ethname, ip_ver="ipv4")
            if not _ip:
                msg = "Interface '%s' could not get IP." % ethname
                msg += "Before bind/unbind it have IP '%s'." % ips[ethname]
                logging.error(msg)
            else:
                logging.info("Interface '%s' get IP '%s'", ethname, _ip)

    msg = "Try to boot up guest(s) with VF(s)."
    error_context.context(msg, logging.info)
    regain_ip_cmd = params.get("regain_ip_cmd", None)
    timeout = int(params.get("login_timeout", 30))

    for vm_name in params["vms"].split(" "):
        params["start_vm"] = "yes"
        vm = env.get_vm(vm_name)
        # User can opt for dhcp IP or a static IP configuration for probed
        # interfaces inside guest. Added option for static IP configuration
        # below
        if static_ip:
            if 'IP_addr_VF' not in locals():
                IP_addr_VF = netaddr.IPAddress(params.get("start_addr_VF"))
                net_mask = params.get("net_mask")
            if not IP_addr_VF:
                test.fail("No IP address found, please"
                          "populate starting IP address in "
                          "configuration file")
            session = vm.wait_for_serial_login(
                timeout=int(params.get("login_timeout", 720)))
            rc, output = session.cmd_status_output(
                "ip li| grep -i 'BROADCAST'|awk '{print $2}'| sed 's/://'")
            if not rc:
                iface_probed = output.splitlines()
                logging.info("probed VF Interface(s) in guest: %s",
                             iface_probed)
                for iface in iface_probed:
                    mac = utils_net.get_linux_mac(session, iface)
                    utils_net.set_guest_ip_addr(session, mac, IP_addr_VF)
                    rc, output = utils_test.ping(str(IP_addr_VF),
                                                 30,
                                                 timeout=60)
                    if rc != 0:
                        test.fail("New nic failed ping test"
                                  "with output:\n %s" % output)
                    IP_addr_VF = IP_addr_VF + 1
            else:
                test.fail("Fail to locate probed interfaces"
                          "for VFs, please check on respective"
                          "drivers in guest image")
        else:
            # User has opted for DHCP IP inside guest
            vm.verify_alive()
            vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))
Beispiel #5
0
def run(test, params, env):
    """
    QEMU 'open vswitch host vlan' test

    1) Start a VM and setup netperf in it
    2) Stop NetworkManager service in host
    3) Create a new private ovs bridge, which has no physical nics inside
    4) Create 4 ovs ports and add to 2 vlans
    4) Boot 4 VMs on this bridge and add them to 2 vlans
    5) Configure ip address of all systems make sure all IPs are in same
       subnet
    6) Ping between two guests in same vlan
    7) Ping between two guests in different vlan
    8) Ping between two guests in another vlan
    9) Netperf test between two guests in same vlan
    10) Transfer file between two guests in same vlan (optional)

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    txt = "Setup netperf in guest."
    image_snapshot = params.get("image_snapshot", "yes")
    error_context.context(txt, logging.info)
    netperf_setup(test, params, env)
    params["image_snapshot"] = image_snapshot

    os_type = params.get("os_type", "linux")
    bridge_name = params.get("private_vlan_bridge", "ovs_private_br")
    login_timeout = int(params.get("login_timeout", 360))
    match_error = params.get("destination_unreachable", "")

    txt = "Stop NetworkManager service in host."
    error_context.context(txt, logging.info)
    process.system(params["stop_network_manager"], timeout=120,
                   ignore_status=True)

    txt = "Create a new private ovs bridge, which has"
    txt += " no physical nics inside."
    error_context.context(txt, logging.info)
    ovs_br_create_cmd = params["ovs_br_create_cmd"]
    ovs_br_remove_cmd = params["ovs_br_remove_cmd"]
    try:
        process.system(ovs_br_create_cmd, shell=True)
    except process.CmdError:
        test.fail("Fail to create ovs bridge %s" % bridge_name)

    try:
        params["start_vm"] = "yes"
        params["netdst"] = bridge_name
        vms = params.get("vms").split()
        sessions = []
        ips = []
        txt = "Start multi vms and add them to 2 vlans."
        error_context.context(txt, logging.info)
        for vm_name in vms:
            vm_params = params.object_params(vm_name)
            env_process.preprocess_vm(test, vm_params, env, vm_name)
            vm = env.get_vm(vm_name)
            ifname = vm.virtnet[0]["ifname"]
            guest_ip = vm.virtnet[0].ip
            vlan = vm_params["ovs_port_vlan"]
            create_port_cmd = "ovs-vsctl set Port %s tag=%s" % (ifname, vlan)
            try:
                output = process.system_output(create_port_cmd, timeout=120,
                                               ignore_status=False).decode()
                process.system_output("ovs-vsctl show")
            except process.CmdError:
                err = "Fail to create ovs port %s " % ifname
                err += "on bridge %s." % bridge_name
                err += " Command: %s, " % create_port_cmd
                err += "output: %s." % output
                test.fail(err)

            session_ctl = vm.wait_for_serial_login(timeout=login_timeout)
            if os_type == "linux":
                txt = "Stop NetworkManager service in guest %s." % vm_name
                session_ctl.cmd(params["stop_network_manager"], timeout=120)

            mac = vm.get_mac_address()
            txt = "Set guest %s mac %s IP to %s" % (vm_name, mac, guest_ip)
            error_context.context(txt, logging.info)
            utils_net.set_guest_ip_addr(session_ctl, mac, guest_ip,
                                        os_type=os_type)
            utils_net.Interface(ifname).down()
            utils_net.Interface(ifname).up()
            ips.append(guest_ip)
            sessions.append(session_ctl)

        txt = "Ping between two guests in same vlan. %s -> %s" % (vms[0],
                                                                  vms[1])
        error_context.context(txt, logging.info)
        ping(test, os_type, match_error, ips[1], count=10,
             session=sessions[0], same_vlan=True)

        txt = "Ping between two guests in different "
        txt += "vlan. %s -> %s" % (vms[0], vms[2])
        error_context.context(txt, logging.info)
        ping(test, os_type, match_error, ips[2], count=10,
             session=sessions[0], same_vlan=False)

        txt = "Ping between two guests in another "
        txt += "vlan. %s -> %s" % (vms[2], vms[3])
        error_context.context(txt, logging.info)
        ping(test, os_type, match_error, ips[3], count=10,
             session=sessions[2], same_vlan=True)

        txt = "Netperf test between two guests in same vlan."
        txt += "%s -> %s" % (vms[0], vms[1])
        error_context.context(txt, logging.info)

        txt = "Run netserver in VM %s" % vms[0]
        error_context.context(txt, logging.info)
        shutdown_firewall_cmd = params["shutdown_firewall"]
        sessions[0].cmd_status_output(shutdown_firewall_cmd, timeout=10)
        netserver_cmd = params.get("netserver_cmd")
        netperf_path = params.get("netperf_path")
        cmd = os.path.join(netperf_path, netserver_cmd)
        status, output = sessions[0].cmd_status_output(cmd, timeout=60)
        if status != 0:
            err = "Fail to start netserver in VM."
            err += " Command output %s" % output
            test.error(err)

        txt = "Run netperf client in VM %s" % vms[1]
        error_context.context(txt, logging.info)
        sessions[1].cmd_status_output(shutdown_firewall_cmd, timeout=10)
        test_duration = int(params.get("netperf_test_duration", 60))
        test_protocol = params.get("test_protocol")
        netperf_cmd = params.get("netperf_cmd")
        netperf_cmd = os.path.join(netperf_path, netperf_cmd)
        cmd = netperf_cmd % (test_duration, ips[0])
        if test_protocol:
            cmd += " -t %s" % test_protocol
        cmd_timeout = test_duration + 20
        status, output = sessions[1].cmd_status_output(cmd,
                                                       timeout=cmd_timeout)
        if status != 0:
            err = "Fail to run netperf test between %s and %s." % (vms[0],
                                                                   vms[1])
            err += " Command output:\n%s" % output
            test.fail(err)

        if params.get("file_transfer_test", "yes") == "yes":
            filesize = int(params.get("filesize", 1024))
            file_create_timeout = int(params.get("file_create_timeout", 720))
            file_path = params.get("file_path", "/var/tmp/src_file")

            txt = "Create %s MB file %s in %s" % (filesize,
                                                  file_path,
                                                  vms[0])
            error_context.context(txt, logging.info)
            create_file_in_guest(test, session=sessions[0],
                                 file_path=file_path,
                                 size=filesize, os_type=os_type,
                                 timeout=file_create_timeout)

            txt = "Transfer file %s between guests in same " % file_path
            txt += "vlan. %s -> %s" % (vms[0], vms[1])
            error_context.context(txt, logging.info)
            password = params.get("password", "kvmautotest")
            username = params.get("username", "root")
            f_tmout = int(params.get("file_transfer_timeout", 1200))
            shell_port = params.get("shell_port", "22")
            data_port = params.get("nc_file_transfer_port", "9000")
            log_file = "file_transfer_from_%s_to_%s.log" % (ips[0], ips[1])
            if os_type == "linux":  # TODO, windows will be supported later
                remote.nc_copy_between_remotes(ips[0], ips[1], shell_port,
                                               password, password,
                                               username, username,
                                               file_path, file_path,
                                               d_port=data_port,
                                               timeout=2,
                                               check_sum=True,
                                               s_session=sessions[0],
                                               d_session=sessions[1],
                                               file_transfer_timeout=f_tmout)
    finally:
        process.system(ovs_br_remove_cmd, ignore_status=False, shell=True)