[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 10/29] qcow2-bitmap: add IN_USE flag
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-block] [PATCH 10/29] qcow2-bitmap: add IN_USE flag |
Date: |
Mon, 8 Aug 2016 18:05:01 +0300 |
This flag means that the bitmap is now in use by the software or was not
successfully saved. In any way, with this flag set the bitmap data must
be considered inconsistent and should not be loaded.
With current implementation this flag is never set, as we just remove
bitmaps from the image after loading. But it defined in qcow2 spec and
must be handled. Also, it can be used in future, if async schemes of
bitmap loading/saving are implemented.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
block/qcow2-bitmap.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 43a9bb9..19f8203 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -44,7 +44,8 @@
#define BME_MAX_NAME_SIZE 1023
/* Bitmap directory entry flags */
-#define BME_RESERVED_FLAGS 0xffffffff
+#define BME_RESERVED_FLAGS 0xfffffffe
+#define BME_FLAG_IN_USE 1
/* bits [1, 8] U [56, 63] are reserved */
#define BME_TABLE_ENTRY_RESERVED_MASK 0xff000000000001fe
@@ -487,6 +488,11 @@ static BdrvDirtyBitmap *load_bitmap(BlockDriverState *bs,
BdrvDirtyBitmap *bitmap = NULL;
char *name = g_strndup((char *)(bmh + 1), bmh->name_size);
+ if (bmh->flags & BME_FLAG_IN_USE) {
+ error_setg(errp, "Bitmap '%s' is in use", name);
+ goto fail;
+ }
+
ret = bitmap_table_load(bs, bmh, &bitmap_table);
if (ret < 0) {
error_setg_errno(errp, -ret,
@@ -795,7 +801,8 @@ void qcow2_bitmap_store(BlockDriverState *bs,
return;
}
- if (bmh->bitmap_table_offset) {
+ if ((bmh->bitmap_table_offset != 0) ||
+ !(bmh->flags & BME_FLAG_IN_USE)) {
error_setg(errp,
"The bitmap with same name already exists, but was"
"not loaded.");
@@ -820,7 +827,7 @@ void qcow2_bitmap_store(BlockDriverState *bs,
}
} else {
ret = directory_set(bs, bmh, granularity, table_offset, table_size,
- bmh->flags);
+ bmh->flags & ~BME_FLAG_IN_USE);
if (ret < 0) {
error_setg_errno(errp, ret, "Can't update dirty bitmap in qcow2.");
goto fail;
--
1.8.3.1
- Re: [Qemu-block] [PATCH 01/29] hbitmap: fix dirty iter, (continued)
- [Qemu-block] [PATCH 14/29] qcow2-bitmap: add qcow2_bitmap_load_check(), Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 15/29] block/dirty-bitmap: introduce persistent bitmaps, Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 11/29] qcow2-bitmap: check constraints, Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 12/29] qcow2: add qcow2_delete_bitmaps, Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 06/29] qcow2-bitmap: add qcow2_read_bitmaps(), Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 17/29] qcow2-bitmap: add autoclear bit, Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 10/29] qcow2-bitmap: add IN_USE flag,
Vladimir Sementsov-Ogievskiy <=
- [Qemu-block] [PATCH 20/29] qcow2-bitmap: add AUTO flag, Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 03/29] block: fix bdrv_dirty_bitmap_granularity signature, Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 29/29] qcow2-dirty-bitmap: refcounts, Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 19/29] block/dirty-bitmap: add autoload field to BdrvDirtyBitmap, Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 23/29] qmp: add autoload parameter to block-dirty-bitmap-add, Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 16/29] block: add bdrv_load_dirty_bitmap(), Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 05/29] qcow2-bitmap: structs and consts, Vladimir Sementsov-Ogievskiy, 2016/08/08