[virt-tools-list] [PATCH 1/2 V3] virt-convert: decompress the .gz files before converting
Cole Robinson
crobinso at redhat.com
Thu Mar 10 01:10:21 UTC 2016
On 03/07/2016 05:39 AM, Lin Ma wrote:
> The OVF specification v1.1.0(page 15) indicates that "Each file
> referenced by a File element may be compressed using gzip
> (see RFC1952)."
>
> In this case the .gz files should be decompressed first before
> converting through qemu-img.
>
> Signed-off-by: Lin Ma <lma at suse.com>
> ---
> virtconv/formats.py | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/virtconv/formats.py b/virtconv/formats.py
> index a7f88cb..6fa6215 100644
> --- a/virtconv/formats.py
> +++ b/virtconv/formats.py
> @@ -263,6 +263,8 @@ class VirtConverter(object):
> """
> binnames = ["qemu-img", "kvm-img"]
>
> + decompress_cmd = None
> +
> if _is_test():
> executable = "/usr/bin/qemu-img"
> else:
> @@ -275,12 +277,23 @@ class VirtConverter(object):
> raise RuntimeError(_("None of %s tools found.") % binnames)
>
> base = os.path.basename(absin)
> + ext = os.path.splitext(base)[1]
> + if (ext and ext[1:] == "gz"):
> + if not find_executable("gzip"):
> + raise RuntimeError("'gzip' is needed to decompress the file, "
> + "but not found.")
> + decompress_cmd = ["gzip", "-d", absin]
> + base = os.path.splitext(base)[0]
> + absin = absin[0:-3]
> + self.print_cb("Running %s" % " ".join(decompress_cmd))
> cmd = [executable, "convert", "-O", disk_format, base, absout]
> self.print_cb("Running %s" % " ".join(cmd))
> if dry:
> return
>
> cmd[4] = absin
> + if decompress_cmd is not None:
> + _run_cmd(decompress_cmd)
> _run_cmd(cmd)
>
> def convert_disks(self, disk_format, destdir=None, dry=False):
>
python setup.py test --coverage, then coverage annotate -d covdir, then look
in covdir/virtconv_formats.py,cover:
> base = os.path.basename(absin)
> ext = os.path.splitext(base)[1]
> if (ext and ext[1:] == "gz"):
! if not find_executable("gzip"):
! raise RuntimeError("'gzip' is needed to decompress the file, "
! "but not found.")
! decompress_cmd = ["gzip", "-d", absin]
! base = os.path.splitext(base)[0]
! absin = absin[0:-3]
! self.print_cb("Running %s" % " ".join(decompress_cmd))
> cmd = [executable, "convert", "-O", disk_format, base, absout]
> self.print_cb("Running %s" % " ".join(cmd))
> if dry:
>
That means the test suite still isn't testing the newly added code, so
something is missing from the test case
- Cole
More information about the virt-tools-list
mailing list