Re: [Libguestfs] [PATCH] v2v: changed to the actual size (if known).

2018-06-21 Thread Pino Toscano
On Monday, 18 June 2018 16:59:49 CEST Richard W.M. Jones wrote:
> Note that this attribute is optional.
> 
> Thanks: Arik Hadas
> ---

LGTM.

Thanks,
-- 
Pino Toscano

signature.asc
Description: This is a digitally signed message part.
___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs

[Libguestfs] [PATCH] v2v: changed to the actual size (if known).

2018-06-18 Thread Richard W.M. Jones
Note that this attribute is optional.

Thanks: Arik Hadas
---
 v2v/create_ovf.ml| 11 ---
 v2v/test-v2v-o-rhv.ovf.expected  |  2 +-
 v2v/test-v2v-o-rhv.sh|  1 +
 v2v/test-v2v-o-vdsm-options.ovf.expected |  2 +-
 v2v/test-v2v-o-vdsm-options.sh   |  1 +
 5 files changed, 12 insertions(+), 5 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  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. *)
diff --git a/v2v/test-v2v-o-rhv.ovf.expected b/v2v/test-v2v-o-rhv.ovf.expected
index 1deec9c9d..7bcc456c5 100644
--- a/v2v/test-v2v-o-rhv.ovf.expected
+++ b/v2v/test-v2v-o-rhv.ovf.expected
@@ -2,7 +2,7 @@
 
   
   
-
+
   
   
 List of networks
diff --git a/v2v/test-v2v-o-rhv.sh b/v2v/test-v2v-o-rhv.sh
index c9ec0dbce..eb22ed95b 100755
--- a/v2v/test-v2v-o-rhv.sh
+++ b/v2v/test-v2v-o-rhv.sh
@@ -74,6 +74,7 @@ sed -i \
   -e "s/$DISK_ID/#DISK_ID#/g" \
   -e "s/$VM_ID/#VM_ID#/g" \
   -e "s/$VOL_ID/#VOL_ID#/g" \
+  -e "s/\('"$RE_UUID"'#UUID#[^<]*#DATE#http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData'
 
xmlns:vssd='http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData'
 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
xmlns:ovf='http://schemas.dmtf.org/ovf/envelope/1/' 
xmlns:ovirt='http://www.ovirt.org/ovf' ovf:version='0.9'>
   
   
-
+
   
   
 List of networks
diff --git a/v2v/test-v2v-o-vdsm-options.sh b/v2v/test-v2v-o-vdsm-options.sh
index 2c9de5eb7..c70446aa1 100755
--- a/v2v/test-v2v-o-vdsm-options.sh
+++ b/v2v/test-v2v-o-vdsm-options.sh
@@ -82,6 +82,7 @@ 
RE_UUID='\<[0-9a-fA-F]\{8\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[
 
 # Filter variable strings
 sed -i \
+  -e "s/\('"$RE_UUID"'#UUID#[^<]*#DATE#https://www.redhat.com/mailman/listinfo/libguestfs