From patchwork Wed Dec 29 22:37:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 440091 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBUMBElU000490 for ; Thu, 30 Dec 2010 22:11:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754092Ab0L2Whr (ORCPT ); Wed, 29 Dec 2010 17:37:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:9081 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754078Ab0L2Whp (ORCPT ); Wed, 29 Dec 2010 17:37:45 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBTMbin6014461 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 29 Dec 2010 17:37:45 -0500 Received: from freedom.redhat.com (vpn-8-145.rdu.redhat.com [10.11.8.145]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oBTMbWiw012882; Wed, 29 Dec 2010 17:37:43 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Suqin Huang Subject: [PATCH 6/8] KVM test: load/unload kvm module Date: Wed, 29 Dec 2010 20:37:28 -0200 Message-Id: <1293662250-18292-7-git-send-email-lmr@redhat.com> In-Reply-To: <1293662250-18292-1-git-send-email-lmr@redhat.com> References: <1293662250-18292-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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 (demeter1.kernel.org [140.211.167.41]); Thu, 30 Dec 2010 22:11:59 +0000 (UTC) diff --git a/client/tests/kvm/tests/module_probe.py b/client/tests/kvm/tests/module_probe.py new file mode 100644 index 0000000..519a916 --- /dev/null +++ b/client/tests/kvm/tests/module_probe.py @@ -0,0 +1,53 @@ +import re, commands, logging, os +from autotest_lib.client.common_lib import error +import kvm_subprocess, kvm_test_utils, kvm_utils + +def run_module_probe(test, params, env): + """ + load/unload kvm modules several times. + + Packet Loss Test: + 1) check host cpu module + 2) get module info + 3) unload modules if they exist, else load them + + @param test: Kvm test object + @param params: Dictionary with the test parameters + @param env: Dictionary with test environment. + """ + + def module_probe(name_list, arg=""): + for name in name_list: + cmd = "modprobe %s %s" % (arg, name) + logging.debug(cmd) + s, o = commands.getstatusoutput(cmd) + if s != 0: + logging.error("Failed to load/unload modules %s" % o) + return False + return True + + #Check host cpu module + flags = file("/proc/cpuinfo").read() + arch_check = re.findall("%s\s" % "vmx", flags) + if arch_check: + arch = "kvm_intel" + else: + arch = "kvm_amd" + + #Check whether ksm module exist + if os.path.exists("/sys/module/ksm"): + mod_list = ["ksm", arch, "kvm"] + else: + mod_list = [arch, "kvm"] + + logging.debug(mod_list) + load_count = int(params.get("load_count", 100)) + + try: + for i in range(load_count): + if not module_probe(mod_list): + raise error.TestFail("Failed to load module %s" % mod_list) + if not module_probe(mod_list, "-r"): + raise error.TestFail("Failed to remove module %s" % mod_list) + finally: + module_probe(mod_list) diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index 1a260b4..8b2d752 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -748,6 +748,12 @@ variants: - vmexit: case = vmexit + - module_probe: + type = module_probe + # You can specify your own module list, though it is not needed usually. + # mod_list = kvm + load_count = 100 + - ioquit: type = ioquit background_cmd = "for i in 1 2 3 4; do (nohup dd if=/dev/urandom of=/tmp/file bs=102400 count=10000000 &) done"