File virtinst-add-sle16-detection-support.patch of Package virt-manager.20260314124236

Index: virt-manager-5.1.0/virtinst/install/urldetect.py
===================================================================
--- virt-manager-5.1.0.orig/virtinst/install/urldetect.py
+++ virt-manager-5.1.0/virtinst/install/urldetect.py
@@ -247,6 +247,8 @@ class _SUSEContent:
             product_name = self.content_dict["LABEL"]
         elif "," in self.content_dict.get("DISTRO", ""):
             product_name = self.content_dict["DISTRO"].rsplit(",", 1)[1]
+        else:
+            product_name = self.content_dict["DISTRO"]
 
         log.debug("SUSE content product_name=%s", product_name)
         return product_name
@@ -271,27 +273,38 @@ class _SUSEContent:
 
         # Special case, parse version out of a line like this
         # cpe:/o:opensuse:opensuse:13.2,openSUSE
-        if not distro_version and re.match("^.*:.*,openSUSE*", self.content_dict["DISTRO"]):
-            distro_version = self.content_dict["DISTRO"].rsplit(",", 1)[0].strip().rsplit(":")[4]
+        if not distro_version:
+            if "DISTRO" in self.content_dict and re.match("^.*:.*,openSUSE*", self.content_dict["DISTRO"]):
+                distro_version = self.content_dict["DISTRO"].rsplit(",", 1)[0].strip().rsplit(":")[4]
+            elif "openSUSE" in self.product_name:
+                distro_version = self.product_name.strip().rsplit(' ')[1]
         distro_version = distro_version.strip()
 
         if "Enterprise" in self.product_name or "SLES" in self.product_name or "Micro" in self.product_name:
+            product_name = self.product_name.strip().rsplit(' ')
             if " SAP " in self.product_name:
-                sle_version = self.product_name.strip().rsplit(' ')[7]
-            if " High Performance " in self.product_name:
-                sle_version = self.product_name.strip().rsplit(' ')[6]
+                sle_version = product_name[7]
+            elif " High Performance " in self.product_name:
+                sle_version = product_name[6]
+            elif "SUSE SL Micro" in self.product_name:
+                sle_version = product_name[3]
             else:
-                if "SUSE SL Micro" in self.product_name:
-                    sle_version = self.product_name.strip().rsplit(' ')[3]
-                else:
-                    sle_version = self.product_name.strip().rsplit(' ')[4]
-            if len(self.product_name.strip().rsplit(' ')) > 5 and not " Micro " in self.product_name:
+                sle_version = product_name
+                for num in sle_version:
+                    num = num.replace(".0", "", 1)
+                    if num.isnumeric():
+                        sle_version = num
+                        break
+            if len(product_name) > 1 and not " Micro " in self.product_name:
                 if " SAP " in self.product_name:
-                    sle_version = (sle_version + '.' + self.product_name.strip().rsplit(' ')[8][2])
-                if " High Performance " in self.product_name:
-                    sle_version = (sle_version + '.' + self.product_name.strip().rsplit(' ')[7][2])
+                    sle_version = (sle_version + '.' + product_name[8][2])
+                elif " High Performance " in self.product_name:
+                    sle_version = (sle_version + '.' + product_name[7][2])
+                elif int(sle_version) <= 15:
+                    sle_version = (sle_version + '.' + product_name[5][2])
                 else:
-                    sle_version = (sle_version + '.' + self.product_name.strip().rsplit(' ')[5][2])
+                    if len(product_name) > 1 and int(product_name[2]) is not 0:
+                        sle_version = (sle_version + '.' + product_name[2])
             distro_version = sle_version
 
         # SUSE Container as a Service Platform
@@ -518,13 +531,28 @@ class _SuseDistro(_RHELDistro):
 
         if not cache.checked_for_suse_content:
             cache.checked_for_suse_content = True
+            # The content file exists in sles12 and older
             content_str = cache.acquire_file_content("content")
             if content_str is None:
                 products_str = cache.acquire_file_content("media.1/products")
+                if not products_str:
+                    # For SLES16 and Leap 16 install iso
+                    products_str = cache.acquire_file_content("install/media.1/products")
                 if products_str:
                     products_str = products_str.replace('/', ' ,', 1)
                     products_str = "DISTRO " + products_str.replace('-', ' ')
                 media_str = cache.acquire_file_content("media.1/media")
+                if not media_str:
+                    # For SLES16 and Leap 16 install iso
+                    media_str = cache.acquire_file_content("install/media.1/media")
+                    # media.1/products file on SLE16 doesn't help us much, rebuild products_str from media_str
+                    if media_str:
+                        media_str_lines = media_str.strip().splitlines()
+                        if "SLE" in media_str and len(media_str_lines) > 1:
+                            products_str = media_str_lines[1]
+                            products_str = products_str.replace('.', ' ')
+                            products_str = products_str.replace('-', ' ').split()
+                            products_str = "DISTRO " + products_str[0] + " " + products_str[1] + " " + products_str[2]
                 if media_str:
                     media_arch = "x86_64"
                     if 'aarch64' in media_str:
@@ -580,6 +608,10 @@ class _SuseDistro(_RHELDistro):
             if tree_arch == "ppc64":
                 self._kernel_paths.append(("suseboot/linux64", "suseboot/initrd64"))
 
+        # Tested with SLES 16
+        self._kernel_paths.append(
+            ("../boot/%s/loader/linux" % tree_arch,
+             "../boot/%s/loader/initrd" % tree_arch))
         # Tested with SLES 12 for ppc64le, all s390x
         self._kernel_paths.append(("boot/%s/linux" % tree_arch, "boot/%s/initrd" % tree_arch))
         # Tested with Opensuse 10.0
@@ -607,8 +639,12 @@ class _SuseDistro(_RHELDistro):
 
         if str(self._variant_prefix).startswith(("sles", "sled", "oes")):
             sp_version = ""
-            if len(distro_version.split(".", 1)) == 2:
-                sp_version = "sp" + distro_version.split(".", 1)[1].strip()
+            d_version = distro_version.split(".", 1)
+            if len(d_version) == 2:
+                if int(d_version[0]) > 15:
+                    sp_version = "." + d_version[1].strip()
+                else:
+                    sp_version = "sp" + d_version[1].strip()
 
             return self._variant_prefix + version + sp_version
 
@@ -669,7 +705,7 @@ class _SLESDistro(_SuseDistro):
     PRETTY_NAME = "SLES"
     matching_distros = ["sles"]
     _variant_prefix = "sles"
-    _suse_regex = [".*SUSE Linux Enterprise Server*", ".*SUSE SLES*"]
+    _suse_regex = [".*SUSE Linux Enterprise Server*", ".*SLES*", ".*SUSE SLES*"]
     famregex = ".*SUSE Linux Enterprise.*"
 
 
@@ -965,17 +1001,17 @@ def _build_distro_list(osobj):
     allstores = [
         # Libosinfo takes priority
         _LibosinfoDistro,
-        _FedoraDistro,
-        _RHELDistro,
-        _CentOSDistro,
-        _OLDistro,
         _SLEDistro,
         _SLESDistro,
+        _OpensuseDistro,
         _SLEHPCDistro,
         _SLEDDistro,
-        _OpensuseDistro,
         _MICRODistro,
         _CAASPDistro,
+        _FedoraDistro,
+        _RHELDistro,
+        _CentOSDistro,
+        _OLDistro,
         _OESDistro,
         _DebianDistro,
         _UbuntuDistro,
Index: virt-manager-5.1.0/virtManager/createvm.py
===================================================================
--- virt-manager-5.1.0.orig/virtManager/createvm.py
+++ virt-manager-5.1.0/virtManager/createvm.py
@@ -31,7 +31,7 @@ from .storagebrowse import vmmStorageBro
 from .vmwindow import vmmVMWindow
 
 # Number of seconds to wait for media detection
-DETECT_TIMEOUT = 20
+DETECT_TIMEOUT = 30
 
 DEFAULT_MEM = 1024
 
openSUSE Build Service is sponsored by