From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WtLiV-0004hh-9I for qemu-devel@nongnu.org; Sat, 07 Jun 2014 14:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WtLiO-0007vK-V4 for qemu-devel@nongnu.org; Sat, 07 Jun 2014 14:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WtLiO-0007vC-LN for qemu-devel@nongnu.org; Sat, 07 Jun 2014 14:51:40 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s57Ipdtt001194 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 7 Jun 2014 14:51:40 -0400 From: Max Reitz Date: Sat, 7 Jun 2014 20:51:11 +0200 Message-Id: <1402167080-20316-6-git-send-email-mreitz@redhat.com> In-Reply-To: <1402167080-20316-1-git-send-email-mreitz@redhat.com> References: <1402167080-20316-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH v8 05/14] blockjob: Add "ready" field List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz When a block job signals readiness, this is currently reported only through QMP. If qemu wants to use block jobs for internal tasks, there needs to be another way to correctly detect when a block job may be completed. For this reason, introduce a bool "ready" which is set when the block job may be completed. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf --- blockjob.c | 7 ++++++- include/block/blockjob.h | 5 +++++ qapi/block-core.json | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/blockjob.c b/blockjob.c index 2423c8a..108cadd 100644 --- a/blockjob.c +++ b/blockjob.c @@ -246,6 +246,7 @@ BlockJobInfo *block_job_query(BlockJob *job) info->offset = job->offset; info->speed = job->speed; info->io_status = job->iostatus; + info->ready = job->ready; return info; } @@ -274,7 +275,11 @@ QObject *qobject_from_block_job(BlockJob *job) void block_job_ready(BlockJob *job) { - QObject *data = qobject_from_block_job(job); + QObject *data; + + job->ready = true; + + data = qobject_from_block_job(job); monitor_protocol_event(QEVENT_BLOCK_JOB_READY, data); qobject_decref(data); } diff --git a/include/block/blockjob.h b/include/block/blockjob.h index df289dc..5db4c14 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -91,6 +91,11 @@ struct BlockJob { */ bool busy; + /** + * Set to true when the job is ready to be completed. + */ + bool ready; + /** Status that is published by the query-block-jobs QMP API */ BlockDeviceIoStatus iostatus; diff --git a/qapi/block-core.json b/qapi/block-core.json index 7215e48..864285c 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -505,12 +505,14 @@ # # @io-status: the status of the job (since 1.3) # +# @ready: true if the job may be completed (since 2.1) +# # Since: 1.1 ## { 'type': 'BlockJobInfo', 'data': {'type': 'str', 'device': 'str', 'len': 'int', 'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int', - 'io-status': 'BlockDeviceIoStatus'} } + 'io-status': 'BlockDeviceIoStatus', 'ready': 'bool'} } ## # @query-block-jobs: -- 2.0.0