diff options
author | John Snow <jsnow@redhat.com> | 2018-03-10 03:27:38 -0500 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-03-19 12:01:24 +0100 |
commit | 43628d9336e832c07dc964433bdfaee44c49e5ac (patch) | |
tree | e7b00705e7298c2e7725556d7e76e2d5f5ce88c7 /blockjob.c | |
parent | 35d6b368f2fcc52de01773b80246bfbe55211903 (diff) | |
download | qemu-43628d9336e832c07dc964433bdfaee44c49e5ac.zip qemu-43628d9336e832c07dc964433bdfaee44c49e5ac.tar.gz qemu-43628d9336e832c07dc964433bdfaee44c49e5ac.tar.bz2 |
blockjobs: add commit, abort, clean helpers
The completed_single function is getting a little mucked up with
checking to see which callbacks exist, so let's factor them out.
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockjob.c')
-rw-r--r-- | blockjob.c | 35 |
1 files changed, 26 insertions, 9 deletions
@@ -415,6 +415,29 @@ static void block_job_update_rc(BlockJob *job) } } +static void block_job_commit(BlockJob *job) +{ + assert(!job->ret); + if (job->driver->commit) { + job->driver->commit(job); + } +} + +static void block_job_abort(BlockJob *job) +{ + assert(job->ret); + if (job->driver->abort) { + job->driver->abort(job); + } +} + +static void block_job_clean(BlockJob *job) +{ + if (job->driver->clean) { + job->driver->clean(job); + } +} + static void block_job_completed_single(BlockJob *job) { assert(job->completed); @@ -423,17 +446,11 @@ static void block_job_completed_single(BlockJob *job) block_job_update_rc(job); if (!job->ret) { - if (job->driver->commit) { - job->driver->commit(job); - } + block_job_commit(job); } else { - if (job->driver->abort) { - job->driver->abort(job); - } - } - if (job->driver->clean) { - job->driver->clean(job); + block_job_abort(job); } + block_job_clean(job); if (job->cb) { job->cb(job->opaque, job->ret); |