On Tue, 2011-02-08 at 12:16 -0200, Cleber Rosa wrote: > This patch adds better checking on the CPU flags (explicit > AMD CPU flag is checked, rather than assumed as a fallback). > > Thus, when constructing the list of KVM modules to load (kvm, > kvm-<cpu>), a test error is raised if the CPU was not properly > detected.
As we spoke on irc, see below: > > Signed-off-by: Cleber Rosa <[email protected]> > --- > client/tests/kvm/installer.py | 19 ++++++++++++++----- > 1 files changed, 14 insertions(+), 5 deletions(-) > > diff --git a/client/tests/kvm/installer.py b/client/tests/kvm/installer.py > index a757223..4f863f9 100644 > --- a/client/tests/kvm/installer.py > +++ b/client/tests/kvm/installer.py > @@ -38,11 +38,16 @@ def kill_qemu_processes(): > > > def cpu_vendor(): > - vendor = "intel" > - if os.system("grep vmx /proc/cpuinfo 1>/dev/null") != 0: > - vendor = "amd" > - logging.debug("Detected CPU vendor as '%s'", vendor) > - return vendor > + flag_vendor_map = { "vmx" : "intel", > + "svm" : "amd" } > + > + for flag, vendor in flag_vendor_map.items(): > + if os.system("grep %s /proc/cpuinfo 1>/dev/null" % flag) == 0: > + logging.debug("Detected CPU vendor as '%s'", vendor) > + return vendor > + > + logging.error("Could not detect CPU vendor: returning it as 'unknown'") > + return "unknown" So, create a class to capture CpuInfo, with some important methods such as verify_virt_capable(), and fail the test right away if the CPU vendor is unknown. > > def _unload_kvm_modules(mod_list): > @@ -244,6 +249,10 @@ class BaseInstaller(object): > def _module_list(self): > """Generate the list of modules that need to be loaded > """ > + if self.cpu_vendor == 'unknown': > + raise error.TestError("CPU vendor is unknown: unable to generate > " > + "kvm module list") > + > yield 'kvm' > yield 'kvm-%s' % (self.cpu_vendor) > if self.extra_modules: _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
