Blame SOURCES/0056-v2v-File-ovf-size-changed-to-the-actual-size-if-know.patch

e9bfca
From b91e15593f5853a9dfabf734aabacb1cc871da07 Mon Sep 17 00:00:00 2001
e9bfca
From: "Richard W.M. Jones" <rjones@redhat.com>
e9bfca
Date: Mon, 18 Jun 2018 10:31:18 +0100
e9bfca
Subject: [PATCH] v2v: <File ovf:size> changed to the actual size (if known).
e9bfca
e9bfca
Note that this attribute is optional.
e9bfca
e9bfca
Thanks: Arik Hadas
e9bfca
(cherry picked from commit 75e8b1386766b18aecefdc8a75fbbf85ddb52037)
e9bfca
---
e9bfca
 v2v/create_ovf.ml | 11 ++++++++---
e9bfca
 1 file changed, 8 insertions(+), 3 deletions(-)
e9bfca
e9bfca
diff --git a/v2v/create_ovf.ml b/v2v/create_ovf.ml
e9bfca
index e0f81e0a2..9e0c772fd 100644
e9bfca
--- a/v2v/create_ovf.ml
e9bfca
+++ b/v2v/create_ovf.ml
e9bfca
@@ -819,12 +819,17 @@ and add_disks targets guestcaps output_alloc sd_uuid image_uuids vol_uuids
e9bfca
 
e9bfca
       (* Add disk to <References/> node. *)
e9bfca
       let disk =
e9bfca
-        e "File" [
e9bfca
+        let attrs = ref [
e9bfca
           "ovf:href", fileref;
e9bfca
           "ovf:id", vol_uuid;
e9bfca
-          "ovf:size", Int64.to_string ov.ov_virtual_size; (* NB: in bytes *)
e9bfca
           "ovf:description", generated_by;
e9bfca
-        ] [] in
e9bfca
+        ] in
e9bfca
+        (match t.target_actual_size with
e9bfca
+         | None -> ()
e9bfca
+         | Some actual_size ->
e9bfca
+            List.push_back attrs ("ovf:size", Int64.to_string actual_size)
e9bfca
+        );
e9bfca
+        e "File" !attrs [] in
e9bfca
       append_child disk references;
e9bfca
 
e9bfca
       (* Add disk to DiskSection. *)
e9bfca
-- 
3d5c2a
2.17.2
e9bfca