Bug 1259116

Summary: qemu can not read disk size of libiscsi and it shows 'disk size: unavailable'
Product: Red Hat Enterprise Linux 7 Reporter: Pei Zhang <pezhang>
Component: qemu-kvm-rhevAssignee: Fam Zheng <famz>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: chayang, famz, juzhang, knoel, kwolf, michen, pbonzini, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-10-20 04:52:53 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 Pei Zhang 2015-09-02 01:45:57 UTC
Description of problem:
After formatting qcow2 image of libiscsi, the disk size shows unavailable which is not friendly to user. If this is a block device, maybe the disk size should be set 0 or other appropriate value. 

Version-Release number of selected component (if applicable):
Host:
Kernel:3.10.0-313.el7.x86_64
qemu-kvm-rhev:qemu-kvm-rhev-2.3.0-21.el7.x86_64


How reproducible:
100%


Steps to Reproduce:
1.
# qemu-img create -f qcow2 iscsi://10.66.9.120:3260/iqn.2003-01.org.linux-iscsi.dhcp-9-120.x8664:sn.68d22325a05a/0 20G
Formatting 'iscsi://10.66.9.120:3260/iqn.2003-01.org.linux-iscsi.dhcp-9-120.x8664:sn.68d22325a05a/0', fmt=qcow2 size=21474836480 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16
2.
# qemu-img info iscsi://10.66.9.120:3260/iqn.2003-01.org.linux-iscsi.dhcp-9-120.x8664:sn.68d22325a05a/0
image: iscsi://10.66.9.120:3260/iqn.2003-01.org.linux-iscsi.dhcp-9-120.x8664:sn.68d22325a05a/0
file format: qcow2
virtual size: 20G (21474836480 bytes)
disk size: unavailable
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false


Actual results:
disk size:unavailable

Expected results:
disk size: 0 (or other appropriate value).


Additional info:

Comment 2 Fam Zheng 2015-09-08 01:25:33 UTC
Actually I think unavailable is more accurate than "0". The allocation status can be retrieved by QEMU scanning each block in the target but that can take unnecessarily long time just to display the summary for the image. So I'm not sure this issue is worth fixing.

Comment 3 Paolo Bonzini 2015-10-19 10:49:43 UTC
I agree with Fam.  Alternatively, qcow2 could store a high-water mark into the header, and qemu-img info could use it.  CCing Kevin for ideas, but I'm okay with CLOSED/NOTABUG.

Comment 4 Kevin Wolf 2015-10-19 13:42:46 UTC
You don't actually have to store another value in the qcow2 header. Scanning
the last refcount block should be quick enough. However, I'm still not
convinced whether that's useful enough to actually do it on every qcow2_open().