Bug 1601871

Summary: Target image needs larger size when executing convert with iscsi backend
Product: Red Hat Enterprise Linux 7 Reporter: Tingting Mao <timao>
Component: qemu-kvm-rhevAssignee: Fam Zheng <famz>
Status: CLOSED WONTFIX QA Contact: Tingting Mao <timao>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.6CC: chaoyang, chayang, juzhang, michen, ngu, pingl, timao, virt-maint
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-07-20 07:14:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tingting Mao 2018-07-17 11:28:26 UTC
Description of problem:
Convert would fail when the target image size is the same as the source image with iscsi backend.

Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.12.0-7.el7
kernel-3.10.0-919.el7

How reproducible:
2/2

Steps to Reproduce:
1.Create lvs after login the iscsi target
#iscsiadm -m node -T iqn.2018-07.com.example:1 -p 10.66.11.19 -l
#pvcreate /dev/sdb
#vgcreate vgtest /dev/sdb
#lvcreate -L 3G -n source vgtest
#lvcreate -L 3G -n target vgtest
2.Convert source image to target
# qemu-img convert -f raw -O qcow2 /dev/vgtest/source /dev/vgtest/target
qemu-img: error while writing sector 6287359: No space left on device


Actual results:
as above.

Expected results:
Convert with no error

Additional info:
1. When creating target file with 4G size, converting successfully
2. The result is correct with qemu-kvm-rhev-2.10.0
# qemu-img --version
qemu-img version 2.10.0(qemu-kvm-rhev-2.10.0-21.el7_5.1)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
# lvcreate -L 3G -n source vgtest01
  Logical volume "source" created.
# lvcreate -L 3G -n target vgtest01
  Logical volume "target" created.
# qemu-img convert -f raw -O qcow2 /dev/vgtest01/source /dev/vgtest01/target -p
    (100.00/100%)
# qemu-img info /dev/vgtest01/target 
image: /dev/vgtest01/target
file format: qcow2
virtual size: 3.0G (3221225472 bytes)
disk size: 0
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

Comment 3 Fam Zheng 2018-07-20 07:14:46 UTC
qcow2 needs some extra disk space for metadata, and in the case of fully allocated image, it will require a bit more than the virtual size.

Use qemu-img measure command to calculate the necessary space:

qemu-img measure /dev/vgtest01/source -O qcow2

The command will count the allocated guest data and estimate metadata.