From nobody Mon Apr 29 14:08:52 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 149787807888147.974869170097804; Mon, 19 Jun 2017 06:14:38 -0700 (PDT) Received: from localhost ([::1]:42610 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMwVm-0004RE-B2 for importer@patchew.org; Mon, 19 Jun 2017 09:14:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMwU2-00035t-9x for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMwTz-0001qC-P2 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:46 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:36298) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMwTz-0001pL-Fb for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:43 -0400 Received: by mail-wr0-x244.google.com with SMTP id 77so13435894wrb.3 for ; Mon, 19 Jun 2017 06:12:43 -0700 (PDT) Received: from centos-minion-1.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id n71sm13459351wrb.62.2017.06.19.06.12.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 06:12: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=PvV10oUJdrbzMzl8H8APQuVCKUFo4VjO1G//6azjSCY=; b=YtCF/VNkcwQC2D9X3oPA1UtF8DcNUeacGmWOqtdtN9h3aS/MHIr73ZJ+wcq8pQBs4H jls3nev4kKKRoXQ6yEy/9UdgNTz0gyiQRlAxgoFPWuRCcurn2oylJWeMpEA1gn/Uwg0w SNwAOPbsNhne62EFa+uXtrL29+wuUD0iAXypayAGT4izwFPypLv0oE26MUG0pIghaay1 2TI3TquJ0znR3uupA1ghKhgE46jwx4Wqr9tazQJEoY9RQbWwTdihc7b50mcD+mdGFwPR FBCh/m6SPqItC53whQRysVqjWhO6usl4FxjZyaDUfETCx0AgPrB4/d38lyZF20ZrQi7v 52/w== 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=PvV10oUJdrbzMzl8H8APQuVCKUFo4VjO1G//6azjSCY=; b=VEp5Q7AM4/rXO7+HKF8T44NDKrPV+EQA9xihwV5mP20IoUzRKg4paYTHaKCtEOC4BX AQ9v/nf94hjJyPZNRJOOPpMUPUKJXoHrGE3KL/W3BO9VfLZ5Z428dePb0O+GvbQ6erjI CCnYEKXPmKtUWhChprQ8V4+YU6nrQNUpLyohTBt/euFJv3LcIvGTPJoOkyW6wMMYIl6D eBkK8xFDx355YeOafuOgR0EmuW0jy6pp4ioznCMYqpIZAHx4AwuVn+XRPie87C2HZ1/q LPKBPXnoHyoJ2ILwRgUckC/118EgfgT5J5C00i/mF7MKEn9aRFGEI2nqTK5Y7TOUSLv+ DMqw== X-Gm-Message-State: AKS2vOwJj5snyVCxKaTQtlabkgEOaYdbu8TRLdV3/n5eFXrFoa7qesyA zH/3ETLA2CCU2g== X-Received: by 10.223.171.25 with SMTP id q25mr5374038wrc.89.1497877962538; Mon, 19 Jun 2017 06:12:42 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Mon, 19 Jun 2017 09:11:32 -0400 Message-Id: <1497877896-35700-2-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1497877896-35700-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1497877896-35700-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:c0c::244 Subject: [Qemu-devel] [PATCH v5 1/5] 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 patch factor out the duplicate throttle code that was present in block and fsdev devices. Signed-off-by: Pradeep Jagadeesh Reviewed-by: Alberto Garcia --- blockdev.c | 44 +----------------------------------- fsdev/qemu-fsdev-throttle.c | 43 +---------------------------------- fsdev/qemu-fsdev-throttle.h | 1 + include/qemu/throttle-options.h | 4 ++++ util/throttle.c | 50 +++++++++++++++++++++++++++++++++++++= ++++ 5 files changed, 57 insertions(+), 85 deletions(-) diff --git a/blockdev.c b/blockdev.c index 6472548..5db9e5c 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); - + throttle_parse_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 7ae4e86..da9c225 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -31,48 +31,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/fsdev/qemu-fsdev-throttle.h b/fsdev/qemu-fsdev-throttle.h index e418643..c493e83 100644 --- a/fsdev/qemu-fsdev-throttle.h +++ b/fsdev/qemu-fsdev-throttle.h @@ -20,6 +20,7 @@ #include "qemu/coroutine.h" #include "qapi/error.h" #include "qemu/throttle.h" +#include "qemu/throttle-options.h" =20 typedef struct FsThrottle { ThrottleState ts; diff --git a/include/qemu/throttle-options.h b/include/qemu/throttle-option= s.h index 3133d1c..565553a 100644 --- a/include/qemu/throttle-options.h +++ b/include/qemu/throttle-options.h @@ -10,6 +10,8 @@ #ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H =20 +#include "qemu/throttle.h" + #define THROTTLE_OPTS \ { \ .name =3D "throttling.iops-total",\ @@ -89,4 +91,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/util/throttle.c b/util/throttle.c index 3570ed2..ebe9dd0 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -514,3 +514,53 @@ void throttle_account(ThrottleState *ts, bool is_write= , uint64_t size) } } =20 +/* 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, "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 From nobody Mon Apr 29 14:08:52 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 1497878074091483.3416507336992; Mon, 19 Jun 2017 06:14:34 -0700 (PDT) Received: from localhost ([::1]:42609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMwVk-0004PH-6e for importer@patchew.org; Mon, 19 Jun 2017 09:14:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMwU2-00035v-At for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMwU0-0001ql-RG for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:46 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:34882) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMwU0-0001qG-HF for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:44 -0400 Received: by mail-wr0-x241.google.com with SMTP id z45so13434521wrb.2 for ; Mon, 19 Jun 2017 06:12:44 -0700 (PDT) Received: from centos-minion-1.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id n71sm13459351wrb.62.2017.06.19.06.12.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 06:12: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=4cI+Uie1cX7ItWfc9sFPksZ7JFWD28KM2UjOw2Nk3p0=; b=AeKE60VhbpxAw8BfUQcDYe+p7YkcRqm9cVUweO5kh+2F3Rc1z4y1qleOfIJ6bGwTCV 57/1WgZksNfeANaiPde4UB+0GXcilLWUKuCH7ne0HUOaHBBabZMHq1K3zpbrnaOjbHpu ru40dVnmGIFQGhmaBMg/tRnmnzi2M8J4hzZ/it+B1AKBicapBoNyTPVU23GhCTSz28PK xtXXx/w65RmvSWhCy9F21cICZHYLOoP183kr++WFjKCZrUsNgCgQW6s2M/PoKJwxqA9k bSmLeHnGR/0yViAoUrZH6KAVk4rRG8rbAhOWFGp7NMZPuX7AQddTclz34El2Uilq+08Y ouuw== 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=4cI+Uie1cX7ItWfc9sFPksZ7JFWD28KM2UjOw2Nk3p0=; b=l1lzS+gNwVBazTg9abJLE61GzDGmZ/sJpW9wDt8Kn7l5sYJupSGdapHXx9L+D4foF0 8biuvCxFwe92y5glymuY9m0HuYBZH0+Wo965uIcgzCoQ4JGPvdQcWDF729RqsgkKvE0Q dAb1Q4idcmPTQBznW7bZPaIhVzety9u+YGj31z8VzLykMVbjiBMOzJGnczq1/6PPQM7O qOpEnnGLaiq9Ew4TH8UkByuzahQYcEUhVgsAzfyvQrd281ty5JkAAh+zne/7M3MMRd91 TcevfrvVnaO8wdpx9erZJTKSeLbOm07pQICQQEGJXtTL9xw8HVtBnv3A4imfG8001UdZ lHvw== X-Gm-Message-State: AKS2vOxHkt1YiNadfMYkfC4RGv8TXOSzTc7ya/g65w7ePzgfY974S0mD /UvZ8X/U4fYBJQ== X-Received: by 10.223.148.97 with SMTP id 88mr15068027wrq.137.1497877963439; Mon, 19 Jun 2017 06:12:43 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Mon, 19 Jun 2017 09:11:33 -0400 Message-Id: <1497877896-35700-3-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1497877896-35700-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1497877896-35700-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:c0c::241 Subject: [Qemu-devel] [PATCH v5 2/5] qmp: 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 patch 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 Reviewed-by: Greg Kurz Reviewed-by: Eric Blake --- qapi/block-core.json | 76 ++------------------------------------------- qapi/iothrottle.json | 88 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 91 insertions(+), 73 deletions(-) create mode 100644 qapi/iothrottle.json diff --git a/qapi/block-core.json b/qapi/block-core.json index f85c223..9320974 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: @@ -1761,84 +1762,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..0f067c3 --- /dev/null +++ b/qapi/iothrottle.json @@ -0,0 +1,88 @@ +# -*- Mode: Python -*- + +## +# =3D=3D QAPI IOThrottle definitions +## + +## +# @IOThrottle: +# +# A set of parameters describing IO throttling +# +# @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 Mon Apr 29 14:08:52 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 1497878285128260.12486030358957; Mon, 19 Jun 2017 06:18:05 -0700 (PDT) Received: from localhost ([::1]:42631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMwZ9-0000uF-Mq for importer@patchew.org; Mon, 19 Jun 2017 09:18:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMwU3-00036o-Do for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMwU1-0001rT-M3 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:47 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:34884) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMwU1-0001qf-Ch for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:45 -0400 Received: by mail-wr0-x242.google.com with SMTP id z45so13434600wrb.2 for ; Mon, 19 Jun 2017 06:12:45 -0700 (PDT) Received: from centos-minion-1.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id n71sm13459351wrb.62.2017.06.19.06.12.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 06:12:43 -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=ALk9mMHmYHjp5vM5gUGfIcNvCjQbx8lFZtjgkfpOvB0=; b=Q4/wXmfVDSCyhUy2VsrtbHLYIYVNnAGMNRr1P9gyPcTo/9Fc8rP+NTocHHpsYxuBXt SPiyzUsBTcz7+8e8S6UOLS2WI4ZyOteTBc9+xRe12gBwqVLv3/TOHmjMSBKgKFqpPc+/ tSCMSSGkb8luYKu10jCVkyen+u5cYrmAnvK1AlP2L4rkW09FlMopjtSz055uKe10qiD1 NA+0APppAN4EwZII9GCPhGBtc1RsIIS6wCQhuW+bFrYUOkqMXOYsLm0g6jzoluW/YXil osZOq+hvmNLVAkAX1ufEpPQE9u1FHXag84jC2T+AsAsqe9GTqV0UzgfneoTYX3yIvYh3 unEg== 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=ALk9mMHmYHjp5vM5gUGfIcNvCjQbx8lFZtjgkfpOvB0=; b=qYX6IfeBh1pgRovtgmbPdXj2xGo9XMuIeUasDwrAuD3tMVBUizenYohhv7Qkd9ltk4 yZ4zAbNzjZ81/Emx8iyBcshCN9eDyE6r58bT+T5wE05/KvYKQ5X4NnxtSXUg3XaWbonB TyE+R9+tZvDtxMY2aUqnMnH2jt8ZP1mYqPcXiYJAl9PTTNfFWNeIQMTa/Grt0BXlr6Rm b+qPXB/N3ofNbz48nv0mGcrzpud8bzjyIOS1uxQtWIqnzzP4epcjj6XxpeoUN056yQl3 nPEAHZQdbB3sKbAkaqGC+DCV7y/Jgky8CNhoXJ3V+8EeECIeRrIrh/QzpD9r44elrNE4 HutA== X-Gm-Message-State: AKS2vOyNnAMte08mHx9awMRIuGo91H4xNT4Gs3AyGmbT80+lL6d5d5RB JlLwKgLXJTB6Mw== X-Received: by 10.28.170.193 with SMTP id t184mr15889169wme.124.1497877964351; Mon, 19 Jun 2017 06:12:44 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Mon, 19 Jun 2017 09:11:34 -0400 Message-Id: <1497877896-35700-4-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1497877896-35700-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1497877896-35700-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:c0c::242 Subject: [Qemu-devel] [PATCH v5 3/5] 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 patch 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 +++--------------------------------- hmp.c | 21 ++++++++++----- include/qemu/throttle-options.h | 3 +++ util/throttle.c | 60 +++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 81 insertions(+), 56 deletions(-) diff --git a/blockdev.c b/blockdev.c index 5db9e5c..3d06e9e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2593,6 +2593,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, @@ -2610,56 +2611,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); + throttle_set_io_limits(&cfg, iothrottle); =20 if (!throttle_is_valid(&cfg, errp)) { goto out; diff --git a/hmp.c b/hmp.c index 8c72c58..220d301 100644 --- a/hmp.c +++ b/hmp.c @@ -1749,20 +1749,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); } diff --git a/include/qemu/throttle-options.h b/include/qemu/throttle-option= s.h index 565553a..e94ea39 100644 --- a/include/qemu/throttle-options.h +++ b/include/qemu/throttle-options.h @@ -11,6 +11,7 @@ #define THROTTLE_OPTIONS_H =20 #include "qemu/throttle.h" +#include "qmp-commands.h" =20 #define THROTTLE_OPTS \ { \ @@ -93,4 +94,6 @@ =20 void throttle_parse_options(ThrottleConfig *, QemuOpts *); =20 +void throttle_set_io_limits(ThrottleConfig *, IOThrottle *); + #endif diff --git a/util/throttle.c b/util/throttle.c index ebe9dd0..2cf9ec5 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -27,6 +27,7 @@ #include "qemu/throttle.h" #include "qemu/timer.h" #include "block/aio.h" +#include "qemu/throttle-options.h" =20 /* This function make a bucket leak * @@ -564,3 +565,62 @@ void throttle_parse_options(ThrottleConfig *throttle_c= fg, QemuOpts *opts) throttle_cfg->op_size =3D qemu_opt_get_number(opts, "throttling.iops-size", 0); } + +/* set the throttle limits + * + * @arg: iothrottle limits + * @cfg: throttle configuration + */ +void throttle_set_io_limits(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 Mon Apr 29 14:08:52 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 1497878220990612.726926791514; Mon, 19 Jun 2017 06:17:00 -0700 (PDT) Received: from localhost ([::1]:42627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMwY6-00072w-Fp for importer@patchew.org; Mon, 19 Jun 2017 09:16:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMwU4-00037m-JL for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMwU2-0001sY-Fw for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:48 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:33391) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMwU2-0001rL-67 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:46 -0400 Received: by mail-wr0-x244.google.com with SMTP id x23so13444250wrb.0 for ; Mon, 19 Jun 2017 06:12:46 -0700 (PDT) Received: from centos-minion-1.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id n71sm13459351wrb.62.2017.06.19.06.12.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 06:12:44 -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=t6XQhAwdffhtMlHMO4T0LD2Dip4EpiMDkh5ZXZKP6XE=; b=EUkadsdjWSTNeNvdBie62FfpOZdrVYV4iV2LOAHZrrTwuTX2HI6l6/FAclhhHr0d66 J7IO3WY5R4Q/TEeqW+qoQxhpxT9wQ1X2HSomLTGjRw/rpIHA5LT+2eLU24hXvtj9vNNc JFbbZHquejaUhUqn0I3hmXvevDZeGmFHF+03RuAv2GI33ZZfz3mE3IH3YY8InyUD8Aud 6fbPw5hRzL5w+8AaNTGWMONxyXRp6SVuAIpdtrqI6iFBsiNH36jLVUasCwH5WDwUEV6z 8rXe+yfjCXkbH9T2AzpCGWyVTYfNzgpG0pnp4qiQzeogKF+7QtflpefZ74461lIA7MKj oLrg== 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=t6XQhAwdffhtMlHMO4T0LD2Dip4EpiMDkh5ZXZKP6XE=; b=RiTPi017T+aCIEC/x3rNDduN9m4Li5F+OT7BvfgM3+gtxTAc9buyu1aujWhTr8tLW1 XYyL+TzALw7HH+355TVwXArWa6i7x+prlEk/rnWxB7KS4UnHL10U6DY3p0B84bRmzJmJ lbnLM37FZM8kur3DE6rIJY2WPXu/pgO9c1A2ByGGll3hGwMeeTCJzM7PEgAyZzZL/7As du6fS/S8FXgqVPWQE1iY6omAZ9PII+ZAGS4Y8dFTAcf0Th1tbZ1suDud+9BSvg4eNrym 9526ga2t4KzxrNO8LnZoh2gjGhJXivycwR7J51KxPSjcNzdDfgCmD3tQDryr9ZuxR1uX 0zow== X-Gm-Message-State: AKS2vOzneN81JJ+sLup6LzR0CB3rGGBiQgO2CdnK83ku8OUUrTcstmZ5 j4yi7JDHZA1kd2Dy X-Received: by 10.28.138.16 with SMTP id m16mr14235884wmd.99.1497877965270; Mon, 19 Jun 2017 06:12:45 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Mon, 19 Jun 2017 09:11:35 -0400 Message-Id: <1497877896-35700-5-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1497877896-35700-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1497877896-35700-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:c0c::244 Subject: [Qemu-devel] [PATCH v5 4/5] fsdev: hmp 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 patch introduces hmp interfaces for the fsdev throttle functionality Signed-off-by: Pradeep Jagadeesh --- hmp-commands-info.hx | 18 ++++++++++++++ hmp-commands.hx | 19 +++++++++++++++ hmp.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ hmp.h | 4 ++++ 4 files changed, 107 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index ae16901..f23b627 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -84,6 +84,24 @@ 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 e763606..c60fd7e 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1662,6 +1662,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 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 220d301..b1c698b 100644 --- a/hmp.c +++ b/hmp.c @@ -1776,6 +1776,72 @@ 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; + + hmp_initialize_io_throttle(&throttle, qdict); + 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 d8b94ce..05e72f2 100644 --- a/hmp.h +++ b/hmp.h @@ -81,6 +81,10 @@ void hmp_set_password(Monitor *mon, const QDict *qdict); void hmp_expire_password(Monitor *mon, const QDict *qdict); void hmp_eject(Monitor *mon, const QDict *qdict); void hmp_change(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_set_io_throttle(Monitor *mon, const QDict *qdict); void hmp_block_stream(Monitor *mon, const QDict *qdict); void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict); --=20 1.8.3.1 From nobody Mon Apr 29 14:08:52 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 1497878217358321.92252666046215; Mon, 19 Jun 2017 06:16:57 -0700 (PDT) Received: from localhost ([::1]:42626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMwY2-0006wi-C1 for importer@patchew.org; Mon, 19 Jun 2017 09:16:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMwU7-0003BT-8L for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMwU3-0001tx-K3 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:51 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:34450) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMwU3-0001sm-8Z for qemu-devel@nongnu.org; Mon, 19 Jun 2017 09:12:47 -0400 Received: by mail-wr0-x243.google.com with SMTP id y25so11254420wrd.1 for ; Mon, 19 Jun 2017 06:12:47 -0700 (PDT) Received: from centos-minion-1.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id n71sm13459351wrb.62.2017.06.19.06.12.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 06:12:45 -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=h3Mr8KohfRXyu33gQQMdAG58qFXTnz5Z3clLicYiXBo=; b=N+zGHv9IAGLQGAOKzjIwMtzaYN4fvQSF3PfzoQI5iPpWYiQcT13ZSonoaND/U2XrA3 d2FN7zYNkPvsnTrxBHVYp79GWi6ykPRda7AYwkiH+5Cji335F8LdKf+HCACuOcWeZhbQ ANLXpFckqsi+qZ0h07Tsk+CrO3n25TAiRwjW338wubmePdt6G+GkhAzq2jfsYU6Cqw3w 7n512PHGGOzfalb5TW17d75GyNJERz8mDktXkZiOa/EGUMWhO3uKCpY3S9npvlalioGD SOHXdu0xsUelfWO6jhaMI4rN3uSi258c4RWdnYb4uyrR9W8qoiTayws4Tyoy+y/cqUEQ 1O1Q== 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=h3Mr8KohfRXyu33gQQMdAG58qFXTnz5Z3clLicYiXBo=; b=axHAhqIMlWV8tmMwAFphMN7g41NDCcISuGXKthgmx6EechkfGMtuQUo2defp4V5dke WIIlVIszhCEY2pmfm3067Shhdj7plmEH73jUx+RDqtylFWGQUl9ZT5HHsiZoA4/gHANe d5EE26vAedlyTn/utfcF8ToCvjwa3ZiGtSnpA2i0gLURNqQQ307xnv5E3/I8tPG1nagL J72TBTsujY+8FFQsFEMG6VBv71D/kN9U5gAOgyKsRNUuCUKve82zoBLDNY3pVuFqNCXe S7icX+hbABDjsyYK/t8wpnEqEe0c9TXLTvI3yYLdRFNEc5XK2rxNI9aknbrXBN+RcexV Txeg== X-Gm-Message-State: AKS2vOxoUdN562KGkRfIHv3TCIEQmXePCCJSIXdvAdi9rqhyF/ImXxID V/KeLtQqJA8vB+Dg X-Received: by 10.223.166.8 with SMTP id k8mr16741395wrc.172.1497877966181; Mon, 19 Jun 2017 06:12:46 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Mon, 19 Jun 2017 09:11:36 -0400 Message-Id: <1497877896-35700-6-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1497877896-35700-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1497877896-35700-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:c0c::243 Subject: [Qemu-devel] [PATCH v5 5/5] 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 patch 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 ++ fsdev/qemu-fsdev-dummy.c | 10 ++++++ fsdev/qemu-fsdev-throttle.c | 75 ++++++++++++++++++++++++++++++++++++++++ fsdev/qemu-fsdev-throttle.h | 12 +++++++ fsdev/qemu-fsdev.c | 37 ++++++++++++++++++++ monitor.c | 5 +++ qapi-schema.json | 3 ++ qapi/fsdev.json | 84 +++++++++++++++++++++++++++++++++++++++++= ++++ qmp.c | 15 ++++++++ 9 files changed, 244 insertions(+) create mode 100644 qapi/fsdev.json diff --git a/Makefile b/Makefile index c830d7a..996b1cf 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/fsdev/qemu-fsdev-dummy.c b/fsdev/qemu-fsdev-dummy.c index 6dc0fbc..f33305d 100644 --- a/fsdev/qemu-fsdev-dummy.c +++ b/fsdev/qemu-fsdev-dummy.c @@ -19,3 +19,13 @@ 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 da9c225..4483533 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -29,6 +29,81 @@ 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_set_io_limits(&cfg, arg); + + 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->has_bps_max =3D cfg.buckets[THROTTLE_BPS_TOTAL].max; + fscfg->bps_max =3D cfg.buckets[THROTTLE_BPS_TOTAL].max; + fscfg->has_bps_rd_max =3D cfg.buckets[THROTTLE_BPS_READ].max; + fscfg->bps_rd_max =3D cfg.buckets[THROTTLE_BPS_READ].max; + fscfg->has_bps_wr_max =3D cfg.buckets[THROTTLE_BPS_WRITE].max; + fscfg->bps_wr_max =3D cfg.buckets[THROTTLE_BPS_WRITE].max; + + fscfg->has_iops_max =3D cfg.buckets[THROTTLE_OPS_TOTAL].max; + fscfg->iops_max =3D cfg.buckets[THROTTLE_OPS_TOTAL].max; + fscfg->has_iops_rd_max =3D cfg.buckets[THROTTLE_OPS_READ].max; + fscfg->iops_rd_max =3D cfg.buckets[THROTTLE_OPS_READ].max; + fscfg->has_iops_wr_max =3D cfg.buckets[THROTTLE_OPS_WRITE].max; + fscfg->iops_wr_max =3D cfg.buckets[THROTTLE_OPS_WRITE].max; + + fscfg->has_bps_max_length =3D fscfg->has_bps_max; + fscfg->bps_max_length =3D + cfg.buckets[THROTTLE_BPS_TOTAL].burst_length; + fscfg->has_bps_rd_max_length =3D fscfg->has_bps_rd_max; + fscfg->bps_rd_max_length =3D + cfg.buckets[THROTTLE_BPS_READ].burst_length; + fscfg->has_bps_wr_max_length =3D fscfg->has_bps_wr_max; + fscfg->bps_wr_max_length =3D + cfg.buckets[THROTTLE_BPS_WRITE].burst_length; + + fscfg->has_iops_max_length =3D fscfg->has_iops_max; + fscfg->iops_max_length =3D + cfg.buckets[THROTTLE_OPS_TOTAL].burst_length; + fscfg->has_iops_rd_max_length =3D fscfg->has_iops_rd_max; + fscfg->iops_rd_max_length =3D + cfg.buckets[THROTTLE_OPS_READ].burst_length; + fscfg->has_iops_wr_max_length =3D fscfg->has_iops_wr_max; + fscfg->iops_wr_max_length =3D + cfg.buckets[THROTTLE_OPS_WRITE].burst_length; + + 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_parse_options(&fst->cfg, opts); diff --git a/fsdev/qemu-fsdev-throttle.h b/fsdev/qemu-fsdev-throttle.h index c493e83..a49b2e5 100644 --- a/fsdev/qemu-fsdev-throttle.h +++ b/fsdev/qemu-fsdev-throttle.h @@ -21,6 +21,12 @@ #include "qapi/error.h" #include "qemu/throttle.h" #include "qemu/throttle-options.h" +#include "qapi/qmp/qerror.h" +#include "qapi/qmp/types.h" +#include "qapi-visit.h" +#include "qapi/qobject-output-visitor.h" +#include "qapi/util.h" +#include "qmp-commands.h" =20 typedef struct FsThrottle { ThrottleState ts; @@ -37,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 **errp); + +void fsdev_get_io_throttle(FsThrottle *, IOThrottle **iothp, + char *, Error **errp); + #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/monitor.c b/monitor.c index fcf4fad..6b8c2cb 100644 --- a/monitor.c +++ b/monitor.c @@ -997,6 +997,11 @@ static void qmp_unregister_commands_hack(void) && !defined(TARGET_S390X) qmp_unregister_command(&qmp_commands, "query-cpu-definitions"); #endif +#ifndef CONFIG_VIRTFS + qmp_unregister_command(&qmp_commands, "fsdev-set-io-throttle"); + qmp_unregister_command(&qmp_commands, "query-fsdev-io-throttle"); +#endif + } =20 void monitor_init_qmp_commands(void) diff --git a/qapi-schema.json b/qapi-schema.json index 4b50b65..dc676be 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/qmp.c b/qmp.c index 7ee9bcf..7dc68a3 100644 --- a/qmp.c +++ b/qmp.c @@ -130,6 +130,21 @@ void qmp_cpu_add(int64_t id, Error **errp) } } =20 +#if defined(_WIN64) || defined(_WIN32) + +void qmp_fsdev_set_io_throttle(IOThrottle *arg, Error **errp) +{ + return; +} + +IOThrottleList *qmp_query_fsdev_io_throttle(Error **errp) +{ + abort(); +} + +#endif + + #ifndef CONFIG_VNC /* If VNC support is enabled, the "true" query-vnc command is defined in the VNC subsystem */ --=20 1.8.3.1