[PATCH] KVM-test: SR-IOV: Fix a bug that wrongly check VFs count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The parameter 'devices_requested' is irrelated to driver_option 'max_vfs'
of 'igb'.

NIC card 82576 has two network interfaces and each can be
virtualized up to 7 virtual functions, therefore we multiply
two for the value of driver_option 'max_vfs' and can thus get
the total number of VFs.

Signed-off-by: Yolkfull Chow <yzhou@xxxxxxxxxx>
---
 client/tests/kvm/kvm_utils.py |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 4565dc1..1813ed1 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -1012,17 +1012,22 @@ class PciAssignable(object):
         """
         Get VFs count number according to lspci.
         """
+        # FIXME: Need to think out a method of identify which
+        # 'virtual function' belongs to which physical card considering
+        # that if the host has more than one 82576 card. PCI_ID?
         cmd = "lspci | grep 'Virtual Function' | wc -l"
-        # For each VF we'll see 2 prints of 'Virtual Function', so let's
-        # divide the result per 2
-        return int(commands.getoutput(cmd)) / 2
+        return int(commands.getoutput(cmd))
 
 
     def check_vfs_count(self):
         """
         Check VFs count number according to the parameter driver_options.
         """
-        return (self.get_vfs_count == self.devices_requested)
+        # Network card 82576 has two network interfaces and each can be
+        # virtualized up to 7 virtual functions, therefore we multiply
+        # two for the value of driver_option 'max_vfs'.
+        expected_count = int((re.findall("(\d)", self.driver_option)[0])) * 2
+        return (self.get_vfs_count == expected_count)
 
 
     def is_binded_to_stub(self, full_id):
@@ -1054,15 +1059,17 @@ class PciAssignable(object):
         elif not self.check_vfs_count():
             os.system("modprobe -r %s" % self.driver)
             re_probe = True
+        else:
+            return True
 
         # Re-probe driver with proper number of VFs
         if re_probe:
             cmd = "modprobe %s %s" % (self.driver, self.driver_option)
+            logging.info("Loading the driver '%s' with option '%s'" %
+                                   (self.driver, self.driver_option))
             s, o = commands.getstatusoutput(cmd)
             if s:
                 return False
-            if not self.check_vfs_count():
-                return False
             return True
 
 
-- 
1.7.0.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux