job: Add Job.aio_context

When block jobs need an AioContext, they just take it from their main
block node. Generic jobs don't have a main block node, so we need to
assign them an AioContext explicitly.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
This commit is contained in:
Kevin Wolf 2018-04-17 13:49:33 +02:00
parent daa7f2f946
commit 08be6fe26f
3 changed files with 13 additions and 3 deletions

View file

@ -47,6 +47,9 @@ typedef struct Job {
/** Current state; See @JobStatus for details. */
JobStatus status;
/** AioContext to run the job coroutine in */
AioContext *aio_context;
/**
* Set to true if the job should cancel itself. The flag must
* always be tested just before toggling the busy flag from false
@ -79,9 +82,11 @@ struct JobDriver {
*
* @job_id: The id of the newly-created job, or %NULL for internal jobs
* @driver: The class object for the newly-created job.
* @ctx: The AioContext to run the job coroutine in.
* @errp: Error object.
*/
void *job_create(const char *job_id, const JobDriver *driver, Error **errp);
void *job_create(const char *job_id, const JobDriver *driver, AioContext *ctx,
Error **errp);
/**
* Add a reference to Job refcnt, it will be decreased with job_unref, and then