From nobody Thu Dec 18 13:21:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526400556002292.23811033095205; Tue, 15 May 2018 09:09:16 -0700 (PDT) Received: from localhost ([::1]:44723 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIcVn-00051s-3z for importer@patchew.org; Tue, 15 May 2018 12:09:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIc4P-0006dl-Ed for qemu-devel@nongnu.org; Tue, 15 May 2018 11:41:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIc4J-0001LO-BI for qemu-devel@nongnu.org; Tue, 15 May 2018 11:40:57 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40540 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fIc4G-0001ID-Gt; Tue, 15 May 2018 11:40:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C72681FE142; Tue, 15 May 2018 15:40:48 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-164.ams2.redhat.com [10.36.117.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F304200BC1E; Tue, 15 May 2018 15:40:47 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 15 May 2018 17:40:05 +0200 Message-Id: <20180515154033.19899-10-kwolf@redhat.com> In-Reply-To: <20180515154033.19899-1-kwolf@redhat.com> References: <20180515154033.19899-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 15 May 2018 15:40:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 15 May 2018 15:40:48 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 09/37] hmp: Allow using a qdev id in 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, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia The QMP version of this command can take a qdev ID since 7a9877a02635, but the HMP version is still using the deprecated block device name so there's no way to refer to a block device added like this: -blockdev node-name=3Ddisk0,driver=3Dqcow2,file.driver=3Dfile,file.filena= me=3Dhd.qcow2 -device virtio-blk-pci,id=3Dvirtio-blk-pci0,drive=3Ddisk0 This patch works around this problem by using the specified name as a qdev ID if the block device name is not found. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- hmp.c | 14 ++++++++++++-- hmp-commands.hx | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/hmp.c b/hmp.c index 898e25f3e1..bdb340605c 100644 --- a/hmp.c +++ b/hmp.c @@ -1789,9 +1789,8 @@ void hmp_change(Monitor *mon, const QDict *qdict) void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; + char *device =3D (char *) qdict_get_str(qdict, "device"); BlockIOThrottle throttle =3D { - .has_device =3D true, - .device =3D (char *) qdict_get_str(qdict, "device"), .bps =3D qdict_get_int(qdict, "bps"), .bps_rd =3D qdict_get_int(qdict, "bps_rd"), .bps_wr =3D qdict_get_int(qdict, "bps_wr"), @@ -1800,6 +1799,17 @@ void hmp_block_set_io_throttle(Monitor *mon, const Q= Dict *qdict) .iops_wr =3D qdict_get_int(qdict, "iops_wr"), }; =20 + /* qmp_block_set_io_throttle has separate parameters for the + * (deprecated) block device name and the qdev ID but the HMP + * version has only one, so we must decide which one to pass. */ + if (blk_by_name(device)) { + throttle.has_device =3D true; + throttle.device =3D device; + } else { + throttle.has_id =3D true; + throttle.id =3D device; + } + qmp_block_set_io_throttle(&throttle, &err); hmp_handle_error(mon, &err); } diff --git a/hmp-commands.hx b/hmp-commands.hx index 35d862a5d2..227f7eee88 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1647,7 +1647,8 @@ ETEXI STEXI @item block_set_io_throttle @var{device} @var{bps} @var{bps_rd} @var{bps_w= r} @var{iops} @var{iops_rd} @var{iops_wr} @findex block_set_io_throttle -Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @va= r{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} +Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @va= r{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr}. +@var{device} can be a block device name, a qdev ID or a QOM path. ETEXI =20 { --=20 2.13.6