[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 07/42] block/stream: refactor stream to use job callb
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PULL 07/42] block/stream: refactor stream to use job callbacks |
Date: |
Tue, 25 Sep 2018 17:15:06 +0200 |
From: John Snow <address@hidden>
Signed-off-by: John Snow <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Message-id: address@hidden
Reviewed-by: Jeff Cody <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
block/stream.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/block/stream.c b/block/stream.c
index 700eb239e4..81a7ec8ece 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -54,16 +54,16 @@ static int coroutine_fn stream_populate(BlockBackend *blk,
return blk_co_preadv(blk, offset, qiov.size, &qiov, BDRV_REQ_COPY_ON_READ);
}
-static void stream_exit(Job *job)
+static int stream_prepare(Job *job)
{
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
BlockJob *bjob = &s->common;
BlockDriverState *bs = blk_bs(bjob->blk);
BlockDriverState *base = s->base;
Error *local_err = NULL;
- int ret = job->ret;
+ int ret = 0;
- if (!job_is_cancelled(job) && bs->backing && ret == 0) {
+ if (bs->backing) {
const char *base_id = NULL, *base_fmt = NULL;
if (base) {
base_id = s->backing_file_str;
@@ -75,12 +75,19 @@ static void stream_exit(Job *job)
bdrv_set_backing_hd(bs, base, &local_err);
if (local_err) {
error_report_err(local_err);
- ret = -EPERM;
- goto out;
+ return -EPERM;
}
}
-out:
+ return ret;
+}
+
+static void stream_clean(Job *job)
+{
+ StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
+ BlockJob *bjob = &s->common;
+ BlockDriverState *bs = blk_bs(bjob->blk);
+
/* Reopen the image back in read-only mode if necessary */
if (s->bs_flags != bdrv_get_flags(bs)) {
/* Give up write permissions before making it read-only */
@@ -89,7 +96,6 @@ out:
}
g_free(s->backing_file_str);
- job->ret = ret;
}
static int coroutine_fn stream_run(Job *job, Error **errp)
@@ -206,7 +212,8 @@ static const BlockJobDriver stream_job_driver = {
.job_type = JOB_TYPE_STREAM,
.free = block_job_free,
.run = stream_run,
- .exit = stream_exit,
+ .prepare = stream_prepare,
+ .clean = stream_clean,
.user_resume = block_job_user_resume,
.drain = block_job_drain,
},
--
2.17.1
- [Qemu-devel] [PULL 00/42] Block patches, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 03/42] block/stream: add block job creation flags, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 05/42] block/mirror: don't install backing chain on abort, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 01/42] block/commit: add block job creation flags, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 02/42] block/mirror: add block job creation flags, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 06/42] block/mirror: conservative mirror_exit refactor, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 07/42] block/stream: refactor stream to use job callbacks,
Max Reitz <=
- [Qemu-devel] [PULL 08/42] tests/blockjob: replace Blockjob with Job, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 09/42] tests/test-blockjob: remove exit callback, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 10/42] tests/test-blockjob-txn: move .exit to .clean, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 12/42] qapi/block-commit: expose new job properties, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 11/42] jobs: remove .exit callback, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 16/42] blockdev: document transactional shortcomings, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 17/42] commit: Add top-node/base-node options, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 15/42] block/backup: qapi documentation fixup, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 14/42] qapi/block-stream: expose new job properties, Max Reitz, 2018/09/25
- [Qemu-devel] [PULL 13/42] qapi/block-mirror: expose new job properties, Max Reitz, 2018/09/25