From patchwork Fri Sep 25 04:53:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 50098 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8P4rT2m028590 for ; Fri, 25 Sep 2009 04:53:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751585AbZIYExG (ORCPT ); Fri, 25 Sep 2009 00:53:06 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751407AbZIYExF (ORCPT ); Fri, 25 Sep 2009 00:53:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10680 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751466AbZIYExD (ORCPT ); Fri, 25 Sep 2009 00:53:03 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8P4r6SO004162; Fri, 25 Sep 2009 00:53:06 -0400 Received: from localhost.localdomain (vpn-12-76.rdu.redhat.com [10.11.12.76]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8P4r3T9005945; Fri, 25 Sep 2009 00:53:04 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH] KVM test: Make possible to build older KVM trees Date: Fri, 25 Sep 2009 01:53:01 -0300 Message-Id: <1253854381-5325-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org * Made the build of older KVM trees possible * Now the test handles loading extra modules, improved module loading code * Other small cleanups Signed-off-by: Lucas Meneghel Rodrigues --- client/tests/kvm/tests/build.py | 125 ++++++++++++++++++++++---------------- 1 files changed, 72 insertions(+), 53 deletions(-) diff --git a/client/tests/kvm/tests/build.py b/client/tests/kvm/tests/build.py index 2b3c6b6..0e6ec40 100644 --- a/client/tests/kvm/tests/build.py +++ b/client/tests/kvm/tests/build.py @@ -66,41 +66,40 @@ def load_kvm_modules(module_dir=None, load_stock=False, extra_modules=None): kvm_vendor_module_path = None abort = False + list_modules = ['kvm.ko', 'kvm-%s.ko' % vendor] + if extra_modules: + for extra_module in extra_modules: + list_modules.append('%s.ko' % extra_module) + + list_module_paths = [] for folder, subdirs, files in os.walk(module_dir): - if "kvm.ko" in files: - kvm_module_path = os.path.join(folder, "kvm.ko") - kvm_vendor_module_path = os.path.join(folder, "kvm-%s.ko" % - vendor) - if extra_modules: - extra_module_list = [] - for module in extra_modules: - extra_module_list.append(os.path.join(folder, - "%s.ko" % module)) - - if not kvm_module_path: - logging.error("Could not find kvm.ko inside the source dir") - abort = True - if not kvm_vendor_module_path: - logging.error("Could not find kvm-%s.ko inside the source dir") - abort = True - - if abort: + for module in list_modules: + if module in files: + module_path = os.path.join(folder, module) + list_module_paths.append(module_path) + + # We might need to arrange the modules in the correct order + # to avoid module load problems + list_modules_load = [] + for module in list_modules: + for module_path in list_module_paths: + if os.path.basename(module_path) == module: + list_modules_load.append(module_path) + + if len(list_module_paths) != len(list_modules): logging.error("KVM modules not found. If you don't want to use the " "modules built by this test, make sure the option " "load_modules: 'no' is marked on the test control " "file.") - raise error.TestFail("Could not find one KVM test modules on %s " - "source dir" % module_dir) + raise error.TestError("The modules %s were requested to be loaded, " + "but the only modules found were %s" % + (list_modules, list_module_paths)) - try: - utils.system('insmod %s' % kvm_module_path) - utils.system('insmod %s' % kvm_vendor_module_path) - if extra_modules: - for module in extra_module_list: - utils.system('insmod %s' % module) - - except Exception, e: - raise error.TestFail("Failed to load KVM modules: %s" % e) + for module_path in list_modules_load: + try: + utils.system("insmod %s" % module_path) + except Exception, e: + raise error.TestFail("Failed to load KVM modules: %s" % e) if load_stock: logging.info("Loading current system KVM modules...") @@ -166,18 +165,10 @@ class KojiInstaller: self.koji_cmd = params.get("koji_cmd", default_koji_cmd) - if not os_dep.command("rpm"): - raise error.TestError("RPM package manager not available. Are " - "you sure you are using an RPM based system?") - if not os_dep.command("yum"): - raise error.TestError("Yum package manager not available. Yum is " - "necessary to handle package install and " - "update.") - if not os_dep.command(self.koji_cmd): - raise error.TestError("Build server command %s not available. " - "You need to install the appropriate package " - "(usually koji and koji-tools)" % - self.koji_cmd) + # Checking if all required dependencies are available + os_dep.command("rpm") + os_dep.command("yum") + os_dep.command(self.koji_cmd) self.src_pkg = params.get("src_pkg", default_src_pkg) self.pkg_list = params.get("pkg_list", default_pkg_list) @@ -377,18 +368,20 @@ class SourceDirInstaller: os.chdir(srcdir) self.srcdir = os.path.join(srcdir, utils.extract_tarball(tarball)) self.repo_type = kvm_utils.check_kvm_source_dir(self.srcdir) + self.extra_modules = params.get('extra_modules', None) configure_script = os.path.join(self.srcdir, 'configure') self.configure_options = check_configure_options(configure_script) def __build(self): + make_jobs = utils.count_cpus() os.chdir(self.srcdir) # For testing purposes, it's better to build qemu binaries with # debugging symbols, so we can extract more meaningful stack traces. cfg = "./configure --prefix=%s" % self.prefix if "--disable-strip" in self.configure_options: cfg += " --disable-strip" - steps = [cfg, "make clean", "make -j %s" % (utils.count_cpus() + 1)] + steps = [cfg, "make clean", "make -j %s" % make_jobs] logging.info("Building KVM") for step in steps: utils.system(step) @@ -405,7 +398,8 @@ class SourceDirInstaller: def __load_modules(self): - load_kvm_modules(self.srcdir) + load_kvm_modules(module_dir=self.srcdir, + extra_modules=self.extra_modules) def install(self): @@ -432,6 +426,13 @@ class GitInstaller: self.test_bindir = test.bindir prefix = os.path.join(test.bindir, 'build') self.prefix = os.path.abspath(prefix) + # Current host kernel directory + default_host_kernel_source = '/lib/modules/%s/build' % os.uname()[2] + self.host_kernel_srcdir = params.get('host_kernel_source', + default_host_kernel_source) + # Extra parameters that can be passed to the configure script + self.extra_configure_options = params.get('extra_configure_options', + None) # Are we going to load modules? load_modules = params.get('load_modules') if not load_modules: @@ -441,6 +442,8 @@ class GitInstaller: elif load_modules == 'no': self.load_modules = False + self.extra_modules = params.get("extra_modules", None) + kernel_repo = params.get("git_repo") user_repo = params.get("user_git_repo") kmod_repo = params.get("kmod_repo") @@ -489,32 +492,46 @@ class GitInstaller: def __build(self): + # Number of concurrent build tasks + make_jobs = utils.count_cpus() if self.kmod_srcdir: logging.info('Building KVM modules') os.chdir(self.kmod_srcdir) utils.system('./configure') utils.system('make clean') utils.system('make sync LINUX=%s' % self.kernel_srcdir) - utils.system('make -j %s' % utils.count_cpus()) + utils.system('make -j %s' % make_jobs) + logging.info('Building KVM userspace code') os.chdir(self.userspace_srcdir) cfg = './configure --prefix=%s' % self.prefix if "--disable-strip" in self.configure_options: cfg += ' --disable-strip' + if self.extra_configure_options: + cfg = ' %s' % self.extra_configure_options utils.system(cfg) utils.system('make clean') - utils.system('make -j %s' % utils.count_cpus()) + utils.system('make -j %s' % make_jobs) else: + logging.info('Building KVM modules') os.chdir(self.userspace_srcdir) - cfg = './configure --prefix=%s' % self.prefix - if "--disable-strip" in self.configure_options: - cfg += ' --disable-strip' + cfg = './configure --kerneldir=%s' % self.host_kernel_srcdir utils.system(cfg) - logging.info('Building KVM modules') utils.system('make clean') - utils.system('make -C kernel LINUX=%s sync' % self.kernel_srcdir) + utils.system('make -j %s -C kernel LINUX=%s sync' % + (make_jobs, self.kernel_srcdir)) + logging.info('Building KVM userspace code') - utils.system('make -j %s' % utils.count_cpus()) + # This build method (no kvm-kmod) requires that we execute + # configure again, but now let's use the full command line. + cfg += ' --prefix=%s' % self.prefix + if "--disable-strip" in self.configure_options: + cfg += ' --disable-strip' + if self.extra_configure_options: + cfg += ' %s' % self.extra_configure_options + steps = [cfg, 'make -j %s' % make_jobs] + for step in steps: + utils.system(step) def __install(self): @@ -525,9 +542,11 @@ class GitInstaller: def __load_modules(self): if self.kmod_srcdir: - load_kvm_modules(self.kmod_srcdir) + load_kvm_modules(module_dir=self.kmod_srcdir, + extra_modules=self.extra_modules) else: - load_kvm_modules(self.userspace_srcdir) + load_kvm_modules(module_dir=self.userspace_srcdir, + extra_modules=self.extra_modules) def install(self):