From nobody Sun May 5 06:50:01 2024 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520604749094329.2650238643124; Fri, 9 Mar 2018 06:12:29 -0800 (PST) Received: from localhost ([::1]:45522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euIl2-0004rq-4Z for importer@patchew.org; Fri, 09 Mar 2018 09:12:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euIkB-0004SO-FC for qemu-devel@nongnu.org; Fri, 09 Mar 2018 09:11:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1euIk6-0001MD-GN for qemu-devel@nongnu.org; Fri, 09 Mar 2018 09:11:35 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48305) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1euIk6-0001Ll-3b; Fri, 09 Mar 2018 09:11:30 -0500 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1euIk3-0005hD-Rw; Fri, 09 Mar 2018 15:11:27 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1euIjk-0003dv-Ub; Fri, 09 Mar 2018 16:11:08 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Message-Id:Date:Subject:Cc:To:From; bh=EyerCwfItlEsE7qqMmmoD2LlKnFT9ugGXICGAT2xLo8=; b=Gj5d8551WqCQHQWF+vs49nF5Q/ITSQXf3GgwlKZ58t4nSVST1XL8dXdgfgVEOZOSvXizMpHXGNwQeyfi3AxrFBWENdLCkJWI/JVIrnPlQeBIgNbsN8MNwp/bHdO/92F5Np+xtkm8sZ9bWNnGwQU8kj0Aa11rHf8kmAnoEOc4L9XSZ8UthGHNjUrtOUp/gv/ST0HjgfDb5lzBmapYF58ijxUkOTjhZ9R4/rliEwAB3FUGD5lekOomsupxdsGCPl6nEiwvsiMX5bY7xap7xOG59EFVJst8X2qz0bN2VqGK/GK0r0t9Py1EpqcQ+jsHDccnZJl5cMCTUhflHXeiUXDE6A==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 9 Mar 2018 16:11:07 +0200 Message-Id: <20180309141107.13964-1-berto@igalia.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH] 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: Kevin Wolf , Alberto Garcia , Markus Armbruster , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- hmp-commands.hx | 3 ++- hmp.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 964eb515cf..097ed0909b 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1645,7 +1645,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 { diff --git a/hmp.c b/hmp.c index 016cb5c4f1..8520d86869 100644 --- a/hmp.c +++ b/hmp.c @@ -1774,9 +1774,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"), @@ -1785,6 +1784,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); } --=20 2.11.0