From nobody Sun Apr 28 09:58:41 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.zoho.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 1493735560804252.24055237900996; Tue, 2 May 2017 07:32:40 -0700 (PDT) Received: from localhost ([::1]:59305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5Yr1-0005TA-5D for importer@patchew.org; Tue, 02 May 2017 10:32:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5YpB-0004I8-Dl for qemu-devel@nongnu.org; Tue, 02 May 2017 10:30:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5Yp7-00062f-89 for qemu-devel@nongnu.org; Tue, 02 May 2017 10:30:45 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:36057) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d5Yp6-000623-UA for qemu-devel@nongnu.org; Tue, 02 May 2017 10:30:41 -0400 Received: by mail-wm0-x244.google.com with SMTP id u65so5000082wmu.3 for ; Tue, 02 May 2017 07:30:40 -0700 (PDT) Received: from centos-minion-1.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id r60sm23997861wrb.37.2017.05.02.07.30.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 May 2017 07:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8dJskterORisKwB5HOqENtzfRzalD6CAEaudImIpJEg=; b=TLxCKewKkMT4XINcfNfA7joIHxPufyLHUudwFwSlkVrXYrpRhYaPWk0o3w8/WMHJR8 wOMu42T7hfE2GG0ml+nHIfPjq52rLU/BTMCqdmomdhtRPHT29umUEJDIUbDeI5kjBjLh kHaGS5AVGnbc3QIJpGyJxoAQo7qer1rIc26cHYUfh+5K1c87MPRqJzetty59x0rT4uyO 8EbgkWyk6r8RPk3K4jNBS4NRiLhE/qOcNLOlKwzTzskGkUavPpucw2SIjLU6tUVtW963 DuBqKaeUfA40ffM1CPF7ReF/ykZXwhr2bYkD415N+mmLfoRJU8MICw44mFwRx6RwISna RtRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8dJskterORisKwB5HOqENtzfRzalD6CAEaudImIpJEg=; b=dW+EE+J18bNNciZ5qQlsM1L1Uci1GUx3GzvaNFJkyqhZoPKLypL/VZD34k9A71yrDR oN8nZkNmjpgFvjMcQYyQcvq8zO+QxfJHWs9FKk737Vo9nLsSrIxylpWBQSYT6PjMzjUD qs1Cj9H0e8H+HbqahHggwOmN5xVf9Tm6CiQKHZUkQbA/P+9YKLamSXphlWzR69xaRmg6 Dn4uTia7BJkNg/GAqQVesAv9EefsPwlCqQtI6JwCtUtRDZkWcKfNvm6elHDNlw93FWlr Xy9ZoR1NlAmcU8hq9o78rpbgnybgZRoewOnVc8oir9ySdtt0wo+vg3wsKruB6gky483k BlcA== X-Gm-Message-State: AN3rC/6TU2ZCcf/WkywaC+aM4cXvHBpr8fZV1C0vFeDL1wIYH0byGWlp rT/UDtUgfD6o1Q== X-Received: by 10.28.197.12 with SMTP id v12mr2357002wmf.82.1493735439725; Tue, 02 May 2017 07:30:39 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Tue, 2 May 2017 10:29:43 -0400 Message-Id: <1493735386-39622-2-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1493735386-39622-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1493735386-39622-1-git-send-email-pradeep.jagadeesh@huawei.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PATCH v3 1/4] Throttle: Create IOThrottle structure 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: jani kokkonen , alberto garcia , Pradeep Jagadeesh , qemu-devel@nongnu.org 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" This patchset introduces a new io throttle structure. This will be used in both block and fsdev devices. Signed-off-by: Pradeep Jagadeesh Reviewed-by: Eric Blake Reviewed-by: Greg Kurz --- qapi/block-core.json | 76 ++-------------------------------------------- qapi/iothrottle.json | 86 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 89 insertions(+), 73 deletions(-) create mode 100644 qapi/iothrottle.json diff --git a/qapi/block-core.json b/qapi/block-core.json index 87fb747..93d346b 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -6,6 +6,7 @@ =20 # QAPI common definitions { 'include': 'common.json' } +{ 'include': 'iothrottle.json' } =20 ## # @SnapshotInfo: @@ -1760,84 +1761,13 @@ # # @device: Block device name (deprecated, use @id instead) # -# @id: The name or QOM path of the guest device (since: 2.8) -# -# @bps: total throughput limit in bytes per second -# -# @bps_rd: read throughput limit in bytes per second -# -# @bps_wr: write throughput limit in bytes per second -# -# @iops: total I/O operations per second -# -# @iops_rd: read I/O operations per second -# -# @iops_wr: write I/O operations per second -# -# @bps_max: total throughput limit during bursts, -# in bytes (Since 1.7) -# -# @bps_rd_max: read throughput limit during bursts, -# in bytes (Since 1.7) -# -# @bps_wr_max: write throughput limit during bursts, -# in bytes (Since 1.7) -# -# @iops_max: total I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @iops_rd_max: read I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @iops_wr_max: write I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @bps_max_length: maximum length of the @bps_max burst -# period, in seconds. It must only -# be set if @bps_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @bps_rd_max_length: maximum length of the @bps_rd_max -# burst period, in seconds. It must only -# be set if @bps_rd_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @bps_wr_max_length: maximum length of the @bps_wr_max -# burst period, in seconds. It must only -# be set if @bps_wr_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_max_length: maximum length of the @iops burst -# period, in seconds. It must only -# be set if @iops_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_rd_max_length: maximum length of the @iops_rd_max -# burst period, in seconds. It must only -# be set if @iops_rd_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_wr_max_length: maximum length of the @iops_wr_max -# burst period, in seconds. It must only -# be set if @iops_wr_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_size: an I/O size in bytes (Since 1.7) -# # @group: throttle group name (Since 2.4) # # Since: 1.1 ## { 'struct': 'BlockIOThrottle', - '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', - '*bps_max_length': 'int', '*bps_rd_max_length': 'int', - '*bps_wr_max_length': 'int', '*iops_max_length': 'int', - '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int', - '*iops_size': 'int', '*group': 'str' } } + 'base': 'IOThrottle', + 'data': { '*device': 'str', '*group': 'str' } } =20 ## # @block-stream: diff --git a/qapi/iothrottle.json b/qapi/iothrottle.json new file mode 100644 index 0000000..124ab40 --- /dev/null +++ b/qapi/iothrottle.json @@ -0,0 +1,86 @@ +# -*- Mode: Python -*- + +## +# =3D=3D QAPI IOThrottle definitions +## +# @IOThrottle: +# +# A set of parameters describing iothrottle +# +# @id: The name or QOM path of the guest device (since: 2.8) +# +# @bps: total throughput limit in bytes per second +# +# @bps_rd: read throughput limit in bytes per second +# +# @bps_wr: write throughput limit in bytes per second +# +# @iops: total I/O operations per second +# +# @iops_rd: read I/O operations per second +# +# @iops_wr: write I/O operations per second +# +# @bps_max: total throughput limit during bursts, +# in bytes (Since 1.7) +# +# @bps_rd_max: read throughput limit during bursts, +# in bytes (Since 1.7) +# +# @bps_wr_max: write throughput limit during bursts, +# in bytes (Since 1.7) +# +# @iops_max: total I/O operations per second during bursts, +# in bytes (Since 1.7) +# +# @iops_rd_max: read I/O operations per second during bursts, +# in bytes (Since 1.7) +# +# @iops_wr_max: write I/O operations per second during bursts, +# in bytes (Since 1.7) +# +# @bps_max_length: maximum length of the @bps_max burst +# period, in seconds. It must only +# be set if @bps_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @bps_rd_max_length: maximum length of the @bps_rd_max +# burst period, in seconds. It must only +# be set if @bps_rd_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @bps_wr_max_length: maximum length of the @bps_wr_max +# burst period, in seconds. It must only +# be set if @bps_wr_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @iops_max_length: maximum length of the @iops burst +# period, in seconds. It must only +# be set if @iops_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @iops_rd_max_length: maximum length of the @iops_rd_max +# burst period, in seconds. It must only +# be set if @iops_rd_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @iops_wr_max_length: maximum length of the @iops_wr_max +# burst period, in seconds. It must only +# be set if @iops_wr_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @iops_size: an I/O size in bytes (Since 1.7) +# +# +# Since: 2.10 +## +{ 'struct': 'IOThrottle', + 'data': { '*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', + '*bps_max_length': 'int', '*bps_rd_max_length': 'int', + '*bps_wr_max_length': 'int', '*iops_max_length': 'int', + '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int', + '*iops_size': 'int' } } --=20 1.8.3.1 From nobody Sun Apr 28 09:58:41 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.zoho.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 1493735688624438.8837155297058; Tue, 2 May 2017 07:34:48 -0700 (PDT) Received: from localhost ([::1]:59312 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5Yt3-00073q-06 for importer@patchew.org; Tue, 02 May 2017 10:34:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5YpB-0004I6-DN for qemu-devel@nongnu.org; Tue, 02 May 2017 10:30:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5Yp8-00063Q-Cz for qemu-devel@nongnu.org; Tue, 02 May 2017 10:30:45 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:33496) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d5Yp8-00062p-0K for qemu-devel@nongnu.org; Tue, 02 May 2017 10:30:42 -0400 Received: by mail-wm0-x242.google.com with SMTP id y10so5046304wmh.0 for ; Tue, 02 May 2017 07:30:41 -0700 (PDT) Received: from centos-minion-1.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id r60sm23997861wrb.37.2017.05.02.07.30.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 May 2017 07:30:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tJnlYMcozsjf1EKyvG1kECjhqxkbLkj8H40UKeNRWrc=; b=Cw9NqIej31rONFlt9carmEnnhysfZMn1kr8l+ZtIU4P1EV8KqsI+78YF9brb20UwHI nj76J17ig0vggr+KPDczUFHfrX3k+EytyUV3FbbwBqOMXYjDLl4CU/ZyIDOUJ3KKf1UK zJCqCqqQkqtXKaIlD02ots+/U/AnpOeP14gFQHpfMvxCEZLKNLmce/RPYdJOP0sXPj+p hciFrhcvI9+iA2IpKaeyr5NQRLy6jBZ/zQMtauACfy28Hx0os63tcLwMg7sFsmGtpsw5 BhMR8xd5hHXDDyChIr+YP3bsrIbPdZHzlPSDsJvmFzPEzQhCXo1aCPVu/9cKEqZVg4jj +NOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tJnlYMcozsjf1EKyvG1kECjhqxkbLkj8H40UKeNRWrc=; b=OA5Cy0doh9xRG8mzI6IMW07Pf2hVWc+mqfEvmOQ5bIUigofoDQiIR85vJiWxtsPxEe oTUGmABD+oXRY4Sv0BNR7h3fbfIMfhLk4GsDOK6Jdl3sQAI8JpE6JblbmEVQ5L4QgEho ZOSGNJvoiynahZ8QdBlSjWw8dJ9CL5+j8uQxSwuQB/8fVgUQRQmhO9ZVlIvqRcXSh13n S4oWMnQlGRb3rzmFE4gRGE+f3GFR88tBQfhZHpdk1xKvJWwWOD3k5zCrbGfor+yPG4IN Eqb02F+H7qEgcZbG5cU9pMAaZDDhxxOAZdDGICNz+XlzvnVR+JMtqtzKp4U4Yv03qq0x Fj3A== X-Gm-Message-State: AN3rC/7SJHwjgYs6j9QOKdz4YLA3N6299lWgTuQCCyrIGS95ZQyBigvn auH+f3txdYMKew== X-Received: by 10.28.203.130 with SMTP id b124mr2698149wmg.30.1493735440784; Tue, 02 May 2017 07:30:40 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Tue, 2 May 2017 10:29:44 -0400 Message-Id: <1493735386-39622-3-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1493735386-39622-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1493735386-39622-1-git-send-email-pradeep.jagadeesh@huawei.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH v3 2/4] fsdev: QMP interface for throttling 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: jani kokkonen , alberto garcia , Pradeep Jagadeesh , qemu-devel@nongnu.org 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" This patchset enables qmp interfaces for the fsdev devices. This provides two interfaces one=20 for querying info of all the fsdev devices. The second one to set the IO limits for the required fsdev device. Signed-off-by: Pradeep Jagadeesh --- Makefile | 3 ++ Makefile.objs | 4 +- fsdev/qemu-fsdev-dummy.c | 11 ++++++ fsdev/qemu-fsdev-throttle.c | 96 +++++++++++++++++++++++++++++++++++++++++= ++++ fsdev/qemu-fsdev-throttle.h | 13 ++++++ fsdev/qemu-fsdev.c | 37 +++++++++++++++++ hmp-commands-info.hx | 19 +++++++++ hmp-commands.hx | 19 +++++++++ hmp.c | 75 +++++++++++++++++++++++++++++++++++ hmp.h | 5 +++ qapi-schema.json | 3 ++ qapi/fsdev.json | 84 +++++++++++++++++++++++++++++++++++++++ qapi/iothrottle.json | 1 + 13 files changed, 368 insertions(+), 2 deletions(-) create mode 100644 qapi/fsdev.json diff --git a/Makefile b/Makefile index 31d41a7..7b928d9 100644 --- a/Makefile +++ b/Makefile @@ -414,6 +414,9 @@ qapi-modules =3D $(SRC_PATH)/qapi-schema.json $(SRC_PAT= H)/qapi/common.json \ $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.jso= n \ $(SRC_PATH)/qapi/crypto.json $(SRC_PATH)/qapi/rocker.json \ $(SRC_PATH)/qapi/trace.json +ifdef CONFIG_VIRTFS +qapi-modules +=3D $(SRC_PATH)/qapi/fsdev.json +endif =20 qapi-types.c qapi-types.h :\ $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) diff --git a/Makefile.objs b/Makefile.objs index 6167e7b..3d01f54 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -79,9 +79,9 @@ common-obj-$(CONFIG_FDT) +=3D device_tree.o ###################################################################### # qapi =20 -common-obj-y +=3D qmp-marshal.o +common-obj-y +=3D qmp-marshal.o qmp.o common-obj-y +=3D qmp-introspect.o -common-obj-y +=3D qmp.o hmp.o +common-obj-y +=3D hmp.o endif =20 ####################################################################### diff --git a/fsdev/qemu-fsdev-dummy.c b/fsdev/qemu-fsdev-dummy.c index 6dc0fbc..0e23636 100644 --- a/fsdev/qemu-fsdev-dummy.c +++ b/fsdev/qemu-fsdev-dummy.c @@ -14,8 +14,19 @@ #include "qemu-fsdev.h" #include "qemu/config-file.h" #include "qemu/module.h" +#include "qmp-commands.h" =20 int qemu_fsdev_add(QemuOpts *opts) { return 0; } + +void qmp_fsdev_set_io_throttle(IOThrottle *arg, Error **errp) +{ + return; +} + +IOThrottleList *qmp_query_fsdev_io_throttle(Error **errp) +{ + abort(); +} diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index 7ae4e86..43dbcd8 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -29,6 +29,102 @@ static void fsdev_throttle_write_timer_cb(void *opaque) qemu_co_enter_next(&fst->throttled_reqs[true]); } =20 +void fsdev_set_io_throttle(IOThrottle *arg, FsThrottle *fst, Error **errp) +{ + ThrottleConfig cfg; + + throttle_config_init(&cfg); + cfg.buckets[THROTTLE_BPS_TOTAL].avg =3D arg->bps; + cfg.buckets[THROTTLE_BPS_READ].avg =3D arg->bps_rd; + cfg.buckets[THROTTLE_BPS_WRITE].avg =3D arg->bps_wr; + + cfg.buckets[THROTTLE_OPS_TOTAL].avg =3D arg->iops; + cfg.buckets[THROTTLE_OPS_READ].avg =3D arg->iops_rd; + cfg.buckets[THROTTLE_OPS_WRITE].avg =3D arg->iops_wr; + + if (arg->has_bps_max) { + cfg.buckets[THROTTLE_BPS_TOTAL].max =3D arg->bps_max; + } + if (arg->has_bps_rd_max) { + cfg.buckets[THROTTLE_BPS_READ].max =3D arg->bps_rd_max; + } + if (arg->has_bps_wr_max) { + cfg.buckets[THROTTLE_BPS_WRITE].max =3D arg->bps_wr_max; + } + if (arg->has_iops_max) { + cfg.buckets[THROTTLE_OPS_TOTAL].max =3D arg->iops_max; + } + if (arg->has_iops_rd_max) { + cfg.buckets[THROTTLE_OPS_READ].max =3D arg->iops_rd_max; + } + if (arg->has_iops_wr_max) { + cfg.buckets[THROTTLE_OPS_WRITE].max =3D arg->iops_wr_max; + } + + if (arg->has_bps_max_length) { + cfg.buckets[THROTTLE_BPS_TOTAL].burst_length =3D arg->bps_max_leng= th; + } + if (arg->has_bps_rd_max_length) { + cfg.buckets[THROTTLE_BPS_READ].burst_length =3D arg->bps_rd_max_le= ngth; + } + if (arg->has_bps_wr_max_length) { + cfg.buckets[THROTTLE_BPS_WRITE].burst_length =3D arg->bps_wr_max_l= ength; + } + if (arg->has_iops_max_length) { + cfg.buckets[THROTTLE_OPS_TOTAL].burst_length =3D arg->iops_max_len= gth; + } + if (arg->has_iops_rd_max_length) { + cfg.buckets[THROTTLE_OPS_READ].burst_length =3D arg->iops_rd_max_l= ength; + } + if (arg->has_iops_wr_max_length) { + cfg.buckets[THROTTLE_OPS_WRITE].burst_length =3D arg->iops_wr_max_= length; + } + + if (arg->has_iops_size) { + cfg.op_size =3D arg->iops_size; + } + + if (throttle_is_valid(&cfg, errp)) { + fst->cfg =3D cfg; + fsdev_throttle_init(fst); + } +} + +void fsdev_get_io_throttle(FsThrottle *fst, IOThrottle **fs9pcfg, + char *fsdevice, Error **errp) +{ + + ThrottleConfig cfg =3D fst->cfg; + IOThrottle *fscfg =3D g_malloc0(sizeof(*fscfg)); + + fscfg->has_id =3D true; + fscfg->id =3D g_strdup(fsdevice); + fscfg->bps =3D cfg.buckets[THROTTLE_BPS_TOTAL].avg; + fscfg->bps_rd =3D cfg.buckets[THROTTLE_BPS_READ].avg; + fscfg->bps_wr =3D cfg.buckets[THROTTLE_BPS_WRITE].avg; + + fscfg->iops =3D cfg.buckets[THROTTLE_OPS_TOTAL].avg; + fscfg->iops_rd =3D cfg.buckets[THROTTLE_OPS_READ].avg; + fscfg->iops_wr =3D cfg.buckets[THROTTLE_OPS_WRITE].avg; + + fscfg->bps_max =3D cfg.buckets[THROTTLE_BPS_TOTAL].max; + fscfg->bps_rd_max =3D cfg.buckets[THROTTLE_BPS_READ].max; + fscfg->bps_wr_max =3D cfg.buckets[THROTTLE_BPS_WRITE].max; + fscfg->bps_max =3D cfg.buckets[THROTTLE_OPS_TOTAL].max; + fscfg->iops_rd_max =3D cfg.buckets[THROTTLE_OPS_READ].max; + fscfg->iops_wr_max =3D cfg.buckets[THROTTLE_OPS_WRITE].max; + + fscfg->bps_max_length =3D cfg.buckets[THROTTLE_BPS_TOTAL].burst_length; + fscfg->bps_rd_max_length =3D cfg.buckets[THROTTLE_BPS_READ].burst_leng= th; + fscfg->bps_wr_max_length =3D cfg.buckets[THROTTLE_BPS_WRITE].burst_len= gth; + fscfg->iops_max_length =3D cfg.buckets[THROTTLE_OPS_TOTAL].burst_lengt= h; + fscfg->iops_rd_max_length =3D cfg.buckets[THROTTLE_OPS_READ].burst_len= gth; + fscfg->iops_wr_max_length =3D cfg.buckets[THROTTLE_OPS_WRITE].burst_le= ngth; + fscfg->iops_size =3D cfg.op_size; + + *fs9pcfg =3D fscfg; +} + void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **er= rp) { throttle_config_init(&fst->cfg); diff --git a/fsdev/qemu-fsdev-throttle.h b/fsdev/qemu-fsdev-throttle.h index e418643..0abba43 100644 --- a/fsdev/qemu-fsdev-throttle.h +++ b/fsdev/qemu-fsdev-throttle.h @@ -19,7 +19,14 @@ #include "qemu/main-loop.h" #include "qemu/coroutine.h" #include "qapi/error.h" +#include "qapi/qmp/qerror.h" #include "qemu/throttle.h" +#include "qapi/qmp/types.h" +#include "qapi-visit.h" +#include "qapi/qobject-output-visitor.h" +#include "qapi/util.h" +#include "qmp-commands.h" +#include "qemu/throttle-options.h" =20 typedef struct FsThrottle { ThrottleState ts; @@ -36,4 +43,10 @@ void coroutine_fn fsdev_co_throttle_request(FsThrottle *= , bool , struct iovec *, int); =20 void fsdev_throttle_cleanup(FsThrottle *); + +void fsdev_set_io_throttle(IOThrottle *, FsThrottle *, Error **); + +void fsdev_get_io_throttle(FsThrottle *, IOThrottle **, char *, Error **); + + #endif /* _FSDEV_THROTTLE_H */ diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index 266e442..a99e299 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -16,6 +16,7 @@ #include "qemu-common.h" #include "qemu/config-file.h" #include "qemu/error-report.h" +#include "qmp-commands.h" =20 static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries= =3D QTAILQ_HEAD_INITIALIZER(fsdriver_entries); @@ -98,3 +99,39 @@ FsDriverEntry *get_fsdev_fsentry(char *id) } return NULL; } + +void qmp_fsdev_set_io_throttle(IOThrottle *arg, Error **errp) +{ + + FsDriverEntry *fse; + + fse =3D get_fsdev_fsentry(arg->has_id ? arg->id : NULL); + if (!fse) { + return; + } + + fsdev_set_io_throttle(arg, &fse->fst, errp); +} + +IOThrottleList *qmp_query_fsdev_io_throttle(Error **errp) +{ + IOThrottleList *head =3D NULL, **p_next =3D &head; + struct FsDriverListEntry *fsle; + Error *local_err =3D NULL; + + QTAILQ_FOREACH(fsle, &fsdriver_entries, next) { + IOThrottleList *fscfg =3D g_malloc0(sizeof(*fscfg)); + fsdev_get_io_throttle(&fsle->fse.fst, &fscfg->value, + fsle->fse.fsdev_id, &local_err); + if (local_err) { + error_propagate(errp, local_err); + g_free(fscfg); + qapi_free_IOThrottleList(head); + return NULL; + } + + *p_next =3D fscfg; + p_next =3D &fscfg->next; + } + return head; +} diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index a53f105..8c1c33e 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -84,6 +84,25 @@ STEXI Show block device statistics. ETEXI =20 +#if defined(CONFIG_VIRTFS) + + { + .name =3D "query-fsdev-iothrottle", + .args_type =3D "", + .params =3D "", + .help =3D "show fsdev device throttle information", + .cmd =3D hmp_fsdev_get_io_throttle, + }, + +#endif + +STEXI +@item info fsdev throttle +@findex fsdevthrottleinfo +Show fsdev device throttleinfo. + +ETEXI + { .name =3D "block-jobs", .args_type =3D "", diff --git a/hmp-commands.hx b/hmp-commands.hx index 0aca984..7699475 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1660,6 +1660,25 @@ STEXI 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} ETEXI =20 +#if defined(CONFIG_VIRTFS) + + { + .name =3D "fsdev-set-io-throttle", + .args_type =3D "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l= ,iops_wr:l", + .params =3D "device bps bps_rd bps_wr iops iops_rd iops_wr", + .help =3D "change I/O throttle limits for a block drive", + .cmd =3D hmp_fsdev_set_io_throttle, + }, + +#endif + +STEXI +@item fsdev_set_io_throttle @var{device} @var{bps} @var{bps_rd} @var{bps_w= r} @var{iops} @var{iops_rd} @var{iops_wr} +@findex fsdev_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} + +ETEXI + { .name =3D "set_password", .args_type =3D "protocol:s,password:s,connected:s?", diff --git a/hmp.c b/hmp.c index ab407d6..9c02e55 100644 --- a/hmp.c +++ b/hmp.c @@ -38,6 +38,7 @@ #include "qemu/cutils.h" #include "qemu/error-report.h" #include "hw/intc/intc.h" +#include "fsdev/qemu-fsdev-throttle.h" =20 #ifdef CONFIG_SPICE #include @@ -1570,6 +1571,80 @@ void hmp_block_set_io_throttle(Monitor *mon, const Q= Dict *qdict) hmp_handle_error(mon, &err); } =20 +#ifdef CONFIG_VIRTFS + +void hmp_fsdev_set_io_throttle(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + IOThrottle throttle =3D { + .has_id =3D true, + .id =3D (char *) qdict_get_str(qdict, "id"), + .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"), + .iops =3D qdict_get_int(qdict, "iops"), + .iops_rd =3D qdict_get_int(qdict, "iops_rd"), + .iops_wr =3D qdict_get_int(qdict, "iops_wr"), + }; + + qmp_fsdev_set_io_throttle(&throttle, &err); + hmp_handle_error(mon, &err); +} + +static void print_fsdev_throttle_config(Monitor *mon, IOThrottle *fscfg, + Error *err) +{ + if (fscfg->bps || fscfg->bps_rd || fscfg->bps_wr || + fscfg->iops || fscfg->iops_rd || fscfg->iops_wr) + { + monitor_printf(mon, "%s", fscfg->id); + monitor_printf(mon, " I/O throttling:" + " bps=3D%" PRId64 + " bps_rd=3D%" PRId64 " bps_wr=3D%" PRId64 + " bps_max=3D%" PRId64 + " bps_rd_max=3D%" PRId64 + " bps_wr_max=3D%" PRId64 + " iops=3D%" PRId64 " iops_rd=3D%" PRId64 + " iops_wr=3D%" PRId64 + " iops_max=3D%" PRId64 + " iops_rd_max=3D%" PRId64 + " iops_wr_max=3D%" PRId64 + " iops_size=3D%" PRId64, + fscfg->bps, + fscfg->bps_rd, + fscfg->bps_wr, + fscfg->bps_max, + fscfg->bps_rd_max, + fscfg->bps_wr_max, + fscfg->iops, + fscfg->iops_rd, + fscfg->iops_wr, + fscfg->iops_max, + fscfg->iops_rd_max, + fscfg->iops_wr_max, + fscfg->iops_size); + } + hmp_handle_error(mon, &err); +} + +void hmp_fsdev_get_io_throttle(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + IOThrottleList *fs9p_list, *info; + fs9p_list =3D qmp_query_fsdev_io_throttle(&err); + + for (info =3D fs9p_list; info; info =3D info->next) { + if (info !=3D fs9p_list) { + monitor_printf(mon, "\n"); + } + print_fsdev_throttle_config(mon, info->value, err); + qapi_free_IOThrottle(info->value); + } + qapi_free_IOThrottleList(fs9p_list); +} + +#endif + void hmp_block_stream(Monitor *mon, const QDict *qdict) { Error *error =3D NULL; diff --git a/hmp.h b/hmp.h index 799fd37..acce4c1 100644 --- a/hmp.h +++ b/hmp.h @@ -78,6 +78,11 @@ void hmp_expire_password(Monitor *mon, const QDict *qdic= t); void hmp_eject(Monitor *mon, const QDict *qdict); void hmp_change(Monitor *mon, const QDict *qdict); void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict); +#ifdef CONFIG_VIRTFS +void hmp_fsdev_set_io_throttle(Monitor *mon, const QDict *qdict); +void hmp_fsdev_get_io_throttle(Monitor *mon, const QDict *qdict); +#endif + void hmp_block_stream(Monitor *mon, const QDict *qdict); void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict); void hmp_block_job_cancel(Monitor *mon, const QDict *qdict); diff --git a/qapi-schema.json b/qapi-schema.json index 01b087f..6aa1446 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -81,6 +81,9 @@ # QAPI block definitions { 'include': 'qapi/block.json' } =20 +# QAPI fsdev definitions +{ 'include': 'qapi/fsdev.json' } + # QAPI event definitions { 'include': 'qapi/event.json' } =20 diff --git a/qapi/fsdev.json b/qapi/fsdev.json new file mode 100644 index 0000000..eff1efe --- /dev/null +++ b/qapi/fsdev.json @@ -0,0 +1,84 @@ +# -*- Mode: Python -*- + +## +# =3D=3D QAPI fsdev definitions +## + +# QAPI common definitions +{ 'include': 'iothrottle.json' } + +## +# @fsdev-set-io-throttle: +# +# Change I/O limits for a 9p/fsdev device. +# +# I/O limits can be enabled by setting throttle value to non-zero number. +# +# I/O limits can be disabled by setting all throttle values to 0. +# +# Returns: Nothing on success +# If @device is not a valid fsdev device, DeviceNotFound +# +# Since: 2.10 +# +# Example: +# +# -> { "execute": "fsdev-set-io-throttle", +# "arguments": { "id": "id0-1-0", +# "bps": 1000000, +# "bps_rd": 0, +# "bps_wr": 0, +# "iops": 0, +# "iops_rd": 0, +# "iops_wr": 0, +# "bps_max": 8000000, +# "bps_rd_max": 0, +# "bps_wr_max": 0, +# "iops_max": 0, +# "iops_rd_max": 0, +# "iops_wr_max": 0, +# "bps_max_length": 60, +# "iops_size": 0 } } +# <- { "returns": {} } +## +{ 'command': 'fsdev-set-io-throttle', 'boxed': true, + 'data': 'IOThrottle' } +## +# @query-fsdev-io-throttle: +# +# Returns: a list of @IOThrottle describing io throttle values of each fsd= ev device +# +# Since: 2.10 +# +# Example: +# +# -> { "Execute": "query-fsdev-io-throttle" } +# <- { "returns" : [ +# { +# "id": "id0-hd0", +# "bps":1000000, +# "bps_rd":0, +# "bps_wr":0, +# "iops":1000000, +# "iops_rd":0, +# "iops_wr":0, +# "bps_max": 8000000, +# "bps_rd_max": 0, +# "bps_wr_max": 0, +# "iops_max": 0, +# "iops_rd_max": 0, +# "iops_wr_max": 0, +# "bps_max_length": 0, +# "bps_rd_max_length": 0, +# "bps_wr_max_length": 0, +# "iops_max_length": 0, +# "iops_rd_max_length": 0, +# "iops_wr_max_length": 0, +# "iops_size": 0 +# } +# ] +# } +# +## +{ 'command': 'query-fsdev-io-throttle', 'returns': [ 'IOThrottle' ] } + diff --git a/qapi/iothrottle.json b/qapi/iothrottle.json index 124ab40..698d4bc 100644 --- a/qapi/iothrottle.json +++ b/qapi/iothrottle.json @@ -3,6 +3,7 @@ ## # =3D=3D QAPI IOThrottle definitions ## +## # @IOThrottle: # # A set of parameters describing iothrottle --=20 1.8.3.1 From nobody Sun Apr 28 09:58:41 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.zoho.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 1493735620708158.53868092068763; Tue, 2 May 2017 07:33:40 -0700 (PDT) Received: from localhost ([::1]:59306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5Yrx-0006Id-99 for importer@patchew.org; Tue, 02 May 2017 10:33:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5YpB-0004I9-Dn for qemu-devel@nongnu.org; Tue, 02 May 2017 10:30:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5Yp9-00064Y-9C for qemu-devel@nongnu.org; Tue, 02 May 2017 10:30:45 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:35744) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d5Yp8-00063F-Vr for qemu-devel@nongnu.org; Tue, 02 May 2017 10:30:43 -0400 Received: by mail-wm0-x243.google.com with SMTP id d79so5043082wmi.2 for ; Tue, 02 May 2017 07:30:42 -0700 (PDT) Received: from centos-minion-1.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id r60sm23997861wrb.37.2017.05.02.07.30.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 May 2017 07:30:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zLGB4lkrru98adayBE5a670aZOoLHjPRejNJLRK6jPs=; b=oEjshbWM5E8knTBrvnvtkkt7QxN1zNU7vT4ugHUtXBdNNrdouAscVn9uzyI7iY58R/ LMeD8shI+L/xQgUWlH/eWIMvZKxZf1G23aUxrbRrW+HXRwsYb1huJ+q8v1+AiTeM8v8j 7O0IBP9CiNpcVcZ7+3CVzwNOTXT9cUDAH/8nUd8JX+0W7NTvlZYwC6Z4+jXFYD5x/rqb 4GbAJdWHH11XkItKObMeHMN/u1S6DBAJKuAWc5XpRxDG4mxN7eTYJdq+08bUeqas2Ljn 1euz+7EgY06lfGPns+3qdsAU5lTG3TQE8ds3fqf1BiFFeQjkrmlnJTNPSud3oa9bskzM PZoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zLGB4lkrru98adayBE5a670aZOoLHjPRejNJLRK6jPs=; b=MzCJ41ezPp9KhHNDO46CB8OWqlCWPFpLXovhGCvNDsOf8CrwzCQU5hhW5gX9Y8/giW qzEH4TMss3G7NtoJoCJBO7FgEZySj+PU/BM4T1QAzIhuRdZKdmXbnnwZnIQyjVzzCToi FkhlaiaFYHp9+AUOJdKKsUqkOag8L0F6begtjY9JuW8osOZSd4xtKanJrfu0MBHUbB6T kcrWiFsjDs7Y8OPRDaOwXx/Dk5fF//QPlSkzdavi30U6gczK583t0ea8+pAhCGRboXSc Wp5/IIzzMeYLUbCn8Povd3VCScmoGoo10+k7OqHiIwW9y1JGJvnOC3ksrsGbG473bs/N g53A== X-Gm-Message-State: AN3rC/7YjUs+iYTSgXvXCTiKRVMS+6fle/uGm1GGCn6Vykt+m+3aj4tG Xn9pTdHSrFrZHg== X-Received: by 10.28.51.9 with SMTP id z9mr2852914wmz.77.1493735441815; Tue, 02 May 2017 07:30:41 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Tue, 2 May 2017 10:29:45 -0400 Message-Id: <1493735386-39622-4-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1493735386-39622-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1493735386-39622-1-git-send-email-pradeep.jagadeesh@huawei.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH v3 3/4] qmp: refactor duplicate code 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: jani kokkonen , alberto garcia , Pradeep Jagadeesh , qemu-devel@nongnu.org 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" This patchset factor out the duplicate qmp throttle interface code that was present in both block and fsdev device files. Signed-off-by: Pradeep Jagadeesh --- blockdev.c | 53 +++---------------------------------- fsdev/qemu-fsdev-throttle.c | 51 +----------------------------------- fsdev/qemu-fsdev.c | 1 - hmp.c | 34 ++++++++++++------------ include/qemu/throttle-options.h | 5 ++++ util/Makefile.objs | 1 + util/throttle-options.c | 58 +++++++++++++++++++++++++++++++++++++= ++++ 7 files changed, 85 insertions(+), 118 deletions(-) create mode 100644 util/throttle-options.c diff --git a/blockdev.c b/blockdev.c index 6428206..b056788 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2635,6 +2635,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, = Error **errp) BlockDriverState *bs; BlockBackend *blk; AioContext *aio_context; + IOThrottle *iothrottle; =20 blk =3D qmp_get_blk(arg->has_device ? arg->device : NULL, arg->has_id ? arg->id : NULL, @@ -2652,56 +2653,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg,= Error **errp) goto out; } =20 - throttle_config_init(&cfg); - cfg.buckets[THROTTLE_BPS_TOTAL].avg =3D arg->bps; - cfg.buckets[THROTTLE_BPS_READ].avg =3D arg->bps_rd; - cfg.buckets[THROTTLE_BPS_WRITE].avg =3D arg->bps_wr; - - cfg.buckets[THROTTLE_OPS_TOTAL].avg =3D arg->iops; - cfg.buckets[THROTTLE_OPS_READ].avg =3D arg->iops_rd; - cfg.buckets[THROTTLE_OPS_WRITE].avg =3D arg->iops_wr; - - if (arg->has_bps_max) { - cfg.buckets[THROTTLE_BPS_TOTAL].max =3D arg->bps_max; - } - if (arg->has_bps_rd_max) { - cfg.buckets[THROTTLE_BPS_READ].max =3D arg->bps_rd_max; - } - if (arg->has_bps_wr_max) { - cfg.buckets[THROTTLE_BPS_WRITE].max =3D arg->bps_wr_max; - } - if (arg->has_iops_max) { - cfg.buckets[THROTTLE_OPS_TOTAL].max =3D arg->iops_max; - } - if (arg->has_iops_rd_max) { - cfg.buckets[THROTTLE_OPS_READ].max =3D arg->iops_rd_max; - } - if (arg->has_iops_wr_max) { - cfg.buckets[THROTTLE_OPS_WRITE].max =3D arg->iops_wr_max; - } - - if (arg->has_bps_max_length) { - cfg.buckets[THROTTLE_BPS_TOTAL].burst_length =3D arg->bps_max_leng= th; - } - if (arg->has_bps_rd_max_length) { - cfg.buckets[THROTTLE_BPS_READ].burst_length =3D arg->bps_rd_max_le= ngth; - } - if (arg->has_bps_wr_max_length) { - cfg.buckets[THROTTLE_BPS_WRITE].burst_length =3D arg->bps_wr_max_l= ength; - } - if (arg->has_iops_max_length) { - cfg.buckets[THROTTLE_OPS_TOTAL].burst_length =3D arg->iops_max_len= gth; - } - if (arg->has_iops_rd_max_length) { - cfg.buckets[THROTTLE_OPS_READ].burst_length =3D arg->iops_rd_max_l= ength; - } - if (arg->has_iops_wr_max_length) { - cfg.buckets[THROTTLE_OPS_WRITE].burst_length =3D arg->iops_wr_max_= length; - } - - if (arg->has_iops_size) { - cfg.op_size =3D arg->iops_size; - } + iothrottle =3D qapi_BlockIOThrottle_base(arg); + qmp_set_io_throttle(&cfg, iothrottle); =20 if (!throttle_is_valid(&cfg, errp)) { goto out; diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index 43dbcd8..cd653af 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -33,56 +33,7 @@ void fsdev_set_io_throttle(IOThrottle *arg, FsThrottle *= fst, Error **errp) { ThrottleConfig cfg; =20 - throttle_config_init(&cfg); - cfg.buckets[THROTTLE_BPS_TOTAL].avg =3D arg->bps; - cfg.buckets[THROTTLE_BPS_READ].avg =3D arg->bps_rd; - cfg.buckets[THROTTLE_BPS_WRITE].avg =3D arg->bps_wr; - - cfg.buckets[THROTTLE_OPS_TOTAL].avg =3D arg->iops; - cfg.buckets[THROTTLE_OPS_READ].avg =3D arg->iops_rd; - cfg.buckets[THROTTLE_OPS_WRITE].avg =3D arg->iops_wr; - - if (arg->has_bps_max) { - cfg.buckets[THROTTLE_BPS_TOTAL].max =3D arg->bps_max; - } - if (arg->has_bps_rd_max) { - cfg.buckets[THROTTLE_BPS_READ].max =3D arg->bps_rd_max; - } - if (arg->has_bps_wr_max) { - cfg.buckets[THROTTLE_BPS_WRITE].max =3D arg->bps_wr_max; - } - if (arg->has_iops_max) { - cfg.buckets[THROTTLE_OPS_TOTAL].max =3D arg->iops_max; - } - if (arg->has_iops_rd_max) { - cfg.buckets[THROTTLE_OPS_READ].max =3D arg->iops_rd_max; - } - if (arg->has_iops_wr_max) { - cfg.buckets[THROTTLE_OPS_WRITE].max =3D arg->iops_wr_max; - } - - if (arg->has_bps_max_length) { - cfg.buckets[THROTTLE_BPS_TOTAL].burst_length =3D arg->bps_max_leng= th; - } - if (arg->has_bps_rd_max_length) { - cfg.buckets[THROTTLE_BPS_READ].burst_length =3D arg->bps_rd_max_le= ngth; - } - if (arg->has_bps_wr_max_length) { - cfg.buckets[THROTTLE_BPS_WRITE].burst_length =3D arg->bps_wr_max_l= ength; - } - if (arg->has_iops_max_length) { - cfg.buckets[THROTTLE_OPS_TOTAL].burst_length =3D arg->iops_max_len= gth; - } - if (arg->has_iops_rd_max_length) { - cfg.buckets[THROTTLE_OPS_READ].burst_length =3D arg->iops_rd_max_l= ength; - } - if (arg->has_iops_wr_max_length) { - cfg.buckets[THROTTLE_OPS_WRITE].burst_length =3D arg->iops_wr_max_= length; - } - - if (arg->has_iops_size) { - cfg.op_size =3D arg->iops_size; - } + qmp_set_io_throttle(&cfg, arg); =20 if (throttle_is_valid(&cfg, errp)) { fst->cfg =3D cfg; diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index a99e299..8c078b1 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -102,7 +102,6 @@ FsDriverEntry *get_fsdev_fsentry(char *id) =20 void qmp_fsdev_set_io_throttle(IOThrottle *arg, Error **errp) { - FsDriverEntry *fse; =20 fse =3D get_fsdev_fsentry(arg->has_id ? arg->id : NULL); diff --git a/hmp.c b/hmp.c index 9c02e55..05c28b5 100644 --- a/hmp.c +++ b/hmp.c @@ -1553,20 +1553,29 @@ void hmp_change(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } =20 +static void hmp_initialize_io_throttle(IOThrottle *iot, const QDict *qdict) +{ + iot->has_id =3D true; + iot->id =3D (char *) qdict_get_str(qdict, "id"); + iot->bps =3D qdict_get_int(qdict, "bps"); + iot->bps_rd =3D qdict_get_int(qdict, "bps_rd"); + iot->bps_wr =3D qdict_get_int(qdict, "bps_wr"); + iot->iops =3D qdict_get_int(qdict, "iops"); + iot->iops_rd =3D qdict_get_int(qdict, "iops_rd"); + iot->iops_wr =3D qdict_get_int(qdict, "iops_wr"); +} + void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; + IOThrottle *iothrottle; 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"), - .iops =3D qdict_get_int(qdict, "iops"), - .iops_rd =3D qdict_get_int(qdict, "iops_rd"), - .iops_wr =3D qdict_get_int(qdict, "iops_wr"), }; =20 + iothrottle =3D qapi_BlockIOThrottle_base(&throttle); + hmp_initialize_io_throttle(iothrottle, qdict); qmp_block_set_io_throttle(&throttle, &err); hmp_handle_error(mon, &err); } @@ -1576,17 +1585,8 @@ void hmp_block_set_io_throttle(Monitor *mon, const Q= Dict *qdict) void hmp_fsdev_set_io_throttle(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; - IOThrottle throttle =3D { - .has_id =3D true, - .id =3D (char *) qdict_get_str(qdict, "id"), - .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"), - .iops =3D qdict_get_int(qdict, "iops"), - .iops_rd =3D qdict_get_int(qdict, "iops_rd"), - .iops_wr =3D qdict_get_int(qdict, "iops_wr"), - }; - + IOThrottle throttle; + hmp_initialize_io_throttle(&throttle, qdict); qmp_fsdev_set_io_throttle(&throttle, &err); hmp_handle_error(mon, &err); } diff --git a/include/qemu/throttle-options.h b/include/qemu/throttle-option= s.h index 3133d1c..ca0fd7d 100644 --- a/include/qemu/throttle-options.h +++ b/include/qemu/throttle-options.h @@ -10,6 +10,9 @@ #ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H =20 +#include "qemu/throttle.h" +#include "qmp-commands.h" + #define THROTTLE_OPTS \ { \ .name =3D "throttling.iops-total",\ @@ -89,4 +92,6 @@ .help =3D "when limiting by iops max size of an I/O in bytes",\ } =20 +void qmp_set_io_throttle(ThrottleConfig *, IOThrottle *); + #endif diff --git a/util/Makefile.objs b/util/Makefile.objs index c6205eb..7119ce0 100644 --- a/util/Makefile.objs +++ b/util/Makefile.objs @@ -43,3 +43,4 @@ util-obj-y +=3D qdist.o util-obj-y +=3D qht.o util-obj-y +=3D range.o util-obj-y +=3D systemd.o +util-obj-y +=3D throttle-options.o diff --git a/util/throttle-options.c b/util/throttle-options.c new file mode 100644 index 0000000..47cffed --- /dev/null +++ b/util/throttle-options.c @@ -0,0 +1,58 @@ +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qemu/throttle-options.h" +#include "qemu/iov.h" + +void qmp_set_io_throttle(ThrottleConfig *cfg, IOThrottle *arg) +{ + throttle_config_init(cfg); + cfg->buckets[THROTTLE_BPS_TOTAL].avg =3D arg->bps; + cfg->buckets[THROTTLE_BPS_READ].avg =3D arg->bps_rd; + cfg->buckets[THROTTLE_BPS_WRITE].avg =3D arg->bps_wr; + + cfg->buckets[THROTTLE_OPS_TOTAL].avg =3D arg->iops; + cfg->buckets[THROTTLE_OPS_READ].avg =3D arg->iops_rd; + cfg->buckets[THROTTLE_OPS_WRITE].avg =3D arg->iops_wr; + + if (arg->has_bps_max) { + cfg->buckets[THROTTLE_BPS_TOTAL].max =3D arg->bps_max; + } + if (arg->has_bps_rd_max) { + cfg->buckets[THROTTLE_BPS_READ].max =3D arg->bps_rd_max; + } + if (arg->has_bps_wr_max) { + cfg->buckets[THROTTLE_BPS_WRITE].max =3D arg->bps_wr_max; + } + if (arg->has_iops_max) { + cfg->buckets[THROTTLE_OPS_TOTAL].max =3D arg->iops_max; + } + if (arg->has_iops_rd_max) { + cfg->buckets[THROTTLE_OPS_READ].max =3D arg->iops_rd_max; + } + if (arg->has_iops_wr_max) { + cfg->buckets[THROTTLE_OPS_WRITE].max =3D arg->iops_wr_max; + } + + if (arg->has_bps_max_length) { + cfg->buckets[THROTTLE_BPS_TOTAL].burst_length =3D arg->bps_max_len= gth; + } + if (arg->has_bps_rd_max_length) { + cfg->buckets[THROTTLE_BPS_READ].burst_length =3D arg->bps_rd_max_l= ength; + } + if (arg->has_bps_wr_max_length) { + cfg->buckets[THROTTLE_BPS_WRITE].burst_length =3D arg->bps_wr_max_= length; + } + if (arg->has_iops_max_length) { + cfg->buckets[THROTTLE_OPS_TOTAL].burst_length =3D arg->iops_max_le= ngth; + } + if (arg->has_iops_rd_max_length) { + cfg->buckets[THROTTLE_OPS_READ].burst_length =3D arg->iops_rd_max_= length; + } + if (arg->has_iops_wr_max_length) { + cfg->buckets[THROTTLE_OPS_WRITE].burst_length =3D arg->iops_wr_max= _length; + } + + if (arg->has_iops_size) { + cfg->op_size =3D arg->iops_size; + } +} --=20 1.8.3.1 From nobody Sun Apr 28 09:58:41 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.zoho.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 1493735562284403.3866647167433; Tue, 2 May 2017 07:32:42 -0700 (PDT) Received: from localhost ([::1]:59304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5Yr0-0005Rw-SO for importer@patchew.org; Tue, 02 May 2017 10:32:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5YpB-0004Ih-MO for qemu-devel@nongnu.org; Tue, 02 May 2017 10:30:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5YpA-00065U-7K for qemu-devel@nongnu.org; Tue, 02 May 2017 10:30:45 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:35747) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d5Yp9-00064N-Ou for qemu-devel@nongnu.org; Tue, 02 May 2017 10:30:44 -0400 Received: by mail-wm0-x242.google.com with SMTP id d79so5043209wmi.2 for ; Tue, 02 May 2017 07:30:43 -0700 (PDT) Received: from centos-minion-1.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id r60sm23997861wrb.37.2017.05.02.07.30.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 May 2017 07:30:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uHIiVjoNlr37AalMAgZRHNAoEpKgo8kPV3HqekiZnEs=; b=EkL/DaPy9SBtoCnuVmSolAoJSqPKdxnvW8Zncpzpw8bGYD8l0i276tgbS3yKTUTpSI PQtf6/+LPDQ1+sSldydqEWkpHZfjOBPMXP1TNtcvO5hocxg1ncXzpoI5HnAb4c9s+2Lr QLHQ0u0Q9eqz3Q27VPxmh78/JLwlkCziUh57qlAIWYeZHZM9GB5j6mqIEmdYaVmqOM2C NbjUkbFkPc+m+L5oobTVNMLDLaxpNdzIWGdLsieEYeQST+m91gTUDBiJFEg9XEKze0v3 FrnHD9jDzqr6rkhNScpLNlX9QD1wt1vMzYVzUHnfWxrawL3FN1ZRxJtMzSsttTthXKTP iJUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uHIiVjoNlr37AalMAgZRHNAoEpKgo8kPV3HqekiZnEs=; b=s7K+/Vo5Njc3ipSxNWkE3ThvbYURgO+9aHPUCJ1dyaz2M9G9WKn9vd2qfWzM+7zw6j By09VLq3hcVdOt0VkiASWc6oWjQMdiwynamQqT0CvLHMjQXG2j35GCK3O8XHSoRJtQPT mEE6lVG53NiFDQI/ECgIPORuJTTpSHvgli8Hw66b1xccqaPZcmrv3aD36xeJpS8K2QBV JDJpbuCWYqXE4yy5EmXjgYHPUenPrBLEz1/RRXqaSqW8XT9PTnSNqvPG1I7muf+Zx94b TeZcf8noOWIyIMDhuraeiNvJfoQfky1phferWtMRAUk3qPsTZUo7YnsoeoqtSnrfY8E5 bBnA== X-Gm-Message-State: AN3rC/6/dPIM4nM2y0K2H5Y2pJxXvTi2FQUdxmteJCaTclEXEeuLmlM0 U6+5HK7BbCS9eg== X-Received: by 10.28.1.143 with SMTP id 137mr2015108wmb.68.1493735442689; Tue, 02 May 2017 07:30:42 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Tue, 2 May 2017 10:29:46 -0400 Message-Id: <1493735386-39622-5-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1493735386-39622-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1493735386-39622-1-git-send-email-pradeep.jagadeesh@huawei.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH v3 4/4] throttle: factor out duplicate code 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: jani kokkonen , alberto garcia , Pradeep Jagadeesh , qemu-devel@nongnu.org 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" This patchset factor out the duplicate throttle code that was present in block and fsdev devices. Signed-off-by: Pradeep Jagadeesh --- blockdev.c | 44 +------------------------------------- fsdev/qemu-fsdev-throttle.c | 43 +------------------------------------ include/qemu/throttle-options.h | 2 ++ util/throttle-options.c | 47 +++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 51 insertions(+), 85 deletions(-) diff --git a/blockdev.c b/blockdev.c index b056788..a55f6be 100644 --- a/blockdev.c +++ b/blockdev.c @@ -386,49 +386,7 @@ static void extract_common_blockdev_options(QemuOpts *= opts, int *bdrv_flags, } =20 if (throttle_cfg) { - throttle_config_init(throttle_cfg); - throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg =3D - qemu_opt_get_number(opts, "throttling.bps-total", 0); - throttle_cfg->buckets[THROTTLE_BPS_READ].avg =3D - qemu_opt_get_number(opts, "throttling.bps-read", 0); - throttle_cfg->buckets[THROTTLE_BPS_WRITE].avg =3D - qemu_opt_get_number(opts, "throttling.bps-write", 0); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL].avg =3D - qemu_opt_get_number(opts, "throttling.iops-total", 0); - throttle_cfg->buckets[THROTTLE_OPS_READ].avg =3D - qemu_opt_get_number(opts, "throttling.iops-read", 0); - throttle_cfg->buckets[THROTTLE_OPS_WRITE].avg =3D - qemu_opt_get_number(opts, "throttling.iops-write", 0); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL].max =3D - qemu_opt_get_number(opts, "throttling.bps-total-max", 0); - throttle_cfg->buckets[THROTTLE_BPS_READ].max =3D - qemu_opt_get_number(opts, "throttling.bps-read-max", 0); - throttle_cfg->buckets[THROTTLE_BPS_WRITE].max =3D - qemu_opt_get_number(opts, "throttling.bps-write-max", 0); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL].max =3D - qemu_opt_get_number(opts, "throttling.iops-total-max", 0); - throttle_cfg->buckets[THROTTLE_OPS_READ].max =3D - qemu_opt_get_number(opts, "throttling.iops-read-max", 0); - throttle_cfg->buckets[THROTTLE_OPS_WRITE].max =3D - qemu_opt_get_number(opts, "throttling.iops-write-max", 0); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL].burst_length =3D - qemu_opt_get_number(opts, "throttling.bps-total-max-length", 1= ); - throttle_cfg->buckets[THROTTLE_BPS_READ].burst_length =3D - qemu_opt_get_number(opts, "throttling.bps-read-max-length", 1); - throttle_cfg->buckets[THROTTLE_BPS_WRITE].burst_length =3D - qemu_opt_get_number(opts, "throttling.bps-write-max-length", 1= ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL].burst_length =3D - qemu_opt_get_number(opts, "throttling.iops-total-max-length", = 1); - throttle_cfg->buckets[THROTTLE_OPS_READ].burst_length =3D - qemu_opt_get_number(opts, "throttling.iops-read-max-length", 1= ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE].burst_length =3D - qemu_opt_get_number(opts, "throttling.iops-write-max-length", = 1); - - throttle_cfg->op_size =3D - qemu_opt_get_number(opts, "throttling.iops-size", 0); - + parse_io_throttle_options(throttle_cfg, opts); if (!throttle_is_valid(throttle_cfg, errp)) { return; } diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index cd653af..3cbf887 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -78,48 +78,7 @@ void fsdev_get_io_throttle(FsThrottle *fst, IOThrottle *= *fs9pcfg, =20 void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **er= rp) { - throttle_config_init(&fst->cfg); - fst->cfg.buckets[THROTTLE_BPS_TOTAL].avg =3D - qemu_opt_get_number(opts, "throttling.bps-total", 0); - fst->cfg.buckets[THROTTLE_BPS_READ].avg =3D - qemu_opt_get_number(opts, "throttling.bps-read", 0); - fst->cfg.buckets[THROTTLE_BPS_WRITE].avg =3D - qemu_opt_get_number(opts, "throttling.bps-write", 0); - fst->cfg.buckets[THROTTLE_OPS_TOTAL].avg =3D - qemu_opt_get_number(opts, "throttling.iops-total", 0); - fst->cfg.buckets[THROTTLE_OPS_READ].avg =3D - qemu_opt_get_number(opts, "throttling.iops-read", 0); - fst->cfg.buckets[THROTTLE_OPS_WRITE].avg =3D - qemu_opt_get_number(opts, "throttling.iops-write", 0); - - fst->cfg.buckets[THROTTLE_BPS_TOTAL].max =3D - qemu_opt_get_number(opts, "throttling.bps-total-max", 0); - fst->cfg.buckets[THROTTLE_BPS_READ].max =3D - qemu_opt_get_number(opts, "throttling.bps-read-max", 0); - fst->cfg.buckets[THROTTLE_BPS_WRITE].max =3D - qemu_opt_get_number(opts, "throttling.bps-write-max", 0); - fst->cfg.buckets[THROTTLE_OPS_TOTAL].max =3D - qemu_opt_get_number(opts, "throttling.iops-total-max", 0); - fst->cfg.buckets[THROTTLE_OPS_READ].max =3D - qemu_opt_get_number(opts, "throttling.iops-read-max", 0); - fst->cfg.buckets[THROTTLE_OPS_WRITE].max =3D - qemu_opt_get_number(opts, "throttling.iops-write-max", 0); - - fst->cfg.buckets[THROTTLE_BPS_TOTAL].burst_length =3D - qemu_opt_get_number(opts, "throttling.bps-total-max-length", 1); - fst->cfg.buckets[THROTTLE_BPS_READ].burst_length =3D - qemu_opt_get_number(opts, "throttling.bps-read-max-length", 1); - fst->cfg.buckets[THROTTLE_BPS_WRITE].burst_length =3D - qemu_opt_get_number(opts, "throttling.bps-write-max-length", 1); - fst->cfg.buckets[THROTTLE_OPS_TOTAL].burst_length =3D - qemu_opt_get_number(opts, "throttling.iops-total-max-length", 1); - fst->cfg.buckets[THROTTLE_OPS_READ].burst_length =3D - qemu_opt_get_number(opts, "throttling.iops-read-max-length", 1); - fst->cfg.buckets[THROTTLE_OPS_WRITE].burst_length =3D - qemu_opt_get_number(opts, "throttling.iops-write-max-length", 1); - fst->cfg.op_size =3D - qemu_opt_get_number(opts, "throttling.iops-size", 0); - + parse_io_throttle_options(&fst->cfg, opts); throttle_is_valid(&fst->cfg, errp); } =20 diff --git a/include/qemu/throttle-options.h b/include/qemu/throttle-option= s.h index ca0fd7d..bcfd185 100644 --- a/include/qemu/throttle-options.h +++ b/include/qemu/throttle-options.h @@ -94,4 +94,6 @@ =20 void qmp_set_io_throttle(ThrottleConfig *, IOThrottle *); =20 +void parse_io_throttle_options(ThrottleConfig *, QemuOpts *); + #endif diff --git a/util/throttle-options.c b/util/throttle-options.c index 47cffed..e92c8c8 100644 --- a/util/throttle-options.c +++ b/util/throttle-options.c @@ -56,3 +56,50 @@ void qmp_set_io_throttle(ThrottleConfig *cfg, IOThrottle= *arg) cfg->op_size =3D arg->iops_size; } } + +void parse_io_throttle_options(ThrottleConfig *throttle_cfg, QemuOpts *opt= s) +{ + throttle_config_init(throttle_cfg); + throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg =3D + qemu_opt_get_number(opts, "throttling.bps-total", 0); + throttle_cfg->buckets[THROTTLE_BPS_READ].avg =3D + qemu_opt_get_number(opts, "throttling.bps-read", 0); + throttle_cfg->buckets[THROTTLE_BPS_WRITE].avg =3D + qemu_opt_get_number(opts, "throttling.bps-write", 0); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL].avg =3D + qemu_opt_get_number(opts, "throttling.iops-total", 0); + throttle_cfg->buckets[THROTTLE_OPS_READ].avg =3D + qemu_opt_get_number(opts, "throttling.iops-read", 0); + throttle_cfg->buckets[THROTTLE_OPS_WRITE].avg =3D + qemu_opt_get_number(opts, "throttling.iops-write", 0); + + throttle_cfg->buckets[THROTTLE_BPS_TOTAL].max =3D + qemu_opt_get_number(opts, "throttling.bps-total-max", 0); + throttle_cfg->buckets[THROTTLE_BPS_READ].max =3D + qemu_opt_get_number(opts, "throttling.bps-read-max", 0); + throttle_cfg->buckets[THROTTLE_BPS_WRITE].max =3D + qemu_opt_get_number(opts, "throttling.bps-write-max", 0); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL].max =3D + qemu_opt_get_number(opts, "throttling.iops-total-max", 0); + throttle_cfg->buckets[THROTTLE_OPS_READ].max =3D + qemu_opt_get_number(opts, "throttling.iops-read-max", 0); + throttle_cfg->buckets[THROTTLE_OPS_WRITE].max =3D + qemu_opt_get_number(opts, "throttling.iops-write-max", 0); + + throttle_cfg->buckets[THROTTLE_BPS_TOTAL].burst_length =3D + qemu_opt_get_number(opts, "throttling.bps-total-max-length", 1); + throttle_cfg->buckets[THROTTLE_BPS_READ].burst_length =3D + qemu_opt_get_number(opts, "throttling.bps-read-max-length", 1); + throttle_cfg->buckets[THROTTLE_BPS_WRITE].burst_length =3D + qemu_opt_get_number(opts, "throttling.bps-write-max-length", 1); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL].burst_length =3D + qemu_opt_get_number(opts, "throttling.iops-total-max-length", 1); + throttle_cfg->buckets[THROTTLE_OPS_READ].burst_length =3D + qemu_opt_get_number(opts, "throttling.iops-read-max-length", 1); + throttle_cfg->buckets[THROTTLE_OPS_WRITE].burst_length =3D + qemu_opt_get_number(opts, "throttling.iops-write-max-length", 1); + + throttle_cfg->op_size =3D + qemu_opt_get_number(opts, "throttling.iops-size", 0); + +} --=20 1.8.3.1