blockjob: introduce block_job_early_fail

Outside blockjob.c, block_job_unref is only used when a block job fails
to start, and block_job_ref is not used at all.  The reference counting
thus is pretty well hidden.  Introduce a separate function to be used
by block jobs; because block_job_ref and block_job_unref now become
static, move them earlier in blockjob.c.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Message-id: 20170508141310.8674-4-pbonzini@redhat.com
Signed-off-by: Jeff Cody <jcody@redhat.com>
This commit is contained in:
Paolo Bonzini 2017-05-08 16:13:02 +02:00 committed by Jeff Cody
parent 9f086abbe4
commit 05b0d8e3b8
6 changed files with 39 additions and 39 deletions

View file

@ -156,21 +156,12 @@ void block_job_sleep_ns(BlockJob *job, QEMUClockType type, int64_t ns);
void block_job_yield(BlockJob *job);
/**
* block_job_ref:
* block_job_early_fail:
* @bs: The block device.
*
* Grab a reference to the block job. Should be paired with block_job_unref.
* The block job could not be started, free it.
*/
void block_job_ref(BlockJob *job);
/**
* block_job_unref:
* @bs: The block device.
*
* Release reference to the block job and release resources if it is the last
* reference.
*/
void block_job_unref(BlockJob *job);
void block_job_early_fail(BlockJob *job);
/**
* block_job_completed: