Richard W.M. Jones
2018-Jun-18 14:59 UTC
[Libguestfs] [PATCH] v2v: <File ovf:size> changed to the actual size (if known).
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 <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. *) 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 @@ <ovf:Envelope xmlns:rasd='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'> <!-- generated by virt-v2v --> <References> - <File ovf:href='#DISK_ID#/#VOL_ID#' ovf:id='#VOL_ID#' ovf:size='536870912' ovf:description='generated by virt-v2v'/> + <File ovf:href='#DISK_ID#/#VOL_ID#' ovf:id='#VOL_ID#' ovf:description='generated by virt-v2v' ovf:size='#SIZE#'/> </References> <Section xsi:type='ovf:NetworkSection_Type'> <Info>List of networks</Info> 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/\(<File.*ovf:size='\)[^']*/\1#SIZE#/g" \ -e 's/\(\<generated by virt-v2v\) [^ <'"'\""']*/\1/' \ -e 's/<rasd:InstanceId>'"$RE_UUID"'</<rasd:InstanceId>#UUID#</' \ -e 's/<\(rasd:\)\?\(CreationDate\|LastModified\|last_modified_date\)>[^<]*</<\1\2>#DATE#</' \ diff --git a/v2v/test-v2v-o-vdsm-options.ovf.expected b/v2v/test-v2v-o-vdsm-options.ovf.expected index c2a3e336c..c1282c19b 100644 --- a/v2v/test-v2v-o-vdsm-options.ovf.expected +++ b/v2v/test-v2v-o-vdsm-options.ovf.expected @@ -2,7 +2,7 @@ <ovf:Envelope xmlns:rasd='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'> <!-- generated by virt-v2v --> <References> - <File ovf:href='VOL' ovf:id='VOL' ovf:size='536870912' ovf:description='generated by virt-v2v'/> + <File ovf:href='VOL' ovf:id='VOL' ovf:description='generated by virt-v2v' ovf:size='#SIZE#'/> </References> <NetworkSection> <Info>List of networks</Info> 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/\(<File.*ovf:size='\)[^']*/\1#SIZE#/g" \ -e 's/\(\<generated by virt-v2v\) [^ <'"'\""']*/\1/' \ -e 's/<rasd:InstanceId>'"$RE_UUID"'</<rasd:InstanceId>#UUID#</' \ -e 's/<\(rasd:\)\?\(CreationDate\|LastModified\|last_modified_date\)>[^<]*</<\1\2>#DATE#</' \ -- 2.16.2
Seemingly Similar Threads
- [PATCH 1/3] v2v: tests: check generated OVF
- [PATCH 3/3] v2v: vdsm: add --vdsm-fixed-ovf option
- [PATCH] v2v: Add <Disk ovf:capacity> attribute containing disk virtual size.
- [PATCH v2 5/5] v2v: update tests to match changes in OVA import
- [PATCH v8 4/4] v2v: ova: don't extract files from OVA if it's not needed