{{ message }}
block: qcow: Return zeros for reads beyond backing file size#7678
Merged
rbradford merged 2 commits intocloud-hypervisor:mainfrom Feb 10, 2026
Merged
block: qcow: Return zeros for reads beyond backing file size#7678rbradford merged 2 commits intocloud-hypervisor:mainfrom
rbradford merged 2 commits intocloud-hypervisor:mainfrom
Conversation
When an overlay QCOW2 image is larger than its backing file, reads from offsets beyond the backing file virtual size would previously fail with an I/O error. The backing file virtual size is determined at open time and stored for bounds checking during read operations: - If the entire read is beyond the backing size, return all zeros - If the read spans the boundary, read available data from backing and fill the remainder with zeros Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
3964de5 to
ce37ad0
Compare
phip1611
approved these changes
Feb 9, 2026
Member
There was a problem hiding this comment.
shouldn't you also assert here that boundary_buf[0..512] is not all zero?
Member
Author
There was a problem hiding this comment.
Absolutely. I've extended it to write some bytes at the end and check both 512 byte chunks. Thanks!
Test reading from overlay at offsets beyond backing file returns zeros. Covers reads within backing range, beyond backing, and boundary spanning. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
ce37ad0 to
b786cd4
Compare
rbradford
approved these changes
Feb 9, 2026
russell-islam
approved these changes
Feb 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

When an overlay QCOW2 image is larger than its backing file, reads from offsets beyond the backing file virtual size previously failed with I/O error.
This PR fixes the issue by returning zeros for such reads. This is matching QEMU that treats unallocated regions beyond the backing file as implicitly zero-filled.
Example:
Added unit test covering reads within, beyond, and spanning the backing boundary.