Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1056126 - virt-v2v OVA/OVF import fails with 'MegaBytes' as memory allocation units
Summary: virt-v2v OVA/OVF import fails with 'MegaBytes' as memory allocation units
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-01-21 14:37 UTC by Ronald van Zantvoort
Modified: 2015-08-27 14:33 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-04-15 15:47:34 UTC


Attachments (Terms of Use)
Proposed patch; fully compliant with OVF specs AFAICT (deleted)
2014-01-21 15:54 UTC, Ronald van Zantvoort
no flags Details | Diff
Revised patch; split out byte-calculation into function (deleted)
2014-01-22 16:13 UTC, Ronald van Zantvoort
no flags Details | Diff


Links
System ID Priority Status Summary Last Updated
Red Hat Bugzilla 1056045 None None None Never
Red Hat Bugzilla 1056534 None None None Never
Red Hat Bugzilla 1056640 None None None Never
Red Hat Bugzilla 1056983 None None None Never
Red Hat Bugzilla 1057006 None None None Never


Description Ronald van Zantvoort 2014-01-21 14:37:29 UTC
Description of problem:
When an OVF file (for example) contains these lines:
   <Item>
        <rasd:AllocationUnits>MegaBytes</rasd:AllocationUnits>
        <rasd:Caption>512 MB of memory</rasd:Caption>
        <rasd:Description>Memory Size</rasd:Description>
        <rasd:ElementName>512 MB of memory</rasd:ElementName>
        <rasd:InstanceID>2</rasd:InstanceID>
        <rasd:ResourceType>4</rasd:ResourceType>
        <rasd:VirtualQuantity>512</rasd:VirtualQuantity>
   </Item>
virt-v2v craps up with:
Unexpected memory units: MegaBytes at /usr/share/perl5/vendor_perl/Sys/VirtConvert/Connection/VMwareOVASource.pm line 133.

Version-Release number of selected component (if applicable):
Fedora 20 w/virt-v2v 0.9.0

How reproducible:
Import an (OVA with an) OVF file with anything other than 'byte' as memory allocation units.

Additional info:
The DMTF OVF standard (http://www.dmtf.org/standards/ovf) states under 8.1 that "this virtual hardware description is based on the CIM classes CIM_VirtualSystemSettingData and 
CIM_ResourceAllocationSettingData"

CIM_ResourceAllocationSettingData (http://schemas.dmtf.org/wbem/cim-html/2.31.0/CIM_ResourceAllocationSettingData.html) states for AllocationUnits that "The value of this property shall be a legal value of the Programmatic Units qualifier as defined in Annex C.1 of DSP0004".

DSP0004 (http://www.dmtf.org/sites/default/files/standards/documents/DSP0004V2.3_final.pdf) specifies for related sizes "Bytes, KiloBytes, MegaBytes, GigaBytes" as valid UNITS.

The code in VMwareOVASource.pm (the name of which in and of itself is a bit odd, considering OVA/OVF is an open standard) reads:

   if (defined($memory)) {
        my $units = _node_val($memory, 'rasd:AllocationUnits/text()');
        $units =~ /^byte \* 2\^(\d+)$/ or die "Unexpected memory units: $units";
        $units = 2 ** $1;
        $memory = _node_val($memory, 'rasd:VirtualQuantity/text()') * $units;
    } else {
        $memory = 1 * 1024 * 1024 * 1024; # Shouldn't happen, but default to 1GB RAM
    }

The ^byte is strictly speaking wrong because of capitalization, but regardless, anything not in bytes is considered 'Unexpected'.

Comment 1 Ronald van Zantvoort 2014-01-21 14:48:10 UTC
hmmm... Strangely enough the examples in the comments behind AllocationUnits do specify 'bytes*10^3' as specific possibility :) However, so would 'bytes' be, which is something the code doesn't take into account either, nor decimal counts.

Comment 2 Ronald van Zantvoort 2014-01-21 15:54:51 UTC
Created attachment 853338 [details]
Proposed patch; fully compliant with OVF specs AFAICT

Patch changes the Memory parser to include the full OVF spec. Old parser just supported 

'byte * 2^[number]', new parser accepts for example:
'byte'
'MegaBytes'
'KiloBytes * 2^5'
'byte*10^3'

Furthermore, according to spec, VirtualQuantityUnits should be used to find the unit for VirtualQuantity, but neither VMware nor VirtualBox seem to do this, instead insisting on AllocationUnits. 

After patch checks VirtualQuantityUnits first, and if it's not there, fall back to AllocationUnits.

Comment 3 Ronald van Zantvoort 2014-01-22 16:13:44 UTC
Created attachment 853938 [details]
Revised patch; split out byte-calculation into function

Revised patch, the Units property interpretation into bytes is now in a separate function so it can be reused for https://bugzilla.redhat.com/show_bug.cgi?id=1056640

Comment 4 Richard W.M. Jones 2015-04-15 15:47:34 UTC
Hi, thanks for the bug report.  Unfortunately it is filed against a
very old version of virt-v2v (0.9) which we don't support at all.

Luckily there is a newer version which almost certainly fixes your
bug already.  It's available starting in Fedora 21.  If you still
experience this bug, please try with the new version, and reopen
if it still happens.

Comment 5 Ronald van Zantvoort 2015-08-27 14:33:16 UTC
(In reply to Richard W.M. Jones from comment #1)
> Unfortunately it is filed against a
> very old version of virt-v2v (0.9) 

Well, that tends to happen if you wait 16 months with a reply to a ready2commit submitted patch.


Note You need to log in before you can comment on or make changes to this bug.