[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v20 17/30] block: introduce persistent dirty bitmaps
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-block] [PATCH v20 17/30] block: introduce persistent dirty bitmaps |
Date: |
Fri, 2 Jun 2017 14:21:45 +0300 |
New field BdrvDirtyBitmap.persistent means, that bitmap should be saved
by format driver in .bdrv_close and .bdrv_inactivate. No format driver
supports it for now.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block/dirty-bitmap.c | 26 ++++++++++++++++++++++++++
block/qcow2-bitmap.c | 1 +
include/block/dirty-bitmap.h | 5 +++++
3 files changed, 32 insertions(+)
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 8a380308c3..d14adff88d 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -53,6 +53,7 @@ struct BdrvDirtyBitmap {
image or this bitmap */
bool autoload; /* For persistent bitmaps: bitmap must be
autoloaded on image opening */
+ bool persistent; /* bitmap must be saved to owner disk image */
QLIST_ENTRY(BdrvDirtyBitmap) list;
};
@@ -79,6 +80,7 @@ void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitmap)
assert(!bdrv_dirty_bitmap_frozen(bitmap));
g_free(bitmap->name);
bitmap->name = NULL;
+ bitmap->persistent = false;
bitmap->autoload = false;
}
@@ -248,6 +250,8 @@ BdrvDirtyBitmap
*bdrv_dirty_bitmap_abdicate(BlockDriverState *bs,
bitmap->name = NULL;
successor->name = name;
bitmap->successor = NULL;
+ successor->persistent = bitmap->persistent;
+ bitmap->persistent = false;
successor->autoload = bitmap->autoload;
bitmap->autoload = false;
bdrv_release_dirty_bitmap(bs, bitmap);
@@ -588,3 +592,25 @@ bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap
*bitmap)
{
return bitmap->autoload;
}
+
+void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap *bitmap, bool
persistent)
+{
+ bitmap->persistent = persistent;
+}
+
+bool bdrv_dirty_bitmap_get_persistance(BdrvDirtyBitmap *bitmap)
+{
+ return bitmap->persistent;
+}
+
+bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs)
+{
+ BdrvDirtyBitmap *bm;
+ QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) {
+ if (bm->persistent && !bm->readonly) {
+ return true;
+ }
+ }
+
+ return false;
+}
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index ee6d8f75a9..52e4616b8c 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -794,6 +794,7 @@ bool qcow2_load_autoloading_dirty_bitmaps(BlockDriverState
*bs, Error **errp)
goto fail;
}
+ bdrv_dirty_bitmap_set_persistance(bitmap, true);
bdrv_dirty_bitmap_set_autoload(bitmap, true);
bm->flags |= BME_FLAG_IN_USE;
created_dirty_bitmaps =
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 9416f9233f..721f025850 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -82,4 +82,9 @@ bool bdrv_has_readonly_bitmaps(BlockDriverState *bs);
void bdrv_dirty_bitmap_set_autoload(BdrvDirtyBitmap *bitmap, bool autoload);
bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap);
+void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap *bitmap,
+ bool persistent);
+bool bdrv_dirty_bitmap_get_persistance(BdrvDirtyBitmap *bitmap);
+bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs);
+
#endif
--
2.11.1
- [Qemu-block] [PATCH v20 07/30] qcow2-refcount: rename inc_refcounts() and make it public, (continued)
- [Qemu-block] [PATCH v20 07/30] qcow2-refcount: rename inc_refcounts() and make it public, Vladimir Sementsov-Ogievskiy, 2017/06/02
- [Qemu-block] [PATCH v20 21/30] block: add bdrv_can_store_new_dirty_bitmap, Vladimir Sementsov-Ogievskiy, 2017/06/02
- [Qemu-block] [PATCH v20 27/30] block/dirty-bitmap: add bdrv_remove_persistent_dirty_bitmap, Vladimir Sementsov-Ogievskiy, 2017/06/02
- [Qemu-block] [PATCH v20 22/30] qcow2: add .bdrv_can_store_new_dirty_bitmap, Vladimir Sementsov-Ogievskiy, 2017/06/02
- [Qemu-block] [PATCH v20 02/30] specs/qcow2: do not use wording 'bitmap header', Vladimir Sementsov-Ogievskiy, 2017/06/02
- [Qemu-block] [PATCH v20 10/30] block/dirty-bitmap: add readonly field to BdrvDirtyBitmap, Vladimir Sementsov-Ogievskiy, 2017/06/02
- [Qemu-block] [PATCH v20 08/30] qcow2: add bitmaps extension, Vladimir Sementsov-Ogievskiy, 2017/06/02
- [Qemu-block] [PATCH v20 17/30] block: introduce persistent dirty bitmaps,
Vladimir Sementsov-Ogievskiy <=
- [Qemu-block] [PATCH v20 30/30] block: release persistent bitmaps on inactivate, Vladimir Sementsov-Ogievskiy, 2017/06/02
- [Qemu-block] [PATCH v20 03/30] hbitmap: improve dirty iter, Vladimir Sementsov-Ogievskiy, 2017/06/02
- [Qemu-block] [PATCH v20 26/30] iotests: test qcow2 persistent dirty bitmap, Vladimir Sementsov-Ogievskiy, 2017/06/02
- [Qemu-block] [PATCH v20 09/30] block/dirty-bitmap: fix comment for BlockDirtyBitmap.disabled field, Vladimir Sementsov-Ogievskiy, 2017/06/02
- [Qemu-block] [PATCH v20 20/30] qcow2: store bitmaps on reopening image as read-only, Vladimir Sementsov-Ogievskiy, 2017/06/02
- [Qemu-block] [PATCH v20 25/30] qmp: add x-debug-block-dirty-bitmap-sha256, Vladimir Sementsov-Ogievskiy, 2017/06/02