From patchwork Wed Jun 22 12:25:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 9192725 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 D8B4060756 for ; Wed, 22 Jun 2016 12:58:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C867228402 for ; Wed, 22 Jun 2016 12:58:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9C0D28404; Wed, 22 Jun 2016 12:58:37 +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 3521020072 for ; Wed, 22 Jun 2016 12:58:37 +0000 (UTC) Received: from localhost ([::1]:58066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFhjo-0002Jr-6k for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jun 2016 08:58:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFhEL-0003ei-Qs for qemu-devel@nongnu.org; Wed, 22 Jun 2016 08:26:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFhEJ-00025z-N5 for qemu-devel@nongnu.org; Wed, 22 Jun 2016 08:26:04 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:21734 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFhEJ-000253-FQ; Wed, 22 Jun 2016 08:26:03 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CkAgCmgmpX/5tjdVtUCh0BgyCBU40qmC4BAQEBAQEFAYEPAZExgg+BeoYXAoEsOBQBAQEBAQEBZSeETQIEeRA/EjwbGYg0AcMKAQEIJ4VfgkeGZnSFDwWNeHCKFY4tiUaFXY98HjaCBQMcgU9rinEBAQE X-IPAS-Result: A2CkAgCmgmpX/5tjdVtUCh0BgyCBU40qmC4BAQEBAQEFAYEPAZExgg+BeoYXAoEsOBQBAQEBAQEBZSeETQIEeRA/EjwbGYg0AcMKAQEIJ4VfgkeGZnSFDwWNeHCKFY4tiUaFXY98HjaCBQMcgU9rinEBAQE X-IronPort-AV: E=Sophos;i="5.26,509,1459807200"; d="scan'208";a="76201873" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 22 Jun 2016 14:25:58 +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 1bFhEE-0004kR-D7; Wed, 22 Jun 2016 14:25:58 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1bFhDo-0007Ff-IE; Wed, 22 Jun 2016 15:25:32 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 22 Jun 2016 15:25:07 +0300 Message-Id: <9e5b63f7f86ad83237bdb47f5f4306afa0331b26.1466598035.git.berto@igalia.com> 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 v2 10/15] blockjob: Add 'id' parameter to 'block-job-set-speed' 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-set-speed' 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_set_speed' command remains unchanged. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz --- blockdev.c | 7 +++++-- hmp.c | 2 +- qapi/block-core.json | 9 +++++++-- qmp-commands.hx | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index 4c2f659..bd276ee 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3760,10 +3760,13 @@ static BlockJob *find_block_job(const char *id, const char *device, return job; } -void qmp_block_job_set_speed(const char *device, int64_t speed, Error **errp) +void qmp_block_job_set_speed(bool has_id, const char *id, bool has_device, + const char *device, int64_t speed, 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 6b7786e..f498ccd 100644 --- a/hmp.c +++ b/hmp.c @@ -1498,7 +1498,7 @@ void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict) const char *device = qdict_get_str(qdict, "device"); int64_t value = qdict_get_int(qdict, "speed"); - qmp_block_job_set_speed(device, value, &error); + qmp_block_job_set_speed(false, NULL, true, device, value, &error); hmp_handle_error(mon, &error); } diff --git a/qapi/block-core.json b/qapi/block-core.json index f754c29..64038cc 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1469,7 +1469,12 @@ # # Throttling can be disabled by setting the speed to 0. # -# @device: the device name +# 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: #optional the device name. # # @speed: the maximum speed, in bytes per second, or 0 for unlimited. # Defaults to 0. @@ -1480,7 +1485,7 @@ # Since: 1.1 ## { 'command': 'block-job-set-speed', - 'data': { 'device': 'str', 'speed': 'int' } } + 'data': { '*id': 'str', '*device': 'str', 'speed': 'int' } } ## # @block-job-cancel: diff --git a/qmp-commands.hx b/qmp-commands.hx index 9ee14a8..cc70007 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1311,7 +1311,7 @@ EQMP { .name = "block-job-set-speed", - .args_type = "device:B,speed:o", + .args_type = "id:s?,device:B?,speed:o", .mhandler.cmd_new = qmp_marshal_block_job_set_speed, },