mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
job: Move coroutine and related code to Job
This commit moves some core functions for dealing with the job coroutine from BlockJob to Job. This includes primarily entering the coroutine (both for the first and reentering) and yielding explicitly and at pause points. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
This commit is contained in:
parent
1908a5590c
commit
da01ff7f38
14 changed files with 305 additions and 299 deletions
|
@ -50,43 +50,18 @@ typedef struct BlockJob {
|
|||
/** The block device on which the job is operating. */
|
||||
BlockBackend *blk;
|
||||
|
||||
/**
|
||||
* The coroutine that executes the job. If not NULL, it is
|
||||
* reentered when busy is false and the job is cancelled.
|
||||
*/
|
||||
Coroutine *co;
|
||||
|
||||
/**
|
||||
* Set to true if the job should abort immediately without waiting
|
||||
* for data to be in sync.
|
||||
*/
|
||||
bool force;
|
||||
|
||||
/**
|
||||
* Counter for pause request. If non-zero, the block job is either paused,
|
||||
* or if busy == true will pause itself as soon as possible.
|
||||
*/
|
||||
int pause_count;
|
||||
|
||||
/**
|
||||
* Set to true if the job is paused by user. Can be unpaused with the
|
||||
* block-job-resume QMP command.
|
||||
*/
|
||||
bool user_paused;
|
||||
|
||||
/**
|
||||
* Set to false by the job while the coroutine has yielded and may be
|
||||
* re-entered by block_job_enter(). There may still be I/O or event loop
|
||||
* activity pending. Accessed under block_job_mutex (in blockjob.c).
|
||||
*/
|
||||
bool busy;
|
||||
|
||||
/**
|
||||
* Set to true by the job while it is in a quiescent state, where
|
||||
* no I/O or event loop activity is pending.
|
||||
*/
|
||||
bool paused;
|
||||
|
||||
/**
|
||||
* Set to true when the job is ready to be completed.
|
||||
*/
|
||||
|
@ -125,12 +100,6 @@ typedef struct BlockJob {
|
|||
/** ret code passed to block_job_completed. */
|
||||
int ret;
|
||||
|
||||
/**
|
||||
* Timer that is used by @block_job_sleep_ns. Accessed under
|
||||
* block_job_mutex (in blockjob.c).
|
||||
*/
|
||||
QEMUTimer sleep_timer;
|
||||
|
||||
/** True if this job should automatically finalize itself */
|
||||
bool auto_finalize;
|
||||
|
||||
|
@ -207,15 +176,6 @@ void block_job_remove_all_bdrv(BlockJob *job);
|
|||
*/
|
||||
void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp);
|
||||
|
||||
/**
|
||||
* block_job_start:
|
||||
* @job: A job that has not yet been started.
|
||||
*
|
||||
* Begins execution of a block job.
|
||||
* Takes ownership of one reference to the job object.
|
||||
*/
|
||||
void block_job_start(BlockJob *job);
|
||||
|
||||
/**
|
||||
* block_job_cancel:
|
||||
* @job: The job to be canceled.
|
||||
|
|
|
@ -38,9 +38,6 @@ struct BlockJobDriver {
|
|||
/** Generic JobDriver callbacks and settings */
|
||||
JobDriver job_driver;
|
||||
|
||||
/** Mandatory: Entrypoint for the Coroutine. */
|
||||
CoroutineEntry *start;
|
||||
|
||||
/**
|
||||
* Optional callback for job types whose completion must be triggered
|
||||
* manually.
|
||||
|
@ -85,20 +82,6 @@ struct BlockJobDriver {
|
|||
*/
|
||||
void (*clean)(BlockJob *job);
|
||||
|
||||
/**
|
||||
* If the callback is not NULL, it will be invoked when the job transitions
|
||||
* into the paused state. Paused jobs must not perform any asynchronous
|
||||
* I/O or event loop activity. This callback is used to quiesce jobs.
|
||||
*/
|
||||
void coroutine_fn (*pause)(BlockJob *job);
|
||||
|
||||
/**
|
||||
* If the callback is not NULL, it will be invoked when the job transitions
|
||||
* out of the paused state. Any asynchronous I/O or event loop activity
|
||||
* should be restarted from this callback.
|
||||
*/
|
||||
void coroutine_fn (*resume)(BlockJob *job);
|
||||
|
||||
/*
|
||||
* If the callback is not NULL, it will be invoked before the job is
|
||||
* resumed in a new AioContext. This is the place to move any resources
|
||||
|
@ -195,15 +178,6 @@ void block_job_early_fail(BlockJob *job);
|
|||
*/
|
||||
void block_job_completed(BlockJob *job, int ret);
|
||||
|
||||
/**
|
||||
* block_job_pause_point:
|
||||
* @job: The job that is ready to pause.
|
||||
*
|
||||
* Pause now if block_job_pause() has been called. Block jobs that perform
|
||||
* lots of I/O must call this between requests so that the job can be paused.
|
||||
*/
|
||||
void coroutine_fn block_job_pause_point(BlockJob *job);
|
||||
|
||||
/**
|
||||
* block_job_enter:
|
||||
* @job: The job to enter.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue