From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: armbru@redhat.com, mreitz@redhat.com, kwolf@redhat.com,
jsnow@redhat.com, famz@redhat.com, vsementsov@virtuozzo.com,
den@openvz.org
Subject: [Qemu-devel] [PATCH 7/7] blockdev: unify block-dirty-bitmap-clear command and transaction action
Date: Mon, 26 Mar 2018 14:20:56 +0300 [thread overview]
Message-ID: <20180326112056.8420-8-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20180326112056.8420-1-vsementsov@virtuozzo.com>
- use error messages from qmp command, as they are more descriptive
- we need not check bs, as block_dirty_bitmap_lookup never returns
bs = NULL on success (and if user set bs to be not NULL pointer),
so, let's just assert it.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
blockdev.c | 53 +++++++++++++++++++++--------------------------------
1 file changed, 21 insertions(+), 32 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 54e1ba8f44..3f0979298e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2114,18 +2114,26 @@ static void block_dirty_bitmap_clear_prepare(BlkActionState *common,
if (!state->bitmap) {
return;
}
+ assert(state->bs != NULL);
if (bdrv_dirty_bitmap_frozen(state->bitmap)) {
- error_setg(errp, "Cannot modify a frozen bitmap");
+ error_setg(errp,
+ "Bitmap '%s' is currently frozen and cannot be modified",
+ action->name);
return;
} else if (bdrv_dirty_bitmap_qmp_locked(state->bitmap)) {
- error_setg(errp, "Cannot modify a locked bitmap");
+ error_setg(errp,
+ "Bitmap '%s' is currently locked and cannot be modified",
+ action->name);
return;
} else if (!bdrv_dirty_bitmap_enabled(state->bitmap)) {
- error_setg(errp, "Cannot clear a disabled bitmap");
+ error_setg(errp,
+ "Bitmap '%s' is currently disabled and cannot be cleared",
+ action->name);
return;
} else if (bdrv_dirty_bitmap_readonly(state->bitmap)) {
- error_setg(errp, "Cannot clear a readonly bitmap");
+ error_setg(errp, "Bitmap '%s' is readonly and cannot be cleared",
+ action->name);
return;
}
}
@@ -2878,35 +2886,16 @@ void qmp_block_dirty_bitmap_remove(const char *node, const char *name,
void qmp_block_dirty_bitmap_clear(const char *node, const char *name,
Error **errp)
{
- BdrvDirtyBitmap *bitmap;
- BlockDriverState *bs;
-
- bitmap = block_dirty_bitmap_lookup(node, name, &bs, errp);
- if (!bitmap || !bs) {
- return;
- }
-
- if (bdrv_dirty_bitmap_frozen(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);
- return;
- } else if (!bdrv_dirty_bitmap_enabled(bitmap)) {
- error_setg(errp,
- "Bitmap '%s' is currently disabled and cannot be cleared",
- name);
- return;
- } else if (bdrv_dirty_bitmap_readonly(bitmap)) {
- error_setg(errp, "Bitmap '%s' is readonly and cannot be cleared", name);
- return;
- }
+ BlockDirtyBitmap data = {
+ .node = (char *)node,
+ .name = (char *)name
+ };
+ TransactionAction action = {
+ .type = TRANSACTION_ACTION_KIND_BLOCK_DIRTY_BITMAP_CLEAR,
+ .u.block_dirty_bitmap_clear.data = &data,
+ };
- bdrv_clear_dirty_bitmap(bitmap);
+ blockdev_do_action(&action, errp);
}
BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,
--
2.11.1
next prev parent reply other threads:[~2018-03-26 11:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-26 11:20 [Qemu-devel] [PATCH 0/7] Dirty bitmaps fixing and refactoring Vladimir Sementsov-Ogievskiy
2018-03-26 11:20 ` [Qemu-devel] [PATCH 1/7] block/dirty-bitmap: add lock to bdrv_enable/disable_dirty_bitmap Vladimir Sementsov-Ogievskiy
2018-03-26 11:20 ` [Qemu-devel] [PATCH 2/7] dirty-bitmaps: fix comment about dirty_bitmap_mutex Vladimir Sementsov-Ogievskiy
2018-03-26 11:20 ` [Qemu-devel] [PATCH 3/7] dirty-bitmap: remove missed bdrv_dirty_bitmap_get_autoload header Vladimir Sementsov-Ogievskiy
2018-03-26 11:20 ` [Qemu-devel] [PATCH 4/7] dirty-bitmap: separate unused meta-bitmap related functions Vladimir Sementsov-Ogievskiy
2018-03-26 11:20 ` [Qemu-devel] [PATCH 5/7] blockdev: refactor block-dirty-bitmap-clear transaction Vladimir Sementsov-Ogievskiy
2018-03-26 11:44 ` Paolo Bonzini
2018-03-26 11:48 ` Vladimir Sementsov-Ogievskiy
2018-03-26 11:53 ` Vladimir Sementsov-Ogievskiy
2018-03-26 11:20 ` [Qemu-devel] [PATCH 6/7] block/dirty-bitmap: bdrv_clear_dirty_bitmap: drop unused parameter Vladimir Sementsov-Ogievskiy
2018-03-26 11:20 ` Vladimir Sementsov-Ogievskiy [this message]
2018-03-26 11:44 ` [Qemu-devel] [PATCH 0/7] Dirty bitmaps fixing and refactoring Paolo Bonzini
2018-03-26 11:53 ` [Qemu-devel] [PATCH 5.5/7] dirty-bitmap: drop unused bdrv_undo_clear_dirty_bitmap Vladimir Sementsov-Ogievskiy
2018-03-26 13:21 ` no-reply
2018-03-26 14:21 ` no-reply
2018-03-26 15:56 ` no-reply
2018-03-26 17:04 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180326112056.8420-8-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=den@openvz.org \
--cc=famz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).