[rhel7-branch 4/7] Multiple loops shouldn't be fatal (#980510)

bcl installerbot-noreply at redhat.com
Thu May 28 23:36:19 UTC 2015


From: "Brian C. Lane" <bcl at redhat.com>

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
(cherry picked from commit d63c967affc5a6b88c355d6b24089d68080f02e2)
(cherry picked from commit 3e75b1e5abbc3b162fca0dbf57431a892acc9499)
---
 blivet/devicelibs/loop.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/blivet/devicelibs/loop.py b/blivet/devicelibs/loop.py
index 0b374a2..661a32e 100644
--- a/blivet/devicelibs/loop.py
+++ b/blivet/devicelibs/loop.py
@@ -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):


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/af90143b1615b4050bc0b5ccb5fd318b9de3698c


More information about the anaconda-patches mailing list