From 9c051fe65f9435a8a0ad82a58843e6e81d2e45c2 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 1 Aug 2019 19:15:08 -0400 Subject: [PATCH] osdict: Use media_create_from_location_with_flags If it's available, because it fixes detection of non-bootable media, like debian s390x --- virtinst/osdict.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/virtinst/osdict.py b/virtinst/osdict.py index 9ec0e2016..c4b08f2f8 100644 --- a/virtinst/osdict.py +++ b/virtinst/osdict.py @@ -19,6 +19,16 @@ def _in_testsuite(): return "VIRTINST_TEST_SUITE" in os.environ +def _media_create_from_location(location): + if not hasattr(Libosinfo.Media, "create_from_location_with_flags"): + return Libosinfo.Media.create_from_location(location, None) + + # We prefer this API, because by default it will not + # reject non-bootable media, like debian s390x + # pylint: disable=no-member + return Libosinfo.Media.create_from_location_with_flags(location, None, 0) + + ################### # Sorting helpers # ################### @@ -236,7 +246,7 @@ class _OSDB(object): def guess_os_by_iso(self, location): try: - media = Libosinfo.Media.create_from_location(location, None) + media = _media_create_from_location(location) except Exception as e: log.debug("Error creating libosinfo media object: %s", str(e)) return None