virt-manager/virtinst-detect-suse-distros.patch
Charles Arnold f71f619bc9 - Update to virt-manager 1.2.0
virt-manager-1.2.0.tar.bz2
  virtinst-default-xen-to-qcow2-format.patch
  * OVMF/AAVMF Support (Laszlo Ersek, Giuseppe Scrivano, Cole Robinson)
  * Improved support for AArch64 qemu/kvm
  * virt-install: Support –disk type=network parameters
  * virt-install: Make –disk just work
  * virt-install: Add –disk sgio= option (Giuseppe Scrivano)
  * addhardware: default to an existing bus when adding a new disk (Giuseppe Scrivano)
  * virt-install: Add –input device option
  * virt-manager: Unify storagebrowser and storage details functionality
  * virt-manager: allow setting a custom connection row name
  * virt-install: Support –hostdev scsi passthrough
  * virt-install: Fill in a bunch of –graphics spice options
  * Disable spice image compression for new local VMs
  * virt-manager: big reworking of the migration dialog
- Dropped tarball and patches
  virt-manager-1.1.0.tar.bz2
  0b391fe9-Gtk-30.patch
  20fe2873-check-for-empty-network-name.patch
  24faf867-ignore-error-403-on-directories.patch
  65f7017e-createnet-fix.patch
  activate-default-console.patch
  ce74cd77-connection-state-tick-updates-lock.patch
  virtinst-ppc64le.patch
  virtinst-supported-disk-formats.patch
  virtinst-support-suse-distros.patch
  virt-manager-1.1.0.tar.bz2
  virtman-default-lxc-uri.patch
  virtman-stable-os-support.patch

OBS-URL: https://build.opensuse.org/package/show/Virtualization/virt-manager?expand=0&rev=226
2015-05-04 20:15:01 +00:00

254 lines
8.7 KiB
Diff

Enhancement to correctly detect SUSE media when such media is
selected as the installation source.
Index: virt-manager-1.1.0/virtinst/urlfetcher.py
===================================================================
--- virt-manager-1.1.0.orig/virtinst/urlfetcher.py
+++ virt-manager-1.1.0/virtinst/urlfetcher.py
@@ -318,6 +318,94 @@ def _distroFromTreeinfo(fetcher, arch, v
return ob
+def _distroFromContent(fetcher, arch, vmtype=None):
+ # Parse content file for the 'LABEL' field containing the distribution name
+ # None if no content, GenericDistro if unknown label type.
+ if not fetcher.hasFile("content"):
+ return None
+
+ distribution = None
+ distro_version = None
+ distro_summary = None
+ distro_distro = None
+ distro_arch = None
+ filename = fetcher.acquireFile("content")
+ cbuf = f = None
+ try:
+ f = open(filename, "r")
+ cbuf = f.read()
+ except:
+ if f:
+ f.close()
+ os.unlink(filename)
+ return None
+ f.close()
+ os.unlink(filename)
+
+ lines = cbuf.splitlines()[1:]
+ for line in lines:
+ if line.startswith("LABEL "):
+ distribution = line.split(' ', 1)
+ elif line.startswith("DISTRO "):
+ distro_distro = line.rsplit(',', 1)
+ elif line.startswith("VERSION "):
+ distro_version = line.split(' ', 1)
+ elif line.startswith("SUMMARY "):
+ distro_summary = line.split(' ', 1)
+ elif line.startswith("BASEARCHS "):
+ distro_arch = line.split(' ', 1)
+ elif line.startswith("DEFAULTBASE "):
+ distro_arch = line.split(' ', 1)
+ elif line.startswith("REPOID "):
+ distro_arch = line.rsplit('/', 1)
+ if distribution and distro_version and distro_arch:
+ break
+
+ if not distribution:
+ if distro_summary:
+ distribution = distro_summary
+ elif distro_distro:
+ distribution = distro_distro
+ if distro_arch:
+ arch = distro_arch[1].strip()
+ else:
+ if cbuf.find("x86_64") != -1:
+ arch = "x86_64"
+ elif cbuf.find("i586") != -1:
+ arch = "i586"
+ elif cbuf.find("s390x") != -1:
+ arch = "s390x"
+
+ dclass = GenericDistro
+ if distribution:
+ if re.match(".*SUSE Linux Enterprise Server*", distribution[1]) or \
+ re.match(".*SUSE SLES*", distribution[1]):
+ dclass = SLESDistro
+ if distro_version is None:
+ distro_version = ['VERSION', distribution[1].strip().rsplit(' ')[4]]
+ elif re.match(".*SUSE Linux Enterprise Desktop*", distribution[1]):
+ dclass = SLEDDistro
+ if distro_version is None:
+ distro_version = ['VERSION', distribution[1].strip().rsplit(' ')[4]]
+ elif re.match(".*openSUSE.*", distribution[1]):
+ dclass = OpensuseDistro
+ if distro_version is None:
+ distro_version = ['VERSION', distribution[0].strip().rsplit(':')[4]]
+ # For tumbleweed we only have an 8 character date string so default to 13.2
+ if distro_version[1] and len(distro_version[1]) == 8:
+ distro_version = ['VERSION', '13.2']
+
+ if distro_version is None:
+ return None
+
+ ob = dclass(fetcher, arch, vmtype)
+ if dclass != GenericDistro:
+ ob.content = distro_version
+
+ # Explictly call this, so we populate os_type/variant info
+ ob.isValidStore()
+
+ return ob
def getDistroStore(guest, fetcher):
stores = []
@@ -334,6 +422,10 @@ def getDistroStore(guest, fetcher):
if dist:
return dist
+ dist = _distroFromContent(fetcher, arch, _type)
+ if dist:
+ return dist
+
stores = _allstores[:]
# If user manually specified an os_distro, bump it's URL class
@@ -375,6 +467,23 @@ def getDistroStore(guest, fetcher):
(fetcher.location, extramsg)))
+def detectMediaDistro(guest, location):
+ """
+ Attempt to detect the os type + variant for the passed location
+ """
+ import urlgrabber
+ meter = urlgrabber.progress.BaseMeter()
+ scratchdir = "/var/tmp"
+ fetcher = fetcherForURI(location, scratchdir, meter)
+
+ try:
+ fetcher.prepareLocation()
+ store = getDistroStore(guest, fetcher)
+ return store.get_osdict_info()
+ finally:
+ fetcher.cleanupLocation()
+
+
##################
# Distro classes #
##################
@@ -832,29 +941,64 @@ class SLDistro(RHELDistro):
class SuseDistro(Distro):
name = "SUSE"
- urldistro = "suse"
- os_variant = "linux"
_boot_iso_paths = ["boot/boot.iso"]
def __init__(self, *args, **kwargs):
+ self.content = None
Distro.__init__(self, *args, **kwargs)
if re.match(r'i[4-9]86', self.arch):
self.arch = 'i386'
- # Tested with Opensuse >= 10.2, 11, and sles 10
- self._hvm_kernel_paths = [("boot/%s/loader/linux" % self.arch,
- "boot/%s/loader/initrd" % self.arch)]
-
- # Matches Opensuse > 10.2 and sles 10
- self._xen_kernel_paths = [("boot/%s/vmlinuz-xen" % self.arch,
- "boot/%s/initrd-xen" % self.arch)]
+ oldkern = "linux"
+ oldinit = "initrd"
+ if self.arch == "x86_64":
+ oldkern += "64"
+ oldinit += "64"
+
+ if self.arch == "s390x" or \
+ self.arch == "ppc64" or self.arch == "ppc64le":
+
+ self._hvm_kernel_paths = [ ("boot/%s/linux" % self.arch,
+ "boot/%s/initrd" % self.arch) ]
+ # No Xen on s390x and ppc
+ self._xen_kernel_paths = []
+ else:
+ # Tested with Opensuse >= 10.2, 11, and sles 10
+ self._hvm_kernel_paths = [ ("boot/%s/loader/linux" % self.arch,
+ "boot/%s/loader/initrd" % self.arch) ]
+ # Tested with Opensuse 10.0
+ self._hvm_kernel_paths.append(("boot/loader/%s" % oldkern,
+ "boot/loader/%s" % oldinit))
+
+ # Matches Opensuse > 10.2 and sles 10
+ self._xen_kernel_paths = [ ("boot/%s/vmlinuz-xen" % self.arch,
+ "boot/%s/initrd-xen" % self.arch) ]
def isValidStore(self):
+ # self.content is the VERSION line from the contents file
+ if self.content is None or self.content[1] is None:
+ return False
+ distro_version = self.content[1].strip()
+ version = distro_version.split('.', 1)[0].strip()
+ if int(version) >= 10:
+ if self.os_variant.startswith("sles"):
+ self.os_variant += version
+ else:
+ self.os_variant += distro_version
+ else:
+ self.os_variant += "9"
+
if not self.fetcher.hasFile("directory.yast"):
return False
self.os_variant = self._detect_osdict_from_url()
+
+ # Reset kernel name for sle11 source on s390x
+ if self.arch == "s390x":
+ if self.os_variant == "sles11" or self.os_variant == "sled11":
+ self._hvm_kernel_paths = [ ("boot/%s/vmrdr.ikr" % self.arch,
+ "boot/%s/initrd" % self.arch) ]
return True
def _get_method_arg(self):
@@ -874,6 +1018,27 @@ class SuseDistro(Distro):
return osobj.name
return self.os_variant
+class SLESDistro(SuseDistro):
+
+ urldistro = "sles"
+ os_variant = "sles"
+
+class SLEDDistro(SuseDistro):
+
+ urldistro = "sled"
+ os_variant = "sled"
+
+# Suse image store is harder - we fetch the kernel RPM and a helper
+# RPM and then munge bits together to generate a initrd
+class OpensuseDistro(SuseDistro):
+
+ urldistro = "opensuse"
+ os_variant = "opensuse"
+
+class OESDistro(SuseDistro):
+
+ urldistro = "oes"
+ os_variant = "oes"
class DebianDistro(Distro):
# ex. http://ftp.egr.msu.edu/debian/dists/sarge/main/installer-i386/
Index: virt-manager-1.1.0/virtinst/distroinstaller.py
===================================================================
--- virt-manager-1.1.0.orig/virtinst/distroinstaller.py
+++ virt-manager-1.1.0/virtinst/distroinstaller.py
@@ -505,6 +505,10 @@ class DistroInstaller(Installer):
"remote connection.")
else:
distro = OSDB.lookup_os_by_media(self.location)
+ # libosinfo relies on treeinfo to detect media which suse
+ # doesn't have. Fallback to url method for detecting ISO media.
+ if distro is None:
+ distro = urlfetcher.detectMediaDistro(guest, self.location)
except:
logging.debug("Error attempting to detect distro.", exc_info=True)