On 2018-05-09 18:26, Kevin Wolf wrote: > This moves the logic that implements job transactions from BlockJob to > Job. > > Signed-off-by: Kevin Wolf > --- > include/block/blockjob.h | 54 ---------- > include/block/blockjob_int.h | 10 -- > include/qemu/job.h | 71 +++++++++++-- > blockdev.c | 6 +- > blockjob.c | 238 +------------------------------------------ > job.c | 235 ++++++++++++++++++++++++++++++++++++++++-- > tests/test-blockjob-txn.c | 12 +-- > tests/test-blockjob.c | 2 +- > 8 files changed, 304 insertions(+), 324 deletions(-) [...] > diff --git a/include/qemu/job.h b/include/qemu/job.h > index 614a2dea92..84a9eb7980 100644 > --- a/include/qemu/job.h > +++ b/include/qemu/job.h [...] > @@ -227,20 +242,52 @@ typedef enum JobCreateFlags { [...] > +/** > + * @txn: The transaction (may be NULL) > + * @job: Job to add to the transaction > + * > + * Add @job to the transaction. The @job must not already be in a transaction. > + * The caller must call either block_job_txn_unref() or block_job_completed() *job_txn_unref() (and maybe even job_completed() in preparation for the next patches) > + * to release the reference that is automatically grabbed here. > + * > + * If @txn is NULL, the function does nothing. > + */ > +void job_txn_add_job(JobTxn *txn, Job *job); [...] > diff --git a/job.c b/job.c > index 49dce57c9e..2d782859ac 100644 > --- a/job.c > +++ b/job.c [...] > @@ -80,6 +93,71 @@ static void __attribute__((__constructor__)) job_init(void) [...] > +static int job_txn_apply(JobTxn *txn, int fn(Job *), bool lock) (“6.7.6.3. (8) A declaration of a parameter as ‘function returning type’ shall be adjusted to ‘pointer to function returning type’, as in 6.3.2.1.” Interesting. Didn't know that worked.) [...] > @@ -542,12 +632,141 @@ int job_finalize_single(Job *job) [...] > +static int job_prepare(Job *job) > +{ > + if (job->ret == 0 && job->driver->prepare) { > + job->ret = job->driver->prepare(job); > + } > + return job->ret; > +} I'd have put this above job_commit() and the like, but it's not like it matters functionally... Well, you know me. With the comment fixed: Reviewed-by: Max Reitz