From patchwork Fri Mar 19 13:19:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 86937 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 o2JDKM6w018975 for ; Fri, 19 Mar 2010 13:20:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752017Ab0CSNUU (ORCPT ); Fri, 19 Mar 2010 09:20:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30481 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751552Ab0CSNUT (ORCPT ); Fri, 19 Mar 2010 09:20:19 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2JDKIkj032431 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 19 Mar 2010 09:20:18 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2JDKH7D009891; Fri, 19 Mar 2010 09:20:17 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o2JDKFFv030104; Fri, 19 Mar 2010 09:20:16 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH] KVM test: support TAP networking mode when executing tests in parallel Date: Fri, 19 Mar 2010 15:19:04 +0200 Message-Id: <1269004745-5738-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 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]); Fri, 19 Mar 2010 13:20:22 +0000 (UTC) diff --git a/client/tests/kvm/kvm_scheduler.py b/client/tests/kvm/kvm_scheduler.py index 93b7df6..f1adb39 100644 --- a/client/tests/kvm/kvm_scheduler.py +++ b/client/tests/kvm/kvm_scheduler.py @@ -63,6 +63,7 @@ class scheduler: test_index = int(cmd[1]) test = self.tests[test_index].copy() test.update(self_dict) + test = kvm_utils.get_sub_pool(test, index, self.num_workers) test_iterations = int(test.get("iterations", 1)) status = run_test_func("kvm", params=test, tag=test.get("shortname"), diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index 78da9f1..d386456 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -178,6 +178,61 @@ def get_mac_ip_pair_from_dict(dict): return (None, None) +def get_sub_pool(dict, piece, num_pieces): + """ + Split a MAC-IP pool and return a single requested piece. + + For example, get_sub_pool(dict, 0, 3) will split the pool in 3 pieces and + return a dict representing the first piece. + + @param dict: A dict that contains pool parameters. + @param piece: The index of the requested piece. Should range from 0 to + num_pieces - 1. + @param num_pieces: The total number of pieces. + @return: A copy of dict, modified to describe the requested sub-pool. + """ + range_dicts = [get_sub_dict(dict, name) for name in + get_sub_dict_names(dict, "address_ranges")] + if not range_dicts: + return dict + ranges = [[d.get("address_range_base_mac"), + d.get("address_range_base_ip"), + int(d.get("address_range_size", 1))] for d in range_dicts] + total_size = sum(r[2] for r in ranges) + base = total_size * piece / num_pieces + size = total_size * (piece + 1) / num_pieces - base + + # Find base of current sub-pool + for i in range(len(ranges)): + r = ranges[i] + if base < r[2]: + r[0] = r[0] and offset_mac(r[0], base) + r[1] = r[1] and offset_ip(r[1], base) + r[2] -= base + break + base -= r[2] + + # Collect ranges up to end of current sub-pool + new_ranges = [] + for i in range(i, len(ranges)): + r = ranges[i] + new_ranges.append(r) + if size <= r[2]: + r[2] = size + break + size -= r[2] + + # Write new dict + new_dict = dict.copy() + new_dict["address_ranges"] = " ".join("r%d" % i for i in + range(len(new_ranges))) + for i in range(len(new_ranges)): + new_dict["address_range_base_mac_r%d" % i] = new_ranges[i][0] + new_dict["address_range_base_ip_r%d" % i] = new_ranges[i][1] + new_dict["address_range_size_r%d" % i] = new_ranges[i][2] + return new_dict + + def verify_ip_address_ownership(ip, macs, timeout=10.0): """ Use arping and the ARP cache to make sure a given IP address belongs to one