Bug 688119

Summary: qcow2: qcow2_open doesn't return useful errors
Product: Red Hat Enterprise Linux 6 Reporter: Kevin Wolf <kwolf>
Component: qemu-kvmAssignee: Kevin Wolf <kwolf>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.1CC: ehabkost, juzhang, mkenneth, tburke, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-0.12.1.2-2.151.el6 Doc Type: Bug Fix
Doc Text:
Cause: qcow2_open() error handling returned -1 instead of proper error codes. Consequence: -1 interpreted as EPERM by callers, causing misleading error messages. Also, qcow2 images with a version number > 2 should return -ENOTSUP, but they would be detected as raw images. Fix: Add proper -errno error return values to qcow2_open(). Result: when opening qcow2 images, permission errors or unsupported qcow versions are properly reported.
Story Points: ---
Clone Of:
: 698927 (view as bug list) Environment:
Last Closed: 2011-05-19 11:21:14 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 698927    

Description Kevin Wolf 2011-03-16 11:39:44 UTC
In error cases, qcow2_open usually returns -1, which is interpreted as EPERM by callers and may cause misleading error messages. Also, qcow2 images with a version number > 2 should return -ENOTSUP, but they really are detected as raw images.

These situations happen when an I/O error occurs during qcow2_open or the header is modified to contain values that qemu can't handle today. This may be by a future version of qemu or manually with a hex editor.

Comment 2 juzhang 2011-03-17 10:58:56 UTC
Can reproduce this issue with qemu-kvm-0.12.1.2-2.149.el6.x86_64.
step
1.create qcow2 image.
#qemu-img create -f qcow2 test.qcow2 1G
Formatting 'test.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=0

2.check qcow2 info
qemu-img info test.qcow2
image: test.qcow2
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: 136K
cluster_size: 65536

3.hack qcow2 file,using 3 instead of 2
4.recheck qcow2 info
qemu-img info test.qcow2
image: test.qcow2
file format: raw
virtual size: 256K (262144 bytes)
disk size: 136K

Mark qa_ack+

Comment 6 juzhang 2011-03-30 06:22:06 UTC
Verified using steps as same as comment2 with qemu-kvm-0.12.1.2-2.153.el6.x86_64

after step 4
#qemu-img info test.qcow2
'' uses a qcow2 feature which is not supported by this qemu version: QCOW version 3
qemu-img: Could not open 'test.qcow2'

Comment 7 juzhang 2011-03-30 06:23:51 UTC
According to comment6,set this issue status as verified.

Comment 8 Eduardo Habkost 2011-05-03 19:12:31 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause: qcow2_open() error handling returned -1 instead of proper error codes.

Cosequence: -1 interpreted as EPERM by
callers, causing misleading error messages. Also, qcow2 images with a version number > 2 should return -ENOTSUP, but they would be detected as raw images.

Fix: Add proper -errno error return values to qcow2_open().

Result: when opening qcow2 images, permission errors or unsupported qcow versions are properly reported.

Comment 9 Eduardo Habkost 2011-05-03 20:56:18 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,6 +1,6 @@
 Cause: qcow2_open() error handling returned -1 instead of proper error codes.
 
-Cosequence: -1 interpreted as EPERM by
+Consequence: -1 interpreted as EPERM by
 callers, causing misleading error messages. Also, qcow2 images with a version number > 2 should return -ENOTSUP, but they would be detected as raw images.
 
 Fix: Add proper -errno error return values to qcow2_open().

Comment 10 errata-xmlrpc 2011-05-19 11:21:14 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0534.html

Comment 11 errata-xmlrpc 2011-05-19 13:02:12 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0534.html