From 8fe6a061b00d6c077dae1d3cb804410581437b48 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Mar 06 2014 17:58:21 +0000 Subject: virt-convert: better error if unar is not installed details: Fix fallback if fetching CPU models fails (bz #1072704) fsdetails: Fix adding a filesystem device (bz #1073067) virt-install: Fix --location iso again, and test it (bz #1071513) Handle libvirt generating invalid volume XML (bz #1072770) --- diff --git a/0010-formats-make-sure-unar-is-existed.patch b/0010-formats-make-sure-unar-is-existed.patch new file mode 100644 index 0000000..ba3a60d --- /dev/null +++ b/0010-formats-make-sure-unar-is-existed.patch @@ -0,0 +1,40 @@ +From 732b00a33ef5a3f26b2842fe28dbcea855c1870b Mon Sep 17 00:00:00 2001 +From: Chen Hanxiao +Date: Wed, 5 Mar 2014 10:31:59 +0800 +Subject: [PATCH] formats: make sure 'unar' is existed + +Commit 0b4a72fd77f74e5a9f6885179febe601156df617 +need unar command to do something. + +But if we haven't installed it, the error message +told us nothing valuable as: +"OSError: [Errno 2] No such file or directory" + +This patch will impove the error message. + +Signed-off-by: Chen Hanxiao +(cherry picked from commit 98a27fc7fd5622eb498ce9746275a0ecd04ad139) +--- + virtconv/formats.py | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/virtconv/formats.py b/virtconv/formats.py +index 5eb4356..0663190 100644 +--- a/virtconv/formats.py ++++ b/virtconv/formats.py +@@ -132,6 +132,15 @@ def _find_input(input_file, parser, print_cb): + prefix="virt-convert-tmp", dir=basedir) + + base = os.path.basename(input_file) ++ ++ # check if 'unar' command existed. ++ if not find_executable("unar"): ++ raise RuntimeError(_("%s appears to be an archive, " ++ "but 'unar' is not installed. " ++ "Please either install 'unar', or extract the archive " ++ "yourself and point virt-convert at " ++ "the extracted directory.") % base) ++ + cmd = ["unar", "-o", tempdir, base] + print_cb(_("%s appears to be an archive, running: %s") % + (base, " ".join(cmd))) diff --git a/0011-details-Fix-fallback-if-fetching-CPU-models-fails-bz.patch b/0011-details-Fix-fallback-if-fetching-CPU-models-fails-bz.patch new file mode 100644 index 0000000..4b12d99 --- /dev/null +++ b/0011-details-Fix-fallback-if-fetching-CPU-models-fails-bz.patch @@ -0,0 +1,35 @@ +From 71de6fb1d9ae2894b644006135237e8502f68e47 Mon Sep 17 00:00:00 2001 +From: Cole Robinson +Date: Thu, 6 Mar 2014 11:31:09 -0500 +Subject: [PATCH] details: Fix fallback if fetching CPU models fails (bz + 1072704) + +(cherry picked from commit b078ba8c3d69b62fe748d9182babef8971914277) +--- + virtManager/details.py | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/virtManager/details.py b/virtManager/details.py +index 72e79da..aa66bdb 100644 +--- a/virtManager/details.py ++++ b/virtManager/details.py +@@ -965,8 +965,9 @@ class vmmDetails(vmmGObjectUI): + no_default = not self.is_customize_dialog + + try: +- cpu_values = caps.get_cpu_values(self.vm.get_arch()) ++ cpu_names = caps.get_cpu_values(self.vm.get_arch()).cpus + except: ++ cpu_names = [] + logging.exception("Error populating CPU model list") + + # CPU model combo +@@ -987,7 +988,7 @@ class vmmDetails(vmmGObjectUI): + model.append([_("Clear CPU configuration"), "3", + virtinst.CPU.SPECIAL_MODE_CLEAR, False]) + model.append([None, None, None, True]) +- for name in [c.model for c in cpu_values.cpus]: ++ for name in [c.model for c in cpu_names]: + model.append([name, name, name, False]) + + # Disk cache combo diff --git a/0012-fsdetails-Fix-adding-a-filesystem-device-bz-1073067.patch b/0012-fsdetails-Fix-adding-a-filesystem-device-bz-1073067.patch new file mode 100644 index 0000000..8c1b355 --- /dev/null +++ b/0012-fsdetails-Fix-adding-a-filesystem-device-bz-1073067.patch @@ -0,0 +1,26 @@ +From f64c0b37e9cf986b912f6a87b5fa575cd5e616dd Mon Sep 17 00:00:00 2001 +From: Cole Robinson +Date: Thu, 6 Mar 2014 11:45:26 -0500 +Subject: [PATCH] fsdetails: Fix adding a filesystem device (bz 1073067) + +(cherry picked from commit 9074fc6c6080cf650cf97457dda799700ee2b635) +--- + virtManager/fsdetails.py | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/virtManager/fsdetails.py b/virtManager/fsdetails.py +index b4d991a..cc9fa19 100644 +--- a/virtManager/fsdetails.py ++++ b/virtManager/fsdetails.py +@@ -158,8 +158,9 @@ class vmmFSDetails(vmmGObjectUI): + rowindex=0, check_visible=True) + + def get_config_fs_readonly(self): +- return uiutil.get_list_selection(self.widget("fs-readonly"), +- rowindex=0, check_visible=True) ++ if not self.widget("fs-readonly").is_visible(): ++ return None ++ return self.widget("fs-readonly").get_active() + + def get_config_fs_driver(self): + return uiutil.get_list_selection(self.widget("fs-driver-combo"), diff --git a/0013-virt-install-Fix-location-iso-again-and-test-it-bz-1.patch b/0013-virt-install-Fix-location-iso-again-and-test-it-bz-1.patch new file mode 100644 index 0000000..a42e545 --- /dev/null +++ b/0013-virt-install-Fix-location-iso-again-and-test-it-bz-1.patch @@ -0,0 +1,303 @@ +From 0e71d70efaa1de17cca2ff7eae8c0d1a6ca99929 Mon Sep 17 00:00:00 2001 +From: Cole Robinson +Date: Thu, 6 Mar 2014 12:35:01 -0500 +Subject: [PATCH] virt-install: Fix --location iso again, and test it (bz + 1071513) + +(cherry picked from commit 797afb3b273d08a74119c878b689730f0b36a252) +--- + tests/__init__.py | 2 + + .../compare/virt-install-location-iso.xml | 129 +++++++++++++++++++++ + tests/cli-test-xml/fake.iso | 0 + tests/clitest.py | 1 + + virtinst/distroinstaller.py | 20 ++-- + virtinst/urlfetcher.py | 35 +++--- + 6 files changed, 167 insertions(+), 20 deletions(-) + create mode 100644 tests/cli-test-xml/compare/virt-install-location-iso.xml + create mode 100644 tests/cli-test-xml/fake.iso + +diff --git a/tests/__init__.py b/tests/__init__.py +index 1b1c902..8b26f5b 100644 +--- a/tests/__init__.py ++++ b/tests/__init__.py +@@ -21,6 +21,8 @@ import logging + import os + + os.environ["VIRTINST_TEST_SUITE"] = "1" ++os.environ["VIRTINST_TEST_URL_DIR"] = os.path.abspath( ++ "tests/cli-test-xml/fakefedoratree/") + + import virtinst + virtinst.stable_defaults = False +diff --git a/tests/cli-test-xml/compare/virt-install-location-iso.xml b/tests/cli-test-xml/compare/virt-install-location-iso.xml +new file mode 100644 +index 0000000..64ce9e6 +--- /dev/null ++++ b/tests/cli-test-xml/compare/virt-install-location-iso.xml +@@ -0,0 +1,129 @@ ++ ++ foobar ++ 00000000-1111-2222-3333-444444444444 ++ 65536 ++ 65536 ++ 1 ++ ++ hvm ++ ./virtinst-vmlinuz. ++ ./virtinst-initrd.img. ++ ++ ++ ++ ++ ++ ++ ++ core2duo ++ ++ ++ ++ ++ ++ ++ destroy ++ destroy ++ destroy ++ ++ /usr/bin/qemu-kvm ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ foobar ++ 00000000-1111-2222-3333-444444444444 ++ 65536 ++ 65536 ++ 1 ++ ++ hvm ++ ++ ++ ++ ++ ++ ++ ++ ++ core2duo ++ ++ ++ ++ ++ ++ ++ destroy ++ restart ++ restart ++ ++ /usr/bin/qemu-kvm ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/cli-test-xml/fake.iso b/tests/cli-test-xml/fake.iso +new file mode 100644 +index 0000000..e69de29 +diff --git a/tests/clitest.py b/tests/clitest.py +index dd94bd3..32c29c7 100644 +--- a/tests/clitest.py ++++ b/tests/clitest.py +@@ -528,6 +528,7 @@ c.add_compare("--os-variant fedora20 --nodisks --boot fd --graphics sdl --arch s + c.add_compare("--arch armv7l --machine vexpress-a9 --boot kernel=/f19-arm.kernel,initrd=/f19-arm.initrd,dtb=/f19-arm.dtb,extra_args=\"console=ttyAMA0 rw root=/dev/mmcblk0p3\" --disk %(EXISTIMG1)s --nographics", "arm-vexpress-plain", skip_check=support.SUPPORT_CONN_DISK_SD) + c.add_compare("--arch armv7l --machine vexpress-a15 --boot kernel=/f19-arm.kernel,initrd=/f19-arm.initrd,dtb=/f19-arm.dtb,kernel_args=\"console=ttyAMA0 rw root=/dev/vda3\",extra_args=foo --disk %(EXISTIMG1)s --nographics --os-variant fedora19", "arm-vexpress-f19", skip_check=support.SUPPORT_CONN_VIRTIO_MMIO) + c.add_compare("--arch ppc64 --machine pseries --boot network --disk %(EXISTIMG1)s --os-variant fedora20", "ppc64-pseries-f20") ++c.add_compare("--nodisks --location tests/cli-test-xml/fake.iso", "location-iso") # Using --location iso mounting + c.add_valid("--cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k3 --wait 0 --sound") # HVM windows install with disk + c.add_valid("--os-variant fedora20 --file %(EXISTIMG1)s --location %(TREEDIR)s --extra-args console=ttyS0 --sound") # F14 Directory tree URL install with extra-args + c.add_invalid("--nodisks --boot network --machine foobar") # Unknown machine type +diff --git a/virtinst/distroinstaller.py b/virtinst/distroinstaller.py +index 13ceb6b..ec63ec3 100644 +--- a/virtinst/distroinstaller.py ++++ b/virtinst/distroinstaller.py +@@ -299,11 +299,12 @@ def _upload_media(conn, scratchdir, system_scratchdir, + + + # Enum of the various install media types we can have +-(MEDIA_LOCATION_PATH, ++(MEDIA_LOCATION_DIR, ++ MEDIA_LOCATION_CDROM, + MEDIA_LOCATION_URL, + MEDIA_CDROM_PATH, + MEDIA_CDROM_URL, +- MEDIA_CDROM_IMPLIED) = range(1, 6) ++ MEDIA_CDROM_IMPLIED) = range(1, 7) + + + class DistroInstaller(Installer): +@@ -324,7 +325,11 @@ class DistroInstaller(Installer): + + if self.location and _is_url(self.conn, self.location): + return self.cdrom and MEDIA_CDROM_URL or MEDIA_LOCATION_URL +- return self.cdrom and MEDIA_CDROM_PATH or MEDIA_LOCATION_PATH ++ if self.cdrom: ++ return MEDIA_CDROM_PATH ++ if self.location and os.path.isdir(self.location): ++ return MEDIA_LOCATION_DIR ++ return MEDIA_LOCATION_CDROM + + def _prepare_local(self): + transient = True +@@ -374,7 +379,7 @@ class DistroInstaller(Installer): + def _get_bootdev(self, isinstall, guest): + mediatype = self._get_media_type() + local = mediatype in [MEDIA_CDROM_PATH, MEDIA_CDROM_IMPLIED, +- MEDIA_LOCATION_PATH] ++ MEDIA_LOCATION_DIR, MEDIA_LOCATION_CDROM] + persistent_cd = (local and + self.cdrom and + self.livecd) +@@ -420,9 +425,10 @@ class DistroInstaller(Installer): + return + + dev = None +- if mediatype == MEDIA_CDROM_PATH: ++ if mediatype == MEDIA_CDROM_PATH or mediatype == MEDIA_LOCATION_CDROM: + dev = self._prepare_local() +- else: ++ ++ if mediatype != MEDIA_CDROM_PATH: + fetcher = urlfetcher.fetcherForURI(self.location, + scratchdir, meter) + try: +@@ -454,7 +460,7 @@ class DistroInstaller(Installer): + + mediatype = self._get_media_type() + return mediatype in [MEDIA_CDROM_URL, MEDIA_LOCATION_URL, +- MEDIA_LOCATION_PATH] ++ MEDIA_LOCATION_DIR, MEDIA_LOCATION_CDROM] + + def check_location(self, guest): + mediatype = self._get_media_type() +diff --git a/virtinst/urlfetcher.py b/virtinst/urlfetcher.py +index 3c273e3..0d9a066 100644 +--- a/virtinst/urlfetcher.py ++++ b/virtinst/urlfetcher.py +@@ -189,10 +189,16 @@ class _MountedImageFetcher(_LocalImageFetcher): + Fetcher capable of extracting files from a NFS server + or loopback mounted file, or local CDROM device + """ ++ _in_test_suite = bool("VIRTINST_TEST_SUITE" in os.environ) ++ + def prepareLocation(self): + cmd = None +- self.srcdir = tempfile.mkdtemp(prefix="virtinstmnt.", +- dir=self.scratchdir) ++ ++ if self._in_test_suite: ++ self.srcdir = os.environ["VIRTINST_TEST_URL_DIR"] ++ else: ++ self.srcdir = tempfile.mkdtemp(prefix="virtinstmnt.", ++ dir=self.scratchdir) + mountcmd = "/bin/mount" + + logging.debug("Preparing mount at " + self.srcdir) +@@ -207,21 +213,24 @@ class _MountedImageFetcher(_LocalImageFetcher): + + logging.debug("mount cmd: %s", cmd) + +- ret = subprocess.call(cmd) +- if ret != 0: +- self.cleanupLocation() +- raise ValueError(_("Mounting location '%s' failed") % +- (self.location)) ++ if not self._in_test_suite: ++ ret = subprocess.call(cmd) ++ if ret != 0: ++ self.cleanupLocation() ++ raise ValueError(_("Mounting location '%s' failed") % ++ (self.location)) + return True + + def cleanupLocation(self): + logging.debug("Cleaning up mount at " + self.srcdir) +- cmd = ["/bin/umount", self.srcdir] +- subprocess.call(cmd) +- try: +- os.rmdir(self.srcdir) +- except: +- pass ++ ++ if not self._in_test_suite: ++ cmd = ["/bin/umount", self.srcdir] ++ subprocess.call(cmd) ++ try: ++ os.rmdir(self.srcdir) ++ except: ++ pass + + + class _DirectImageFetcher(_LocalImageFetcher): diff --git a/0014-Handle-libvirt-generating-invalid-volume-XML-bz-1072.patch b/0014-Handle-libvirt-generating-invalid-volume-XML-bz-1072.patch new file mode 100644 index 0000000..6403572 --- /dev/null +++ b/0014-Handle-libvirt-generating-invalid-volume-XML-bz-1072.patch @@ -0,0 +1,37 @@ +From 02ad309daaedc409d8ecd5e493a19b06529e5f10 Mon Sep 17 00:00:00 2001 +From: Cole Robinson +Date: Thu, 6 Mar 2014 12:04:08 -0500 +Subject: [PATCH] Handle libvirt generating invalid volume XML (bz 1072770) + +(cherry picked from commit df7012a68b6a13a676e2019523f6863617a110d8) +--- + virtManager/connection.py | 2 +- + virtinst/connection.py | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/virtManager/connection.py b/virtManager/connection.py +index 96dfa1c..57e143d 100644 +--- a/virtManager/connection.py ++++ b/virtManager/connection.py +@@ -179,7 +179,7 @@ class vmmConnection(vmmGObject): + for vol in pool.get_volumes(refresh=False).values(): + try: + ret.append(vol.get_xmlobj(refresh_if_nec=False)) +- except libvirt.libvirtError, e: ++ except Exception, e: + logging.debug("Fetching volume XML failed: %s", e) + return ret + self._backend.cb_fetch_all_vols = fetch_all_vols +diff --git a/virtinst/connection.py b/virtinst/connection.py +index a915f25..3cc5b79 100644 +--- a/virtinst/connection.py ++++ b/virtinst/connection.py +@@ -222,7 +222,7 @@ class VirtualConnection(object): + try: + xml = vol.XMLDesc(0) + ret.append(StorageVolume(weakref.ref(self), parsexml=xml)) +- except libvirt.libvirtError, e: ++ except Exception, e: + logging.debug("Fetching volume XML failed: %s", e) + + if self.cache_object_fetch: diff --git a/0015-xmlbuilder-Log-broken-XML-if-we-can-t-parse-it.patch b/0015-xmlbuilder-Log-broken-XML-if-we-can-t-parse-it.patch new file mode 100644 index 0000000..88c3eab --- /dev/null +++ b/0015-xmlbuilder-Log-broken-XML-if-we-can-t-parse-it.patch @@ -0,0 +1,31 @@ +From f65c9dd2d1baccb66e1ac985e50d8cd021e59509 Mon Sep 17 00:00:00 2001 +From: Cole Robinson +Date: Tue, 25 Feb 2014 12:45:15 -0500 +Subject: [PATCH] xmlbuilder: Log broken XML if we can't parse it + +Related to https://bugzilla.redhat.com/show_bug.cgi?id=1066564 + +(cherry picked from commit 87c2ff1a14f3a78648c8a17cfa72e83098763ec8) +--- + virtinst/xmlbuilder.py | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/virtinst/xmlbuilder.py b/virtinst/xmlbuilder.py +index d46738c..328f6f2 100644 +--- a/virtinst/xmlbuilder.py ++++ b/virtinst/xmlbuilder.py +@@ -686,7 +686,13 @@ class _XMLState(object): + else: + if not xml: + xml = self.make_xml_stub() +- doc = libxml2.parseDoc(xml) ++ ++ try: ++ doc = libxml2.parseDoc(xml) ++ except: ++ logging.debug("Error parsing xml=\n%s", xml) ++ raise ++ + self.xml_root_doc = _DocCleanupWrapper(doc) + self.xml_node = doc.children + self.xml_node.virtinst_is_build = self.is_build diff --git a/0016-xmlbuilder-Actually-import-logging.patch b/0016-xmlbuilder-Actually-import-logging.patch new file mode 100644 index 0000000..55fb18b --- /dev/null +++ b/0016-xmlbuilder-Actually-import-logging.patch @@ -0,0 +1,22 @@ +From 8bac5c2dc1b66fb78b82cbd41d385a166073c7c4 Mon Sep 17 00:00:00 2001 +From: Cole Robinson +Date: Tue, 25 Feb 2014 14:56:54 -0500 +Subject: [PATCH] xmlbuilder: Actually import logging + +(cherry picked from commit 0b94c83beb361712c7a6af4dd5da4f6ff1658967) +--- + virtinst/xmlbuilder.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/virtinst/xmlbuilder.py b/virtinst/xmlbuilder.py +index 328f6f2..1be1cf9 100644 +--- a/virtinst/xmlbuilder.py ++++ b/virtinst/xmlbuilder.py +@@ -20,6 +20,7 @@ + # MA 02110-1301 USA. + + import copy ++import logging + import os + import re + diff --git a/virt-manager.spec b/virt-manager.spec index aefda90..147e1e7 100644 --- a/virt-manager.spec +++ b/virt-manager.spec @@ -20,7 +20,7 @@ %define _version 1.0.0 -%define _release 3 +%define _release 4 # This macro is used for the continuous automated builds. It just @@ -56,6 +56,18 @@ Patch0007: 0007-engine-Fix-closing-connection-when-tick-fails-bz-106.patch Patch0008: 0008-vmm-connection-Handle-missing-storage-volumes-bz-107.patch # Fix unsetting 'auto resize' console property Patch0009: 0009-console-Fix-unsetting-resize-guest-property-from-UI.patch +# virt-convert: better error if unar is not installed +Patch0010: 0010-formats-make-sure-unar-is-existed.patch +# details: Fix fallback if fetching CPU models fails (bz #1072704) +Patch0011: 0011-details-Fix-fallback-if-fetching-CPU-models-fails-bz.patch +# fsdetails: Fix adding a filesystem device (bz #1073067) +Patch0012: 0012-fsdetails-Fix-adding-a-filesystem-device-bz-1073067.patch +# virt-install: Fix --location iso again, and test it (bz #1071513) +Patch0013: 0013-virt-install-Fix-location-iso-again-and-test-it-bz-1.patch +# Handle libvirt generating invalid volume XML (bz #1072770) +Patch0014: 0014-Handle-libvirt-generating-invalid-volume-XML-bz-1072.patch +Patch0015: 0015-xmlbuilder-Log-broken-XML-if-we-can-t-parse-it.patch +Patch0016: 0016-xmlbuilder-Actually-import-logging.patch BuildArch: noarch @@ -138,6 +150,18 @@ machine). %patch0008 -p1 # Fix unsetting 'auto resize' console property %patch0009 -p1 +# virt-convert: better error if unar is not installed +%patch0010 -p1 +# details: Fix fallback if fetching CPU models fails (bz #1072704) +%patch0011 -p1 +# fsdetails: Fix adding a filesystem device (bz #1073067) +%patch0012 -p1 +# virt-install: Fix --location iso again, and test it (bz #1071513) +%patch0013 -p1 +# Handle libvirt generating invalid volume XML (bz #1072770) +%patch0014 -p1 +%patch0015 -p1 +%patch0016 -p1 %build %if %{qemu_user} @@ -247,6 +271,13 @@ fi %changelog +* Thu Mar 06 2014 Cole Robinson - 1.0.0-4 +- virt-convert: better error if unar is not installed +- details: Fix fallback if fetching CPU models fails (bz #1072704) +- fsdetails: Fix adding a filesystem device (bz #1073067) +- virt-install: Fix --location iso again, and test it (bz #1071513) +- Handle libvirt generating invalid volume XML (bz #1072770) + * Fri Feb 28 2014 Cole Robinson - 1.0.0-3 - Fix creating storage paths if directory is all digits (bz #1069351) - Properly close connection if tick fails (bz #1069351)