From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
vsementsov@virtuozzo.com, Eduardo Habkost <ehabkost@redhat.com>,
qemu-block@nongnu.org, Markus Armbruster <armbru@redhat.com>,
Max Reitz <mreitz@redhat.com>,
pkrempa@redhat.com, Cleber Rosa <crosa@redhat.com>,
John Snow <jsnow@redhat.com>
Subject: [PATCH 2/6] qmp: expose block-dirty-bitmap-populate
Date: Mon, 24 Feb 2020 19:56:37 -0500 [thread overview]
Message-ID: <20200225005641.5478-3-jsnow@redhat.com> (raw)
In-Reply-To: <20200225005641.5478-1-jsnow@redhat.com>
This is a new job-creating command.
Signed-off-by: John Snow <jsnow@redhat.com>
---
qapi/block-core.json | 18 ++++++++++
qapi/transaction.json | 2 ++
blockdev.c | 78 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 98 insertions(+)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index df1797681a..a8be1fb36b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2293,6 +2293,24 @@
'*auto-finalize': 'bool',
'*auto-dismiss': 'bool' } }
+##
+# @block-dirty-bitmap-populate:
+#
+# Creates a new job that writes a pattern into a dirty bitmap.
+#
+# Since: 5.0
+#
+# Example:
+#
+# -> { "execute": "block-dirty-bitmap-populate",
+# "arguments": { "node": "drive0", "target": "bitmap0",
+# "job-id": "job0", "pattern": "allocate-top" } }
+# <- { "return": {} }
+#
+##
+{ 'command': 'block-dirty-bitmap-populate', 'boxed': true,
+ 'data': 'BlockDirtyBitmapPopulate' }
+
##
# @BlockDirtyBitmapSha256:
#
diff --git a/qapi/transaction.json b/qapi/transaction.json
index 04301f1be7..28521d5c7f 100644
--- a/qapi/transaction.json
+++ b/qapi/transaction.json
@@ -50,6 +50,7 @@
# - @block-dirty-bitmap-enable: since 4.0
# - @block-dirty-bitmap-disable: since 4.0
# - @block-dirty-bitmap-merge: since 4.0
+# - @block-dirty-bitmap-populate: since 5.0
# - @blockdev-backup: since 2.3
# - @blockdev-snapshot: since 2.5
# - @blockdev-snapshot-internal-sync: since 1.7
@@ -67,6 +68,7 @@
'block-dirty-bitmap-enable': 'BlockDirtyBitmap',
'block-dirty-bitmap-disable': 'BlockDirtyBitmap',
'block-dirty-bitmap-merge': 'BlockDirtyBitmapMerge',
+ 'block-dirty-bitmap-populate': 'BlockDirtyBitmapPopulate',
'blockdev-backup': 'BlockdevBackup',
'blockdev-snapshot': 'BlockdevSnapshot',
'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternal',
diff --git a/blockdev.c b/blockdev.c
index 011dcfec27..33c0e35399 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2314,6 +2314,67 @@ static void block_dirty_bitmap_remove_commit(BlkActionState *common)
bdrv_release_dirty_bitmap(state->bitmap);
}
+static void block_dirty_bitmap_populate_prepare(BlkActionState *common, Error **errp)
+{
+ BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common);
+ BlockDirtyBitmapPopulate *bitpop;
+ BlockDriverState *bs;
+ AioContext *aio_context;
+ BdrvDirtyBitmap *bmap = NULL;
+ int job_flags = JOB_DEFAULT;
+
+ assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCK_DIRTY_BITMAP_POPULATE);
+ bitpop = common->action->u.block_dirty_bitmap_populate.data;
+
+ bs = bdrv_lookup_bs(bitpop->node, bitpop->node, errp);
+ if (!bs) {
+ return;
+ }
+
+ aio_context = bdrv_get_aio_context(bs);
+ aio_context_acquire(aio_context);
+ state->bs = bs;
+
+ bmap = bdrv_find_dirty_bitmap(bs, bitpop->name);
+ if (!bmap) {
+ error_setg(errp, "Bitmap '%s' could not be found", bitpop->name);
+ return;
+ }
+
+ /* Paired with .clean() */
+ bdrv_drained_begin(state->bs);
+
+ if (!bitpop->has_on_error) {
+ bitpop->on_error = BLOCKDEV_ON_ERROR_REPORT;
+ }
+ if (!bitpop->has_auto_finalize) {
+ bitpop->auto_finalize = true;
+ }
+ if (!bitpop->has_auto_dismiss) {
+ bitpop->auto_dismiss = true;
+ }
+
+ if (!bitpop->auto_finalize) {
+ job_flags |= JOB_MANUAL_FINALIZE;
+ }
+ if (!bitpop->auto_dismiss) {
+ job_flags |= JOB_MANUAL_DISMISS;
+ }
+
+ state->job = bitpop_job_create(
+ bitpop->job_id,
+ bs,
+ bmap,
+ bitpop->pattern,
+ bitpop->on_error,
+ job_flags,
+ NULL, NULL,
+ common->block_job_txn,
+ errp);
+
+ aio_context_release(aio_context);
+}
+
static void abort_prepare(BlkActionState *common, Error **errp)
{
error_setg(errp, "Transaction aborted using Abort action");
@@ -2397,6 +2458,13 @@ static const BlkActionOps actions[] = {
.commit = block_dirty_bitmap_remove_commit,
.abort = block_dirty_bitmap_remove_abort,
},
+ [TRANSACTION_ACTION_KIND_BLOCK_DIRTY_BITMAP_POPULATE] = {
+ .instance_size = sizeof(BlockdevBackupState),
+ .prepare = block_dirty_bitmap_populate_prepare,
+ .commit = blockdev_backup_commit,
+ .abort = blockdev_backup_abort,
+ .clean = blockdev_backup_clean,
+ },
/* Where are transactions for MIRROR, COMMIT and STREAM?
* Although these blockjobs use transaction callbacks like the backup job,
* these jobs do not necessarily adhere to transaction semantics.
@@ -3225,6 +3293,16 @@ void qmp_block_dirty_bitmap_merge(const char *node, const char *target,
do_block_dirty_bitmap_merge(node, target, bitmaps, NULL, errp);
}
+void qmp_block_dirty_bitmap_populate(BlockDirtyBitmapPopulate *bitpop,
+ Error **errp)
+{
+ TransactionAction action = {
+ .type = TRANSACTION_ACTION_KIND_BLOCK_DIRTY_BITMAP_POPULATE,
+ .u.block_dirty_bitmap_populate.data = bitpop,
+ };
+ blockdev_do_action(&action, errp);
+}
+
BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,
const char *name,
Error **errp)
--
2.21.1
next prev parent reply other threads:[~2020-02-25 0:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-25 0:56 [PATCH 0/6] block: add block-dirty-bitmap-populate job John Snow
2020-02-25 0:56 ` [PATCH 1/6] block: add bitmap-populate job John Snow
2020-02-25 16:04 ` Vladimir Sementsov-Ogievskiy
2020-02-25 20:41 ` John Snow
2020-02-26 5:07 ` Vladimir Sementsov-Ogievskiy
2020-02-26 19:11 ` John Snow
2020-02-27 6:11 ` Vladimir Sementsov-Ogievskiy
2020-03-03 21:39 ` John Snow
2020-02-25 0:56 ` John Snow [this message]
2020-02-27 10:44 ` [PATCH 2/6] qmp: expose block-dirty-bitmap-populate Vladimir Sementsov-Ogievskiy
2020-03-03 21:48 ` John Snow
2020-02-25 0:56 ` [PATCH 3/6] iotests: move bitmap helpers into their own file John Snow
2020-02-27 10:54 ` Vladimir Sementsov-Ogievskiy
2020-03-03 21:55 ` John Snow
2020-02-25 0:56 ` [PATCH 4/6] iotests: add hmp helper with logging John Snow
2020-02-27 10:57 ` Vladimir Sementsov-Ogievskiy
2020-02-25 0:56 ` [PATCH 5/6] qmp.py: change event_wait to use a dict John Snow
2020-02-27 11:25 ` Vladimir Sementsov-Ogievskiy
2020-03-03 21:58 ` John Snow
2020-02-25 0:56 ` [PATCH 6/6] iotests: add 287 for block-dirty-bitmap-populate John Snow
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=20200225005641.5478-3-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=armbru@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pkrempa@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.