RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 638055 - Allow qemu-img re-base with undersized backing files
Summary: Allow qemu-img re-base with undersized backing files
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm
Version: 6.0
Hardware: All
OS: Linux
low
medium
Target Milestone: beta
: 6.2
Assignee: Kevin Wolf
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 580953
TreeView+ depends on / blocked
 
Reported: 2010-09-28 04:51 UTC by Shirley Zhou
Modified: 2015-03-05 00:52 UTC (History)
12 users (show)

Fixed In Version: qemu-kvm-0.12.1.2-2.237.el6
Doc Type: Bug Fix
Doc Text:
Cause: qemu-img rebase assumed in safe mode that backing files have the same size as the rebased image. This is not true, they may be smaller and the rest of the image is considered to be backed by sectors filled with zeros. Consequence: Rebase an image, where the old or the new backing file is smaller than the image itself. In order to compare its content to the backing files, qemu-img tries to read after the end of the backing file and fails with error message "qemu-img: error while reading from new backing file" Fix: Before reading a sector from the new or old backing file for comparison, check if it is even contained in the backing file and use a sector of zeros otherwise. Result: qemu-img rebase succeeds even with backing files that are smaller than the rebased image.
Clone Of:
Environment:
Last Closed: 2012-06-20 11:32:28 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2012:0746 0 normal SHIPPED_LIVE qemu-kvm bug fix and enhancement update 2012-06-19 19:31:48 UTC

Description Shirley Zhou 2010-09-28 04:51:54 UTC
Description of problem:
qemu-img should check new disk image size is same to base image or not when rebase snapshot to new disk.

Version-Release number of selected component (if applicable):
qemu-kvm-0.12.1.2-2.113.el6_0.1.x86_64

How reproducible:
3/3

Steps to Reproduce:
1.there is a previous installed images, which actually size is 30000M(29.3G)
# qemu-img info win7x64.img
image: win7x64.img
file format: qcow2
virtual size: 29G (31457280000 bytes)
disk size: 9.2G
cluster_size: 65536
2.create 3 snapshot one by one as following
qemu-img create -f qcow2 -F qcow2 -b win7x64.img A
qemu-img create -f qcow2 -F qcow2 -b A B
qemu-img create -f qcow2 -F qcow2 -b B C
3.create a new disk image with 29G image size
qemu-img create -f qcow2 base_new.img 29G 
it is litter less than base image.
4.rebase snapshot C to new base image
# qemu-img rebase -b base_new.img -f qcow2 -F qcow2 C
5.after more than 30mins later, one error prompts
qemu-img: error while reading from new backing file

Actual results:
After write and read 29G data, error prompts.

Expected results:
before rebase, qemu should check the new base image, if the size is not correct, should prompt error at once.

Additional info:
If I create a 30000M new base image, can rebase successfully.

Comment 4 Kevin Wolf 2010-10-07 16:23:45 UTC
Actually, I think it shouldn't abort. If I remember correctly, it's legal to have a snapshot that is larger than its backing file. Probably not a common use case, though.

Comment 5 Shirley Zhou 2010-10-08 10:44:36 UTC
In function bdrv_check_byte_request, it will check validity of parameter len and size, for this bug, it return -EIO, the rebase will end with error "error while reading from new backing file".

    if ((offset > len) || (len - offset < size))
        return -EIO;

When create snapshot for backing file, the size of snapshot is equal to backing file, when rebase to new disk,the size of new disk may be smaller than backing file, at that time, the error is acceptable. 
But the error should be show up before rebase start,it should not prompt after write 29G file. QE prefer to compare size of backing file and new disk before rebase.

Thanks.

Comment 12 Sibiao Luo 2012-03-09 10:42:07 UTC
I have reproduced this issue on qemu-kvm-0.12.1.2-2.236.el6.x86_64 and verified
this issue on qemu-kvm-0.12.1.2-2.237.el6.x86_64 with the same steps.

The result of reproduce is that a error prompts after rebase snapshot C to the new base image:
# qemu-img rebase -b base_new.qcow2 -f qcow2 -F qcow2 C
qemu-img: error while reading from new backing file

The result of verify is that rebase snapshot C to the new base image successfully.
# qemu-img rebase -b base_new.qcow2 -f qcow2 -F qcow2 C
# qemu-img info C
image: C
file format: qcow2
virtual size: 20G (21474836480 bytes)
disk size: 3.2G
cluster_size: 65536
backing file: base_new.qcow2 (actual path: base_new.qcow2)

Above all, this issue has been fixed.

Comment 14 Michal Novotny 2012-05-03 16:59:20 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:
Create several snapshots of a backing image and rebase one of them to higher size than the backing file.

Consequence:
qemu-img fails with error message "qemu-img: error while reading from new backing file"

Fix:
Rebase backing image as well and fill sectors after the end of original backing file by zeros.

Result:
File is being rebased to the new size.

Comment 15 Kevin Wolf 2012-05-07 08:57:58 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,11 +1,11 @@
 Cause:
-Create several snapshots of a backing image and rebase one of them to higher size than the backing file.
+qemu-img rebase assumed in safe mode that backing files have the same size as the rebased image. This is not true, they may be smaller and the rest of the image is considered to be backed by sectors filled with zeros.
 
 Consequence:
-qemu-img fails with error message "qemu-img: error while reading from new backing file"
+Rebase an image, where the old or the new backing file is smaller than the image itself. In order to compare its content to the backing files, qemu-img tries to read after the end of the backing file and fails with error message "qemu-img: error while reading from new backing file"
 
 Fix:
-Rebase backing image as well and fill sectors after the end of original backing file by zeros.
+Before reading a sector from the new or old backing file for comparison, check if it is even contained in the backing file and use a sector of zeros otherwise.
 
 Result:
-File is being rebased to the new size.+qemu-img rebase succeeds even with backing files that are smaller than the rebased image.

Comment 16 errata-xmlrpc 2012-06-20 11:32:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0746.html


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