[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 33/35] qcow2: Fix unaligned preallocated truncation
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 33/35] qcow2: Fix unaligned preallocated truncation |
Date: |
Thu, 26 Oct 2017 15:17:39 +0200 |
From: Max Reitz <address@hidden>
A qcow2 image file's length is not required to have a length that is a
multiple of the cluster size. However, qcow2_refcount_area() expects an
aligned value for its @start_offset parameter, so we need to round
@old_file_size up to the next cluster boundary.
Reported-by: Ping Li <address@hidden>
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1414049
Signed-off-by: Max Reitz <address@hidden>
Message-id: address@hidden
Cc: address@hidden
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Jeff Cody <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
block/qcow2.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/block/qcow2.c b/block/qcow2.c
index d3e114bce5..1ea763126d 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3188,6 +3188,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t
offset,
"Failed to inquire current file length");
return old_file_size;
}
+ old_file_size = ROUND_UP(old_file_size, s->cluster_size);
nb_new_data_clusters = DIV_ROUND_UP(offset - old_length,
s->cluster_size);
--
2.13.6
- [Qemu-devel] [PULL 21/35] qemu-img: Change img_rebase() to be byte-based, (continued)
- [Qemu-devel] [PULL 21/35] qemu-img: Change img_rebase() to be byte-based, Kevin Wolf, 2017/10/26
- [Qemu-devel] [PULL 20/35] qemu-img: Change compare_sectors() to be byte-based, Kevin Wolf, 2017/10/26
- [Qemu-devel] [PULL 23/35] block: Align block status requests, Kevin Wolf, 2017/10/26
- [Qemu-devel] [PULL 26/35] qemu-io: Relax 'alloc' now that block-status doesn't assert, Kevin Wolf, 2017/10/26
- [Qemu-devel] [PULL 28/35] qcow2: Use BDRV_SECTOR_BITS instead of its literal value, Kevin Wolf, 2017/10/26
- [Qemu-devel] [PULL 27/35] qemu-img.1: Image invalidation on qemu-img commit, Kevin Wolf, 2017/10/26
- [Qemu-devel] [PULL 30/35] iotests: Pull _filter_actual_image_size from 67/87, Kevin Wolf, 2017/10/26
- [Qemu-devel] [PULL 29/35] iotests: Add test for dataplane mirroring, Kevin Wolf, 2017/10/26
- [Qemu-devel] [PULL 31/35] iotests: Filter actual image size in 184 and 191, Kevin Wolf, 2017/10/26
- [Qemu-devel] [PULL 32/35] qcow2: Emit errp when truncating the image tail, Kevin Wolf, 2017/10/26
- [Qemu-devel] [PULL 33/35] qcow2: Fix unaligned preallocated truncation,
Kevin Wolf <=
- [Qemu-devel] [PULL 34/35] qcow2: Always execute preallocate() in a coroutine, Kevin Wolf, 2017/10/26
- [Qemu-devel] [PULL 35/35] iotests: Add cluster_size=64k to 125, Kevin Wolf, 2017/10/26
- Re: [Qemu-devel] [PULL 00/35] Block layer patches, Peter Maydell, 2017/10/27