From: Lucas Meneghel Rodrigues <lmr@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: Mike Burns <mburns@redhat.com>,
kvm@vger.kernel.org, ulublin@redhat.com, dhuff@redhat.com
Subject: Re: [PATCH][KVM-AUTOTEST] Make code to remove kvm modules more robust
Date: Tue, 26 May 2009 01:43:15 -0300 [thread overview]
Message-ID: <1243312995.2683.7.camel@localhost.localdomain> (raw)
In-Reply-To: <4A1AC9F2.9030000@redhat.com>
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
prev parent reply other threads:[~2009-05-26 4:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-20 20:04 [PATCH][KVM-AUTOTEST] Make code to remove kvm modules more robust Mike Burns
2009-05-24 15:36 ` Avi Kivity
2009-05-25 13:41 ` Lucas Meneghel Rodrigues
2009-05-25 16:40 ` Avi Kivity
2009-05-26 4:43 ` Lucas Meneghel Rodrigues [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1243312995.2683.7.camel@localhost.localdomain \
--to=lmr@redhat.com \
--cc=avi@redhat.com \
--cc=dhuff@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mburns@redhat.com \
--cc=ulublin@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox