Re: [Qemu-devel] [PATCH 14/17] qmp: add x-debug-block-dirty-bitmap-sha256
16.02.2017 03:35, John Snow wrote: On 02/13/2017 04:54 AM, Vladimir Sementsov-Ogievskiy wrote: Signed-off-by: Vladimir Sementsov-OgievskiyReviewed-by: Max Reitz This is simply the same as the version in the other two series, right? Yes. Context a bit differs... Aha, I've discovered that in migration I'm adding bdrv_next_dirty_bitmap and in persistent - bdrv_dirty_bitmap_next. Anyway, one series should be rebased after applying the second.. Reviewed-by: John Snow --- block/dirty-bitmap.c | 5 + blockdev.c | 29 + include/block/dirty-bitmap.h | 2 ++ include/qemu/hbitmap.h | 8 qapi/block-core.json | 27 +++ tests/Makefile.include | 2 +- util/hbitmap.c | 11 +++ 7 files changed, 83 insertions(+), 1 deletion(-) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 32aa6eb..5bec99b 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -558,3 +558,8 @@ BdrvDirtyBitmap *bdrv_next_dirty_bitmap(BlockDriverState *bs, return QLIST_NEXT(bitmap, list); } + +char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap *bitmap, Error **errp) +{ +return hbitmap_sha256(bitmap->bitmap, errp); +} diff --git a/blockdev.c b/blockdev.c index db82ac9..4d06885 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2790,6 +2790,35 @@ void qmp_block_dirty_bitmap_clear(const char *node, const char *name, aio_context_release(aio_context); } +BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node, + const char *name, + Error **errp) +{ +AioContext *aio_context; +BdrvDirtyBitmap *bitmap; +BlockDriverState *bs; +BlockDirtyBitmapSha256 *ret = NULL; +char *sha256; + +bitmap = block_dirty_bitmap_lookup(node, name, , _context, errp); +if (!bitmap || !bs) { +return NULL; +} + +sha256 = bdrv_dirty_bitmap_sha256(bitmap, errp); +if (sha256 == NULL) { +goto out; +} + +ret = g_new(BlockDirtyBitmapSha256, 1); +ret->sha256 = sha256; + +out: +aio_context_release(aio_context); + +return ret; +} + void hmp_drive_del(Monitor *mon, const QDict *qdict) { const char *id = qdict_get_str(qdict, "id"); diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index 20b3ec7..ded872a 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -78,4 +78,6 @@ void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap); BdrvDirtyBitmap *bdrv_next_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap); +char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap *bitmap, Error **errp); + #endif diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h index 9239fe5..f353e56 100644 --- a/include/qemu/hbitmap.h +++ b/include/qemu/hbitmap.h @@ -238,6 +238,14 @@ void hbitmap_deserialize_zeroes(HBitmap *hb, uint64_t start, uint64_t count, void hbitmap_deserialize_finish(HBitmap *hb); /** + * hbitmap_sha256: + * @bitmap: HBitmap to operate on. + * + * Returns SHA256 hash of the last level. + */ +char *hbitmap_sha256(const HBitmap *bitmap, Error **errp); + +/** * hbitmap_free: * @hb: HBitmap to operate on. * diff --git a/qapi/block-core.json b/qapi/block-core.json index 932f5bb..8646054 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1632,6 +1632,33 @@ 'data': 'BlockDirtyBitmap' } ## +# @BlockDirtyBitmapSha256: +# +# SHA256 hash of dirty bitmap data +# +# @sha256: ASCII representation of SHA256 bitmap hash +# +# Since: 2.9 +## + { 'struct': 'BlockDirtyBitmapSha256', +'data': {'sha256': 'str'} } + +## +# @x-debug-block-dirty-bitmap-sha256: +# +# Get bitmap SHA256 +# +# Returns: BlockDirtyBitmapSha256 on success +# If @node is not a valid block device, DeviceNotFound +# If @name is not found or if hashing has failed, GenericError with an +# explanation +# +# Since: 2.9 +## + { 'command': 'x-debug-block-dirty-bitmap-sha256', +'data': 'BlockDirtyBitmap', 'returns': 'BlockDirtyBitmapSha256' } + +## # @blockdev-mirror: # # Start mirroring a block device's writes to a new destination. diff --git a/tests/Makefile.include b/tests/Makefile.include index 634394a..7a71b4d 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -526,7 +526,7 @@ tests/test-blockjob$(EXESUF): tests/test-blockjob.o $(test-block-obj-y) $(test-u tests/test-blockjob-txn$(EXESUF): tests/test-blockjob-txn.o $(test-block-obj-y) $(test-util-obj-y) tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y) tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y) -tests/test-hbitmap$(EXESUF):
Re: [Qemu-devel] [PATCH 14/17] qmp: add x-debug-block-dirty-bitmap-sha256
On 02/13/2017 04:54 AM, Vladimir Sementsov-Ogievskiy wrote: > Signed-off-by: Vladimir Sementsov-Ogievskiy> Reviewed-by: Max Reitz This is simply the same as the version in the other two series, right? Reviewed-by: John Snow > --- > block/dirty-bitmap.c | 5 + > blockdev.c | 29 + > include/block/dirty-bitmap.h | 2 ++ > include/qemu/hbitmap.h | 8 > qapi/block-core.json | 27 +++ > tests/Makefile.include | 2 +- > util/hbitmap.c | 11 +++ > 7 files changed, 83 insertions(+), 1 deletion(-) > > diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c > index 32aa6eb..5bec99b 100644 > --- a/block/dirty-bitmap.c > +++ b/block/dirty-bitmap.c > @@ -558,3 +558,8 @@ BdrvDirtyBitmap *bdrv_next_dirty_bitmap(BlockDriverState > *bs, > > return QLIST_NEXT(bitmap, list); > } > + > +char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap *bitmap, Error **errp) > +{ > +return hbitmap_sha256(bitmap->bitmap, errp); > +} > diff --git a/blockdev.c b/blockdev.c > index db82ac9..4d06885 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -2790,6 +2790,35 @@ void qmp_block_dirty_bitmap_clear(const char *node, > const char *name, > aio_context_release(aio_context); > } > > +BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char > *node, > + const char > *name, > + Error **errp) > +{ > +AioContext *aio_context; > +BdrvDirtyBitmap *bitmap; > +BlockDriverState *bs; > +BlockDirtyBitmapSha256 *ret = NULL; > +char *sha256; > + > +bitmap = block_dirty_bitmap_lookup(node, name, , _context, errp); > +if (!bitmap || !bs) { > +return NULL; > +} > + > +sha256 = bdrv_dirty_bitmap_sha256(bitmap, errp); > +if (sha256 == NULL) { > +goto out; > +} > + > +ret = g_new(BlockDirtyBitmapSha256, 1); > +ret->sha256 = sha256; > + > +out: > +aio_context_release(aio_context); > + > +return ret; > +} > + > void hmp_drive_del(Monitor *mon, const QDict *qdict) > { > const char *id = qdict_get_str(qdict, "id"); > diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h > index 20b3ec7..ded872a 100644 > --- a/include/block/dirty-bitmap.h > +++ b/include/block/dirty-bitmap.h > @@ -78,4 +78,6 @@ void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap > *bitmap); > BdrvDirtyBitmap *bdrv_next_dirty_bitmap(BlockDriverState *bs, > BdrvDirtyBitmap *bitmap); > > +char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap *bitmap, Error **errp); > + > #endif > diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h > index 9239fe5..f353e56 100644 > --- a/include/qemu/hbitmap.h > +++ b/include/qemu/hbitmap.h > @@ -238,6 +238,14 @@ void hbitmap_deserialize_zeroes(HBitmap *hb, uint64_t > start, uint64_t count, > void hbitmap_deserialize_finish(HBitmap *hb); > > /** > + * hbitmap_sha256: > + * @bitmap: HBitmap to operate on. > + * > + * Returns SHA256 hash of the last level. > + */ > +char *hbitmap_sha256(const HBitmap *bitmap, Error **errp); > + > +/** > * hbitmap_free: > * @hb: HBitmap to operate on. > * > diff --git a/qapi/block-core.json b/qapi/block-core.json > index 932f5bb..8646054 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -1632,6 +1632,33 @@ >'data': 'BlockDirtyBitmap' } > > ## > +# @BlockDirtyBitmapSha256: > +# > +# SHA256 hash of dirty bitmap data > +# > +# @sha256: ASCII representation of SHA256 bitmap hash > +# > +# Since: 2.9 > +## > + { 'struct': 'BlockDirtyBitmapSha256', > +'data': {'sha256': 'str'} } > + > +## > +# @x-debug-block-dirty-bitmap-sha256: > +# > +# Get bitmap SHA256 > +# > +# Returns: BlockDirtyBitmapSha256 on success > +# If @node is not a valid block device, DeviceNotFound > +# If @name is not found or if hashing has failed, GenericError with > an > +# explanation > +# > +# Since: 2.9 > +## > + { 'command': 'x-debug-block-dirty-bitmap-sha256', > +'data': 'BlockDirtyBitmap', 'returns': 'BlockDirtyBitmapSha256' } > + > +## > # @blockdev-mirror: > # > # Start mirroring a block device's writes to a new destination. > diff --git a/tests/Makefile.include b/tests/Makefile.include > index 634394a..7a71b4d 100644 > --- a/tests/Makefile.include > +++ b/tests/Makefile.include > @@ -526,7 +526,7 @@ tests/test-blockjob$(EXESUF): tests/test-blockjob.o > $(test-block-obj-y) $(test-u > tests/test-blockjob-txn$(EXESUF): tests/test-blockjob-txn.o > $(test-block-obj-y) $(test-util-obj-y) > tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y) > tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y) > -tests/test-hbitmap$(EXESUF):
Re: [Qemu-devel] [PATCH 14/17] qmp: add x-debug-block-dirty-bitmap-sha256
On 11/21/2016 09:29 AM, Vladimir Sementsov-Ogievskiy wrote: > Signed-off-by: Vladimir Sementsov-Ogievskiy> --- > block/dirty-bitmap.c | 5 + > blockdev.c | 33 + > include/block/dirty-bitmap.h | 2 ++ > include/qemu/hbitmap.h | 8 > qapi/block-core.json | 26 ++ > util/hbitmap.c | 11 +++ > 6 files changed, 85 insertions(+) > > +++ b/qapi/block-core.json > @@ -1280,6 +1280,32 @@ >'data': 'BlockDirtyBitmap' } > > ## > +# @BlockDirtyBitmapSha256: > +# > +# SHA256 hash of dirty bitmap data Maybe 'ASCII representation of SHA256 hash...' to make it clear that this is a longhand representation rather than a binary value that might include non-characters. > +# > +# @sha256: bitmap SHA256 hash > +# > +# Since: 2.8 2.9, probably > +## > + { 'struct': 'BlockDirtyBitmapSha256', > +'data': {'sha256': 'str'} } > + > +## > +# @x-debug-block-dirty-bitmap-sha256 > +# > +# Get bitmap SHA256 > +# > +# Returns: BlockDirtyBitmapSha256 on success > +# If @node is not a valid block device, DeviceNotFound > +# If @name is not found, GenericError with an explanation > +# > +# Since 2.8 > +## and again > + { 'command': 'x-debug-block-dirty-bitmap-sha256', > +'data': 'BlockDirtyBitmap', 'returns': 'BlockDirtyBitmapSha256' } > + -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature