On 02/23/2016 09:55 PM, 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@xxxxxxxx> > --- > virtconv/formats.py | 10 ++++++++++ > 1 file changed, 10 insertions(+) > Thanks for the patch! Comments below > diff --git a/virtconv/formats.py b/virtconv/formats.py > index a7f88cb..ab37e10 100644 > --- a/virtconv/formats.py > +++ b/virtconv/formats.py > @@ -275,12 +275,22 @@ 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 > + _run_cmd(decompress_cmd) > _run_cmd(cmd) > decompress_cmd is conditionally defined. you'll need to set decompress_cmd = None first, and have this _run_cmd dependent on that. Also a test case that exercises that code path would be appreciated. Thanks, Cole _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list