[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v15 23/25] qcow2: add .bdrv_remove_persistent_dirty_
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-block] [PATCH v15 23/25] qcow2: add .bdrv_remove_persistent_dirty_bitmap |
Date: |
Wed, 15 Feb 2017 13:10:28 +0300 |
Realize .bdrv_remove_persistent_dirty_bitmap interface.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: John Snow <address@hidden>
---
block/qcow2-bitmap.c | 41 +++++++++++++++++++++++++++++++++++++++++
block/qcow2.c | 1 +
block/qcow2.h | 3 +++
3 files changed, 45 insertions(+)
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 05d3f28..9177c56 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1055,6 +1055,47 @@ static Qcow2Bitmap *find_bitmap_by_name(Qcow2BitmapList
*bm_list,
return NULL;
}
+void qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs,
+ const char *name,
+ Error **errp)
+{
+ int ret;
+ BDRVQcow2State *s = bs->opaque;
+ Qcow2Bitmap *bm;
+ Qcow2BitmapList *bm_list;
+
+ if (s->nb_bitmaps == 0) {
+ /* Absence of the bitmap is not an error: see explanation above
+ * bdrv_remove_persistent_dirty_bitmap() definition. */
+ return;
+ }
+
+ bm_list = bitmap_list_load(bs, s->bitmap_directory_offset,
+ s->bitmap_directory_size, errp);
+ if (bm_list == NULL) {
+ return;
+ }
+
+ bm = find_bitmap_by_name(bm_list, name);
+ if (bm == NULL) {
+ goto fail;
+ }
+
+ QSIMPLEQ_REMOVE(bm_list, bm, Qcow2Bitmap, entry);
+
+ ret = update_ext_header_and_dir(bs, bm_list);
+ if (ret < 0) {
+ error_setg_errno(errp, -ret, "Failed to update bitmap extension");
+ goto fail;
+ }
+
+ free_bitmap_clusters(bs, &bm->table);
+
+fail:
+ bitmap_free(bm);
+ bitmap_list_free(bm_list);
+}
+
void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
{
BdrvDirtyBitmap *bitmap;
diff --git a/block/qcow2.c b/block/qcow2.c
index 6e1fe53..653ba78 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3542,6 +3542,7 @@ BlockDriver bdrv_qcow2 = {
.bdrv_load_autoloading_dirty_bitmaps =
qcow2_load_autoloading_dirty_bitmaps,
.bdrv_store_persistent_dirty_bitmaps =
qcow2_store_persistent_dirty_bitmaps,
.bdrv_can_store_new_dirty_bitmap = qcow2_can_store_new_dirty_bitmap,
+ .bdrv_remove_persistent_dirty_bitmap =
qcow2_remove_persistent_dirty_bitmap,
};
static void bdrv_qcow2_init(void)
diff --git a/block/qcow2.h b/block/qcow2.h
index eaad34a..a009827 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -627,5 +627,8 @@ bool qcow2_can_store_new_dirty_bitmap(BlockDriverState *bs,
int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
void **refcount_table,
int64_t *refcount_table_size);
+void qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs,
+ const char *name,
+ Error **errp);
#endif
--
1.8.3.1
- Re: [Qemu-block] [PATCH v15 08/25] block: introduce auto-loading bitmaps, (continued)
- Re: [Qemu-block] [PATCH v15 08/25] block: introduce auto-loading bitmaps, Kevin Wolf, 2017/02/17
- Re: [Qemu-block] [PATCH v15 08/25] block: introduce auto-loading bitmaps, Denis V. Lunev, 2017/02/17
- Re: [Qemu-block] [PATCH v15 08/25] block: introduce auto-loading bitmaps, Kevin Wolf, 2017/02/17
- Re: [Qemu-block] [PATCH v15 08/25] block: introduce auto-loading bitmaps, Vladimir Sementsov-Ogievskiy, 2017/02/17
- Re: [Qemu-block] [PATCH v15 08/25] block: introduce auto-loading bitmaps, Denis V. Lunev, 2017/02/18
- Re: [Qemu-block] [PATCH v15 08/25] block: introduce auto-loading bitmaps, Kevin Wolf, 2017/02/20
- Re: [Qemu-block] [PATCH v15 08/25] block: introduce auto-loading bitmaps, Denis V. Lunev, 2017/02/20
- Re: [Qemu-block] [PATCH v15 08/25] block: introduce auto-loading bitmaps, Vladimir Sementsov-Ogievskiy, 2017/02/20
- Re: [Qemu-block] [PATCH v15 08/25] block: introduce auto-loading bitmaps, Kevin Wolf, 2017/02/20
- Re: [Qemu-block] [PATCH v15 08/25] block: introduce auto-loading bitmaps, Vladimir Sementsov-Ogievskiy, 2017/02/20
[Qemu-block] [PATCH v15 23/25] qcow2: add .bdrv_remove_persistent_dirty_bitmap,
Vladimir Sementsov-Ogievskiy <=
[Qemu-block] [PATCH v15 07/25] qcow2: add bitmaps extension, Vladimir Sementsov-Ogievskiy, 2017/02/15
[Qemu-block] [PATCH v15 20/25] qcow2-refcount: rename inc_refcounts() and make it public, Vladimir Sementsov-Ogievskiy, 2017/02/15
[Qemu-block] [PATCH v15 18/25] qmp: add x-debug-block-dirty-bitmap-sha256, Vladimir Sementsov-Ogievskiy, 2017/02/15
[Qemu-block] [PATCH v15 12/25] block/dirty-bitmap: add bdrv_dirty_bitmap_next(), Vladimir Sementsov-Ogievskiy, 2017/02/15
[Qemu-block] [PATCH v15 19/25] iotests: test qcow2 persistent dirty bitmap, Vladimir Sementsov-Ogievskiy, 2017/02/15
[Qemu-block] [PATCH v15 16/25] qmp: add persistent flag to block-dirty-bitmap-add, Vladimir Sementsov-Ogievskiy, 2017/02/15
[Qemu-block] [PATCH v15 10/25] block/dirty-bitmap: add autoload field to BdrvDirtyBitmap, Vladimir Sementsov-Ogievskiy, 2017/02/15
[Qemu-block] [PATCH v15 06/25] block/dirty-bitmap: add deserialize_ones func, Vladimir Sementsov-Ogievskiy, 2017/02/15