1 import logging, threading 2 from autotest_lib.client.common_lib import error 3 from autotest_lib.client.bin import utils 4 from autotest_lib.client.virt.tests import file_transfer 5 from autotest_lib.client.virt import virt_test_utils, virt_utils 6 7 8 def run_nic_promisc(test, params, env): 9 """ 10 Test nic driver in promisc mode: 11 12 1) Boot up a VM. 13 2) Repeatedly enable/disable promiscuous mode in guest. 14 3) Transfer file from host to guest, and from guest to host in the same time 15 16 @param test: KVM test object. 17 @param params: Dictionary with the test parameters. 18 @param env: Dictionary with test environment. 19 """ 20 vm = env.get_vm(params["main_vm"]) 21 vm.verify_alive() 22 timeout = int(params.get("login_timeout", 360)) 23 session_serial = vm.wait_for_serial_login(timeout=timeout) 24 25 ethname = virt_test_utils.get_linux_ifname(session_serial, 26 vm.get_mac_address(0)) 27 28 try: 29 transfer_thread = virt_utils.Thread(file_transfer.run_file_transfer, 30 (test, params, env)) 31 transfer_thread.start() 32 while transfer_thread.isAlive(): 33 session_serial.cmd("ip link set %s promisc on" % ethname) 34 session_serial.cmd("ip link set %s promisc off" % ethname) 35 except: 36 transfer_thread.join(suppress_exception=True) 37 raise 38 else: 39 transfer_thread.join() 40