From patchwork Tue Sep 20 11:38:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 672228 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3sdh3g1qyfz9sC7 for ; Tue, 20 Sep 2016 21:53:35 +1000 (AEST) Received: from localhost ([::1]:34181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmJcC-0006rD-Pr for incoming@patchwork.ozlabs.org; Tue, 20 Sep 2016 07:53:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmJOM-0003We-7T for qemu-devel@nongnu.org; Tue, 20 Sep 2016 07:39:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmJOK-0001Xj-3L for qemu-devel@nongnu.org; Tue, 20 Sep 2016 07:39:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39782) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmJOH-0001UU-D1; Tue, 20 Sep 2016 07:39:09 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DFA8337E71; Tue, 20 Sep 2016 11:39:08 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-84.ams2.redhat.com [10.36.116.84]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8KBcpPn006281; Tue, 20 Sep 2016 07:39:07 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 20 Sep 2016 13:38:48 +0200 Message-Id: <1474371529-24466-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1474371529-24466-1-git-send-email-kwolf@redhat.com> References: <1474371529-24466-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 20 Sep 2016 11:39:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 09/10] block: Accept device model name for block_set_io_throttle 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: kwolf@redhat.com, jsnow@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" In order to remove the necessity to use BlockBackend names in the external API, we want to allow qdev device names in all device related commands. This converts block_set_io_throttle to accept a qdev device name. Signed-off-by: Kevin Wolf --- blockdev.c | 12 +++++++----- docs/qmp-commands.txt | 6 ++++-- qapi/block-core.json | 8 +++++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/blockdev.c b/blockdev.c index 8c8fcd6..405145a 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2647,10 +2647,10 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp) BlockBackend *blk; AioContext *aio_context; - blk = blk_by_name(arg->device); + blk = qmp_get_blk(arg->has_device ? arg->device : NULL, + arg->has_id ? arg->id : NULL, + errp); if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, - "Device '%s' not found", arg->device); return; } @@ -2659,7 +2659,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp) bs = blk_bs(blk); if (!bs) { - error_setg(errp, "Device '%s' has no medium", arg->device); + error_setg(errp, "Device has no medium"); goto out; } @@ -2723,7 +2723,9 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp) * just update the throttling group. */ if (!blk_get_public(blk)->throttle_state) { blk_io_limits_enable(blk, - arg->has_group ? arg->group : arg->device); + arg->has_group ? arg->group : + arg->has_device ? arg->device : + arg->id); } else if (arg->has_group) { blk_io_limits_update_group(blk, arg->group); } diff --git a/docs/qmp-commands.txt b/docs/qmp-commands.txt index 8b2a0ea..41f5698 100644 --- a/docs/qmp-commands.txt +++ b/docs/qmp-commands.txt @@ -1459,7 +1459,9 @@ Change I/O throttle limits for a block drive. Arguments: -- "device": device name (json-string) +- "device": block device name (deprecated, use @id instead) + (json-string, optional) +- "id": the name or QOM path of the guest device (json-string, optional) - "bps": total throughput limit in bytes per second (json-int) - "bps_rd": read throughput limit in bytes per second (json-int) - "bps_wr": write throughput limit in bytes per second (json-int) @@ -1483,7 +1485,7 @@ Arguments: Example: --> { "execute": "block_set_io_throttle", "arguments": { "device": "virtio0", +-> { "execute": "block_set_io_throttle", "arguments": { "id": "ide0-1-0", "bps": 1000000, "bps_rd": 0, "bps_wr": 0, diff --git a/qapi/block-core.json b/qapi/block-core.json index 1d7d4cc..5f04dab 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1377,7 +1377,9 @@ # # A set of parameters describing block throttling. # -# @device: The name of the device +# @device: #optional Block device name (deprecated, use @id instead) +# +# @id: #optional The name or QOM path of the guest device (since: 2.8) # # @bps: total throughput limit in bytes per second # @@ -1446,8 +1448,8 @@ # Since: 1.1 ## { 'struct': 'BlockIOThrottle', - 'data': { 'device': 'str', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int', - 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', + 'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int', + 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', '*bps_max': 'int', '*bps_rd_max': 'int', '*bps_wr_max': 'int', '*iops_max': 'int', '*iops_rd_max': 'int', '*iops_wr_max': 'int',