[rhel7/master] Multiple loops shouldn't be fatal (#980510)

Brian C. Lane bcl at redhat.com
Wed Jan 7 17:23:41 UTC 2015


On Wed, Jan 07, 2015 at 08:44:55AM -0500, Anne Mulhern wrote:
> 
> 
> 
> 
> ----- Original Message -----
> > From: "Vratislav Podzimek" <vpodzime at redhat.com>
> > To: "anaconda patch review" <anaconda-patches at lists.fedorahosted.org>
> > Sent: Tuesday, January 6, 2015 1:38:23 PM
> > Subject: Re: [rhel7/master] Multiple loops shouldn't be fatal (#980510)
> > 
> > On Tue, 2015-01-06 at 10:25 -0800, Brian C. Lane wrote:
> > > Backing files can have multiple loops associated with them without
> > > problems. Raising an error here causes a crash when using an iso for
> > > both stage2 and for the repo (eg. boot with
> > > inst.repo=hd:/dev/sdb1:/path-to-dvd.iso).
> > > 
> > > Instead just use the first loop device in the list as the name.
> > > 
> > > Resolves: rhbz#980510
> > > ---
> > >  blivet/devicelibs/loop.py | 5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/blivet/devicelibs/loop.py b/blivet/devicelibs/loop.py
> > > index 0b374a2..1600ed8 100644
> > > --- a/blivet/devicelibs/loop.py
> > > +++ b/blivet/devicelibs/loop.py
> > > @@ -55,8 +55,9 @@ def get_loop_name(path):
> > >      args = ["-j", path]
> > >      buf = losetup(args, capture=True)
> > >      if len(buf.splitlines()) > 1:
> > > -        # there should never be more than one loop device listed
> > > -        raise LoopError("multiple loops associated with %s" % path)
> > > +        # If there are multiple loop devices use the first one
> > > +        buf = buf.splitlines()[0]
> > > +        log.warning("multiple loops associated with %s. Using %s" % (path,
> > > buf))
> > It would be nicer to do splitlines() only once and then check+use the
> > result. But the change genrally looks good to me.
> > 
> 
> I was a bit confused for a while because buf ends up meaning so many things.
> 
> Would be more readable with different names for different things, like:
> 
>       buf = losetup(args, capture=True)
>       entries = buf.splitlines()
>       first_entry = entries[0]
>       if len(entries) > 1:
>         log.warning("multiple loops associated with %s. Using %s" % (path, first_entry))
>       name = os.path.basename(first_entry.split(":")[0])
>       ...

Yeah, it doesn't hurt to just go ahead and allways do the splitlines

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)


More information about the anaconda-patches mailing list