Blob Blame History Raw
From b91e15593f5853a9dfabf734aabacb1cc871da07 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 18 Jun 2018 10:31:18 +0100
Subject: [PATCH] v2v: <File ovf:size> changed to the actual size (if known).

Note that this attribute is optional.

Thanks: Arik Hadas
(cherry picked from commit 75e8b1386766b18aecefdc8a75fbbf85ddb52037)
---
 v2v/create_ovf.ml | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/v2v/create_ovf.ml b/v2v/create_ovf.ml
index e0f81e0a2..9e0c772fd 100644
--- a/v2v/create_ovf.ml
+++ b/v2v/create_ovf.ml
@@ -819,12 +819,17 @@ and add_disks targets guestcaps output_alloc sd_uuid image_uuids vol_uuids
 
       (* Add disk to <References/> node. *)
       let disk =
-        e "File" [
+        let attrs = ref [
           "ovf:href", fileref;
           "ovf:id", vol_uuid;
-          "ovf:size", Int64.to_string ov.ov_virtual_size; (* NB: in bytes *)
           "ovf:description", generated_by;
-        ] [] in
+        ] in
+        (match t.target_actual_size with
+         | None -> ()
+         | Some actual_size ->
+            List.push_back attrs ("ovf:size", Int64.to_string actual_size)
+        );
+        e "File" !attrs [] in
       append_child disk references;
 
       (* Add disk to DiskSection. *)
-- 
2.20.1