From patchwork Wed May 20 20:04:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Burns X-Patchwork-Id: 25081 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 n4KK4I1E002500 for ; Wed, 20 May 2009 20:04:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755079AbZETUEO (ORCPT ); Wed, 20 May 2009 16:04:14 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754848AbZETUEO (ORCPT ); Wed, 20 May 2009 16:04:14 -0400 Received: from mx1.redhat.com ([66.187.233.31]:59147 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753155AbZETUEN (ORCPT ); Wed, 20 May 2009 16:04:13 -0400 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n4KK4Flh003279 for ; Wed, 20 May 2009 16:04:15 -0400 Received: from mburns.csb (vpn-10-87.bos.redhat.com [10.16.10.87]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n4KK4DtE032601; Wed, 20 May 2009 16:04:13 -0400 Received: by mburns.csb (Postfix, from userid 13432) id 8E5D5A84CC; Wed, 20 May 2009 16:04:11 -0400 (EDT) From: Mike Burns To: kvm@vger.kernel.org Cc: lmr@redhat.com, ulublin@redhat.com, dhuff@redhat.com, Mike Burns Subject: [PATCH][KVM-AUTOTEST] Make code to remove kvm modules more robust Date: Wed, 20 May 2009 16:04:11 -0400 Message-Id: <1242849851-8029-1-git-send-email-mburns@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Mike Burns --- client/tests/kvm_runtest_2/kvm_install.py | 56 ++++++++++++++++++++++++---- 1 files changed, 48 insertions(+), 8 deletions(-) diff --git a/client/tests/kvm_runtest_2/kvm_install.py b/client/tests/kvm_runtest_2/kvm_install.py index 5429a65..d1aceb2 100755 --- a/client/tests/kvm_runtest_2/kvm_install.py +++ b/client/tests/kvm_runtest_2/kvm_install.py @@ -86,11 +86,11 @@ def run_kvm_install(test, params, env): kvm_log.error(message) raise error.TestError, message for k in params.keys(): - kvm_log.info("Adding KVM_INSTALL_%s to Environment" % (k)) - os.putenv("KVM_INSTALL_%s" % (k), str(params[k])) - kvm_log.info("Running " + script + " to install kvm") + kvm_log.info("Adding KVM_INSTALL_%s to Environment" % (k)) + os.putenv("KVM_INSTALL_%s" % (k), str(params[k])) + kvm_log.info("Running " + script + " to install kvm") os.system("cd %s; %s" % (test.bindir, script)) - kvm_log.info("Completed %s" % (script)) + kvm_log.info("Completed %s" % (script)) # invalid installation mode else: @@ -215,11 +215,11 @@ def __load_kvm_modules(): kvm_log.info("Unloading loaded KVM modules (if present)...") #utils.system("pkill qemu 1>/dev/null 2>&1", ignore_status=True) utils.system("pkill qemu", ignore_status=True) - #if utils.system("grep kvm_%s /proc/modules 1>/dev/null" % vendor, ignore_status=True) == 0: - utils.system("/sbin/rmmod kvm_%s" % vendor, ignore_status=True) - #if utils.system("grep kvm /proc/modules 1>/dev/null", ignore_status=True) == 0: - utils.system("/sbin/rmmod kvm", ignore_status=True) + # Remove existing modules + kvm_log.info("Checking KVM module") + __unload_modules("kvm") + if utils.system("grep kvm /proc/modules 1>/dev/null", ignore_status=True) == 0: message = "Failed to remove old KVM modules" kvm_log.error(message) @@ -241,6 +241,46 @@ def __load_kvm_modules(): kvm_log.error(message) raise error.TestError, message + +def __unload_modules(module): + lsmod = os.popen("lsmod | grep \"^%s \"" % module) + line_parts = lsmod.readline().split() + if len(line_parts) == 0: + kvm_log.info("%s not loaded." % module) + else: + kvm_log.info("Found module %s, checking for dependecies..." %module) + if len(line_parts) == 4: + submodules = line_parts[3].split(",") + for submodule in submodules: + __unload_modules(submodule) + else: + kvm_log.info("No modules dependent on %s" % module ) + + kvm_log.info("Removing module: %s" % module) + utils.system("/sbin/modprobe -r %s" % module, ignore_status=False) + + + + #line_count = os.popen("lsmod | grep \"^%s \" | wc -l" % module) + #if line_count > 0: + #kvm_log.info("Found module %s, checking for dependecies..." %module) + #dependencies = os.popen("lsmod | grep \"^%s \" | awk '{print $4}'" % module).readline() + #submodules = dependencies.split(",") + #for submodule in submodules: + #__unload_modules(submodule) +# + # + #kvm_log.info("Found module %s" % module) + #dependencies = os.popen("lsmod | grep \"^%s \" | awk '{print $4}'" % module) + #for line in dependencies.readlines(): + #print "Line: %s" % line + #submodules = line.split(",") +## for submodule in submodules: +## __unload_modules(submodule) + #raise error.TestError, "Aborting..." + #kvm_log.info("Deleting Module %s" % module) + #utils.system("/sbin/modprobe -r %s" % module) + def __install_kvm(test, srcdir): # create destination dir