[PATCH] kvm test cpuflags: Try all supported cpu models.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If cpu model isn't defined then test compare all
guest cpu models with host cpu model and try test
all cpu models which is supported by host.

Signed-off-by: Jiří Župka <jzupka@xxxxxxxxxx>
---
 client/tests/kvm/tests/cpuflags.py |   66 ++++++++++++++++++++++++++++++------
 client/virt/subtests.cfg.sample    |   10 +++++
 2 files changed, 65 insertions(+), 11 deletions(-)

diff --git a/client/tests/kvm/tests/cpuflags.py b/client/tests/kvm/tests/cpuflags.py
index 19c48aa..7e8cb49 100644
--- a/client/tests/kvm/tests/cpuflags.py
+++ b/client/tests/kvm/tests/cpuflags.py
@@ -1,4 +1,4 @@
-import logging, re, random, os, time, socket, pickle
+import logging, re, random, os, time, socket, pickle, sys, traceback
 from autotest_lib.client.common_lib import error, utils
 from autotest_lib.client.virt import kvm_vm
 from autotest_lib.client.virt import virt_utils, aexpect
@@ -24,6 +24,8 @@ def run_cpuflags(test, params, env):
     mig_protocol = params.get("migration_protocol", "tcp")
     mig_speed = params.get("mig_speed", "100M")
 
+    cpu_model_black_list = params.get("cpu_model_blacklist", "").split(" ")
+
     multi_host_migration = params.get("multi_host_migration", "no")
 
     class HgFlags(object):
@@ -196,6 +198,19 @@ def run_cpuflags(test, params, env):
         logging.debug("Flags on guest not defined by host: %s", (gf - rf))
         return rf - gf
 
+    def get_cpu_models_supported_by_host():
+        """
+        Get all cpumodels which set of flags is subset of hosts flags.
+
+        @return: [cpumodels]
+        """
+        cpumodels = []
+        for cpumodel in get_cpu_models():
+            flags = HgFlags(cpumodel)
+            if flags.host_unsupported_flags == set([]):
+                cpumodels.append(cpumodel)
+        return cpumodels
+
     def disable_cpu(vm_session, cpu, disable=True):
         """
         Disable cpu in guest system.
@@ -315,6 +330,16 @@ def run_cpuflags(test, params, env):
                     self.clean()
             return ret
 
+    def print_exception(called_object):
+        exc_type, exc_value, exc_traceback = sys.exc_info()
+        logging.error("In function (" + called_object.__name__ + "):")
+        logging.error("Call from:\n" +
+                      traceback.format_stack()[-2][:-1])
+        logging.error("Exception from:\n" +
+                      "".join(traceback.format_exception(
+                                              exc_type, exc_value,
+                                              exc_traceback.tb_next)))
+
     class Test_temp(MiniSubtest):
         def clean(self):
             logging.info("cleanup")
@@ -472,10 +497,10 @@ def run_cpuflags(test, params, env):
             cpu_model, extra_flags = parse_cpu_model()
 
             flags = HgFlags(cpu_model, extra_flags)
+            cpuf_model = cpu_model + ",enforce"
 
             logging.debug("Unsupported flags %s.",
                           str(flags.host_all_unsupported_flags))
-            cpuf_model = cpu_model + ",enforce"
 
             # Add unsupported flags.
             for fadd in flags.host_all_unsupported_flags:
@@ -506,18 +531,21 @@ def run_cpuflags(test, params, env):
 
             flags = HgFlags(cpu_model, extra_flags)
 
+            cpuf_model = cpu_model
+
             logging.debug("Cpu mode flags %s.",
                           str(flags.quest_cpu_model_flags))
-            logging.debug("Added flags %s.",
-                          str(flags.cpumodel_unsupport_flags))
-            cpuf_model = cpu_model
 
-            # Add unsupported flags.
-            for fadd in flags.cpumodel_unsupport_flags:
-                cpuf_model += ",+" + str(fadd)
+            if all_host_supported_flags == "yes":
+                logging.debug("Added flags %s.",
+                              str(flags.cpumodel_unsupport_flags))
 
-            for fdel in flags.host_unsupported_flags:
-                cpuf_model += ",-" + str(fdel)
+                # Add unsupported flags.
+                for fadd in flags.cpumodel_unsupport_flags:
+                    cpuf_model += ",+" + str(fadd)
+
+                for fdel in flags.host_unsupported_flags:
+                    cpuf_model += ",-" + str(fdel)
 
             (self.vm, _) = start_guest_with_cpuflags(cpuf_model, smp)
 
@@ -751,7 +779,23 @@ def run_cpuflags(test, params, env):
     test_type = params.get("test_type")
     if (test_type in locals()):
         tests_group = locals()[test_type]
-        tests_group()
+        if params.get("cpu_model"):
+            tests_group()
+        else:
+            cpu_models = (set(get_cpu_models_supported_by_host()) -
+                          set(cpu_model_black_list))
+            logging.info("Start test with cpu models %s" % (str(cpu_models)))
+            failed = []
+            for cpumodel in cpu_models:
+                params["cpu_model"] = cpumodel
+                try:
+                    tests_group()
+                except:
+                    print_exception(tests_group)
+                    failed.append(cpumodel)
+            if failed != []:
+                raise error.TestFail("Test of cpu models %s failed." %
+                                     (str(failed)))
     else:
         raise error.TestFail("Test group '%s' is not defined in"
                              " cpuflags test" % test_type)
diff --git a/client/virt/subtests.cfg.sample b/client/virt/subtests.cfg.sample
index bd2b60f..f8ba2a0 100644
--- a/client/virt/subtests.cfg.sample
+++ b/client/virt/subtests.cfg.sample
@@ -1710,7 +1710,17 @@ variants:
         vms = ""
         #Try to start guest with all flags which are supported by host.
         all_host_supported_flags = "no"
+
+        #If cpu_model is "" or isn't defined test try test all cpu models,
+        #which host supports.
         cpu_model = "core2duo"
+
+        #Cpumodels defined in blacklist is not tested.
+        #Works only if cpu_model is not defined.
+        cpu_model_blacklist = ""
+        64:
+            cpu_model_blacklist += "486 kvm32 qemu32 pentium pentium2"
+            cpu_model_blacklist += "pentium3 coreduo n270"
         guest_spec_flags = "fxsr_opt hypervisor ds pdpe1gb osxsave svm"
         host_spec_flags = "pbe tm ds_cpl monitor acpi dtes64 ht tm2 xtpr est pdcm smx"
         variants:
-- 
1.7.7.6

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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux