On Wednesday, 7 December 2016 17:13:06 CET Tomáš Golembiovský wrote:
The information whether the disk is gzip compressed or not is stored in the OVF. There is no reason to do the detection.
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> --- v2v/input_ova.ml | 28 +++++++++++++++++----------- v2v/test-v2v-i-ova-gz.ovf | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml index b283629..61930f0 100644 --- a/v2v/input_ova.ml +++ b/v2v/input_ova.ml @@ -275,6 +275,13 @@ object | None -> error (f_"no href in ovf:File (id=%s)") file_ref | Some s -> s in
+ let expr = sprintf "/ovf:Envelope/ovf:References/ovf:File[@ovf:id='%s']/@ovf:compression" file_ref in + let compressed = + match xpath_string expr with + | None | Some "identity" -> false + | Some "gzip" -> true + | Some s -> error (f_"unsupported compression in OVF: %s") s in
I'd still do the detection when no ovf:compression attribute is found (that is, the None case above). After all, right now we do the detection for any ova already, so a "broken ova" (with no compression attribute in the ovf but with a compressed image) is already handled by the current code. It could look something like this: let compressed = match xpath_string expr with | None -> None | Some "identity" -> Some false | Some "gzip" -> Some true | Some s -> error (f_"unsupported compression in OVF: %s") s in let compressed = match compressed with | None -> (* do detection *) | Some c -> c in Thanks, -- Pino Toscano