[PATCH] This patch is to solve the problem that the bitmap file in memory is lost after creating a snapshot

Hongleilee posted 1 patch 3 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/tencent._5F647D077359960B50AA4B806516042ABCC508@qq.com
Maintainers: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Markus Armbruster <armbru@redhat.com>
blockdev.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] This patch is to solve the problem that the bitmap file in memory is lost after creating a snapshot
Posted by Hongleilee 3 years, 4 months ago
From: Hongleili Li (李红磊)-云数据中心集团 <lihonglei03@inspur.com>

Signed-off-by: Hongleili Li (李红磊)-云数据中心集团 <lihonglei03@inspur.com>
---
 blockdev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/blockdev.c b/blockdev.c
index 9230888e34..a6b85d06b7 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1534,6 +1534,10 @@ static void external_snapshot_prepare(BlkActionState *common,
 
     state->new_bs = bdrv_open(new_image_file, snapshot_ref, options, flags,
                               errp);
+
+    state->new_bs->dirty_bitmaps = state->old_bs->dirty_bitmaps;
+    QLIST_INIT(&state->old_bs->dirty_bitmaps);
+
     /* We will manually add the backing_hd field to the bs later */
     if (!state->new_bs) {
         goto out;
-- 
2.37.3.windows.1


Re: [PATCH] This patch is to solve the problem that the bitmap file in memory is lost after creating a snapshot
Posted by Vladimir Sementsov-Ogievskiy 3 years, 4 months ago
[Cc Eric and John]

On 9/20/22 05:47, Hongleilee wrote:
> From: Hongleili Li (李红磊)-云数据中心集团 <lihonglei03@inspur.com>
> 
> Signed-off-by: Hongleili Li (李红磊)-云数据中心集团 <lihonglei03@inspur.com>
> ---
>   blockdev.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 9230888e34..a6b85d06b7 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1534,6 +1534,10 @@ static void external_snapshot_prepare(BlkActionState *common,
>   
>       state->new_bs = bdrv_open(new_image_file, snapshot_ref, options, flags,
>                                 errp);
> +
> +    state->new_bs->dirty_bitmaps = state->old_bs->dirty_bitmaps;
> +    QLIST_INIT(&state->old_bs->dirty_bitmaps);
> +
>       /* We will manually add the backing_hd field to the bs later */
>       if (!state->new_bs) {
>           goto out;

Hi Hongleili Li!

I understand your problem, but we can't change the behavior in that manner, as it will break existing users.

Qemu don't move bitmaps to the new node automatically. Instead we have Bitmap API: to move the bitmap from node A to node B, you need three QMP commands:

block-dirty-bitmap-add {node: B, name: bitmap0}
block-dirty-bitmap-merge {node: B, target: bitmap0, bitmaps: [{node: A, name: bitmap0}]}
block-dirty-bitmap-remove {node: A, name: bitmap0}

(and you may run them in a QMP transaction, even together with blockdev-snapshot)

Will it work for you?

-- 
Best regards,
Vladimir