[v2] Multiple loops shouldn't be fatal (#980510)
Anne Mulhern
amulhern at redhat.com
Wed Jan 7 18:09:37 UTC 2015
----- Original Message -----
> From: "Brian C. Lane" <bcl at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Wednesday, January 7, 2015 12:45:34 PM
> Subject: [v2] 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
> ---
> 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):
> --
> 1.9.3
>
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
>
Ack.
- mulhern
More information about the anaconda-patches
mailing list