Bug 709307

Summary: Virt-v2v create preallocated file when convert a sparse ESX guest.
Product: Red Hat Enterprise Linux 5 Reporter: yuping zhang <yupzhang>
Component: virt-v2vAssignee: Matthew Booth <mbooth>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.7CC: leiwang, mbooth, mkenneth, mshao, qguan, rjones, rwu, whuang, yupzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 709648 (view as bug list) Environment:
Last Closed: 2011-09-07 10:16:03 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 709648    

Description yuping zhang 2011-05-31 10:35:50 UTC
Description of problem:
Create a sparse ESX guest,then convert it to libvirt,virt-v2v create preallocated file.

Version-Release number of selected component (if applicable):
virt-v2v-0.7.1-4.el5
libguestfs-1.2.7-1.el5.13
zlib-1.2.3-3

How reproducible:
100%

Steps to Reproduce:
1.On ESX,create a sparse disk,and install os.
/vmfs/volumes/4d59e988-657f9720-6906-b8ac6f3e66d3/yp-test-rhel5-32 # ls -shl yp-test-rhel5-32-flat.vmdk
2787328 -rw-------    1 root     root         8.0G May 31 07:23 yp-test-rhel5-32-flat.vmdk

2.# virt-v2v -ic esx://10.66.72.79/?no_verify=1 -os default -b breth0  yp-test-rhel5-32
virt-v2v: Transferring storage volume yp-test-rhel5-32_yp-test-rhel5-32: 8589934592 bytes
virt-v2v: yp-test-rhel5-32 configured with virtio drivers

3.# ll -sh /var/lib/libvirt/images/yp-test-rhel5-32_yp-test-rhel5-32
8.1G -rw------- 1 root root 8.0G May 31 17:08 /var/lib/libvirt/images/yp-test-rhel5-32_yp-test-rhel5-32

Actual results:
As step 3.

Expected results:
After conversion,the disk is sparse.

Additional info:
Convert the guest with -oa sparse parameters:
# virt-v2v -ic esx://10.66.72.79/?no_verify=1 -os default -b breth0  -oa sparse yp-test-rhel5-32
After conversion the disk is sparse.

Comment 1 Qin Guan 2011-05-31 11:30:53 UTC
The default allocation is hard code as preallocated for ESX image:

1. The target volume allocation type will be created according to src sparse type in Source.pm:
# /usr/lib/perl5/vendor_perl/5.8.8/Sys/VirtV2V/Connection/Source.pm
sub copy_storage
{
...
            $dst = $target->create_volume(
                $src->get_name(),
                defined($output_format) ?  $output_format : $src->get_format(),
                $src->get_size(),
                defined($output_sparse) ? $output_sparse : $src->is_sparse()
            );

...
}

2. While the src sparse type is hard code as 0 (prealloc) for ESX image:
# /usr/lib/perl5/vendor_perl/5.8.8/Sys/VirtV2V/Connection/LibVirtSource.pm
sub get_volume
{
...
   if ($uri->scheme eq "esx") {
        $format = "raw";

        $transfer = $self->_get_transfer($path, 0, $format, 0);

        $name = $transfer->esx_get_name();
        $size = $transfer->esx_get_size();
        $usage = $size;
        $is_sparse = 0;    <--- hard code as prealloc
        $is_block = 0;
    }
...
}

Comment 3 RHEL Program Management 2011-09-07 10:16:03 UTC
Development Management has reviewed and declined this request.  You may appeal
this decision by reopening this request.