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(a)redhat.com>
---
v2v/input_ova.ml | 9 ++++++++-
v2v/test-v2v-i-ova-gz.ovf | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
index 9b8d28aca..40f723633 100644
--- a/v2v/input_ova.ml
+++ b/v2v/input_ova.ml
@@ -276,6 +276,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
+
(* Does the file exist and is it readable? *)
let filename = ovf_folder // filename in
Unix.access filename [Unix.R_OK];
@@ -284,7 +291,7 @@ object
* we must uncompress it into the tmpdir.
*)
let filename =
- if detect_file_type filename = `GZip then (
+ if compressed then (
let new_filename = tmpdir // String.random8 () ^ ".vmdk" in
let cmd =
sprintf "zcat %s > %s" (quote filename) (quote new_filename)
in
diff --git a/v2v/test-v2v-i-ova-gz.ovf b/v2v/test-v2v-i-ova-gz.ovf
index e10ad2bc5..4a03e85fb 100644
--- a/v2v/test-v2v-i-ova-gz.ovf
+++ b/v2v/test-v2v-i-ova-gz.ovf
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Envelope vmw:buildId="build-1750787"
xmlns="http://schemas.dmtf.org/ovf/envelope/1"
xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Re...
xmlns:vmw="http://www.vmware.com/schema/ovf"
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Vi...
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<References>
- <File ovf:href="disk1.vmdk.gz" ovf:id="file1"
ovf:size="7804077568"/>
+ <File ovf:href="disk1.vmdk.gz" ovf:id="file1"
ovf:size="7804077568" ovf:compression="gzip"/>
</References>
<DiskSection>
<Info>Virtual disk information</Info>
--
2.11.0