From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, vsementsov@virtuozzo.com,
wencongyang2@huawei.com, xiechanglong.d@gmail.com,
qemu-devel@nongnu.org, armbru@redhat.com, den@openvz.org,
mreitz@redhat.com, jsnow@redhat.com
Subject: [PATCH v15 3/5] block/block-copy: split block_copy_set_callbacks function
Date: Tue, 1 Oct 2019 16:14:07 +0300 [thread overview]
Message-ID: <20191001131409.14202-4-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20191001131409.14202-1-vsementsov@virtuozzo.com>
Split block_copy_set_callbacks out of block_copy_state_new. It's needed
for further commit: block-copy will use BdrvChildren of backup-top
filter, so it will be created from backup-top filter creation function.
But callbacks will still belong to backup job and will be set in
separate.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
include/block/block-copy.h | 13 +++++++++----
block/backup.c | 6 ++++--
block/block-copy.c | 24 +++++++++++++++---------
3 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
index 962f91056a..340d856246 100644
--- a/include/block/block-copy.h
+++ b/include/block/block-copy.h
@@ -66,12 +66,17 @@ typedef struct BlockCopyState {
void *progress_opaque;
} BlockCopyState;
-BlockCopyState *block_copy_state_new(
- BlockDriverState *source, BlockDriverState *target,
- int64_t cluster_size, BdrvRequestFlags write_flags,
+BlockCopyState *block_copy_state_new(BlockDriverState *source,
+ BlockDriverState *target,
+ int64_t cluster_size,
+ BdrvRequestFlags write_flags,
+ Error **errp);
+
+void block_copy_set_callbacks(
+ BlockCopyState *s,
ProgressBytesCallbackFunc progress_bytes_callback,
ProgressResetCallbackFunc progress_reset_callback,
- void *progress_opaque, Error **errp);
+ void *progress_opaque);
void block_copy_state_free(BlockCopyState *s);
diff --git a/block/backup.c b/block/backup.c
index b5b7939356..1057ed0a4e 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -478,8 +478,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
job->bitmap_mode = bitmap_mode;
job->bcs = block_copy_state_new(bs, target, cluster_size, write_flags,
- backup_progress_bytes_callback,
- backup_progress_reset_callback, job, errp);
+ errp);
if (!job->bcs) {
goto error;
}
@@ -487,6 +486,9 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
job->cluster_size = cluster_size;
job->len = len;
+ block_copy_set_callbacks(job->bcs, backup_progress_bytes_callback,
+ backup_progress_reset_callback, job);
+
/* Required permissions are already taken by block-copy-state target */
block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL,
&error_abort);
diff --git a/block/block-copy.c b/block/block-copy.c
index 61e5ea5f46..fcb112da14 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -66,12 +66,10 @@ void block_copy_state_free(BlockCopyState *s)
g_free(s);
}
-BlockCopyState *block_copy_state_new(
- BlockDriverState *source, BlockDriverState *target,
- int64_t cluster_size, BdrvRequestFlags write_flags,
- ProgressBytesCallbackFunc progress_bytes_callback,
- ProgressResetCallbackFunc progress_reset_callback,
- void *progress_opaque, Error **errp)
+BlockCopyState *block_copy_state_new(BlockDriverState *source,
+ BlockDriverState *target,
+ int64_t cluster_size,
+ BdrvRequestFlags write_flags, Error **errp)
{
BlockCopyState *s;
int ret;
@@ -95,9 +93,6 @@ BlockCopyState *block_copy_state_new(
.cluster_size = cluster_size,
.len = bdrv_dirty_bitmap_size(copy_bitmap),
.write_flags = write_flags,
- .progress_bytes_callback = progress_bytes_callback,
- .progress_reset_callback = progress_reset_callback,
- .progress_opaque = progress_opaque,
};
s->copy_range_size = QEMU_ALIGN_DOWN(MIN(blk_get_max_transfer(s->source),
@@ -144,6 +139,17 @@ fail:
return NULL;
}
+void block_copy_set_callbacks(
+ BlockCopyState *s,
+ ProgressBytesCallbackFunc progress_bytes_callback,
+ ProgressResetCallbackFunc progress_reset_callback,
+ void *progress_opaque)
+{
+ s->progress_bytes_callback = progress_bytes_callback;
+ s->progress_reset_callback = progress_reset_callback;
+ s->progress_opaque = progress_opaque;
+}
+
/*
* Copy range to target with a bounce buffer and return the bytes copied. If
* error occurred, return a negative error number
--
2.21.0
next prev parent reply other threads:[~2019-10-01 13:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-01 13:14 [PATCH v15 0/5] backup-top filter driver for backup Vladimir Sementsov-Ogievskiy
2019-10-01 13:14 ` [PATCH v15 1/5] block/backup: move in-flight requests handling from backup to block-copy Vladimir Sementsov-Ogievskiy
2019-10-02 18:09 ` Max Reitz
2019-10-01 13:14 ` [PATCH v15 2/5] block/backup: move write_flags calculation inside backup_job_create Vladimir Sementsov-Ogievskiy
2019-10-02 18:35 ` Max Reitz
2019-10-01 13:14 ` Vladimir Sementsov-Ogievskiy [this message]
2019-10-02 18:43 ` [PATCH v15 3/5] block/block-copy: split block_copy_set_callbacks function Max Reitz
2019-10-01 13:14 ` [PATCH v15 4/5] block: introduce backup-top filter driver Vladimir Sementsov-Ogievskiy
2019-10-04 13:37 ` Max Reitz
2019-10-01 13:14 ` [PATCH v15 5/5] block/backup: use backup-top instead of write notifiers Vladimir Sementsov-Ogievskiy
2019-10-04 14:19 ` Max Reitz
2019-10-04 14:21 ` [PATCH v15 0/5] backup-top filter driver for backup Max Reitz
2019-10-04 14:36 ` Vladimir Sementsov-Ogievskiy
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=20191001131409.14202-4-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=den@openvz.org \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=wencongyang2@huawei.com \
--cc=xiechanglong.d@gmail.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 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).