From patchwork Thu Jun 9 08:20:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 9166465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 881796048F for ; Thu, 9 Jun 2016 08:33:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A3F527248 for ; Thu, 9 Jun 2016 08:33:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EE1D28326; Thu, 9 Jun 2016 08:33:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0E0F127248 for ; Thu, 9 Jun 2016 08:33:56 +0000 (UTC) Received: from localhost ([::1]:33085 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAvPX-0007cc-3Q for patchwork-qemu-devel@patchwork.kernel.org; Thu, 09 Jun 2016 04:33:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAvD8-0004c0-NQ for qemu-devel@nongnu.org; Thu, 09 Jun 2016 04:21:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAvD6-0004gn-IT for qemu-devel@nongnu.org; Thu, 09 Jun 2016 04:21:05 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:26594 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAvD6-0004eu-Ac; Thu, 09 Jun 2016 04:21:04 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2DBCgBDJllX/5tjdVtUCh0BgyCBU6ZEAQEBAQEBBQGBDwGRJYIPgXqGEwKBPzkTAQEBAQEBAWUnhEYCBHkQPxI8GxmIMwG+CwEBCCeFX4JHhmZ0hQ4Fh36FbHBCiTaOJolEhVuPYyACMoIHHIFOa4hEBIFAAQEB X-IPAS-Result: A2DBCgBDJllX/5tjdVtUCh0BgyCBU6ZEAQEBAQEBBQGBDwGRJYIPgXqGEwKBPzkTAQEBAQEBAWUnhEYCBHkQPxI8GxmIMwG+CwEBCCeFX4JHhmZ0hQ4Fh36FbHBCiTaOJolEhVuPYyACMoIHHIFOa4hEBIFAAQEB X-IronPort-AV: E=Sophos;i="5.26,443,1459807200"; d="scan'208";a="71068752" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 09 Jun 2016 10:21:03 +0200 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1bAvD5-0007zG-3g; Thu, 09 Jun 2016 10:21:03 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1bAvCf-000523-KU; Thu, 09 Jun 2016 11:20:37 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 9 Jun 2016 11:20:19 +0300 Message-Id: X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Subject: [Qemu-devel] [PATCH 14/15] blockjob: Add 'id' parameter to 'block-job-complete' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Jeff Cody , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch allows the 'block-job-complete' command to identify the job by either its ID or its device name. The latter becomes now optional since the ID alone is enough to identify the job. The HMP 'block_job_complete' command remains unchanged. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz --- blockdev.c | 7 +++++-- hmp.c | 2 +- qapi/block-core.json | 7 ++++++- qmp-commands.hx | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/blockdev.c b/blockdev.c index 97e5fef..63135d1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3819,10 +3819,13 @@ void qmp_block_job_resume(bool has_id, const char *id, aio_context_release(aio_context); } -void qmp_block_job_complete(const char *device, Error **errp) +void qmp_block_job_complete(bool has_id, const char *id, + bool has_device, const char *device, Error **errp) { AioContext *aio_context; - BlockJob *job = find_block_job(NULL, device, &aio_context, errp); + BlockJob *job = find_block_job(has_id ? id : NULL, + has_device ? device : NULL, + &aio_context, errp); if (!job) { return; diff --git a/hmp.c b/hmp.c index dae1735..a2548f2 100644 --- a/hmp.c +++ b/hmp.c @@ -1535,7 +1535,7 @@ void hmp_block_job_complete(Monitor *mon, const QDict *qdict) Error *error = NULL; const char *device = qdict_get_str(qdict, "device"); - qmp_block_job_complete(device, &error); + qmp_block_job_complete(false, NULL, true, device, &error); hmp_handle_error(mon, &error); } diff --git a/qapi/block-core.json b/qapi/block-core.json index 0efa73d..f15e62f 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1593,6 +1593,11 @@ # # A cancelled or paused job cannot be completed. # +# The job must be identified with the @id or @device parameters, but +# only one of them must be set. +# +# @id: #optional the job identifier. (Since 2.7) +# # @device: the device name # # Returns: Nothing on success @@ -1600,7 +1605,7 @@ # # Since: 1.3 ## -{ 'command': 'block-job-complete', 'data': { 'device': 'str' } } +{ 'command': 'block-job-complete', 'data': { '*id': 'str', '*device': 'str' } } ## # @BlockdevDiscardOptions diff --git a/qmp-commands.hx b/qmp-commands.hx index 716d493..d0242dc 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1305,7 +1305,7 @@ EQMP }, { .name = "block-job-complete", - .args_type = "device:B", + .args_type = "id:s?,device:B?", .mhandler.cmd_new = qmp_marshal_block_job_complete, }, {