From patchwork Thu Mar 11 05:54:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yolkfull Chow X-Patchwork-Id: 84790 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2B5sR5N002528 for ; Thu, 11 Mar 2010 05:54:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751723Ab0CKFyY (ORCPT ); Thu, 11 Mar 2010 00:54:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52748 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751524Ab0CKFyY (ORCPT ); Thu, 11 Mar 2010 00:54:24 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2B5sLeX006266 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 11 Mar 2010 00:54:22 -0500 Received: from localhost.localdomain (dhcp-65-181.nay.redhat.com [10.66.65.181]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2B5sJfV019702; Thu, 11 Mar 2010 00:54:20 -0500 From: Yolkfull Chow To: kvm@vger.kernel.org Cc: autotest@test.kernel.org, Yolkfull Chow Subject: [PATCH] KVM-test: SR-IOV: Fix a bug that wrongly check VFs count Date: Thu, 11 Mar 2010 13:54:17 +0800 Message-Id: <1268286857-10204-1-git-send-email-yzhou@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 11 Mar 2010 05:54:28 +0000 (UTC) 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