Message ID | 20170503122539.282182-25-vsementsov@virtuozzo.com |
---|---|
State | New |
Headers | show |
On 2017-05-03 14:25, Vladimir Sementsov-Ogievskiy wrote: > Remove persistent bitmap from the storage on block-dirty-bitmap-remove. > > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> > Reviewed-by: Max Reitz <mreitz@redhat.com> > Reviewed-by: John Snow <jsnow@redhat.com> > --- > blockdev.c | 10 ++++++++++ > qapi/block-core.json | 3 ++- > 2 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/blockdev.c b/blockdev.c > index c49d414891..0ad1a658b9 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -2802,6 +2802,7 @@ void qmp_block_dirty_bitmap_remove(const char *node, const char *name, > AioContext *aio_context; > BlockDriverState *bs; > BdrvDirtyBitmap *bitmap; > + Error *local_err = NULL; > > bitmap = block_dirty_bitmap_lookup(node, name, &bs, &aio_context, errp); > if (!bitmap || !bs) { > @@ -2814,6 +2815,15 @@ void qmp_block_dirty_bitmap_remove(const char *node, const char *name, > name); > goto out; > } > + > + if (bdrv_dirty_bitmap_get_persistance(bitmap)) { > + bdrv_remove_persistent_dirty_bitmap(bs, name, &local_err); > + if (local_err != NULL) { > + error_propagate(errp, local_err); > + goto out; > + } > + } > + > bdrv_dirty_bitmap_make_anon(bitmap); > bdrv_release_dirty_bitmap(bs, bitmap); > > diff --git a/qapi/block-core.json b/qapi/block-core.json > index e9523b4b8c..933b1a5fe5 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -1600,7 +1600,8 @@ > # @block-dirty-bitmap-remove: > # > # Stop write tracking and remove the dirty bitmap that was created > -# with block-dirty-bitmap-add. > +# with block-dirty-bitmap-add. If bitmap is persistent, remove it from it's s/If bitmap/If the bitmap/, s/it's/its/ Max > +# storage too. > # > # Returns: nothing on success > # If @node is not a valid block device or node, DeviceNotFound >
diff --git a/blockdev.c b/blockdev.c index c49d414891..0ad1a658b9 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2802,6 +2802,7 @@ void qmp_block_dirty_bitmap_remove(const char *node, const char *name, AioContext *aio_context; BlockDriverState *bs; BdrvDirtyBitmap *bitmap; + Error *local_err = NULL; bitmap = block_dirty_bitmap_lookup(node, name, &bs, &aio_context, errp); if (!bitmap || !bs) { @@ -2814,6 +2815,15 @@ void qmp_block_dirty_bitmap_remove(const char *node, const char *name, name); goto out; } + + if (bdrv_dirty_bitmap_get_persistance(bitmap)) { + bdrv_remove_persistent_dirty_bitmap(bs, name, &local_err); + if (local_err != NULL) { + error_propagate(errp, local_err); + goto out; + } + } + bdrv_dirty_bitmap_make_anon(bitmap); bdrv_release_dirty_bitmap(bs, bitmap); diff --git a/qapi/block-core.json b/qapi/block-core.json index e9523b4b8c..933b1a5fe5 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1600,7 +1600,8 @@ # @block-dirty-bitmap-remove: # # Stop write tracking and remove the dirty bitmap that was created -# with block-dirty-bitmap-add. +# with block-dirty-bitmap-add. If bitmap is persistent, remove it from it's +# storage too. # # Returns: nothing on success # If @node is not a valid block device or node, DeviceNotFound