[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 20/22] block/qcow2-bitmap: Don't check size for IN_US
From: |
John Snow |
Subject: |
[Qemu-devel] [PULL 20/22] block/qcow2-bitmap: Don't check size for IN_USE bitmap |
Date: |
Tue, 12 Mar 2019 16:23:35 -0400 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
We are going to allow image resize when there are persistent bitmaps.
It may lead to appearing of inconsistent bitmaps (IN_USE=1) with
inconsistent size. But we still want to load them as inconsistent.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Message-id: address@hidden
Signed-off-by: John Snow <address@hidden>
---
block/qcow2-bitmap.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 885f36c2ab..92cef1cfd4 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -462,10 +462,25 @@ static int check_dir_entry(BlockDriverState *bs,
Qcow2BitmapDirEntry *entry)
return len;
}
- fail = (phys_bitmap_bytes > BME_MAX_PHYS_SIZE) ||
- (len > ((phys_bitmap_bytes * 8) << entry->granularity_bits));
+ if (phys_bitmap_bytes > BME_MAX_PHYS_SIZE) {
+ return -EINVAL;
+ }
- return fail ? -EINVAL : 0;
+ if (!(entry->flags & BME_FLAG_IN_USE) &&
+ (len > ((phys_bitmap_bytes * 8) << entry->granularity_bits)))
+ {
+ /*
+ * We've loaded a valid bitmap (IN_USE not set) or we are going to
+ * store a valid bitmap, but the allocated bitmap table size is not
+ * enough to store this bitmap.
+ *
+ * Note, that it's OK to have an invalid bitmap with invalid size due
+ * to a bitmap that was not correctly saved after image resize.
+ */
+ return -EINVAL;
+ }
+
+ return 0;
}
static inline void bitmap_directory_to_be(uint8_t *dir, size_t size)
--
2.17.2
- [Qemu-devel] [PULL 11/22] block/dirty-bitmaps: add inconsistent bit, (continued)
- [Qemu-devel] [PULL 11/22] block/dirty-bitmaps: add inconsistent bit, John Snow, 2019/03/12
- [Qemu-devel] [PULL 10/22] iotests: add busy/recording bit test to 124, John Snow, 2019/03/12
- [Qemu-devel] [PULL 12/22] block/dirty-bitmap: add inconsistent status, John Snow, 2019/03/12
- [Qemu-devel] [PULL 13/22] block/dirty-bitmaps: add block_dirty_bitmap_check function, John Snow, 2019/03/12
- [Qemu-devel] [PULL 15/22] block/dirty-bitmaps: prohibit removing readonly bitmaps, John Snow, 2019/03/12
- [Qemu-devel] [PULL 16/22] block/dirty-bitmaps: disallow busy bitmaps as merge source, John Snow, 2019/03/12
- [Qemu-devel] [PULL 14/22] block/dirty-bitmaps: prohibit readonly bitmaps for backups, John Snow, 2019/03/12
- [Qemu-devel] [PULL 17/22] block/dirty-bitmaps: implement inconsistent bit, John Snow, 2019/03/12
- [Qemu-devel] [PULL 18/22] bitmaps: Fix typo in function name, John Snow, 2019/03/12
- [Qemu-devel] [PULL 19/22] docs/interop/qcow2: Improve bitmap flag in_use specification, John Snow, 2019/03/12
- [Qemu-devel] [PULL 20/22] block/qcow2-bitmap: Don't check size for IN_USE bitmap,
John Snow <=
- [Qemu-devel] [PULL 21/22] block/qcow2-bitmap: Allow resizes with persistent bitmaps, John Snow, 2019/03/12
- [Qemu-devel] [PULL 22/22] tests/qemu-iotests: add bitmap resize test 246, John Snow, 2019/03/12
- Re: [Qemu-devel] [PULL 00/22] Bitmaps patches, Peter Maydell, 2019/03/13