From patchwork Sat Jul 5 17:47:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 367340 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 64B9214011D for ; Sun, 6 Jul 2014 03:54:07 +1000 (EST) Received: from localhost ([::1]:43559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3UA1-00055G-KI for incoming@patchwork.ozlabs.org; Sat, 05 Jul 2014 13:54:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3U8G-0002hX-Q4 for qemu-devel@nongnu.org; Sat, 05 Jul 2014 13:52:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X3U8A-0001hx-Kb for qemu-devel@nongnu.org; Sat, 05 Jul 2014 13:52:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32199) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3U3x-0000gW-LL for qemu-devel@nongnu.org; Sat, 05 Jul 2014 13:47:50 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s65HlnJV018938 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 5 Jul 2014 13:47:49 -0400 Received: from localhost (ovpn-116-17.ams2.redhat.com [10.36.116.17]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s65HlkJp004610 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Sat, 5 Jul 2014 13:47:48 -0400 From: Max Reitz To: qemu-devel@nongnu.org Date: Sat, 5 Jul 2014 19:47:19 +0200 Message-Id: <1404582448-23840-6-git-send-email-mreitz@redhat.com> In-Reply-To: <1404582448-23840-1-git-send-email-mreitz@redhat.com> References: <1404582448-23840-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz Subject: [Qemu-devel] [PATCH v9 05/14] blockjob: Add "ready" field X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- blockjob.c | 3 +++ include/block/blockjob.h | 5 +++++ qapi/block-core.json | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/blockjob.c b/blockjob.c index 2c98689..ff1d78e 100644 --- a/blockjob.c +++ b/blockjob.c @@ -260,6 +260,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; } @@ -295,6 +296,8 @@ void block_job_event_completed(BlockJob *job, const char *msg) void block_job_event_ready(BlockJob *job) { + job->ready = true; + qapi_event_send_block_job_ready(job->driver->job_type, bdrv_get_device_name(job->bs), job->len, diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 88f4be2..97658ca 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 e378653..72ebfef 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: