blockdev: implement n-ary bitmap merge
cover blockdev: implement n-ary bitmap merge
requires: [email protected]
See patch for details; this is somewhat an RFC that I suspect will be useful for libvirt in some situations, but maybe it's actually overkill.
John Snow (1):
blockdev: n-ary bitmap merge
blockdev.c | 40 ++++++++++++++++++++++++++++++---------- qapi/block-core.json | 10 +++++----- 2 files changed, 35 insertions(+), 15 deletions(-)
Signature · 1 line
2.14.3
PATCH 1/1 blockdev: n-ary bitmap merge
It might be nice to have an all-or-nothing merge command that either succeeds in merging all bitmaps or fails for all of them. This way, when assembling bitmaps that represent arbitrary points in time from component bitmaps, we always know the state of the target bitmap even in cases of failure.
--- blockdev.c | 40 ++++++++++++++++++++++++++++++---------- qapi/block-core.json | 10 +++++----- 2 files changed, 35 insertions(+), 15 deletions(-)
blockdev.c +30 -10
@@ -3054,34 +3054,54 @@ void qmp_x_block_dirty_bitmap_disable(const char *node, const char *name,bdrv_disable_dirty_bitmap (bitmap); } -void qmp_x_block_dirty_bitmap_merge (const char *node,const char *dst_name, -const char *src_name,Error **errp) +void qmp_x_block_dirty_bitmap_merge (const char *node,const char *target, +strList *bitmaps,Error **errp) {BlockDriverState *bs; -BdrvDirtyBitmap *dst, *src; +BdrvDirtyBitmap *dst, *src, *anon; +strList *lst; +Error *local_err =NULL ; - dst =block_dirty_bitmap_lookup (node, dst_name, &bs, errp); + dst =block_dirty_bitmap_lookup (node, target, &bs, errp);if (!dst) {return ; }if (bdrv_dirty_bitmap_frozen (dst)) {error_setg (errp,"Bitmap '%s' is frozen and cannot be modified" , - dst_name); + target);return ; }else if (bdrv_dirty_bitmap_readonly (dst)) {error_setg (errp,"Bitmap '%s' is readonly and cannot be modified" , - dst_name); + target);return ; } - src =bdrv_find_dirty_bitmap (bs, src_name); -if (!src) { -error_setg (errp,"Dirty bitmap '%s' not found" , src_name); + anon =bdrv_create_dirty_bitmap (bs,bdrv_dirty_bitmap_granularity (dst), +NULL , errp); +if (!anon) {return ; } -bdrv_merge_dirty_bitmap (dst, src, errp); +/* Aggregate bitmaps to anonymous temp bitmap */ +for (lst = bitmaps; lst; lst = lst->next) { + src =bdrv_find_dirty_bitmap (bs, lst->value); +if (!src) { +error_setg (errp,"Dirty bitmap '%s' not found" , lst->value); + goto out; + } +bdrv_merge_dirty_bitmap (anon, src, &local_err); +if (local_err) { +error_propagate (errp, local_err); + goto out; + } + } + +/* Merge into dst; dst is unchanged on failure */ +bdrv_merge_dirty_bitmap (dst, anon, errp); + +out: +bdrv_release_dirty_bitmap (bs, anon); } BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,
qapi/block-core.json +5 -5
@@ -1749,14 +1749,14 @@ # # @node: name of device/node which the bitmap is tracking # -# @dst_name: name of the destination dirty bitmap +# @target: name of the destination dirty bitmap # -# @src_name: name of the source dirty bitmap +# @bitmaps: name(s) of the source dirty bitmap(s) # # Since: 3.0 ## { 'struct': 'BlockDirtyBitmapMerge', - 'data': { 'node': 'str', 'dst_name': 'str', 'src_name': 'str' } } + 'data': { 'node': 'str', 'target': 'str', 'bitmaps': ['str'] } } ## # @block-dirty-bitmap-add:
@@ -1884,8 +1884,8 @@ # Example: # # -> { "execute": "x-block-dirty-bitmap-merge", -# "arguments": { "node": "drive0", "dst_name": "bitmap0", -# "src_name": "bitmap1" } } +# "arguments": { "node": "drive0", "target": "bitmap0", +# "bitmaps": ["bitmap1"] } } # <- { "return": {} } # ##
Signature · 1 line
2.14.3
I mis-typed Vladimir's email, I have corrected it here.
Quoted 13 lines · John Snow
requires: [email protected]
See patch for details; this is somewhat an RFC that I suspect will be useful for libvirt in some situations, but maybe it's actually overkill.
John Snow (1):
blockdev: n-ary bitmap mergeblockdev.c | 40 ++++++++++++++++++++++++++++++---------- qapi/block-core.json | 10 +++++----- 2 files changed, 35 insertions(+), 15 deletions(-)
Quoted 1 line · John Snow
requires: [email protected]
No longer requires any prerequisites.
--js
Quoted 12 lines
See patch for details; this is somewhat an RFC that I suspect will be useful for libvirt in some situations, but maybe it's actually overkill.
John Snow (1):
blockdev: n-ary bitmap mergeblockdev.c | 40 ++++++++++++++++++++++++++++++---------- qapi/block-core.json | 10 +++++----- 2 files changed, 35 insertions(+), 15 deletions(-)
Re: [Qemu-devel] [PATCH 1/1] blockdev: n-ary bitmap merge
In reply to John Snowadd Nikolay
Quoted 114 lines · John Snow
It might be nice to have an all-or-nothing merge command that either succeeds in merging all bitmaps or fails for all of them. This way, when assembling bitmaps that represent arbitrary points in time from component bitmaps, we always know the state of the target bitmap even in cases of failure.
Signed-off-by John Snow <[email protected]>--- blockdev.c | 40 ++++++++++++++++++++++++++++++---------- qapi/block-core.json | 10 +++++----- 2 files changed, 35 insertions(+), 15 deletions(-)blockdev.c +30
-10@@ -3054,34 +3054,54 @@ void qmp_x_block_dirty_bitmap_disable(const char *node, const char *name,bdrv_disable_dirty_bitmap (bitmap); } -void qmp_x_block_dirty_bitmap_merge (const char *node,const char *dst_name, -const char *src_name,Error **errp) +void qmp_x_block_dirty_bitmap_merge (const char *node,const char *target, +strList *bitmaps,Error **errp) {BlockDriverState *bs; -BdrvDirtyBitmap *dst, *src; +BdrvDirtyBitmap *dst, *src, *anon; +strList *lst; +Error *local_err =NULL ; - dst =block_dirty_bitmap_lookup (node, dst_name, &bs, errp); + dst =block_dirty_bitmap_lookup (node, target, &bs, errp);if (!dst) {return ; }if (bdrv_dirty_bitmap_frozen (dst)) {error_setg (errp,"Bitmap '%s' is frozen and cannot be modified" , - dst_name); + target);return ; }else if (bdrv_dirty_bitmap_readonly (dst)) {error_setg (errp,"Bitmap '%s' is readonly and cannot be modified" , - dst_name); + target);return ; } - src =bdrv_find_dirty_bitmap (bs, src_name); -if (!src) { -error_setg (errp,"Dirty bitmap '%s' not found" , src_name); + anon =bdrv_create_dirty_bitmap (bs,bdrv_dirty_bitmap_granularity (dst), +NULL , errp); +if (!anon) {return ; } -bdrv_merge_dirty_bitmap (dst, src, errp); +/* Aggregate bitmaps to anonymous temp bitmap */ +for (lst = bitmaps; lst; lst = lst->next) { + src =bdrv_find_dirty_bitmap (bs, lst->value); +if (!src) { +error_setg (errp,"Dirty bitmap '%s' not found" , lst->value); + goto out; + } +bdrv_merge_dirty_bitmap (anon, src, &local_err); +if (local_err) { +error_propagate (errp, local_err); + goto out; + } + } + +/* Merge into dst; dst is unchanged on failure */ +bdrv_merge_dirty_bitmap (dst, anon, errp); + +out: +bdrv_release_dirty_bitmap (bs, anon); } BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,qapi/block-core.json +5
-5@@ -1749,14 +1749,14 @@ # # @node: name of device/node which the bitmap is tracking # -# @dst_name: name of the destination dirty bitmap +# @target: name of the destination dirty bitmap # -# @src_name: name of the source dirty bitmap +# @bitmaps: name(s) of the source dirty bitmap(s) # # Since: 3.0 ## { 'struct': 'BlockDirtyBitmapMerge', - 'data': { 'node': 'str', 'dst_name': 'str', 'src_name': 'str' } } + 'data': { 'node': 'str', 'target': 'str', 'bitmaps': ['str'] } } ## # @block-dirty-bitmap-add:@@ -1884,8 +1884,8 @@ # Example: # # -> { "execute": "x-block-dirty-bitmap-merge", -# "arguments": { "node": "drive0", "dst_name": "bitmap0", -# "src_name": "bitmap1" } } +# "arguments": { "node": "drive0", "target": "bitmap0", +# "bitmaps": ["bitmap1"] } } # <- { "return": {} } # ##
Signature · 2 lines
Best regards, Vladimir