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

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