From nobody Thu Nov 6 14:17:14 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542355611019794.440309106177; Fri, 16 Nov 2018 00:06:51 -0800 (PST) Received: from localhost ([::1]:42631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZ9N-0002UC-Mv for importer@patchew.org; Fri, 16 Nov 2018 03:06:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZ7p-0001lX-Vq for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:05:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNZ7l-0005nt-QL for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:05:13 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:3106 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gNZ7j-0005gN-Qm for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:05:09 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 9C7C031C7F464; Fri, 16 Nov 2018 16:04:56 +0800 (CST) Received: from huawei.com (10.143.28.95) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.408.0; Fri, 16 Nov 2018 16:04:50 +0800 From: xiezhide To: Date: Fri, 16 Nov 2018 15:59:16 +0800 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.143.28.95] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [PATCH v5 1/6] fsdev-throttle-qmp: factor out throttle code to reuse 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: berto@igalia.com, armbru@redhat.com, zengcanfu@huawei.com, groug@kaod.org, aneesh.kumar@linux.vnet.ibm.com, jinxuefeng@huawei.com, chenhui.rtos@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Factor out throttle parameter parsing code to a new common function which will be used by block and fsdev. Rename function throttle_parse_options to throttle_parse_group to resolve function name conflict Reviewed-by: Eric Blake Signed-off-by: xiezhide Acked-by: Greg Kurz Reviewed-by: Greg Kurz --- block/throttle.c | 6 ++-- blockdev.c | 43 +------------------------- fsdev/qemu-fsdev-throttle.c | 44 ++------------------------ include/qemu/throttle-options.h | 2 ++ include/qemu/throttle.h | 4 +-- include/qemu/typedefs.h | 1 + util/throttle.c | 68 +++++++++++++++++++++++++++++++++++++= ++++ 7 files changed, 79 insertions(+), 89 deletions(-) diff --git a/block/throttle.c b/block/throttle.c index 636c976..bd23c58 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -41,7 +41,7 @@ static QemuOptsList throttle_opts =3D { * @group and must be freed by the caller. * If there's an error then @group remains unmodified. */ -static int throttle_parse_options(QDict *options, char **group, Error **er= rp) +static int throttle_parse_group(QDict *options, char **group, Error **errp) { int ret; const char *group_name; @@ -90,7 +90,7 @@ static int throttle_open(BlockDriverState *bs, QDict *opt= ions, bs->supported_zero_flags =3D bs->file->bs->supported_zero_flags | BDRV_REQ_WRITE_UNCHANGED; =20 - ret =3D throttle_parse_options(options, &group, errp); + ret =3D throttle_parse_group(options, &group, errp); if (ret =3D=3D 0) { /* Register membership to group with name group_name */ throttle_group_register_tgm(tgm, group, bdrv_get_aio_context(bs)); @@ -179,7 +179,7 @@ static int throttle_reopen_prepare(BDRVReopenState *reo= pen_state, assert(reopen_state !=3D NULL); assert(reopen_state->bs !=3D NULL); =20 - ret =3D throttle_parse_options(reopen_state->options, &group, errp); + ret =3D throttle_parse_group(reopen_state->options, &group, errp); reopen_state->opaque =3D group; return ret; } diff --git a/blockdev.c b/blockdev.c index 81f95d9..fce5d8f 100644 --- a/blockdev.c +++ b/blockdev.c @@ -400,48 +400,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); + throttle_parse_options(throttle_cfg, opts); =20 if (!throttle_is_valid(throttle_cfg, errp)) { return; diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index cfd8641..6a4108a 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -17,6 +17,7 @@ #include "qemu-fsdev-throttle.h" #include "qemu/iov.h" #include "qemu/option.h" +#include "qemu/throttle-options.h" =20 static void fsdev_throttle_read_timer_cb(void *opaque) { @@ -32,48 +33,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque) =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); - + throttle_parse_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 3528a8f..944a08c 100644 --- a/include/qemu/throttle-options.h +++ b/include/qemu/throttle-options.h @@ -111,4 +111,6 @@ .help =3D "when limiting by iops max size of an I/O in bytes",\ } =20 +void throttle_parse_options(ThrottleConfig *, QemuOpts *); + #endif diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h index abeb886..f379d91 100644 --- a/include/qemu/throttle.h +++ b/include/qemu/throttle.h @@ -90,10 +90,10 @@ typedef struct LeakyBucket { * However it allows to keep the code clean and the bucket field is reset = to * zero at the right time. */ -typedef struct ThrottleConfig { +struct ThrottleConfig { LeakyBucket buckets[BUCKETS_COUNT]; /* leaky buckets */ uint64_t op_size; /* size of an operation in bytes */ -} ThrottleConfig; +}; =20 typedef struct ThrottleState { ThrottleConfig cfg; /* configuration */ diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 3ec0e13..0d75edc 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -109,6 +109,7 @@ typedef struct SerialState SerialState; typedef struct SHPCDevice SHPCDevice; typedef struct SMBusDevice SMBusDevice; typedef struct SSIBus SSIBus; +typedef struct ThrottleConfig ThrottleConfig; typedef struct uWireSlave uWireSlave; typedef struct VirtIODevice VirtIODevice; typedef struct Visitor Visitor; diff --git a/util/throttle.c b/util/throttle.c index b38e742..e7db2ad 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -27,6 +27,8 @@ #include "qemu/throttle.h" #include "qemu/timer.h" #include "block/aio.h" +#include "qemu/option.h" +#include "qemu/throttle-options.h" =20 /* This function make a bucket leak * @@ -636,3 +638,69 @@ void throttle_config_to_limits(ThrottleConfig *cfg, Th= rottleLimits *var) var->has_iops_write_max_length =3D true; var->has_iops_size =3D true; } + +/* parse the throttle options + * + * @opts: qemu options + * @throttle_cfg: throttle configuration + */ +void throttle_parse_options(ThrottleConfig *throttle_cfg, QemuOpts *opts) +{ + throttle_config_init(throttle_cfg); + throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_BPS_TOTAL, 0); + throttle_cfg->buckets[THROTTLE_BPS_READ].avg =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_BPS_READ, 0); + throttle_cfg->buckets[THROTTLE_BPS_WRITE].avg =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_BPS_WRITE, 0); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL].avg =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_IOPS_TOTAL, 0); + throttle_cfg->buckets[THROTTLE_OPS_READ].avg =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_IOPS_READ, 0); + throttle_cfg->buckets[THROTTLE_OPS_WRITE].avg =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_IOPS_WRITE, 0); + throttle_cfg->buckets[THROTTLE_BPS_TOTAL].max =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_BPS_TOTAL_MAX, 0); + throttle_cfg->buckets[THROTTLE_BPS_READ].max =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_BPS_READ_MAX, 0); + throttle_cfg->buckets[THROTTLE_BPS_WRITE].max =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_BPS_WRITE_MAX, 0); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL].max =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_IOPS_TOTAL_MAX, 0); + throttle_cfg->buckets[THROTTLE_OPS_READ].max =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_IOPS_READ_MAX, 0); + throttle_cfg->buckets[THROTTLE_OPS_WRITE].max =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_IOPS_WRITE_MAX, 0); + throttle_cfg->buckets[THROTTLE_BPS_TOTAL].burst_length =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_BPS_TOTAL_MAX_LENGTH, 1); + throttle_cfg->buckets[THROTTLE_BPS_READ].burst_length =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_BPS_READ_MAX_LENGTH, 1); + throttle_cfg->buckets[THROTTLE_BPS_WRITE].burst_length =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_BPS_WRITE_MAX_LENGTH, 1); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL].burst_length =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_IOPS_TOTAL_MAX_LENGTH, 1); + throttle_cfg->buckets[THROTTLE_OPS_READ].burst_length =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_IOPS_READ_MAX_LENGTH, 1); + throttle_cfg->buckets[THROTTLE_OPS_WRITE].burst_length =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX + QEMU_OPT_IOPS_WRITE_MAX_LENGTH, 1); + throttle_cfg->op_size =3D + qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_SIZE, = 0); +} --=20 1.8.3.1 From nobody Thu Nov 6 14:17:14 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542355765831644.8027993905355; Fri, 16 Nov 2018 00:09:25 -0800 (PST) Received: from localhost ([::1]:42641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZBs-0004ip-Gx for importer@patchew.org; Fri, 16 Nov 2018 03:09:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZ84-0001vx-Pj for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:05:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNZ81-00060q-I5 for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:05:28 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:3107 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gNZ80-0005ul-Pc for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:05:25 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B964F9A3B94CF; Fri, 16 Nov 2018 16:05:18 +0800 (CST) Received: from huawei.com (10.143.28.95) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.408.0; Fri, 16 Nov 2018 16:05:10 +0800 From: xiezhide To: Date: Fri, 16 Nov 2018 15:59:35 +0800 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.143.28.95] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [PATCH v5 2/6] fsdev-throttle-qmp: Rename the ThrottleLimits member names 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: berto@igalia.com, armbru@redhat.com, zengcanfu@huawei.com, groug@kaod.org, aneesh.kumar@linux.vnet.ibm.com, jinxuefeng@huawei.com, chenhui.rtos@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename the ThrottleLimits member names and modify related code Signed-off-by: xiezhide --- qapi/block-core.json | 70 +++++++++++----------- util/throttle.c | 163 +++++++++++++++++++++++++----------------------= ---- 2 files changed, 116 insertions(+), 117 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index d4fe710..4ffaaea 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2240,45 +2240,45 @@ # transaction. All fields are optional. When setting limits, if a field is # missing the current value is not changed. # -# @iops-total: limit total I/O operations per second -# @iops-total-max: I/O operations burst -# @iops-total-max-length: length of the iops-total-max burst period, in s= econds -# It must only be set if @iops-total-max is set a= s well. -# @iops-read: limit read operations per second -# @iops-read-max: I/O operations read burst -# @iops-read-max-length: length of the iops-read-max burst period, in se= conds -# It must only be set if @iops-read-max is set as= well. -# @iops-write: limit write operations per second -# @iops-write-max: I/O operations write burst -# @iops-write-max-length: length of the iops-write-max burst period, in s= econds -# It must only be set if @iops-write-max is set a= s well. -# @bps-total: limit total bytes per second -# @bps-total-max: total bytes burst -# @bps-total-max-length: length of the bps-total-max burst period, in se= conds. -# It must only be set if @bps-total-max is set as= well. -# @bps-read: limit read bytes per second -# @bps-read-max: total bytes read burst -# @bps-read-max-length: length of the bps-read-max burst period, in sec= onds -# It must only be set if @bps-read-max is set as = well. -# @bps-write: limit write bytes per second -# @bps-write-max: total bytes write burst -# @bps-write-max-length: length of the bps-write-max burst period, in se= conds -# It must only be set if @bps-write-max is set as= well. -# @iops-size: when limiting by iops max size of an I/O in byt= es +# @iops: limit total I/O operations per second +# @iops_max: I/O operations burst +# @iops_max_length: length of the iops_total_max burst period, in seconds +# It must only be set if @iops_total_max is set a= s well. +# @iops_rd: limit read operations per second +# @iops_rd_max: I/O operations read burst +# @iops_rd_max_length: length of the iops_read_max burst period, in seco= nds +# It must only be set if @iops_read_max is set as= well. +# @iops_wr: limit write operations per second +# @iops_wr_max: I/O operations write burst +# @iops_wr_max_length: length of the iops_write_max burst period, in seco= nds +# It must only be set if @iops_write_max is set a= s well. +# @bps: limit total bytes per second +# @bps_max: total bytes burst +# @bps_max_length: length of the bps_total_max burst period, in seconds. +# It must only be set if @bps_total_max is set as= well. +# @bps_rd: limit read bytes per second +# @bps_rd_max: total bytes read burst +# @bps_rd_max_length: length of the bps_read_max burst period, in secon= ds +# It must only be set if @bps_read_max is set as = well. +# @bps_wr: limit write bytes per second +# @bps_wr_max: total bytes write burst +# @bps_wr_max_length: length of the bps_write_max burst period, in secon= ds +# It must only be set if @bps_write_max is set as= well. +# @iops_size: when limiting by iops max size of an I/O in byt= es # # Since: 2.11 ## { 'struct': 'ThrottleLimits', - 'data': { '*iops-total' : 'int', '*iops-total-max' : 'int', - '*iops-total-max-length' : 'int', '*iops-read' : 'int', - '*iops-read-max' : 'int', '*iops-read-max-length' : 'int', - '*iops-write' : 'int', '*iops-write-max' : 'int', - '*iops-write-max-length' : 'int', '*bps-total' : 'int', - '*bps-total-max' : 'int', '*bps-total-max-length' : 'int', - '*bps-read' : 'int', '*bps-read-max' : 'int', - '*bps-read-max-length' : 'int', '*bps-write' : 'int', - '*bps-write-max' : 'int', '*bps-write-max-length' : 'int', - '*iops-size' : 'int' } } + 'data': { '*iops' : 'int', '*iops_max' : 'int', + '*iops_max_length' : 'int', '*iops_rd' : 'int', + '*iops_rd_max' : 'int', '*iops_rd_max_length' : 'int', + '*iops_wr' : 'int', '*iops_wr_max' : 'int', + '*iops_wr_max_length' : 'int', '*bps' : 'int', + '*bps_max' : 'int', '*bps_max_length' : 'int', + '*bps_rd' : 'int', '*bps_rd_max' : 'int', + '*bps_rd_max_length' : 'int', '*bps_wr' : 'int', + '*bps_wr_max' : 'int', '*bps_wr_max_length' : 'int', + '*iops_size' : 'int' } } =20 ## # @block-stream: diff --git a/util/throttle.c b/util/throttle.c index e7db2ad..b421e33 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -496,98 +496,97 @@ void throttle_account(ThrottleState *ts, bool is_writ= e, uint64_t size) void throttle_limits_to_config(ThrottleLimits *arg, ThrottleConfig *cfg, Error **errp) { - if (arg->has_bps_total) { - cfg->buckets[THROTTLE_BPS_TOTAL].avg =3D arg->bps_total; + if (arg->has_bps) { + cfg->buckets[THROTTLE_BPS_TOTAL].avg =3D arg->bps; } - if (arg->has_bps_read) { - cfg->buckets[THROTTLE_BPS_READ].avg =3D arg->bps_read; + if (arg->has_bps_rd) { + cfg->buckets[THROTTLE_BPS_READ].avg =3D arg->bps_rd; } - if (arg->has_bps_write) { - cfg->buckets[THROTTLE_BPS_WRITE].avg =3D arg->bps_write; + if (arg->has_bps_wr) { + cfg->buckets[THROTTLE_BPS_WRITE].avg =3D arg->bps_wr; } =20 - if (arg->has_iops_total) { - cfg->buckets[THROTTLE_OPS_TOTAL].avg =3D arg->iops_total; + if (arg->has_iops) { + cfg->buckets[THROTTLE_OPS_TOTAL].avg =3D arg->iops; } - if (arg->has_iops_read) { - cfg->buckets[THROTTLE_OPS_READ].avg =3D arg->iops_read; + if (arg->has_iops_rd) { + cfg->buckets[THROTTLE_OPS_READ].avg =3D arg->iops_rd; } - if (arg->has_iops_write) { - cfg->buckets[THROTTLE_OPS_WRITE].avg =3D arg->iops_write; + if (arg->has_iops_wr) { + cfg->buckets[THROTTLE_OPS_WRITE].avg =3D arg->iops_wr; } =20 - if (arg->has_bps_total_max) { - cfg->buckets[THROTTLE_BPS_TOTAL].max =3D arg->bps_total_max; + if (arg->has_bps_max) { + cfg->buckets[THROTTLE_BPS_TOTAL].max =3D arg->bps_max; } - if (arg->has_bps_read_max) { - cfg->buckets[THROTTLE_BPS_READ].max =3D arg->bps_read_max; + if (arg->has_bps_rd_max) { + cfg->buckets[THROTTLE_BPS_READ].max =3D arg->bps_rd_max; } - if (arg->has_bps_write_max) { - cfg->buckets[THROTTLE_BPS_WRITE].max =3D arg->bps_write_max; + if (arg->has_bps_wr_max) { + cfg->buckets[THROTTLE_BPS_WRITE].max =3D arg->bps_wr_max; } - if (arg->has_iops_total_max) { - cfg->buckets[THROTTLE_OPS_TOTAL].max =3D arg->iops_total_max; + if (arg->has_iops_max) { + cfg->buckets[THROTTLE_OPS_TOTAL].max =3D arg->iops_max; } - if (arg->has_iops_read_max) { - cfg->buckets[THROTTLE_OPS_READ].max =3D arg->iops_read_max; + if (arg->has_iops_rd_max) { + cfg->buckets[THROTTLE_OPS_READ].max =3D arg->iops_rd_max; } - if (arg->has_iops_write_max) { - cfg->buckets[THROTTLE_OPS_WRITE].max =3D arg->iops_write_max; + if (arg->has_iops_wr_max) { + cfg->buckets[THROTTLE_OPS_WRITE].max =3D arg->iops_wr_max; } =20 - if (arg->has_bps_total_max_length) { - if (arg->bps_total_max_length > UINT_MAX) { + if (arg->has_bps_max_length) { + if (arg->bps_max_length > UINT_MAX) { error_setg(errp, "bps-total-max-length value must be in" " the range [0, %u]", UINT_MAX); return; } - cfg->buckets[THROTTLE_BPS_TOTAL].burst_length =3D arg->bps_total_m= ax_length; + cfg->buckets[THROTTLE_BPS_TOTAL].burst_length =3D arg->bps_max_len= gth; } - if (arg->has_bps_read_max_length) { - if (arg->bps_read_max_length > UINT_MAX) { + if (arg->has_bps_rd_max_length) { + if (arg->bps_rd_max_length > UINT_MAX) { error_setg(errp, "bps-read-max-length value must be in" " the range [0, %u]", UINT_MAX); return; } - cfg->buckets[THROTTLE_BPS_READ].burst_length =3D arg->bps_read_max= _length; + cfg->buckets[THROTTLE_BPS_READ].burst_length =3D arg->bps_rd_max_l= ength; } - if (arg->has_bps_write_max_length) { - if (arg->bps_write_max_length > UINT_MAX) { + if (arg->has_bps_wr_max_length) { + if (arg->bps_wr_max_length > UINT_MAX) { error_setg(errp, "bps-write-max-length value must be in" " the range [0, %u]", UINT_MAX); return; } - cfg->buckets[THROTTLE_BPS_WRITE].burst_length =3D arg->bps_write_m= ax_length; + cfg->buckets[THROTTLE_BPS_WRITE].burst_length =3D arg->bps_wr_max_= length; } - if (arg->has_iops_total_max_length) { - if (arg->iops_total_max_length > UINT_MAX) { + if (arg->has_iops_max_length) { + if (arg->iops_max_length > UINT_MAX) { error_setg(errp, "iops-total-max-length value must be in" " the range [0, %u]", UINT_MAX); return; } - cfg->buckets[THROTTLE_OPS_TOTAL].burst_length =3D arg->iops_total_= max_length; + cfg->buckets[THROTTLE_OPS_TOTAL].burst_length =3D arg->iops_max_le= ngth; } - if (arg->has_iops_read_max_length) { - if (arg->iops_read_max_length > UINT_MAX) { + if (arg->has_iops_rd_max_length) { + if (arg->iops_rd_max_length > UINT_MAX) { error_setg(errp, "iops-read-max-length value must be in" " the range [0, %u]", UINT_MAX); return; } - cfg->buckets[THROTTLE_OPS_READ].burst_length =3D arg->iops_read_ma= x_length; + cfg->buckets[THROTTLE_OPS_READ].burst_length =3D arg->iops_rd_max_= length; } - if (arg->has_iops_write_max_length) { - if (arg->iops_write_max_length > UINT_MAX) { + if (arg->has_iops_wr_max_length) { + if (arg->iops_wr_max_length > UINT_MAX) { error_setg(errp, "iops-write-max-length value must be in" " the range [0, %u]", UINT_MAX); return; } - cfg->buckets[THROTTLE_OPS_WRITE].burst_length =3D arg->iops_write_= max_length; + cfg->buckets[THROTTLE_OPS_WRITE].burst_length =3D arg->iops_wr_max= _length; } =20 if (arg->has_iops_size) { cfg->op_size =3D arg->iops_size; } - throttle_is_valid(cfg, errp); } =20 @@ -598,45 +597,45 @@ void throttle_limits_to_config(ThrottleLimits *arg, T= hrottleConfig *cfg, */ void throttle_config_to_limits(ThrottleConfig *cfg, ThrottleLimits *var) { - var->bps_total =3D cfg->buckets[THROTTLE_BPS_TOTAL].avg; - var->bps_read =3D cfg->buckets[THROTTLE_BPS_READ].avg; - var->bps_write =3D cfg->buckets[THROTTLE_BPS_WRITE].avg; - var->iops_total =3D cfg->buckets[THROTTLE_OPS_TOTAL].avg; - var->iops_read =3D cfg->buckets[THROTTLE_OPS_READ].avg; - var->iops_write =3D cfg->buckets[THROTTLE_OPS_WRITE].avg; - var->bps_total_max =3D cfg->buckets[THROTTLE_BPS_TOTAL].max; - var->bps_read_max =3D cfg->buckets[THROTTLE_BPS_READ].max; - var->bps_write_max =3D cfg->buckets[THROTTLE_BPS_WRITE].max; - var->iops_total_max =3D cfg->buckets[THROTTLE_OPS_TOTAL].max; - var->iops_read_max =3D cfg->buckets[THROTTLE_OPS_READ].max; - var->iops_write_max =3D cfg->buckets[THROTTLE_OPS_WRITE].max; - var->bps_total_max_length =3D cfg->buckets[THROTTLE_BPS_TOTAL].burs= t_length; - var->bps_read_max_length =3D cfg->buckets[THROTTLE_BPS_READ].burst= _length; - var->bps_write_max_length =3D cfg->buckets[THROTTLE_BPS_WRITE].burs= t_length; - var->iops_total_max_length =3D cfg->buckets[THROTTLE_OPS_TOTAL].burs= t_length; - var->iops_read_max_length =3D cfg->buckets[THROTTLE_OPS_READ].burst= _length; - var->iops_write_max_length =3D cfg->buckets[THROTTLE_OPS_WRITE].burs= t_length; - var->iops_size =3D cfg->op_size; - - var->has_bps_total =3D true; - var->has_bps_read =3D true; - var->has_bps_write =3D true; - var->has_iops_total =3D true; - var->has_iops_read =3D true; - var->has_iops_write =3D true; - var->has_bps_total_max =3D true; - var->has_bps_read_max =3D true; - var->has_bps_write_max =3D true; - var->has_iops_total_max =3D true; - var->has_iops_read_max =3D true; - var->has_iops_write_max =3D true; - var->has_bps_read_max_length =3D true; - var->has_bps_total_max_length =3D true; - var->has_bps_write_max_length =3D true; - var->has_iops_total_max_length =3D true; - var->has_iops_read_max_length =3D true; - var->has_iops_write_max_length =3D true; - var->has_iops_size =3D true; + var->bps =3D cfg->buckets[THROTTLE_BPS_TOTAL].avg; + var->bps_rd =3D cfg->buckets[THROTTLE_BPS_READ].avg; + var->bps_wr =3D cfg->buckets[THROTTLE_BPS_WRITE].avg; + var->iops =3D cfg->buckets[THROTTLE_OPS_TOTAL].avg; + var->iops_rd =3D cfg->buckets[THROTTLE_OPS_READ].avg; + var->iops_wr =3D cfg->buckets[THROTTLE_OPS_WRITE].avg; + var->bps_max =3D cfg->buckets[THROTTLE_BPS_TOTAL].max; + var->bps_rd_max =3D cfg->buckets[THROTTLE_BPS_READ].max; + var->bps_wr_max =3D cfg->buckets[THROTTLE_BPS_WRITE].max; + var->iops_max =3D cfg->buckets[THROTTLE_OPS_TOTAL].max; + var->iops_rd_max =3D cfg->buckets[THROTTLE_OPS_READ].max; + var->iops_wr_max =3D cfg->buckets[THROTTLE_OPS_WRITE].max; + var->bps_max_length =3D cfg->buckets[THROTTLE_BPS_TOTAL].burst= _length; + var->bps_rd_max_length =3D cfg->buckets[THROTTLE_BPS_READ].burst_= length; + var->bps_wr_max_length =3D cfg->buckets[THROTTLE_BPS_WRITE].burst= _length; + var->iops_max_length =3D cfg->buckets[THROTTLE_OPS_TOTAL].burst= _length; + var->iops_rd_max_length =3D cfg->buckets[THROTTLE_OPS_READ].burst_= length; + var->iops_wr_max_length =3D cfg->buckets[THROTTLE_OPS_WRITE].burst= _length; + var->iops_size =3D cfg->op_size; + + var->has_bps =3D true; + var->has_bps_rd =3D true; + var->has_bps_wr =3D true; + var->has_iops =3D true; + var->has_iops_rd =3D true; + var->has_iops_wr =3D true; + var->has_bps_max =3D true; + var->has_bps_rd_max =3D true; + var->has_bps_wr_max =3D true; + var->has_iops_max =3D true; + var->has_iops_rd_max =3D true; + var->has_iops_wr_max =3D true; + var->has_bps_rd_max_length =3D true; + var->has_bps_max_length =3D true; + var->has_bps_wr_max_length =3D true; + var->has_iops_max_length =3D true; + var->has_iops_rd_max_length =3D true; + var->has_iops_wr_max_length =3D true; + var->has_iops_size =3D true; } =20 /* parse the throttle options --=20 1.8.3.1 From nobody Thu Nov 6 14:17:14 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542355729712340.01665697217004; Fri, 16 Nov 2018 00:08:49 -0800 (PST) Received: from localhost ([::1]:42638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZBI-0004FI-Ja for importer@patchew.org; Fri, 16 Nov 2018 03:08:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZ8U-00029T-Ot for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:05:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNZ8R-0006dG-M3 for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:05:54 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:3108 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gNZ8R-0006D2-6N for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:05:51 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 61A4CEA212A29; Fri, 16 Nov 2018 16:05:31 +0800 (CST) Received: from huawei.com (10.143.28.95) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.408.0; Fri, 16 Nov 2018 16:05:27 +0800 From: xiezhide To: Date: Fri, 16 Nov 2018 15:59:50 +0800 Message-ID: <570359424051acbdd6816bc224ed2c03de2ab210.1542384802.git.xiezhide@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.143.28.95] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [PATCH v5 3/6] fsdev-throttle-qmp: Rewrite BlockIOThrottle with ThrottleLimits as its base class 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: berto@igalia.com, armbru@redhat.com, zengcanfu@huawei.com, groug@kaod.org, aneesh.kumar@linux.vnet.ibm.com, jinxuefeng@huawei.com, chenhui.rtos@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rewrite BlockIOThrottle with ThrottleLimits as its base class and modify re= lated code Signed-off-by: xiezhide --- blockdev.c | 2 ++ qapi/block-core.json | 73 ++----------------------------------------------= ---- 2 files changed, 4 insertions(+), 71 deletions(-) diff --git a/blockdev.c b/blockdev.c index fce5d8f..89921ec 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2752,6 +2752,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, = Error **errp) cfg.op_size =3D arg->iops_size; } =20 + throttle_limits_to_config(qapi_BlockIOThrottle_base(arg), &cfg, errp); + if (!throttle_is_valid(&cfg, errp)) { goto out; } diff --git a/qapi/block-core.json b/qapi/block-core.json index 4ffaaea..3abd6af 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2155,82 +2155,13 @@ # # @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': 'ThrottleLimits', + 'data': { '*device': 'str', '*id': 'str', '*group': 'str' } } =20 ## # @ThrottleLimits: --=20 1.8.3.1 From nobody Thu Nov 6 14:17:14 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542355902042994.2930946965988; Fri, 16 Nov 2018 00:11:42 -0800 (PST) Received: from localhost ([::1]:42654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZE4-0006W5-Le for importer@patchew.org; Fri, 16 Nov 2018 03:11:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZ8V-0002A4-Me for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:05:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNZ8S-0006fh-Vv for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:05:55 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:50196 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gNZ8R-0006bP-W5 for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:05:52 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 681AC38CE0513; Fri, 16 Nov 2018 16:05:48 +0800 (CST) Received: from huawei.com (10.143.28.95) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.408.0; Fri, 16 Nov 2018 16:05:41 +0800 From: xiezhide To: Date: Fri, 16 Nov 2018 16:00:06 +0800 Message-ID: <2aadccc4e1230fdd81f0963ed5cdfef77d5c03d8.1542384802.git.xiezhide@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.143.28.95] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH v5 4/6] fsdev-throttle-qmp: Move ThrottleLimits into a new file for future reuse 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: berto@igalia.com, armbru@redhat.com, zengcanfu@huawei.com, groug@kaod.org, aneesh.kumar@linux.vnet.ibm.com, jinxuefeng@huawei.com, chenhui.rtos@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move ThrottleLimits into a new file for future reuse. Signed-off-by: xiezhide --- Makefile | 9 +++++++++ Makefile.objs | 4 ++++ qapi/block-core.json | 49 +---------------------------------------------- qapi/qapi-schema.json | 1 + qapi/tlimits.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ 5 files changed, 68 insertions(+), 48 deletions(-) create mode 100644 qapi/tlimits.json diff --git a/Makefile b/Makefile index f294718..b546e98 100644 --- a/Makefile +++ b/Makefile @@ -106,6 +106,7 @@ GENERATED_FILES +=3D qapi/qapi-types-sockets.h qapi/qap= i-types-sockets.c GENERATED_FILES +=3D qapi/qapi-types-tpm.h qapi/qapi-types-tpm.c GENERATED_FILES +=3D qapi/qapi-types-trace.h qapi/qapi-types-trace.c GENERATED_FILES +=3D qapi/qapi-types-transaction.h qapi/qapi-types-transac= tion.c +GENERATED_FILES +=3D qapi/qapi-types-tlimits.h qapi/qapi-types-tlimits.c GENERATED_FILES +=3D qapi/qapi-types-ui.h qapi/qapi-types-ui.c GENERATED_FILES +=3D qapi/qapi-builtin-visit.h qapi/qapi-builtin-visit.c GENERATED_FILES +=3D qapi/qapi-visit.h qapi/qapi-visit.c @@ -125,6 +126,7 @@ GENERATED_FILES +=3D qapi/qapi-visit-sockets.h qapi/qap= i-visit-sockets.c GENERATED_FILES +=3D qapi/qapi-visit-tpm.h qapi/qapi-visit-tpm.c GENERATED_FILES +=3D qapi/qapi-visit-trace.h qapi/qapi-visit-trace.c GENERATED_FILES +=3D qapi/qapi-visit-transaction.h qapi/qapi-visit-transac= tion.c +GENERATED_FILES +=3D qapi/qapi-visit-tlimits.h qapi/qapi-visit-tlimits.c GENERATED_FILES +=3D qapi/qapi-visit-ui.h qapi/qapi-visit-ui.c GENERATED_FILES +=3D qapi/qapi-commands.h qapi/qapi-commands.c GENERATED_FILES +=3D qapi/qapi-commands-block-core.h qapi/qapi-commands-bl= ock-core.c @@ -143,6 +145,7 @@ GENERATED_FILES +=3D qapi/qapi-commands-sockets.h qapi/= qapi-commands-sockets.c GENERATED_FILES +=3D qapi/qapi-commands-tpm.h qapi/qapi-commands-tpm.c GENERATED_FILES +=3D qapi/qapi-commands-trace.h qapi/qapi-commands-trace.c GENERATED_FILES +=3D qapi/qapi-commands-transaction.h qapi/qapi-commands-t= ransaction.c +GENERATED_FILES +=3D qapi/qapi-commands-tlimits.h qapi/qapi-commands-tlimi= ts.c GENERATED_FILES +=3D qapi/qapi-commands-ui.h qapi/qapi-commands-ui.c GENERATED_FILES +=3D qapi/qapi-events.h qapi/qapi-events.c GENERATED_FILES +=3D qapi/qapi-events-block-core.h qapi/qapi-events-block-= core.c @@ -161,6 +164,7 @@ GENERATED_FILES +=3D qapi/qapi-events-sockets.h qapi/qa= pi-events-sockets.c GENERATED_FILES +=3D qapi/qapi-events-tpm.h qapi/qapi-events-tpm.c GENERATED_FILES +=3D qapi/qapi-events-trace.h qapi/qapi-events-trace.c GENERATED_FILES +=3D qapi/qapi-events-transaction.h qapi/qapi-events-trans= action.c +GENERATED_FILES +=3D qapi/qapi-events-tlimits.h qapi/qapi-events-tlimits.c GENERATED_FILES +=3D qapi/qapi-events-ui.h qapi/qapi-events-ui.c GENERATED_FILES +=3D qapi/qapi-introspect.c qapi/qapi-introspect.h GENERATED_FILES +=3D qapi/qapi-doc.texi @@ -596,6 +600,7 @@ qapi-modules =3D $(SRC_PATH)/qapi/qapi-schema.json $(SR= C_PATH)/qapi/common.json \ $(SRC_PATH)/qapi/run-state.json \ $(SRC_PATH)/qapi/sockets.json \ $(SRC_PATH)/qapi/tpm.json \ + $(SRC_PATH)/qapi/tlimits.json \ $(SRC_PATH)/qapi/trace.json \ $(SRC_PATH)/qapi/transaction.json \ $(SRC_PATH)/qapi/ui.json @@ -618,6 +623,7 @@ qapi/qapi-types-sockets.c qapi/qapi-types-sockets.h \ qapi/qapi-types-tpm.c qapi/qapi-types-tpm.h \ qapi/qapi-types-trace.c qapi/qapi-types-trace.h \ qapi/qapi-types-transaction.c qapi/qapi-types-transaction.h \ +qapi/qapi-types-tlimits.c qapi/qapi-types-tlimits.h \ qapi/qapi-types-ui.c qapi/qapi-types-ui.h \ qapi/qapi-builtin-visit.c qapi/qapi-builtin-visit.h \ qapi/qapi-visit.c qapi/qapi-visit.h \ @@ -637,6 +643,7 @@ qapi/qapi-visit-sockets.c qapi/qapi-visit-sockets.h \ qapi/qapi-visit-tpm.c qapi/qapi-visit-tpm.h \ qapi/qapi-visit-trace.c qapi/qapi-visit-trace.h \ qapi/qapi-visit-transaction.c qapi/qapi-visit-transaction.h \ +qapi/qapi-visit-tlimits.c qapi/qapi-visit-tlimits.h \ qapi/qapi-visit-ui.c qapi/qapi-visit-ui.h \ qapi/qapi-commands.h qapi/qapi-commands.c \ qapi/qapi-commands-block-core.c qapi/qapi-commands-block-core.h \ @@ -655,6 +662,7 @@ qapi/qapi-commands-sockets.c qapi/qapi-commands-sockets= .h \ qapi/qapi-commands-tpm.c qapi/qapi-commands-tpm.h \ qapi/qapi-commands-trace.c qapi/qapi-commands-trace.h \ qapi/qapi-commands-transaction.c qapi/qapi-commands-transaction.h \ +qapi/qapi-commands-tlimits.c qapi/qapi-commands-tlimits.h \ qapi/qapi-commands-ui.c qapi/qapi-commands-ui.h \ qapi/qapi-events.c qapi/qapi-events.h \ qapi/qapi-events-block-core.c qapi/qapi-events-block-core.h \ @@ -673,6 +681,7 @@ qapi/qapi-events-sockets.c qapi/qapi-events-sockets.h \ qapi/qapi-events-tpm.c qapi/qapi-events-tpm.h \ qapi/qapi-events-trace.c qapi/qapi-events-trace.h \ qapi/qapi-events-transaction.c qapi/qapi-events-transaction.h \ +qapi/qapi-events-tlimits.c qapi/qapi-events-tlimits.h \ qapi/qapi-events-ui.c qapi/qapi-events-ui.h \ qapi/qapi-introspect.h qapi/qapi-introspect.c \ qapi/qapi-doc.texi: \ diff --git a/Makefile.objs b/Makefile.objs index 1e1ff38..682e6ba 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -20,6 +20,7 @@ util-obj-y +=3D qapi/qapi-types-sockets.o util-obj-y +=3D qapi/qapi-types-tpm.o util-obj-y +=3D qapi/qapi-types-trace.o util-obj-y +=3D qapi/qapi-types-transaction.o +util-obj-y +=3D qapi/qapi-types-tlimits.o util-obj-y +=3D qapi/qapi-types-ui.o util-obj-y +=3D qapi/qapi-builtin-visit.o util-obj-y +=3D qapi/qapi-visit.o @@ -39,6 +40,7 @@ util-obj-y +=3D qapi/qapi-visit-sockets.o util-obj-y +=3D qapi/qapi-visit-tpm.o util-obj-y +=3D qapi/qapi-visit-trace.o util-obj-y +=3D qapi/qapi-visit-transaction.o +util-obj-y +=3D qapi/qapi-visit-tlimits.o util-obj-y +=3D qapi/qapi-visit-ui.o util-obj-y +=3D qapi/qapi-events.o util-obj-y +=3D qapi/qapi-events-block-core.o @@ -57,6 +59,7 @@ util-obj-y +=3D qapi/qapi-events-sockets.o util-obj-y +=3D qapi/qapi-events-tpm.o util-obj-y +=3D qapi/qapi-events-trace.o util-obj-y +=3D qapi/qapi-events-transaction.o +util-obj-y +=3D qapi/qapi-events-tlimits.o util-obj-y +=3D qapi/qapi-events-ui.o util-obj-y +=3D qapi/qapi-introspect.o =20 @@ -154,6 +157,7 @@ common-obj-y +=3D qapi/qapi-commands-sockets.o common-obj-y +=3D qapi/qapi-commands-tpm.o common-obj-y +=3D qapi/qapi-commands-trace.o common-obj-y +=3D qapi/qapi-commands-transaction.o +common-obj-y +=3D qapi/qapi-commands-tlimits.o common-obj-y +=3D qapi/qapi-commands-ui.o common-obj-y +=3D qapi/qapi-introspect.o common-obj-y +=3D qmp.o hmp.o diff --git a/qapi/block-core.json b/qapi/block-core.json index 3abd6af..05296b0 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -8,6 +8,7 @@ { 'include': 'crypto.json' } { 'include': 'job.json' } { 'include': 'sockets.json' } +{ 'include': 'tlimits.json' } =20 ## # @SnapshotInfo: @@ -2164,54 +2165,6 @@ 'data': { '*device': 'str', '*id': 'str', '*group': 'str' } } =20 ## -# @ThrottleLimits: -# -# Limit parameters for throttling. -# Since some limit combinations are illegal, limits should always be set i= n one -# transaction. All fields are optional. When setting limits, if a field is -# missing the current value is not changed. -# -# @iops: limit total I/O operations per second -# @iops_max: I/O operations burst -# @iops_max_length: length of the iops_total_max burst period, in seconds -# It must only be set if @iops_total_max is set a= s well. -# @iops_rd: limit read operations per second -# @iops_rd_max: I/O operations read burst -# @iops_rd_max_length: length of the iops_read_max burst period, in seco= nds -# It must only be set if @iops_read_max is set as= well. -# @iops_wr: limit write operations per second -# @iops_wr_max: I/O operations write burst -# @iops_wr_max_length: length of the iops_write_max burst period, in seco= nds -# It must only be set if @iops_write_max is set a= s well. -# @bps: limit total bytes per second -# @bps_max: total bytes burst -# @bps_max_length: length of the bps_total_max burst period, in seconds. -# It must only be set if @bps_total_max is set as= well. -# @bps_rd: limit read bytes per second -# @bps_rd_max: total bytes read burst -# @bps_rd_max_length: length of the bps_read_max burst period, in secon= ds -# It must only be set if @bps_read_max is set as = well. -# @bps_wr: limit write bytes per second -# @bps_wr_max: total bytes write burst -# @bps_wr_max_length: length of the bps_write_max burst period, in secon= ds -# It must only be set if @bps_write_max is set as= well. -# @iops_size: when limiting by iops max size of an I/O in byt= es -# -# Since: 2.11 -## -{ 'struct': 'ThrottleLimits', - 'data': { '*iops' : 'int', '*iops_max' : 'int', - '*iops_max_length' : 'int', '*iops_rd' : 'int', - '*iops_rd_max' : 'int', '*iops_rd_max_length' : 'int', - '*iops_wr' : 'int', '*iops_wr_max' : 'int', - '*iops_wr_max_length' : 'int', '*bps' : 'int', - '*bps_max' : 'int', '*bps_max_length' : 'int', - '*bps_rd' : 'int', '*bps_rd_max' : 'int', - '*bps_rd_max_length' : 'int', '*bps_wr' : 'int', - '*bps_wr_max' : 'int', '*bps_wr_max_length' : 'int', - '*iops_size' : 'int' } } - -## # @block-stream: # # Copy data from a backing file into a block device. diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index 65b6dc2..e9f594e 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -90,6 +90,7 @@ { 'include': 'tpm.json' } { 'include': 'ui.json' } { 'include': 'migration.json' } +{ 'include': 'tlimits.json' } { 'include': 'transaction.json' } { 'include': 'trace.json' } { 'include': 'introspect.json' } diff --git a/qapi/tlimits.json b/qapi/tlimits.json new file mode 100644 index 0000000..ad867de --- /dev/null +++ b/qapi/tlimits.json @@ -0,0 +1,53 @@ +# -*- Mode: Python -*- + +## +# =3D=3D Throttle limits +## + +## +# @ThrottleLimits: +# +# Limit parameters for throttling. +# Since some limit combinations are illegal, limits should always be set i= n one +# transaction. All fields are optional. When setting limits, if a field is +# missing the current value is not changed. +# +# @iops: limit total I/O operations per second +# @iops_max: I/O operations burst +# @iops_max_length: length of the iops_total_max burst period, in seconds +# It must only be set if @iops_total_max is set a= s well. +# @iops_rd: limit read operations per second +# @iops_rd_max: I/O operations read burst +# @iops_rd_max_length: length of the iops_read_max burst period, in seco= nds +# It must only be set if @iops_read_max is set as= well. +# @iops_wr: limit write operations per second +# @iops_wr_max: I/O operations write burst +# @iops_wr_max_length: length of the iops_write_max burst period, in seco= nds +# It must only be set if @iops_write_max is set a= s well. +# @bps: limit total bytes per second +# @bps_max: total bytes burst +# @bps_max_length: length of the bps_total_max burst period, in seconds. +# It must only be set if @bps_total_max is set as= well. +# @bps_rd: limit read bytes per second +# @bps_rd_max: total bytes read burst +# @bps_rd_max_length: length of the bps_read_max burst period, in secon= ds +# It must only be set if @bps_read_max is set as = well. +# @bps_wr: limit write bytes per second +# @bps_wr_max: total bytes write burst +# @bps_wr_max_length: length of the bps_read_max burst period, in secon= ds +# It must only be set if @bps_read_max is set as = well. +# @iops_size: when limiting by iops max size of an I/O in byt= es +# +# Since: 2.11 +## +{ 'struct': 'ThrottleLimits', + 'data': { '*iops' : 'int', '*iops_max' : 'int', + '*iops_max_length' : 'int', '*iops_rd' : 'int', + '*iops_rd_max' : 'int', '*iops_rd_max_length' : 'int', + '*iops_wr' : 'int', '*iops_wr_max' : 'int', + '*iops_wr_max_length' : 'int', '*bps' : 'int', + '*bps_max' : 'int', '*bps_max_length' : 'int', + '*bps_rd' : 'int', '*bps_rd_max' : 'int', + '*bps_rd_max_length' : 'int', '*bps_wr' : 'int', + '*bps_wr_max' : 'int', '*bps_wr_max_length' : 'int', + '*iops_size' : 'int' } } --=20 1.8.3.1 From nobody Thu Nov 6 14:17:14 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542355682441822.3050546832883; Fri, 16 Nov 2018 00:08:02 -0800 (PST) Received: from localhost ([::1]:42635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZAX-0003Fk-3M for importer@patchew.org; Fri, 16 Nov 2018 03:08:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZ8k-0002Ka-Rt for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:06:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNZ8i-000781-3j for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:06:10 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:50275 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gNZ8h-00074O-1b for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:06:08 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 9C70D48462AAD; Fri, 16 Nov 2018 16:06:03 +0800 (CST) Received: from huawei.com (10.143.28.95) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.408.0; Fri, 16 Nov 2018 16:05:54 +0800 From: xiezhide To: Date: Fri, 16 Nov 2018 16:00:20 +0800 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.143.28.95] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH v5 5/6] fsdev-throttle-qmp: qmp interface for fsdev io 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: berto@igalia.com, armbru@redhat.com, zengcanfu@huawei.com, groug@kaod.org, aneesh.kumar@linux.vnet.ibm.com, jinxuefeng@huawei.com, chenhui.rtos@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" provides two interfaces: 1. set the IO limits for the required fsdev device 2. query info of all the fsdev devices. Signed-off-by: xiezhide --- Makefile | 27 ++++++++----- Makefile.objs | 12 ++++-- fsdev/qemu-fsdev-dummy.c | 11 +++++ fsdev/qemu-fsdev-throttle.c | 98 +++++++++++++++++++++++++++++++++++++++++= +--- fsdev/qemu-fsdev-throttle.h | 6 ++- fsdev/qemu-fsdev.c | 29 ++++++++++++++ qapi/fsdev.json | 96 +++++++++++++++++++++++++++++++++++++++++= +++ qapi/qapi-schema.json | 1 + qmp.c | 13 ++++++ 9 files changed, 272 insertions(+), 21 deletions(-) create mode 100644 qapi/fsdev.json diff --git a/Makefile b/Makefile index b546e98..e2c0e92 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,7 @@ GENERATED_FILES +=3D qapi/qapi-types-block.h qapi/qapi-ty= pes-block.c GENERATED_FILES +=3D qapi/qapi-types-char.h qapi/qapi-types-char.c GENERATED_FILES +=3D qapi/qapi-types-common.h qapi/qapi-types-common.c GENERATED_FILES +=3D qapi/qapi-types-crypto.h qapi/qapi-types-crypto.c +GENERATED_FILES +=3D qapi/qapi-types-fsdev.h qapi/qapi-types-fsdev.c GENERATED_FILES +=3D qapi/qapi-types-introspect.h qapi/qapi-types-introspe= ct.c GENERATED_FILES +=3D qapi/qapi-types-job.h qapi/qapi-types-job.c GENERATED_FILES +=3D qapi/qapi-types-migration.h qapi/qapi-types-migration= .c @@ -103,10 +104,10 @@ GENERATED_FILES +=3D qapi/qapi-types-net.h qapi/qapi-= types-net.c GENERATED_FILES +=3D qapi/qapi-types-rocker.h qapi/qapi-types-rocker.c GENERATED_FILES +=3D qapi/qapi-types-run-state.h qapi/qapi-types-run-state= .c GENERATED_FILES +=3D qapi/qapi-types-sockets.h qapi/qapi-types-sockets.c +GENERATED_FILES +=3D qapi/qapi-types-tlimits.h qapi/qapi-types-tlimits.c GENERATED_FILES +=3D qapi/qapi-types-tpm.h qapi/qapi-types-tpm.c GENERATED_FILES +=3D qapi/qapi-types-trace.h qapi/qapi-types-trace.c GENERATED_FILES +=3D qapi/qapi-types-transaction.h qapi/qapi-types-transac= tion.c -GENERATED_FILES +=3D qapi/qapi-types-tlimits.h qapi/qapi-types-tlimits.c GENERATED_FILES +=3D qapi/qapi-types-ui.h qapi/qapi-types-ui.c GENERATED_FILES +=3D qapi/qapi-builtin-visit.h qapi/qapi-builtin-visit.c GENERATED_FILES +=3D qapi/qapi-visit.h qapi/qapi-visit.c @@ -115,6 +116,7 @@ GENERATED_FILES +=3D qapi/qapi-visit-block.h qapi/qapi-= visit-block.c GENERATED_FILES +=3D qapi/qapi-visit-char.h qapi/qapi-visit-char.c GENERATED_FILES +=3D qapi/qapi-visit-common.h qapi/qapi-visit-common.c GENERATED_FILES +=3D qapi/qapi-visit-crypto.h qapi/qapi-visit-crypto.c +GENERATED_FILES +=3D qapi/qapi-visit-fsdev.h qapi/qapi-visit-fsdev.c GENERATED_FILES +=3D qapi/qapi-visit-introspect.h qapi/qapi-visit-introspe= ct.c GENERATED_FILES +=3D qapi/qapi-visit-job.h qapi/qapi-visit-job.c GENERATED_FILES +=3D qapi/qapi-visit-migration.h qapi/qapi-visit-migration= .c @@ -123,10 +125,10 @@ GENERATED_FILES +=3D qapi/qapi-visit-net.h qapi/qapi-= visit-net.c GENERATED_FILES +=3D qapi/qapi-visit-rocker.h qapi/qapi-visit-rocker.c GENERATED_FILES +=3D qapi/qapi-visit-run-state.h qapi/qapi-visit-run-state= .c GENERATED_FILES +=3D qapi/qapi-visit-sockets.h qapi/qapi-visit-sockets.c +GENERATED_FILES +=3D qapi/qapi-visit-tlimits.h qapi/qapi-visit-tlimits.c GENERATED_FILES +=3D qapi/qapi-visit-tpm.h qapi/qapi-visit-tpm.c GENERATED_FILES +=3D qapi/qapi-visit-trace.h qapi/qapi-visit-trace.c GENERATED_FILES +=3D qapi/qapi-visit-transaction.h qapi/qapi-visit-transac= tion.c -GENERATED_FILES +=3D qapi/qapi-visit-tlimits.h qapi/qapi-visit-tlimits.c GENERATED_FILES +=3D qapi/qapi-visit-ui.h qapi/qapi-visit-ui.c GENERATED_FILES +=3D qapi/qapi-commands.h qapi/qapi-commands.c GENERATED_FILES +=3D qapi/qapi-commands-block-core.h qapi/qapi-commands-bl= ock-core.c @@ -134,6 +136,7 @@ GENERATED_FILES +=3D qapi/qapi-commands-block.h qapi/qa= pi-commands-block.c GENERATED_FILES +=3D qapi/qapi-commands-char.h qapi/qapi-commands-char.c GENERATED_FILES +=3D qapi/qapi-commands-common.h qapi/qapi-commands-common= .c GENERATED_FILES +=3D qapi/qapi-commands-crypto.h qapi/qapi-commands-crypto= .c +GENERATED_FILES +=3D qapi/qapi-commands-fsdev.h qapi/qapi-commands-fsdev.c GENERATED_FILES +=3D qapi/qapi-commands-introspect.h qapi/qapi-commands-in= trospect.c GENERATED_FILES +=3D qapi/qapi-commands-job.h qapi/qapi-commands-job.c GENERATED_FILES +=3D qapi/qapi-commands-migration.h qapi/qapi-commands-mig= ration.c @@ -142,10 +145,10 @@ GENERATED_FILES +=3D qapi/qapi-commands-net.h qapi/qa= pi-commands-net.c GENERATED_FILES +=3D qapi/qapi-commands-rocker.h qapi/qapi-commands-rocker= .c GENERATED_FILES +=3D qapi/qapi-commands-run-state.h qapi/qapi-commands-run= -state.c GENERATED_FILES +=3D qapi/qapi-commands-sockets.h qapi/qapi-commands-socke= ts.c +GENERATED_FILES +=3D qapi/qapi-commands-tlimits.h qapi/qapi-commands-tlimi= ts.c GENERATED_FILES +=3D qapi/qapi-commands-tpm.h qapi/qapi-commands-tpm.c GENERATED_FILES +=3D qapi/qapi-commands-trace.h qapi/qapi-commands-trace.c GENERATED_FILES +=3D qapi/qapi-commands-transaction.h qapi/qapi-commands-t= ransaction.c -GENERATED_FILES +=3D qapi/qapi-commands-tlimits.h qapi/qapi-commands-tlimi= ts.c GENERATED_FILES +=3D qapi/qapi-commands-ui.h qapi/qapi-commands-ui.c GENERATED_FILES +=3D qapi/qapi-events.h qapi/qapi-events.c GENERATED_FILES +=3D qapi/qapi-events-block-core.h qapi/qapi-events-block-= core.c @@ -153,6 +156,7 @@ GENERATED_FILES +=3D qapi/qapi-events-block.h qapi/qapi= -events-block.c GENERATED_FILES +=3D qapi/qapi-events-char.h qapi/qapi-events-char.c GENERATED_FILES +=3D qapi/qapi-events-common.h qapi/qapi-events-common.c GENERATED_FILES +=3D qapi/qapi-events-crypto.h qapi/qapi-events-crypto.c +GENERATED_FILES +=3D qapi/qapi-events-fsdev.h qapi/qapi-events-fsdev.c GENERATED_FILES +=3D qapi/qapi-events-introspect.h qapi/qapi-events-intros= pect.c GENERATED_FILES +=3D qapi/qapi-events-job.h qapi/qapi-events-job.c GENERATED_FILES +=3D qapi/qapi-events-migration.h qapi/qapi-events-migrati= on.c @@ -161,10 +165,10 @@ GENERATED_FILES +=3D qapi/qapi-events-net.h qapi/qapi= -events-net.c GENERATED_FILES +=3D qapi/qapi-events-rocker.h qapi/qapi-events-rocker.c GENERATED_FILES +=3D qapi/qapi-events-run-state.h qapi/qapi-events-run-sta= te.c GENERATED_FILES +=3D qapi/qapi-events-sockets.h qapi/qapi-events-sockets.c +GENERATED_FILES +=3D qapi/qapi-events-tlimits.h qapi/qapi-events-tlimits.c GENERATED_FILES +=3D qapi/qapi-events-tpm.h qapi/qapi-events-tpm.c GENERATED_FILES +=3D qapi/qapi-events-trace.h qapi/qapi-events-trace.c GENERATED_FILES +=3D qapi/qapi-events-transaction.h qapi/qapi-events-trans= action.c -GENERATED_FILES +=3D qapi/qapi-events-tlimits.h qapi/qapi-events-tlimits.c GENERATED_FILES +=3D qapi/qapi-events-ui.h qapi/qapi-events-ui.c GENERATED_FILES +=3D qapi/qapi-introspect.c qapi/qapi-introspect.h GENERATED_FILES +=3D qapi/qapi-doc.texi @@ -591,6 +595,7 @@ qapi-modules =3D $(SRC_PATH)/qapi/qapi-schema.json $(SR= C_PATH)/qapi/common.json \ $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.jso= n \ $(SRC_PATH)/qapi/char.json \ $(SRC_PATH)/qapi/crypto.json \ + $(SRC_PATH)/qapi/fsdev.json \ $(SRC_PATH)/qapi/introspect.json \ $(SRC_PATH)/qapi/job.json \ $(SRC_PATH)/qapi/migration.json \ @@ -599,8 +604,8 @@ qapi-modules =3D $(SRC_PATH)/qapi/qapi-schema.json $(SR= C_PATH)/qapi/common.json \ $(SRC_PATH)/qapi/rocker.json \ $(SRC_PATH)/qapi/run-state.json \ $(SRC_PATH)/qapi/sockets.json \ - $(SRC_PATH)/qapi/tpm.json \ $(SRC_PATH)/qapi/tlimits.json \ + $(SRC_PATH)/qapi/tpm.json \ $(SRC_PATH)/qapi/trace.json \ $(SRC_PATH)/qapi/transaction.json \ $(SRC_PATH)/qapi/ui.json @@ -612,6 +617,7 @@ qapi/qapi-types-block.c qapi/qapi-types-block.h \ qapi/qapi-types-char.c qapi/qapi-types-char.h \ qapi/qapi-types-common.c qapi/qapi-types-common.h \ qapi/qapi-types-crypto.c qapi/qapi-types-crypto.h \ +qapi/qapi-types-fsdev.c qapi/qapi-types-fsdev.h \ qapi/qapi-types-introspect.c qapi/qapi-types-introspect.h \ qapi/qapi-types-job.c qapi/qapi-types-job.h \ qapi/qapi-types-migration.c qapi/qapi-types-migration.h \ @@ -620,10 +626,10 @@ qapi/qapi-types-net.c qapi/qapi-types-net.h \ qapi/qapi-types-rocker.c qapi/qapi-types-rocker.h \ qapi/qapi-types-run-state.c qapi/qapi-types-run-state.h \ qapi/qapi-types-sockets.c qapi/qapi-types-sockets.h \ +qapi/qapi-types-tlimits.c qapi/qapi-types-tlimits.h \ qapi/qapi-types-tpm.c qapi/qapi-types-tpm.h \ qapi/qapi-types-trace.c qapi/qapi-types-trace.h \ qapi/qapi-types-transaction.c qapi/qapi-types-transaction.h \ -qapi/qapi-types-tlimits.c qapi/qapi-types-tlimits.h \ qapi/qapi-types-ui.c qapi/qapi-types-ui.h \ qapi/qapi-builtin-visit.c qapi/qapi-builtin-visit.h \ qapi/qapi-visit.c qapi/qapi-visit.h \ @@ -632,6 +638,7 @@ qapi/qapi-visit-block.c qapi/qapi-visit-block.h \ qapi/qapi-visit-char.c qapi/qapi-visit-char.h \ qapi/qapi-visit-common.c qapi/qapi-visit-common.h \ qapi/qapi-visit-crypto.c qapi/qapi-visit-crypto.h \ +qapi/qapi-visit-fsdev.c qapi/qapi-visit-fsdev.h \ qapi/qapi-visit-introspect.c qapi/qapi-visit-introspect.h \ qapi/qapi-visit-job.c qapi/qapi-visit-job.h \ qapi/qapi-visit-migration.c qapi/qapi-visit-migration.h \ @@ -640,10 +647,10 @@ qapi/qapi-visit-net.c qapi/qapi-visit-net.h \ qapi/qapi-visit-rocker.c qapi/qapi-visit-rocker.h \ qapi/qapi-visit-run-state.c qapi/qapi-visit-run-state.h \ qapi/qapi-visit-sockets.c qapi/qapi-visit-sockets.h \ +qapi/qapi-visit-tlimits.c qapi/qapi-visit-tlimits.h \ qapi/qapi-visit-tpm.c qapi/qapi-visit-tpm.h \ qapi/qapi-visit-trace.c qapi/qapi-visit-trace.h \ qapi/qapi-visit-transaction.c qapi/qapi-visit-transaction.h \ -qapi/qapi-visit-tlimits.c qapi/qapi-visit-tlimits.h \ qapi/qapi-visit-ui.c qapi/qapi-visit-ui.h \ qapi/qapi-commands.h qapi/qapi-commands.c \ qapi/qapi-commands-block-core.c qapi/qapi-commands-block-core.h \ @@ -651,6 +658,7 @@ qapi/qapi-commands-block.c qapi/qapi-commands-block.h \ qapi/qapi-commands-char.c qapi/qapi-commands-char.h \ qapi/qapi-commands-common.c qapi/qapi-commands-common.h \ qapi/qapi-commands-crypto.c qapi/qapi-commands-crypto.h \ +qapi/qapi-commands-fsdev.c qapi/qapi-commands-fsdev.h \ qapi/qapi-commands-introspect.c qapi/qapi-commands-introspect.h \ qapi/qapi-commands-job.c qapi/qapi-commands-job.h \ qapi/qapi-commands-migration.c qapi/qapi-commands-migration.h \ @@ -659,10 +667,10 @@ qapi/qapi-commands-net.c qapi/qapi-commands-net.h \ qapi/qapi-commands-rocker.c qapi/qapi-commands-rocker.h \ qapi/qapi-commands-run-state.c qapi/qapi-commands-run-state.h \ qapi/qapi-commands-sockets.c qapi/qapi-commands-sockets.h \ +qapi/qapi-commands-tlimits.c qapi/qapi-commands-tlimits.h \ qapi/qapi-commands-tpm.c qapi/qapi-commands-tpm.h \ qapi/qapi-commands-trace.c qapi/qapi-commands-trace.h \ qapi/qapi-commands-transaction.c qapi/qapi-commands-transaction.h \ -qapi/qapi-commands-tlimits.c qapi/qapi-commands-tlimits.h \ qapi/qapi-commands-ui.c qapi/qapi-commands-ui.h \ qapi/qapi-events.c qapi/qapi-events.h \ qapi/qapi-events-block-core.c qapi/qapi-events-block-core.h \ @@ -670,6 +678,7 @@ qapi/qapi-events-block.c qapi/qapi-events-block.h \ qapi/qapi-events-char.c qapi/qapi-events-char.h \ qapi/qapi-events-common.c qapi/qapi-events-common.h \ qapi/qapi-events-crypto.c qapi/qapi-events-crypto.h \ +qapi/qapi-events-fsdev.c qapi/qapi-events-fsdev.h \ qapi/qapi-events-introspect.c qapi/qapi-events-introspect.h \ qapi/qapi-events-job.c qapi/qapi-events-job.h \ qapi/qapi-events-migration.c qapi/qapi-events-migration.h \ @@ -678,10 +687,10 @@ qapi/qapi-events-net.c qapi/qapi-events-net.h \ qapi/qapi-events-rocker.c qapi/qapi-events-rocker.h \ qapi/qapi-events-run-state.c qapi/qapi-events-run-state.h \ qapi/qapi-events-sockets.c qapi/qapi-events-sockets.h \ +qapi/qapi-events-tlimits.c qapi/qapi-events-tlimits.h \ qapi/qapi-events-tpm.c qapi/qapi-events-tpm.h \ qapi/qapi-events-trace.c qapi/qapi-events-trace.h \ qapi/qapi-events-transaction.c qapi/qapi-events-transaction.h \ -qapi/qapi-events-tlimits.c qapi/qapi-events-tlimits.h \ qapi/qapi-events-ui.c qapi/qapi-events-ui.h \ qapi/qapi-introspect.h qapi/qapi-introspect.c \ qapi/qapi-doc.texi: \ diff --git a/Makefile.objs b/Makefile.objs index 682e6ba..1c4bf88 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -9,6 +9,7 @@ util-obj-y +=3D qapi/qapi-types-block.o util-obj-y +=3D qapi/qapi-types-char.o util-obj-y +=3D qapi/qapi-types-common.o util-obj-y +=3D qapi/qapi-types-crypto.o +util-obj-y +=3D qapi/qapi-types-fsdev.o util-obj-y +=3D qapi/qapi-types-introspect.o util-obj-y +=3D qapi/qapi-types-job.o util-obj-y +=3D qapi/qapi-types-migration.o @@ -17,10 +18,10 @@ util-obj-y +=3D qapi/qapi-types-net.o util-obj-y +=3D qapi/qapi-types-rocker.o util-obj-y +=3D qapi/qapi-types-run-state.o util-obj-y +=3D qapi/qapi-types-sockets.o +util-obj-y +=3D qapi/qapi-types-tlimits.o util-obj-y +=3D qapi/qapi-types-tpm.o util-obj-y +=3D qapi/qapi-types-trace.o util-obj-y +=3D qapi/qapi-types-transaction.o -util-obj-y +=3D qapi/qapi-types-tlimits.o util-obj-y +=3D qapi/qapi-types-ui.o util-obj-y +=3D qapi/qapi-builtin-visit.o util-obj-y +=3D qapi/qapi-visit.o @@ -29,6 +30,7 @@ util-obj-y +=3D qapi/qapi-visit-block.o util-obj-y +=3D qapi/qapi-visit-char.o util-obj-y +=3D qapi/qapi-visit-common.o util-obj-y +=3D qapi/qapi-visit-crypto.o +util-obj-y +=3D qapi/qapi-visit-fsdev.o util-obj-y +=3D qapi/qapi-visit-introspect.o util-obj-y +=3D qapi/qapi-visit-job.o util-obj-y +=3D qapi/qapi-visit-migration.o @@ -37,10 +39,10 @@ util-obj-y +=3D qapi/qapi-visit-net.o util-obj-y +=3D qapi/qapi-visit-rocker.o util-obj-y +=3D qapi/qapi-visit-run-state.o util-obj-y +=3D qapi/qapi-visit-sockets.o +util-obj-y +=3D qapi/qapi-visit-tlimits.o util-obj-y +=3D qapi/qapi-visit-tpm.o util-obj-y +=3D qapi/qapi-visit-trace.o util-obj-y +=3D qapi/qapi-visit-transaction.o -util-obj-y +=3D qapi/qapi-visit-tlimits.o util-obj-y +=3D qapi/qapi-visit-ui.o util-obj-y +=3D qapi/qapi-events.o util-obj-y +=3D qapi/qapi-events-block-core.o @@ -48,6 +50,7 @@ util-obj-y +=3D qapi/qapi-events-block.o util-obj-y +=3D qapi/qapi-events-char.o util-obj-y +=3D qapi/qapi-events-common.o util-obj-y +=3D qapi/qapi-events-crypto.o +util-obj-y +=3D qapi/qapi-events-fsdev.o util-obj-y +=3D qapi/qapi-events-introspect.o util-obj-y +=3D qapi/qapi-events-job.o util-obj-y +=3D qapi/qapi-events-migration.o @@ -56,10 +59,10 @@ util-obj-y +=3D qapi/qapi-events-net.o util-obj-y +=3D qapi/qapi-events-rocker.o util-obj-y +=3D qapi/qapi-events-run-state.o util-obj-y +=3D qapi/qapi-events-sockets.o +util-obj-y +=3D qapi/qapi-events-tlimits.o util-obj-y +=3D qapi/qapi-events-tpm.o util-obj-y +=3D qapi/qapi-events-trace.o util-obj-y +=3D qapi/qapi-events-transaction.o -util-obj-y +=3D qapi/qapi-events-tlimits.o util-obj-y +=3D qapi/qapi-events-ui.o util-obj-y +=3D qapi/qapi-introspect.o =20 @@ -146,6 +149,7 @@ common-obj-y +=3D qapi/qapi-commands-block.o common-obj-y +=3D qapi/qapi-commands-char.o common-obj-y +=3D qapi/qapi-commands-common.o common-obj-y +=3D qapi/qapi-commands-crypto.o +common-obj-y +=3D qapi/qapi-commands-fsdev.o common-obj-y +=3D qapi/qapi-commands-introspect.o common-obj-y +=3D qapi/qapi-commands-job.o common-obj-y +=3D qapi/qapi-commands-migration.o @@ -154,10 +158,10 @@ common-obj-y +=3D qapi/qapi-commands-net.o common-obj-y +=3D qapi/qapi-commands-rocker.o common-obj-y +=3D qapi/qapi-commands-run-state.o common-obj-y +=3D qapi/qapi-commands-sockets.o +common-obj-y +=3D qapi/qapi-commands-tlimits.o common-obj-y +=3D qapi/qapi-commands-tpm.o common-obj-y +=3D qapi/qapi-commands-trace.o common-obj-y +=3D qapi/qapi-commands-transaction.o -common-obj-y +=3D qapi/qapi-commands-tlimits.o common-obj-y +=3D qapi/qapi-commands-ui.o common-obj-y +=3D qapi/qapi-introspect.o common-obj-y +=3D qmp.o hmp.o diff --git a/fsdev/qemu-fsdev-dummy.c b/fsdev/qemu-fsdev-dummy.c index 489cd29..9a90960 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 "qapi/qapi-commands-fsdev.h" =20 int qemu_fsdev_add(QemuOpts *opts, Error **errp) { return 0; } + +void qmp_fsdev_set_io_throttle(FsdevIOThrottle *arg, Error **errp) +{ + return; +} + +FsdevIOThrottleList *qmp_query_fsdev_io_throttle(Error **errp) +{ + return NULL; +} diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index 6a4108a..720fea9 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -17,6 +17,7 @@ #include "qemu-fsdev-throttle.h" #include "qemu/iov.h" #include "qemu/option.h" +#include "qemu/main-loop.h" #include "qemu/throttle-options.h" =20 static void fsdev_throttle_read_timer_cb(void *opaque) @@ -31,6 +32,94 @@ static void fsdev_throttle_write_timer_cb(void *opaque) qemu_co_enter_next(&fst->throttled_reqs[true], NULL); } =20 +typedef struct { + FsThrottle *fst; + bool is_write; +} RestartData; + +static bool coroutine_fn throttle_co_restart_queue(FsThrottle *fst, + bool is_write) +{ + return qemu_co_queue_next(&fst->throttled_reqs[is_write]); +} + +static void schedule_next_request(FsThrottle *fst, bool is_write) +{ + bool must_wait =3D throttle_schedule_timer(&fst->ts, &fst->tt, is_writ= e); + if (!must_wait) { + if (qemu_in_coroutine() && + throttle_co_restart_queue(fst, is_write)) { + return; + } else { + int64_t now =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); + timer_mod(fst->tt.timers[is_write], now); + } + } +} + +static void coroutine_fn throttle_restart_queue_entry(void *opaque) +{ + RestartData *data =3D opaque; + bool is_write =3D data->is_write; + bool empty_queue =3D !throttle_co_restart_queue(data->fst, is_write); + if (empty_queue) { + schedule_next_request(data->fst, is_write); + } +} + +static void throttle_restart_queues(FsThrottle *fst) +{ + Coroutine *co; + RestartData rd =3D { + .fst =3D fst, + .is_write =3D true + }; + co =3D qemu_coroutine_create(throttle_restart_queue_entry, &rd); + aio_co_enter(fst->ctx, co); + rd.is_write =3D false; + co =3D qemu_coroutine_create(throttle_restart_queue_entry, &rd); + aio_co_enter(fst->ctx, co); +} + +static void coroutine_fn fsdev_throttle_config(FsThrottle *fst) +{ + if (throttle_enabled(&fst->cfg)) { + throttle_config(&fst->ts, QEMU_CLOCK_REALTIME, &fst->cfg); + } else { + throttle_restart_queues(fst); + } +} + +void fsdev_set_io_throttle(FsdevIOThrottle *arg, FsThrottle *fst, Error **= errp) +{ + ThrottleConfig cfg; + + throttle_get_config(&fst->ts, &cfg); + throttle_limits_to_config(qapi_FsdevIOThrottle_base(arg), &cfg, errp); + + if (*errp =3D=3D NULL) { + fst->cfg =3D cfg; + if (!throttle_timers_are_initialized(&fst->tt)) { + fsdev_throttle_init(fst); + } else { + fsdev_throttle_config(fst); + } + } +} + +void fsdev_get_io_throttle(FsThrottle *fst, FsdevIOThrottle **fs9pcfg, + char *fsdevice) +{ + ThrottleConfig cfg =3D fst->cfg; + ThrottleLimits *tlimits; + FsdevIOThrottle *fscfg =3D g_malloc(sizeof(*fscfg)); + tlimits =3D qapi_FsdevIOThrottle_base(fscfg); + fscfg->has_id =3D true; + fscfg->id =3D g_strdup(fsdevice); + throttle_config_to_limits(&cfg, tlimits); + *fs9pcfg =3D fscfg; +} + void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **er= rp) { throttle_parse_options(&fst->cfg, opts); @@ -41,8 +130,9 @@ void fsdev_throttle_init(FsThrottle *fst) { if (throttle_enabled(&fst->cfg)) { throttle_init(&fst->ts); + fst->ctx =3D qemu_get_aio_context(); throttle_timers_init(&fst->tt, - qemu_get_aio_context(), + fst->ctx, QEMU_CLOCK_REALTIME, fsdev_throttle_read_timer_cb, fsdev_throttle_write_timer_cb, @@ -63,11 +153,7 @@ void coroutine_fn fsdev_co_throttle_request(FsThrottle = *fst, bool is_write, } =20 throttle_account(&fst->ts, is_write, iov_size(iov, iovcnt)); - - if (!qemu_co_queue_empty(&fst->throttled_reqs[is_write]) && - !throttle_schedule_timer(&fst->ts, &fst->tt, is_write)) { - qemu_co_queue_next(&fst->throttled_reqs[is_write]); - } + schedule_next_request(fst, is_write); } } =20 diff --git a/fsdev/qemu-fsdev-throttle.h b/fsdev/qemu-fsdev-throttle.h index 4e83bda..7107769 100644 --- a/fsdev/qemu-fsdev-throttle.h +++ b/fsdev/qemu-fsdev-throttle.h @@ -15,15 +15,15 @@ #ifndef _FSDEV_THROTTLE_H #define _FSDEV_THROTTLE_H =20 -#include "block/aio.h" -#include "qemu/main-loop.h" #include "qemu/coroutine.h" #include "qemu/throttle.h" +#include "qapi/qapi-types-fsdev.h" =20 typedef struct FsThrottle { ThrottleState ts; ThrottleTimers tt; ThrottleConfig cfg; + AioContext *ctx; CoQueue throttled_reqs[2]; } FsThrottle; =20 @@ -35,4 +35,6 @@ void coroutine_fn fsdev_co_throttle_request(FsThrottle *,= bool , struct iovec *, int); =20 void fsdev_throttle_cleanup(FsThrottle *); +void fsdev_set_io_throttle(FsdevIOThrottle *, FsThrottle *, Error **errp); +void fsdev_get_io_throttle(FsThrottle *, FsdevIOThrottle **iothp, char *); #endif /* _FSDEV_THROTTLE_H */ diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index 7a3b87c..609d8fc 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -17,6 +17,7 @@ #include "qemu/config-file.h" #include "qemu/error-report.h" #include "qemu/option.h" +#include "qapi/qapi-commands-fsdev.h" =20 static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries= =3D QTAILQ_HEAD_INITIALIZER(fsdriver_entries); @@ -99,3 +100,31 @@ FsDriverEntry *get_fsdev_fsentry(char *id) } return NULL; } + +void qmp_fsdev_set_io_throttle(FsdevIOThrottle *arg, Error **errp) +{ + FsDriverEntry *fse; + + fse =3D get_fsdev_fsentry(arg->has_id ? arg->id : NULL); + if (!fse) { + error_setg(errp, "Not a valid fsdev device"); + return; + } + + fsdev_set_io_throttle(arg, &fse->fst, errp); +} + +FsdevIOThrottleList *qmp_query_fsdev_io_throttle(Error **errp) +{ + FsdevIOThrottleList *head =3D NULL, *p_next; + struct FsDriverListEntry *fsle; + + QTAILQ_FOREACH(fsle, &fsdriver_entries, next) { + p_next =3D g_new0(FsdevIOThrottleList, 1); + fsdev_get_io_throttle(&fsle->fse.fst, &p_next->value, + fsle->fse.fsdev_id); + p_next->next =3D head; + head =3D p_next; + } + return head; +} diff --git a/qapi/fsdev.json b/qapi/fsdev.json new file mode 100644 index 0000000..5c8e7de --- /dev/null +++ b/qapi/fsdev.json @@ -0,0 +1,96 @@ +# -*- Mode: Python -*- + +## +# =3D=3D QAPI fsdev definitions +## + +{ 'include': 'tlimits.json' } + +## +# @FsdevIOThrottle: +# +# A set of parameters describing fsdev throttling. +# +# @id: device id +# +# Since: 3.2 +## +{ 'struct': 'FsdevIOThrottle', + 'base': 'ThrottleLimits', + 'data': { '*id': 'str' } } + +## +# @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, GenericError +# +# Since: 3.2 +# +# 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': 'FsdevIOThrottle' } +## +# @query-fsdev-io-throttle: +# +# Returns: a list of @IOThrottle describing I/O throttle +# values of each fsdev device +# +# Since: 3.2 +# +# 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': [ 'FsdevIOThrottle' ] } diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index e9f594e..8fce6d9 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -95,3 +95,4 @@ { 'include': 'trace.json' } { 'include': 'introspect.json' } { 'include': 'misc.json' } +{ 'include': 'fsdev.json' } diff --git a/qmp.c b/qmp.c index e7c0a2f..3f3171a 100644 --- a/qmp.c +++ b/qmp.c @@ -32,6 +32,7 @@ #include "qom/qom-qobject.h" #include "qapi/error.h" #include "qapi/qapi-commands-block-core.h" +#include "qapi/qapi-commands-fsdev.h" #include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qdict.h" @@ -737,3 +738,15 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp) =20 return mem_info; } + +#if defined(_WIN64) || defined(_WIN32) || defined(__FreeBSD__) +void qmp_fsdev_set_io_throttle(FsdevIOThrottle *arg, Error **errp) +{ + return; +} + +FsdevIOThrottleList *qmp_query_fsdev_io_throttle(Error **errp) +{ + return NULL; +} +#endif --=20 1.8.3.1 From nobody Thu Nov 6 14:17:14 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542355871574304.887406579923; Fri, 16 Nov 2018 00:11:11 -0800 (PST) Received: from localhost ([::1]:42652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZDa-00063p-AG for importer@patchew.org; Fri, 16 Nov 2018 03:11:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZ94-0002aI-Iy for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:06:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNZ8v-0007Kb-IS for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:06:26 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:50365 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gNZ8u-0007FF-92 for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:06:20 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 44CC0F0C0B515; Fri, 16 Nov 2018 16:06:14 +0800 (CST) Received: from huawei.com (10.143.28.95) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 16 Nov 2018 16:06:08 +0800 From: xiezhide To: Date: Fri, 16 Nov 2018 16:00:33 +0800 Message-ID: <05988243066ce14c5f78799952aba7fd33af35d3.1542384802.git.xiezhide@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.143.28.95] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH v5 6/6] fsdev-throttle-qmp: hmp interface for fsdev io 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: berto@igalia.com, armbru@redhat.com, zengcanfu@huawei.com, groug@kaod.org, aneesh.kumar@linux.vnet.ibm.com, jinxuefeng@huawei.com, chenhui.rtos@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" introduces io throttling hmp interfaces for the fsdev devices Signed-off-by: xiezhide --- hmp-commands-info.hx | 15 ++++++++++ hmp-commands.hx | 15 ++++++++++ hmp.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++--= ---- hmp.h | 4 +++ 4 files changed, 107 insertions(+), 8 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index cbee8b9..eaf0ff5 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -100,6 +100,21 @@ STEXI Show progress of ongoing block device operations. ETEXI =20 +#if defined(CONFIG_VIRTFS) + { + .name =3D "fsdev_iothrottle", + .args_type =3D "", + .params =3D "", + .help =3D "show fsdev iothrottle information", + .cmd =3D hmp_info_fsdev_iothrottle, + }, +#endif +STEXI +@item info fsdev_iothrottle +@findex fsdev_iothrottle +Show fsdev device throttle info. +ETEXI + { .name =3D "registers", .args_type =3D "cpustate_all:-a", diff --git a/hmp-commands.hx b/hmp-commands.hx index db0c681..40ca7fe 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1716,6 +1716,21 @@ Change I/O throttle limits for a block drive to @var= {bps} @var{bps_rd} @var{bps_ @var{device} can be a block device name, a qdev ID or a QOM path. 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 fs devices", + .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 fs devices to @var{bps} @var{bps_rd} @var= {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 7828f93..7162d87 100644 --- a/hmp.c +++ b/hmp.c @@ -38,6 +38,7 @@ #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-commands-fsdev.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qapi/string-input-visitor.h" @@ -1886,18 +1887,22 @@ void hmp_change(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } =20 +static void hmp_initialize_throttle_limits(ThrottleLimits *iot, + const QDict *qdict) +{ + 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; char *device =3D (char *) qdict_get_str(qdict, "device"); - BlockIOThrottle throttle =3D { - .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"), - }; + BlockIOThrottle throttle =3D {0}; =20 /* qmp_block_set_io_throttle has separate parameters for the * (deprecated) block device name and the qdev ID but the HMP @@ -1910,10 +1915,70 @@ void hmp_block_set_io_throttle(Monitor *mon, const = QDict *qdict) throttle.id =3D device; } =20 + hmp_initialize_throttle_limits(qapi_BlockIOThrottle_base(&throttle), q= dict); qmp_block_set_io_throttle(&throttle, &err); hmp_handle_error(mon, &err); } =20 +#ifdef CONFIG_VIRTFS +void hmp_fsdev_set_io_throttle(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + ThrottleLimits *tlimits; + FsdevIOThrottle throttle =3D { + .has_id =3D true, + .id =3D (char *) qdict_get_str(qdict, "device"), + }; + + tlimits =3D qapi_FsdevIOThrottle_base(&throttle); + hmp_initialize_throttle_limits(tlimits, qdict); + qmp_fsdev_set_io_throttle(&throttle, &err); + hmp_handle_error(mon, &err); +} + +static void print_fsdev_throttle_config(Monitor *mon, FsdevIOThrottle *fsc= fg) +{ + 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 + "\n", + 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); +} + +void hmp_info_fsdev_iothrottle(Monitor *mon, const QDict *qdict) +{ + FsdevIOThrottleList *fsdev_list, *info; + fsdev_list =3D qmp_query_fsdev_io_throttle(NULL); + + for (info =3D fsdev_list; info; info =3D info->next) { + print_fsdev_throttle_config(mon, info->value); + } + qapi_free_FsdevIOThrottleList(fsdev_list); +} +#endif + void hmp_block_stream(Monitor *mon, const QDict *qdict) { Error *error =3D NULL; diff --git a/hmp.h b/hmp.h index 5f1addc..9330e11 100644 --- a/hmp.h +++ b/hmp.h @@ -91,6 +91,10 @@ void hmp_block_job_cancel(Monitor *mon, const QDict *qdi= ct); void hmp_block_job_pause(Monitor *mon, const QDict *qdict); void hmp_block_job_resume(Monitor *mon, const QDict *qdict); void hmp_block_job_complete(Monitor *mon, const QDict *qdict); +#ifdef CONFIG_VIRTFS +void hmp_fsdev_set_io_throttle(Monitor *mon, const QDict *qdict); +void hmp_info_fsdev_iothrottle(Monitor *mon, const QDict *qdict); +#endif void hmp_migrate(Monitor *mon, const QDict *qdict); void hmp_device_add(Monitor *mon, const QDict *qdict); void hmp_device_del(Monitor *mon, const QDict *qdict); --=20 1.8.3.1