From: Lucas Meneghel Rodrigues <lmr@redhat.com>
To: autotest@test.kernel.org
Cc: Suqin Huang <shuang@redhat.com>, kvm@vger.kernel.org
Subject: [PATCH 6/8] KVM test: load/unload kvm module
Date: Wed, 29 Dec 2010 20:37:28 -0200 [thread overview]
Message-ID: <1293662250-18292-7-git-send-email-lmr@redhat.com> (raw)
In-Reply-To: <1293662250-18292-1-git-send-email-lmr@redhat.com>
From: Suqin Huang <shuang@redhat.com>
check whether kvm modules exist, unload them if exist, else load them.
Signed-off-by: Suqin Huang <shuang@redhat.com>
---
client/tests/kvm/tests/module_probe.py | 53 ++++++++++++++++++++++++++++++++
client/tests/kvm/tests_base.cfg.sample | 6 +++
2 files changed, 59 insertions(+), 0 deletions(-)
create mode 100644 client/tests/kvm/tests/module_probe.py
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"
--
1.7.2.3
next prev parent reply other threads:[~2010-12-29 22:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-29 22:37 [PATCH 0/8] KVM test: Build code refactor + module_probe test Lucas Meneghel Rodrigues
2010-12-29 22:37 ` [PATCH 1/8] KVM test: Refactor the KVM build code into installer Lucas Meneghel Rodrigues
2010-12-29 22:37 ` [PATCH 2/8] KVM test: rename 'mode' to 'install_mode' on the sample cfg files Lucas Meneghel Rodrigues
2010-12-29 22:37 ` [PATCH 3/8] KVM test: add methods to store a installer object in 'env' Lucas Meneghel Rodrigues
2010-12-29 22:37 ` [PATCH 4/8] KVM test: Make the build test to use the installer library Lucas Meneghel Rodrigues
2010-12-29 22:37 ` [PATCH 5/8] KVM test: installer: fix the 'layout 1' detection Lucas Meneghel Rodrigues
2010-12-29 22:37 ` Lucas Meneghel Rodrigues [this message]
2010-12-29 22:37 ` [PATCH 7/8] KVM test: add interface to get modules from cfg file, and load/unload them Lucas Meneghel Rodrigues
2010-12-29 22:37 ` [PATCH 8/8] KVM test: test/module_probe: use installer object to load modules Lucas Meneghel Rodrigues
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1293662250-18292-7-git-send-email-lmr@redhat.com \
--to=lmr@redhat.com \
--cc=autotest@test.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=shuang@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox