Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Multiple loops shouldn't be fatal (#980510)
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
  • Loading branch information
bcl committed Jan 7, 2015
1 parent ddb2e17 commit d63c967
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions blivet/devicelibs/loop.py
Expand Up @@ -54,11 +54,17 @@ def get_backing_file(name):
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)

name = os.path.basename(buf.split(":")[0])
entries = buf.splitlines()
if not entries:
raise LoopError("No loop associated with %s" % (path))

first_entry = entries[0]
if len(entries) > 1:
# If there are multiple loop devices use the first one
log.warning("multiple loops associated with %s. Using %s", path, first_entry)

name = os.path.basename(first_entry.split(":")[0])
return name

def loop_setup(path):
Expand Down

0 comments on commit d63c967

Please sign in to comment.