+
void bdrv_dirty_bitmap_set_qmp_locked(BdrvDirtyBitmap *bitmap, bool
qmp_locked)
{
qemu_mutex_lock(bitmap->mutex);
diff --git a/blockdev.c b/blockdev.c
index 670ae5bbde..dedcebb0fa 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2009,11 +2009,8 @@ static void
block_dirty_bitmap_clear_prepare(BlkActionState *common,
return;
}
- if (bdrv_dirty_bitmap_frozen(state->bitmap)) {
- error_setg(errp, "Cannot modify a frozen bitmap");
- return;
- } else if (bdrv_dirty_bitmap_qmp_locked(state->bitmap)) {
- error_setg(errp, "Cannot modify a locked bitmap");
+ if (!bdrv_dirty_bitmap_user_modifiable(state->bitmap)) {
+ error_setg(errp, "Cannot modify a bitmap in-use by another
operation");
return;
} else if (!bdrv_dirty_bitmap_enabled(state->bitmap)) {
error_setg(errp, "Cannot clear a disabled bitmap");
@@ -2882,15 +2879,10 @@ void qmp_block_dirty_bitmap_remove(const char
*node, const char *name,
return;
}
- if (bdrv_dirty_bitmap_frozen(bitmap)) {
+ if (!bdrv_dirty_bitmap_user_modifiable(bitmap)) {
error_setg(errp,
- "Bitmap '%s' is currently frozen and cannot be
removed",
- name);
- return;
- } else if (bdrv_dirty_bitmap_qmp_locked(bitmap)) {
- error_setg(errp,
- "Bitmap '%s' is currently locked and cannot be
removed",
- name);
+ "Bitmap '%s' is currently in-use by another
operation and"
+ " cannot be removed", name);
return;
}
@@ -2920,15 +2912,10 @@ void qmp_block_dirty_bitmap_clear(const
char *node, const char *name,
return;
}
- if (bdrv_dirty_bitmap_frozen(bitmap)) {
+ if (!bdrv_dirty_bitmap_user_modifiable(bitmap)) {
error_setg(errp,
- "Bitmap '%s' is currently frozen and cannot be
modified",
- name);
- return;
- } else if (bdrv_dirty_bitmap_qmp_locked(bitmap)) {
- error_setg(errp,
- "Bitmap '%s' is currently locked and cannot be
modified",
- name);
+ "Bitmap '%s' is currently in-use by another
operation"
+ " and cannot be cleared", name);
return;
} else if (!bdrv_dirty_bitmap_enabled(bitmap)) {
error_setg(errp,
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 201ff7f20b..92cf7e39d2 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -94,6 +94,7 @@ bool bdrv_has_readonly_bitmaps(BlockDriverState *bs);
bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap);
bool bdrv_dirty_bitmap_get_persistance(BdrvDirtyBitmap *bitmap);
bool bdrv_dirty_bitmap_qmp_locked(BdrvDirtyBitmap *bitmap);
+bool bdrv_dirty_bitmap_user_modifiable(BdrvDirtyBitmap *bitmap);
bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs);
BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BlockDriverState *bs,
BdrvDirtyBitmap *bitmap);