|
|
0d20ef |
From 356511f6d9079bb121b211dae4a95a6127ce817f Mon Sep 17 00:00:00 2001
|
|
|
0d20ef |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
0d20ef |
Date: Sat, 18 Oct 2014 18:54:12 +0100
|
|
|
0d20ef |
Subject: [PATCH] v2v: Handle *.vmdk.gz compressed files (RHBZ#1152998).
|
|
|
0d20ef |
|
|
|
0d20ef |
The OVA spec allows the disk images to be gzipped within the OVA
|
|
|
0d20ef |
container.
|
|
|
0d20ef |
|
|
|
0d20ef |
(cherry picked from commit ede39a7591122abe29fc6de29aaa717ee9f8bb55)
|
|
|
0d20ef |
---
|
|
|
0d20ef |
v2v/input_ova.ml | 26 ++++++++++++++++++++++++--
|
|
|
0d20ef |
1 file changed, 24 insertions(+), 2 deletions(-)
|
|
|
0d20ef |
|
|
|
0d20ef |
diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
|
|
|
0d20ef |
index 4ad38a0..001a579 100644
|
|
|
0d20ef |
--- a/v2v/input_ova.ml
|
|
|
0d20ef |
+++ b/v2v/input_ova.ml
|
|
|
0d20ef |
@@ -181,14 +181,36 @@ object
|
|
|
0d20ef |
let file_id = xpath_to_string "rasd:HostResource/text()" "" in
|
|
|
0d20ef |
let rex = Str.regexp "^ovf:/disk/\\(.*\\)" in
|
|
|
0d20ef |
if Str.string_match rex file_id 0 then (
|
|
|
0d20ef |
+ (* Chase the references through to the actual file name. *)
|
|
|
0d20ef |
let file_id = Str.matched_group 1 file_id in
|
|
|
0d20ef |
let expr = sprintf "/ovf:Envelope/ovf:DiskSection/ovf:Disk[@ovf:diskId='%s']/@ovf:fileRef" file_id in
|
|
|
0d20ef |
let file_ref = xpath_to_string expr "" in
|
|
|
0d20ef |
if file_ref == "" then error (f_"error parsing disk fileRef");
|
|
|
0d20ef |
let expr = sprintf "/ovf:Envelope/ovf:References/ovf:File[@ovf:id='%s']/@ovf:href" file_ref in
|
|
|
0d20ef |
- let file_name = xpath_to_string expr "" in
|
|
|
0d20ef |
+ let filename = xpath_to_string expr "" in
|
|
|
0d20ef |
+
|
|
|
0d20ef |
+ (* Does the file exist and is it readable? *)
|
|
|
0d20ef |
+ let filename = exploded // filename in
|
|
|
0d20ef |
+ Unix.access filename [Unix.R_OK];
|
|
|
0d20ef |
+
|
|
|
0d20ef |
+ (* The spec allows the file to be gzip-compressed, in which case
|
|
|
0d20ef |
+ * we must uncompress it into the tmpdir.
|
|
|
0d20ef |
+ *)
|
|
|
0d20ef |
+ let filename =
|
|
|
0d20ef |
+ if detect_file_type filename = `GZip then (
|
|
|
0d20ef |
+ let new_filename = tmpdir // string_random8 () ^ ".vmdk" in
|
|
|
0d20ef |
+ let cmd =
|
|
|
0d20ef |
+ sprintf "zcat %s > %s" (quote filename) (quote new_filename) in
|
|
|
0d20ef |
+ if verbose then printf "%s\n%!" cmd;
|
|
|
0d20ef |
+ if Sys.command cmd <> 0 then
|
|
|
0d20ef |
+ error (f_"error uncompressing %s, see earlier error messages")
|
|
|
0d20ef |
+ filename;
|
|
|
0d20ef |
+ new_filename
|
|
|
0d20ef |
+ )
|
|
|
0d20ef |
+ else filename in
|
|
|
0d20ef |
+
|
|
|
0d20ef |
let disk = {
|
|
|
0d20ef |
- s_qemu_uri= exploded // file_name;
|
|
|
0d20ef |
+ s_qemu_uri = filename;
|
|
|
0d20ef |
s_format = Some "vmdk";
|
|
|
0d20ef |
s_target_dev = Some target_dev;
|
|
|
0d20ef |
} in
|
|
|
0d20ef |
--
|
|
|
0d20ef |
1.8.3.1
|
|
|
0d20ef |
|