On 07/28/2010 01:12 PM, Lucas Meneghel Rodrigues wrote:
> On Tue, 2010-07-20 at 09:35 +0800, Amos Kong wrote:
>> Repeatedly load/unload nic driver, try to transfer file between guest and
>> host
>> by threads at the same time, and check the md5sum.
>>
>> Signed-off-by: Amos Kong <[email protected]>
>> ---
>> 0 files changed, 0 insertions(+), 0 deletions(-)
>>
>> diff --git a/client/tests/kvm/tests/nicdriver_unload.py
>> b/client/tests/kvm/tests/nicdriver_unload.py
>> new file mode 100644
>> index 0000000..22f9f44
>> --- /dev/null
>> +++ b/client/tests/kvm/tests/nicdriver_unload.py
>> @@ -0,0 +1,128 @@
>> +import logging, commands, threading, re, os
>> +from autotest_lib.client.common_lib import error
>> +import kvm_utils, kvm_test_utils, kvm_net_utils
>> +
>> +def run_nicdriver_unload(test, params, env):
>> + """
>> + Test nic driver
>> +
>> + 1) Boot a vm
>> + 2) Get the nic driver name
>> + 3) Repeatedly unload/load nic driver
>> + 4) Multi-session TCP transfer on test interface
>> + 5) Check the test interface should still work
>> +
>> + @param test: KVM test object
>> + @param params: Dictionary with the test parameters
>> + @param env: Dictionary with test environment.
>> + """
>> + timeout = int(params.get("login_timeout", 360))
>> + vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
>> + session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
>> + logging.info("Trying to log into guest '%s' by serial", vm.name)
>> + session2 = kvm_utils.wait_for(lambda: vm.serial_login(),
>> + timeout, 0, step=2)
>> + if not session2:
>> + raise error.TestFail("Could not log into guest '%s'" % vm.name)
>> +
>> + ethname = kvm_net_utils.get_linux_ifname(session, vm.get_macaddr(0))
>> + try:
>> + # FIXME: Try three waies to get nic driver name, because the
>> + # modprobe.conf is dropped in latest system, and ethtool method is
>> not
>> + # supported by virtio_nic.
>> +
>> + output = session.get_command_output("cat /etc/modprobe.conf")
>> + driver = re.findall(r'%s (\w+)' % ethname,output)
>> + if not driver:
>> + output = session.get_command_output("ethtool -i %s" % ethname)
>> + driver = re.findall(r'driver: (\w+)', output)
>> + if not driver:
>> + output = session.get_command_output("lspci -k")
>> + driver = re.findall("Ethernet controller.*\n.*\n.*Kernel driver"
>> + " in use: (\w+)", output)
>> + driver = driver[0]
>> + except IndexError:
>> + raise error.TestError("Could not find driver name")
>
> ^ About this whole block where there's an attempt to discover what the
> driver name is. The methods listed there are not reliable (depends on
> ethtool being installed, lspci -k not allways will list the kernel
> driver in use, /etc/modprobe.conf will not be present on more recent
> distributions). Instead of these methods, why don't we have a variant
> for this test on each linux distro definition block, with the
> appropriate driver names? It'd be something along the lines:
>
> - 13.64:
> image_name = f13-64
> cdrom_cd1 = linux/Fedora-13-x86_64-DVD.iso
> md5sum = 6fbae6379cf27f36e1f2c7827ba7dc35
> md5sum_1m = 68821b9de4d3b5975d6634334e7f47a6
> unattended_install:
> unattended_file = unattended/Fedora-13.ks
> tftp = images/f13-64/tftpboot
> floppy = images/f13-64/floppy.img
> nicdriver_unload:
> e1000:
> driver = e1000c
> virtio:
> driver = virtio_net
> rtl8139:
> driver = rtl8939
>
> I believe it's safer than having to rely on the above methods.
>
What about looking for the driver link? i.e.:
def get_netdriver_from_ethname(ethname):
temp_path = "/sys/class/net/%s/device/driver" % (ethname)
if os.path.islink(temp_path):
return os.path.split(os.path.realpath(temp_path))[-1]
else:
raise Exception("'%s' not found" % (ethname))
--
Shaun Ruffell
Digium, Inc. | Linux Kernel Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest