From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH][KVM-AUTOTEST] Make code to remove kvm modules more robust Date: Mon, 25 May 2009 19:40:18 +0300 Message-ID: <4A1AC9F2.9030000@redhat.com> References: <1242849851-8029-1-git-send-email-mburns@redhat.com> <1243258893.2838.18.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Mike Burns , kvm@vger.kernel.org, ulublin@redhat.com, dhuff@redhat.com To: Lucas Meneghel Rodrigues Return-path: Received: from mx2.redhat.com ([66.187.237.31]:39743 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751055AbZEYQkS (ORCPT ); Mon, 25 May 2009 12:40:18 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4PGeKK2030477 for ; Mon, 25 May 2009 12:40:20 -0400 In-Reply-To: <1243258893.2838.18.camel@localhost.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: Lucas Meneghel Rodrigues wrote: > Hi Mike, > > On Wed, 2009-05-20 at 16:04 -0400, Mike Burns wrote: > >> + >> +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) >> > > ignore_status is False by default, so no need to do explicitly pass it > to the function. Also, as we are putting something that can throw an > exception, you can wrap it in a try/except module that throws a > error.TestError exception in case our module removal still fails. > Wrapping every function with try/except defeats the purpose of exceptions. Can't autotest handle arbitrary exceptions? -- error compiling committee.c: too many arguments to function