[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/19] block/dirty-bitmaps: add user_locked status ch
From: |
John Snow |
Subject: |
[Qemu-devel] [PULL 10/19] block/dirty-bitmaps: add user_locked status checker |
Date: |
Mon, 29 Oct 2018 17:24:52 -0400 |
Instead of both frozen and qmp_locked checks, wrap it into one check.
frozen implies the bitmap is split in two (for backup), and shouldn't
be modified. qmp_locked implies it's being used by another operation,
like being exported over NBD. In both cases it means we shouldn't allow
the user to modify it in any meaningful way.
Replace any usages where we check both frozen and qmp_locked with the
new check.
Signed-off-by: John Snow <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
[w/edits Suggested-By: Vladimir Sementsov-Ogievskiy <address@hidden>]
Signed-off-by: John Snow <address@hidden>
---
block/dirty-bitmap.c | 6 ++++++
blockdev.c | 29 ++++++++---------------------
include/block/dirty-bitmap.h | 1 +
migration/block-dirty-bitmap.c | 10 ++--------
4 files changed, 17 insertions(+), 29 deletions(-)
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 8ac933cf1c..9603cdd29b 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -176,6 +176,12 @@ bool bdrv_dirty_bitmap_frozen(BdrvDirtyBitmap *bitmap)
return bitmap->successor;
}
+/* Both conditions disallow user-modification via QMP. */
+bool bdrv_dirty_bitmap_user_locked(BdrvDirtyBitmap *bitmap) {
+ return bdrv_dirty_bitmap_frozen(bitmap) ||
+ bdrv_dirty_bitmap_qmp_locked(bitmap);
+}
+
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 d685bb7746..9da0cf1a72 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2010,11 +2010,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_locked(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");
@@ -2883,15 +2880,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_locked(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;
}
@@ -2921,15 +2913,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_locked(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..14639439a2 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_locked(BdrvDirtyBitmap *bitmap);
bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs);
BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BlockDriverState *bs,
BdrvDirtyBitmap *bitmap);
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
index 477826330c..dfbfb853b7 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -301,14 +301,8 @@ static int init_dirty_bitmap_migration(void)
goto fail;
}
- if (bdrv_dirty_bitmap_frozen(bitmap)) {
- error_report("Can't migrate frozen dirty bitmap: '%s",
- bdrv_dirty_bitmap_name(bitmap));
- goto fail;
- }
-
- if (bdrv_dirty_bitmap_qmp_locked(bitmap)) {
- error_report("Can't migrate locked dirty bitmap: '%s",
+ if (bdrv_dirty_bitmap_user_locked(bitmap)) {
+ error_report("Can't migrate a bitmap that is in use by another
operation: '%s'",
bdrv_dirty_bitmap_name(bitmap));
goto fail;
}
--
2.14.5
- [Qemu-devel] [PULL 00/19] Bitmaps patches, John Snow, 2018/10/29
- [Qemu-devel] [PULL 03/19] dirty-bitmap: rename bdrv_undo_clear_dirty_bitmap, John Snow, 2018/10/29
- [Qemu-devel] [PULL 01/19] blockdev-backup: add bitmap argument, John Snow, 2018/10/29
- [Qemu-devel] [PULL 05/19] blockdev: rename block-dirty-bitmap-clear transaction handlers, John Snow, 2018/10/29
- [Qemu-devel] [PULL 02/19] dirty-bitmap: switch assert-fails to errors in bdrv_merge_dirty_bitmap, John Snow, 2018/10/29
- [Qemu-devel] [PULL 07/19] iotests: 169: drop deprecated 'autoload' parameter, John Snow, 2018/10/29
- [Qemu-devel] [PULL 06/19] qapi: add transaction support for x-block-dirty-bitmap-merge, John Snow, 2018/10/29
- [Qemu-devel] [PULL 08/19] block/qcow2: improve error message in qcow2_inactivate, John Snow, 2018/10/29
- [Qemu-devel] [PULL 04/19] dirty-bitmap: make it possible to restore bitmap after merge, John Snow, 2018/10/29
- [Qemu-devel] [PULL 09/19] bloc/qcow2: drop dirty_bitmaps_loaded state variable, John Snow, 2018/10/29
- [Qemu-devel] [PULL 10/19] block/dirty-bitmaps: add user_locked status checker,
John Snow <=
- [Qemu-devel] [PULL 13/19] block/dirty-bitmaps: prohibit enable/disable on locked/frozen bitmaps, John Snow, 2018/10/29
- [Qemu-devel] [PULL 12/19] block/dirty-bitmaps: allow clear on disabled bitmaps, John Snow, 2018/10/29
- [Qemu-devel] [PULL 11/19] block/dirty-bitmaps: fix merge permissions, John Snow, 2018/10/29
- [Qemu-devel] [PULL 18/19] iotests: improve 169, John Snow, 2018/10/29
- [Qemu-devel] [PULL 19/19] iotests: 169: add cases for source vm resuming, John Snow, 2018/10/29
- [Qemu-devel] [PULL 15/19] nbd: forbid use of frozen bitmaps, John Snow, 2018/10/29
- [Qemu-devel] [PULL 14/19] block/backup: prohibit backup from using in use bitmaps, John Snow, 2018/10/29
- [Qemu-devel] [PULL 16/19] bitmap: Update count after a merge, John Snow, 2018/10/29
- [Qemu-devel] [PULL 17/19] dirty-bitmaps: clean-up bitmaps loading and migration logic, John Snow, 2018/10/29
- Re: [Qemu-devel] [PULL 00/19] Bitmaps patches, Peter Maydell, 2018/10/30