[Libguestfs] [PATCH 0/5] Import directly from OVA tar archive if possible
Tomáš Golembiovský
tgolembi at redhat.com
Mon Nov 7 15:30:48 UTC 2016
On Mon, 07 Nov 2016 15:03:36 +0100
Pino Toscano <ptoscano at redhat.com> wrote:
> On Friday, 4 November 2016 14:52:48 CET Tomáš Golembiovský wrote:
> > 1) The obviously missing check whether QEMU installed in the system
> > supports the feature we need. Do we already have such (or similar)
> > checks in libguestfs? Should it be compile-time check or runtime
> > check?
>
> - yes, we have version checks for qemu, but only internally in the
> library (and it does not make sense to export)
>
> - runtime check indeed -- for example something like the following
> (taken & simplified from virt-sysprep in the rhel-6.x branches):
>
Thanks. I'll reuse that.
> let qemu_img_version () =
> let cmd = "qemu-img --version" in
> let lines = external_command cmd in
> match lines with
> | [] -> error ("'qemu-img --version' returned no output")
> | line :: _ ->
> try
> sscanf line "qemu-img version %d.%d" (
> fun major minor ->
> let minor = if minor > 9 then 9 else minor in
> float major +. float minor /. 10.
Uhm. I know this is easy to compare with, but why not return a tuple?
QEMU 2.10 will be here sooner than we can imagine.
> )
> with
> Scan_failure msg ->
> warning (f_"warning: failed to read qemu-img version\n line: %S\n message: %s\n%!")
> line msg;
> 0.9
>
> > 2) Lots of 'tar' invocations that may not be easily understandable.
>
> Left some comments about them.
I will try to rewrite that and do the filtering in OCaml.
>
> > 3) We need a check for sparse files in tar archive. There is a GNU
> > extension to tar format that allows space-efficient archiving of
> > sparse files. While the OVF standard does not allow the use of GNU
> > extensions we probably should not rely on that.
>
> Is there a way to detect such kind of files in archives, falling back
> to usual "extract everything" way as done currently.
Sorry, somehow I left out this important piece of information. I didn't
find a way to get this information neither with GNU tar utility nor with
bsdtar. I didn't look at the OCaml tar module too closely yet, so I
don't know if this is possible. libarchive on the other hand is able to
tell us whether the file is sparse or not.
> > To address points 2) and 3) I see two possible options. We can either
> > use some OCaml module that understands tar. There is however a risk that
> > such module won't provide the necessary info to detect 3). The second
> > option is to use e.g. libarchive and write small set of C functions that
> > would implement the necessary magic and use those in OCaml code.
> > Richard, do you have any preferences or suggestions in this matter?
>
> That's a workable way too, IMHO.
>
> Thanks,
> --
> Pino Toscano
--
Tomáš Golembiovský <tgolembi at redhat.com>
More information about the Libguestfs
mailing list