/* An inactive or completed job doesn't have any pending requests. Jobs
* with !job->busy are either already paused or have a pause point after
* being reentered, so no job driver code will run before they pause. */
- if (!job->busy || job_is_completed(job) || job->deferred_to_main_loop) {
+ if (!job->busy || job_is_completed(job)) {
return false;
}
return 0;
}
+static void block_job_on_idle(Notifier *n, void *opaque)
+{
+ aio_wait_kick();
+}
+
bool block_job_is_internal(BlockJob *job)
{
return (job->job.id == NULL);
job->finalize_completed_notifier.notify = block_job_event_completed;
job->pending_notifier.notify = block_job_event_pending;
job->ready_notifier.notify = block_job_event_ready;
+ job->idle_notifier.notify = block_job_on_idle;
notifier_list_add(&job->job.on_finalize_cancelled,
&job->finalize_cancelled_notifier);
&job->finalize_completed_notifier);
notifier_list_add(&job->job.on_pending, &job->pending_notifier);
notifier_list_add(&job->job.on_ready, &job->ready_notifier);
+ notifier_list_add(&job->job.on_idle, &job->idle_notifier);
error_setg(&job->blocker, "block device is in use by block job: %s",
job_type_str(&job->job));
action);
}
if (action == BLOCK_ERROR_ACTION_STOP) {
- job_pause(&job->job);
- /* make the pause user visible, which will be resumed from QMP. */
- job->job.user_paused = true;
+ if (!job->job.user_paused) {
+ job_pause(&job->job);
+ /* make the pause user visible, which will be resumed from QMP. */
+ job->job.user_paused = true;
+ }
block_job_iostatus_set_err(job, error);
}
return action;