@@ -481,3 +481,20 @@ def run_autotest(vm, session, control_path, timeout, outputdir):
e_msg = ("Tests %s failed during control file execution" %
" ".join(bad_results))
raise error.TestFail(e_msg)
+
+
+def get_linux_ifname(session, mac_address):
+ """
+ Return the interface name through the mac address.
+
+ @param session: session to the virtual machine
+ @mac_address: the macaddress of nic
+ """
+ output = session.get_command_output("ifconfig -a")
+
+ try:
+ ethname = re.findall("(\w+)\s+Link.*%s" % mac_address, output,
+ re.IGNORECASE)[0]
+ return ethname
+ except:
+ return None