KSM may have various control interface for different distributions,so
this patch launch ksm through pre_command instead of the hard-coded
bits in the test. User may specify their owner suitable commands or
paramteres.

Signed-off-by: Jason Wang <jasow...@redhat.com>
---
 client/tests/kvm/tests/ksm_overcommit.py |   15 ---------------
 client/tests/kvm/tests_base.cfg.sample   |    2 ++
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/client/tests/kvm/tests/ksm_overcommit.py 
b/client/tests/kvm/tests/ksm_overcommit.py
index 2dd46c4..4aa6deb 100644
--- a/client/tests/kvm/tests/ksm_overcommit.py
+++ b/client/tests/kvm/tests/ksm_overcommit.py
@@ -412,21 +412,6 @@ def run_ksm_overcommit(test, params, env):
                                      (3100 - 64.0)))
                 mem = int(math.floor(host_mem * overcommit / vmsc))
 
-    logging.debug("Checking KSM status...")
-    ksm_flag = 0
-    for line in os.popen('ksmctl info').readlines():
-        if line.startswith('flags'):
-            ksm_flag = int(line.split(' ')[1].split(',')[0])
-    if int(ksm_flag) != 1:
-        logging.info("KSM module is not loaded! Trying to load module and "
-                     "start ksmctl...")
-        try:
-            utils.run("modprobe ksm")
-            utils.run("ksmctl start 5000 100")
-        except error.CmdError, e:
-            raise error.TestFail("Failed to load KSM: %s" % e)
-    logging.debug("KSM module loaded and ksmctl started")
-
     swap = int(utils.read_from_meminfo("SwapTotal")) / 1024
 
     logging.debug("Overcommit = %f", overcommit)
diff --git a/client/tests/kvm/tests_base.cfg.sample 
b/client/tests/kvm/tests_base.cfg.sample
index e73ba44..2db0d2c 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -285,6 +285,8 @@ variants:
         catch_uuid_cmd = dmidecode | awk -F: '/UUID/ {print $2}'
 
     - ksm_overcommit:
+        pre_command = "[ -e /dev/ksm ] && true || modprobe ksm && ksmctl start 
5000 50"
+        pre_command_critical = yes
         # Don't preprocess any vms as we need to change its params
         vms = ''
         image_snapshot = yes

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

Reply via email to