On Mon, 2009-05-25 at 19:40 +0300, Avi Kivity wrote: > 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? Yes it can, the point is that a failure trying to unload the module leads to a test failure, so the only idea here is try to mark the test as failed (with error.TestFail exception). The CmdError will mark the test as failed anyway, so my suggestion of wrapping the utils.system call with a try/except block is not necessary, Mike can just remove the ignore_status assignment and it's done. -- Lucas Meneghel Rodrigues Software Engineer (QE) Red Hat - Emerging Technologies -- 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