From 81b76796ddf63cf3926fd8a9c451c1a76f0e7693 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Oct 22 2009 13:38:01 +0000 Subject: Ensure unknown OS detection doesn't break the install --- diff --git a/python-virtinst.spec b/python-virtinst.spec index 031cdab..e28bbad 100644 --- a/python-virtinst.spec +++ b/python-virtinst.spec @@ -11,7 +11,7 @@ Summary: Python modules and utilities for installing virtual machines Name: python-%{appname} Version: 0.400.3 -Release: 4%{_extra_release} +Release: 5%{_extra_release} Source0: http://virt-manager.org/download/sources/%{appname}/%{appname}-%{version}.tar.gz Patch1: %{appname}-%{version}-fix-virtimage-scratch.patch Patch2: %{appname}-%{version}-hostdev-libvirt-calls.patch @@ -22,6 +22,8 @@ Patch5: %{appname}-%{version}-updated-trans.patch Patch6: %{appname}-%{version}-preview-detection.patch # Add F12 to os dictionary Patch7: %{appname}-%{version}-f12-distro.patch +# Ensure unknown OS detection doesn't break the install +Patch8: %{appname}-%{version}-safe-os-detect.patch License: GPLv2+ Group: Development/Libraries BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -54,6 +56,7 @@ and install new VMs) and virt-clone (clone an existing virtual machine). %patch5 -p1 %patch6 -p1 %patch7 -p1 +%patch8 -p1 %build python setup.py build @@ -87,6 +90,9 @@ rm -rf $RPM_BUILD_ROOT %{_bindir}/virt-convert %changelog +* Thu Oct 22 2009 Cole Robinson - 0.400.3-5.fc10 +- Ensure unknown OS detection doesn't break the install + * Mon Oct 05 2009 Cole Robinson - 0.400.3-4.fc10 - Fix detection of fedora preview trees (bz 499718) - Add F12 to os dictionary diff --git a/virtinst-0.400.3-safe-os-detect.patch b/virtinst-0.400.3-safe-os-detect.patch new file mode 100644 index 0000000..148d72c --- /dev/null +++ b/virtinst-0.400.3-safe-os-detect.patch @@ -0,0 +1,70 @@ +# HG changeset patch +# User Cole Robinson +# Date 1241726968 14400 +# Node ID db997572bdc8a8fc4c567fbf165f853167dfa462 +# Parent 9768e52d4d624f83853f7f23f85402c8a078eb6f +Make sure autodetected OS type/variant are in the osdict. + +If not, log a message and set the values to None, rather than barf later +down the line. + +diff -r 9768e52d4d62 -r db997572bdc8 virtinst/OSDistro.py +--- a/virtinst/OSDistro.py Thu May 07 15:50:06 2009 -0400 ++++ b/virtinst/OSDistro.py Thu May 07 16:09:28 2009 -0400 +@@ -28,6 +28,7 @@ + import ConfigParser + + import virtinst ++from virtinst.Guest import Guest + from virtinst import _util + from virtinst import _virtinst as _ + +@@ -118,8 +119,9 @@ + if iskernel is True: + # FIXME: We should probably do this for both kernel and boot + # disk? ++ os_type, os_variant = store.get_osdict_info() + return (store.acquireKernel(guest, fetcher, progresscb), +- store.os_type, store.os_variant) ++ os_type, os_variant) + elif iskernel is False: + return store.acquireBootDisk(fetcher, progresscb) + else: +@@ -145,7 +147,7 @@ + import urlgrabber + progress = urlgrabber.progress.BaseMeter() + store = _acquireMedia(None, None, location, progress, arch, "/var/tmp") +- return (store.os_type, store.os_variant) ++ return store.get_osdict_info() + + + def distroFromTreeinfo(fetcher, progresscb, uri, arch, vmtype=None, +@@ -246,6 +248,28 @@ + raise RuntimeError(_("Could not find boot.iso in %s tree." % \ + self.name)) + ++ def get_osdict_info(self): ++ """ ++ Return (distro, variant) tuple, checking to make sure they are valid ++ osdict entries ++ """ ++ if not self.os_type: ++ return (None, None) ++ ++ if self.os_type not in Guest.list_os_types(): ++ logging.debug("%s set os_type to %s, which is not in osdict." % ++ (self, self.os_type)) ++ return (None, None) ++ ++ if (self.os_variant and ++ self.os_variant not in Guest.list_os_variants(self.os_type)): ++ logging.debug("%s set os_variant to %s, which is not in osdict" ++ " for distro %s." % ++ (self, self.os_variant, self.os_type)) ++ return (self.os_type, None) ++ ++ return (self.os_type, self.os_variant) ++ + def _hasTreeinfo(self, fetcher, progresscb): + # all Red Hat based distros should have .treeinfo, perhaps others + # will in time