mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 06:43:53 -06:00
blockjob: Allow nested pause
This patch changes block_job_pause to increase the pause counter and block_job_resume to decrease it. The counter will allow calling block_job_pause/block_job_resume unconditionally on a job when we need to suspend the IO temporarily. From now on, each block_job_resume must be paired with a block_job_pause to keep the counter balanced. The user pause from QMP or HMP will only trigger block_job_pause once until it's resumed, this is achieved by adding a user_paused flag in BlockJob. One occurrence of block_job_resume in mirror_complete is replaced with block_job_enter which does what is necessary. In block_job_cancel, the cancel flag is good enough to instruct coroutines to quit loop, so use block_job_enter to replace the unpaired block_job_resume. Upon block job IO error, user is notified about the entering to the pause state, so this pause belongs to user pause, set the flag accordingly and expect a matching QMP resume. [Extended doc comments as suggested by Paolo Bonzini <pbonzini@redhat.com>. --Stefan] Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Message-id: 1428069921-2957-2-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
199667a8c8
commit
751ebd76e6
4 changed files with 41 additions and 14 deletions
|
@ -79,10 +79,16 @@ struct BlockJob {
|
|||
bool cancelled;
|
||||
|
||||
/**
|
||||
* Set to true if the job is either paused, or will pause itself
|
||||
* as soon as possible (if busy == true).
|
||||
* Counter for pause request. If non-zero, the block job is either paused,
|
||||
* or if busy == true will pause itself as soon as possible.
|
||||
*/
|
||||
bool paused;
|
||||
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 it is in a quiescent state, where
|
||||
|
@ -225,10 +231,18 @@ void block_job_pause(BlockJob *job);
|
|||
* block_job_resume:
|
||||
* @job: The job to be resumed.
|
||||
*
|
||||
* Resume the specified job.
|
||||
* Resume the specified job. Must be paired with a preceding block_job_pause.
|
||||
*/
|
||||
void block_job_resume(BlockJob *job);
|
||||
|
||||
/**
|
||||
* block_job_enter:
|
||||
* @job: The job to enter.
|
||||
*
|
||||
* Continue the specified job by entering the coroutine.
|
||||
*/
|
||||
void block_job_enter(BlockJob *job);
|
||||
|
||||
/**
|
||||
* block_job_event_cancelled:
|
||||
* @job: The job whose information is requested.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue