diff mbox series

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

Message ID tencent_647D077359960B50AA4B806516042ABCC508@qq.com
State New
Headers show
Series This patch is to solve the problem that the bitmap file in memory is lost after creating a snapshot | expand

Commit Message

Hongleilee Sept. 20, 2022, 2:47 a.m. UTC
From: Hongleili Li (李红磊)-云数据中心集团 <lihonglei03@inspur.com>

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

Comments

Vladimir Sementsov-Ogievskiy Sept. 20, 2022, 12:29 p.m. UTC | #1
[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?
diff mbox series

Patch

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;