block/dirty-bitmap: bdrv_merge_dirty_bitmap(): add return value

That simplifies handling failure in existing code and in further new
usage of bdrv_merge_dirty_bitmap().

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220303194349.2304213-3-vsementsov@virtuozzo.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy 2022-03-03 20:43:35 +01:00 committed by Hanna Reitz
parent 051f66caa2
commit 34ffacb7f4
3 changed files with 9 additions and 7 deletions

View File

@ -884,11 +884,14 @@ bool bdrv_dirty_bitmap_next_dirty_area(BdrvDirtyBitmap *bitmap,
* Ensures permissions on bitmaps are reasonable; use for public API. * Ensures permissions on bitmaps are reasonable; use for public API.
* *
* @backup: If provided, make a copy of dest here prior to merge. * @backup: If provided, make a copy of dest here prior to merge.
*
* Returns true on success, false on failure. In case of failure bitmaps are
* untouched.
*/ */
void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, bool bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src,
HBitmap **backup, Error **errp) HBitmap **backup, Error **errp)
{ {
bool ret; bool ret = false;
bdrv_dirty_bitmaps_lock(dest->bs); bdrv_dirty_bitmaps_lock(dest->bs);
if (src->bs != dest->bs) { if (src->bs != dest->bs) {
@ -916,6 +919,8 @@ out:
if (src->bs != dest->bs) { if (src->bs != dest->bs) {
bdrv_dirty_bitmaps_unlock(src->bs); bdrv_dirty_bitmaps_unlock(src->bs);
} }
return ret;
} }
/** /**

View File

@ -263,7 +263,6 @@ BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target,
BlockDriverState *bs; BlockDriverState *bs;
BdrvDirtyBitmap *dst, *src, *anon; BdrvDirtyBitmap *dst, *src, *anon;
BlockDirtyBitmapMergeSourceList *lst; BlockDirtyBitmapMergeSourceList *lst;
Error *local_err = NULL;
GLOBAL_STATE_CODE(); GLOBAL_STATE_CODE();
@ -303,9 +302,7 @@ BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target,
abort(); abort();
} }
bdrv_merge_dirty_bitmap(anon, src, NULL, &local_err); if (!bdrv_merge_dirty_bitmap(anon, src, NULL, errp)) {
if (local_err) {
error_propagate(errp, local_err);
dst = NULL; dst = NULL;
goto out; goto out;
} }

View File

@ -77,7 +77,7 @@ void bdrv_dirty_bitmap_set_persistence(BdrvDirtyBitmap *bitmap,
bool persistent); bool persistent);
void bdrv_dirty_bitmap_set_inconsistent(BdrvDirtyBitmap *bitmap); void bdrv_dirty_bitmap_set_inconsistent(BdrvDirtyBitmap *bitmap);
void bdrv_dirty_bitmap_set_busy(BdrvDirtyBitmap *bitmap, bool busy); void bdrv_dirty_bitmap_set_busy(BdrvDirtyBitmap *bitmap, bool busy);
void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, bool bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src,
HBitmap **backup, Error **errp); HBitmap **backup, Error **errp);
void bdrv_dirty_bitmap_skip_store(BdrvDirtyBitmap *bitmap, bool skip); void bdrv_dirty_bitmap_skip_store(BdrvDirtyBitmap *bitmap, bool skip);
bool bdrv_dirty_bitmap_get(BdrvDirtyBitmap *bitmap, int64_t offset); bool bdrv_dirty_bitmap_get(BdrvDirtyBitmap *bitmap, int64_t offset);