[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 18/29] qcow2-bitmap: disallow storing bitmap to othe
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-block] [PATCH 18/29] qcow2-bitmap: disallow storing bitmap to other bs |
Date: |
Mon, 8 Aug 2016 18:05:09 +0300 |
Check, that bitmap is stored to the owning bs.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
block/dirty-bitmap.c | 12 ++++++++++++
block/qcow2-bitmap.c | 5 +++++
include/block/dirty-bitmap.h | 2 ++
3 files changed, 19 insertions(+)
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 1d0ea25..90ac794 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -613,3 +613,15 @@ BdrvDirtyBitmap *bdrv_load_dirty_bitmap(BlockDriverState
*bs, const char *name,
}
return NULL;
}
+
+bool bdrv_has_dirty_bitmap(BlockDriverState *bs, const BdrvDirtyBitmap *bitmap)
+{
+ BdrvDirtyBitmap *bm, *next;
+ QLIST_FOREACH_SAFE(bm, &bs->dirty_bitmaps, list, next) {
+ if (bm == bitmap) {
+ return true;
+ }
+ }
+
+ return false;
+}
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 0e95121..bfc1db8 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -881,6 +881,11 @@ void qcow2_bitmap_store(BlockDriverState *bs,
uint32_t table_size;
uint64_t *bitmap_table;
+ if (!bdrv_has_dirty_bitmap(bs, bitmap)) {
+ error_setg(errp, "Can't store bitmap to the other node.");
+ return;
+ }
+
/* find/create dirty bitmap */
bmh = find_bitmap_by_name(bs, bm_name);
if (bmh != NULL) {
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index d482098..1af3890 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -84,4 +84,6 @@ void bdrv_finalize_persistent_dirty_bitmaps(BlockDriverState
*bs);
BdrvDirtyBitmap *bdrv_load_dirty_bitmap(BlockDriverState *bs, const char *name,
Error **errp);
+bool bdrv_has_dirty_bitmap(BlockDriverState *bs, const BdrvDirtyBitmap
*bitmap);
+
#endif
--
1.8.3.1
- [Qemu-block] [PATCH 19/29] block/dirty-bitmap: add autoload field to BdrvDirtyBitmap, (continued)
- [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
- [Qemu-block] [PATCH 08/29] qcow2-bitmap: delete bitmap from qcow2 after load, Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 18/29] qcow2-bitmap: disallow storing bitmap to other bs,
Vladimir Sementsov-Ogievskiy <=
- [Qemu-block] [PATCH 25/29] qapi: add md5 checksum of last dirty bitmap level to query-block, Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 04/29] block/dirty-bitmap: add deserialize_ones func, Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 09/29] qcow2-bitmap: add qcow2_bitmap_store(), Vladimir Sementsov-Ogievskiy, 2016/08/08
- [Qemu-block] [PATCH 02/29] tests: add hbitmap iter test, Vladimir Sementsov-Ogievskiy, 2016/08/08