From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDXys-0007yI-VL for qemu-devel@nongnu.org; Thu, 16 Jun 2016 10:09:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDXyr-0000ag-TX for qemu-devel@nongnu.org; Thu, 16 Jun 2016 10:09:14 -0400 From: Kevin Wolf Date: Thu, 16 Jun 2016 16:08:19 +0200 Message-Id: <1466086108-24868-31-git-send-email-kwolf@redhat.com> In-Reply-To: <1466086108-24868-1-git-send-email-kwolf@redhat.com> References: <1466086108-24868-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 30/39] block: Prevent sleeping jobs from resuming if they have been paused List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Alberto Garcia If we pause a block job and drain its BlockDriverState we want that the job remains inactive until we call block_job_resume() again. However if we pause the job while it is sleeping then it will resume when the sleep timer fires. This patch prevents that from happening by checking if the job has been paused after it comes back from sleeping. Signed-off-by: Alberto Garcia Suggested-by: Kevin Wolf Message-id: 3d9011151512326b890d22bdab3530244ef349d7.1464346103.git.berto@igalia.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- blockjob.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/blockjob.c b/blockjob.c index c095cc5..01b896b 100644 --- a/blockjob.c +++ b/blockjob.c @@ -361,10 +361,12 @@ void block_job_sleep_ns(BlockJob *job, QEMUClockType type, int64_t ns) } job->busy = false; + if (!block_job_is_paused(job)) { + co_aio_sleep_ns(blk_get_aio_context(job->blk), type, ns); + } + /* The job can be paused while sleeping, so check this again */ if (block_job_is_paused(job)) { qemu_coroutine_yield(); - } else { - co_aio_sleep_ns(blk_get_aio_context(job->blk), type, ns); } job->busy = true; } -- 1.8.3.1