From nobody Sun Apr 28 06:28:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502109774324515.9698436626758; Mon, 7 Aug 2017 05:42:54 -0700 (PDT) Received: from localhost ([::1]:37124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehMx-0007Zr-W2 for importer@patchew.org; Mon, 07 Aug 2017 08:42:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehIY-0003CR-My for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dehIS-0002vF-Of for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:18 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:36387) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dehIS-0002rR-F8 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:12 -0400 Received: by mail-wm0-x244.google.com with SMTP id d40so882000wma.3 for ; Mon, 07 Aug 2017 05:38:10 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id v23sm7004777wrd.71.2017.08.07.05.38.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 05:38:09 -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=irDKxKGkaoOLI6Ox8CLrOXgSHf87WhGrI0kxMmsev4c=; b=rMnyXSFixfSWjW3DKoSHlDgd8eu7Ic3MA+ziqWXwhv9VRhVwbz+NB9hUw2xROOOdak 2LlFrqaTUE6sz+QQHJpklRwLa9s5owmsPBKqNke31Gjyna9cGyyMX/ldZFFUQPGLdZr4 B0L5sqzZPn5nxBToTymwHl4aJvkQPcjuv8s5zff3aOYD2gjYPMAoQXzTKN3O2DgDwqI6 I31SUuJy2/DYbINfIYgOnhMsyXbmNVcF6yvC+F8KmMM7WMcnX0JYNs3KvKxA1+OznF+2 7P5WMYN4t3KQv9z1byf/FHe98eTkjFDQoGCq01WNQZ2UalrEEaoklNNBV4LL+NFfBuQT GVOw== 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=irDKxKGkaoOLI6Ox8CLrOXgSHf87WhGrI0kxMmsev4c=; b=HQyh8XEN7kravQU6+hLFgkj6LLw2PAiOq5TTOohYZdUJf2a/b7RoORrSN2ab0c02rX N4cXUwiREPgy6TGibYkLSQrShrY6RskMWJg3qrXK2P/epskEoKo099Mw7U9FJKj6yAU+ uYez3Hhljd7h4U8GZ2a7rW862rIjFoUdyo6RKRktVJ/CfoZ9OwPiW4PYjfc90CtxwK3u XeLPSd6auOSV9aLoS016q/9aSVJnuXk0NRB3Y49Z3qWs00isQJMdwxZoezRkD1NrkEkb b7GmgnIjjKUX1e83MDDeSMOpfer2QkrRGheVVc0qg1RAJvD4PUiyTGkbcrWHQkWZyPBi oC9g== X-Gm-Message-State: AHYfb5hW4iO/ySLTKCEA/oNErduG2hrkC4l6I44aJAFgVyPE37iPhH4D zgpcyWqpgQ4cRQ== X-Received: by 10.28.73.193 with SMTP id w184mr667325wma.178.1502109489981; Mon, 07 Aug 2017 05:38:09 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Mon, 7 Aug 2017 08:37:33 -0400 Message-Id: <1502109458-31251-2-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1502109458-31251-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1502109458-31251-1-git-send-email-pradeep.jagadeesh@huawei.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PATCH V8 1/6] 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: qemu-devel@nongnu.org, jani kokkonen , alberto garcia , Pradeep Jagadeesh , Markus Armbruster 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 | 44 ++--------------------------------- include/qemu/throttle-options.h | 4 ++++ include/qemu/throttle.h | 4 ++-- include/qemu/typedefs.h | 1 + util/throttle.c | 51 +++++++++++++++++++++++++++++++++++++= ++++ 6 files changed, 61 insertions(+), 87 deletions(-) diff --git a/blockdev.c b/blockdev.c index 02cd69b..780ae58 100644 --- a/blockdev.c +++ b/blockdev.c @@ -388,49 +388,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 49eebb5..0e6fb86 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -16,6 +16,7 @@ #include "qemu/error-report.h" #include "qemu-fsdev-throttle.h" #include "qemu/iov.h" +#include "qemu/throttle-options.h" =20 static void fsdev_throttle_read_timer_cb(void *opaque) { @@ -31,48 +32,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 3133d1c..f63d38c 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 "typedefs.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/include/qemu/throttle.h b/include/qemu/throttle.h index d056008..75d930c 100644 --- a/include/qemu/throttle.h +++ b/include/qemu/throttle.h @@ -89,10 +89,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 39bc835..90fe0f9 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -100,6 +100,7 @@ typedef struct uWireSlave uWireSlave; typedef struct VirtIODevice VirtIODevice; typedef struct Visitor Visitor; typedef struct node_info NodeInfo; +typedef struct ThrottleConfig ThrottleConfig; typedef void SaveStateHandler(QEMUFile *f, void *opaque); typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); =20 diff --git a/util/throttle.c b/util/throttle.c index b2a52b8..95c2ecf 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 * @@ -502,3 +503,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 Sun Apr 28 06:28:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502109619601395.0394435361454; Mon, 7 Aug 2017 05:40:19 -0700 (PDT) Received: from localhost ([::1]:37110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehKU-0005Jh-3q for importer@patchew.org; Mon, 07 Aug 2017 08:40:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehIX-0003Bx-TG for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dehIS-0002v4-Gi for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:17 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:33843) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dehIS-0002uD-8E for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:12 -0400 Received: by mail-wr0-x242.google.com with SMTP id o33so261163wrb.1 for ; Mon, 07 Aug 2017 05:38:12 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id v23sm7004777wrd.71.2017.08.07.05.38.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 05:38:10 -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=n+Tt0M4+hpnSyGSQ/WlYR4xDs0qB8yPSd5fOM3VPaXM=; b=IOFfVIB+2wqzPoQygVZefJ6u3R/IejMAhN5ZzJkJUS0NgkTs/2U0100AaRvM9qkMSj j4VLe5Trz3/NSROcAkkxR6RN+sEcNAuDoeDIVWVPQLdP0Xa/XuX7JkgAFRxqxaB+S7hd qdlv3YT4ghWlCH1c2uCJDFWkLBixGweGwaVs+1IAzyMkICC1tulWSeZZjRq4gUN19ahr X4hvuIaEcC7VsFq/YLuhFO4hp4rjipPWQ0/tk6Afc+KD3leLbid7zmNBqa5BrET8FLCj ZjQcJmBsjLXMJTCJJPYacGExcOO0q7xtC4yvTvNyLR8m2YLCGH1mCFgK+/3jERCTIvLs Zy+A== 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=n+Tt0M4+hpnSyGSQ/WlYR4xDs0qB8yPSd5fOM3VPaXM=; b=b6+Bk63qLVrn7TdB0u+hA1qbgZkN3LRXuQPUez2nTYGYHhLuIdeanJlyo9T9qW5UPh l1ryWyYgVepvTUtAcpxkWjIlKSLOPtjl+rTIUC7x0Z+qjn2Ai73lQ2nISSGdShg72BVQ 0AUJ/tnQcajgyjjDEdo8dJM2EKJiGxfrascztIs8n1l6ClWeVD5B6AxfPtwdc8n2MW6B J6ftvzc/GB8J/Gs58KnQNWRdA1Fllu03DfNesZ3U9AK4bxZ9xC3T4/Qj1M9zkAxVR8z7 X1tSr8PTSMteNjG5mGNKsowkK/3Zfp2KoGG2pBOXAfGBpM/XkRrZrn7gr7cHEq6Adsml /NRw== X-Gm-Message-State: AHYfb5hZ0pv1Q7I8+jjmuv7S+cfsKDDbd83trPkBoLbVNNe8y57ldzzO WhDjuYVw+3yn/g== X-Received: by 10.223.138.232 with SMTP id z37mr322962wrz.66.1502109491020; Mon, 07 Aug 2017 05:38:11 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Mon, 7 Aug 2017 08:37:34 -0400 Message-Id: <1502109458-31251-3-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1502109458-31251-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1502109458-31251-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 V8 2/6] 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 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 Reviewed-by: Alberto Garcia --- 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 833c602..98147ef 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: @@ -1825,84 +1826,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 Sun Apr 28 06:28:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502109623436567.1681010896509; Mon, 7 Aug 2017 05:40:23 -0700 (PDT) Received: from localhost ([::1]:37111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehKX-0005M0-Nk for importer@patchew.org; Mon, 07 Aug 2017 08:40:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehIZ-0003Cc-0b for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dehIT-0002wA-Rx for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:19 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:33844) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dehIT-0002vR-IC for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:13 -0400 Received: by mail-wr0-x243.google.com with SMTP id o33so261199wrb.1 for ; Mon, 07 Aug 2017 05:38:13 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id v23sm7004777wrd.71.2017.08.07.05.38.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 05:38:11 -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=rzDROED0CTzRR0Srkya+UDdqlCvGx1/jjY45f0aZWqU=; b=qA2q4vPB4urUmGt5VIjJQEgIsXGjmHpCwctClJLza9TOGCqiwCDWpFI8qCrXQtZZWa VmTUFpBSYVarLqr6w/IkFbBYYhmbvn2inhKrVkaUAtjIkcvYq6Im2YjWK6ajfOaafGsC uBGoV8uOC3p/8pwyWZzR2PfvMzB3uNBCJbLu/Rirp/j2NDAQU7jiJr/4pn6kyonZT8Hv V3zUipiUTW4EvckoZTIyCXP7P1lnI8XpBgRKVW5pUsJagGzjmaVON0EX3lTgCHwpWrVq kDw6pdzdlSuULDJx/gGPCQNDyTsJeR1lFA/S7PnvQwivzfR3rYTSMrRsmgHSUDlN7SLV 8WdA== 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=rzDROED0CTzRR0Srkya+UDdqlCvGx1/jjY45f0aZWqU=; b=rd/heK4K2lkYDu4dvG15tiYxikjjHbDyxnYUamsKVyjqYbdqPsi+Sw8wpMKT/ZRwYR IURQydWEZ62NV83zDJEZ/IubsG2HQZknIhWQlwmbG7mo3z7xTPxy8KieNWZhsPdNFTQL 3unyFIyCbyALK3pIuww2ejNDBvJa2LEPCIbEQhaz7EBPPy52f5IXTN+qMzZIHuQIpiyS Q106+7bAPPRzd0y4mqxAJCK1O/mN598++jqDNLCJKnSH0nYyVxMLG2aHdWPhPhTNOpGP iYrpTz8qep9e6WuULMcLmWE5YeTmUy0Llfz7eXF06zgFlLx6R6PSPYECRwpXGCsFXBw/ CfHQ== X-Gm-Message-State: AHYfb5jfd32sngtQ03FEHHE/O5hrMaUgYYRRFT7kkDEQgfRRMSfLQORh +JtjhTl6WTxLXA== X-Received: by 10.223.164.208 with SMTP id h16mr357602wrb.100.1502109492310; Mon, 07 Aug 2017 05:38:12 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Mon, 7 Aug 2017 08:37:35 -0400 Message-Id: <1502109458-31251-4-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1502109458-31251-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1502109458-31251-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 V8 3/6] throttle: move out function to reuse the 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: qemu-devel@nongnu.org, jani kokkonen , alberto garcia , Pradeep Jagadeesh , Markus Armbruster 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 move out the throttle code to util/throttle.c to maximize the reusability of the code.The same code is also used by fsdev. Signed-off-by: Pradeep Jagadeesh Reviewed-by: Alberto Garcia --- blockdev.c | 53 +++--------------------------------- include/qemu/throttle-options.h | 3 +++ util/throttle.c | 59 +++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 65 insertions(+), 50 deletions(-) diff --git a/blockdev.c b/blockdev.c index 780ae58..1caf2e0 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2571,6 +2571,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, @@ -2588,56 +2589,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/include/qemu/throttle-options.h b/include/qemu/throttle-option= s.h index f63d38c..a9deb8e 100644 --- a/include/qemu/throttle-options.h +++ b/include/qemu/throttle-options.h @@ -11,6 +11,7 @@ #define THROTTLE_OPTIONS_H =20 #include "typedefs.h" +#include "qapi-types.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 95c2ecf..2d00532 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -553,3 +553,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 Sun Apr 28 06:28:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502109701132260.3988196312598; Mon, 7 Aug 2017 05:41:41 -0700 (PDT) Received: from localhost ([::1]:37120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehLn-0006Xu-Mm for importer@patchew.org; Mon, 07 Aug 2017 08:41:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehIZ-0003Cu-Dl for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dehIU-0002ws-H2 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:19 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:33456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dehIU-0002vt-9i for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:14 -0400 Received: by mail-wm0-x243.google.com with SMTP id q189so903432wmd.0 for ; Mon, 07 Aug 2017 05:38:14 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id v23sm7004777wrd.71.2017.08.07.05.38.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 05:38:12 -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=0A09PHsWtkbl3qVkFa3DyhICvvM1yY42z7IfzxkBSHc=; b=KK9cPYhxjoQdtK9ynLM+7C65tHNQmvzsBQBQTAAcKxRQvIcYgr1MT81m0dVMC4z4Ad 7J7xr6tsyvH+ZnEfwHfmrAaOoHdLpKdKBdGGg+6SPQRM24QAmNXbsDvdZgsYmvn4vHbb vkk3Cqg+1pTBTXLNisWNPq8D90TD4xQLqy4ADALTL8l5sjhR+0YQswpY0Za96fMX8le+ rD+VPesyEdfy3D6ibsvdAn/g9wAhSXImbsGGE6RoZDVPtsArq22oY4D4boSSh5AJmGv2 bFE+H+Djh8c0TGxTQA1GdwxN61tHtMY7ZWDZrIWWFJL56ZmvVqxPpyJ2YhyLYXYTRenO yJTA== 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=0A09PHsWtkbl3qVkFa3DyhICvvM1yY42z7IfzxkBSHc=; b=dfspQK3YbvKHim2aCureHFYLDmCXOflaP3v++7Qk7yjE1OT/NBOpZhge0JQOohwJgF 4Bn4YEECt7e+3qdF5sPEk5eTPXpsGYc5b0u7kE0c7HBuc/bVs8TLXpPzKIlZvH5eC9Q5 DRR6j3Hoy/Wt7jymr6hTd5GY2I/FfNcuIJpY7Qqf7jdYV4YtwhNmNKD31ao/avCNo6pC WbqrC3RbL9G1g58FHJVPo3q2LEUDpldo+gj4Nj25WRqTKAa6J2IPnsLMK3ZFLvw9LAIs SgFNZ8oFIP814ka3VQwaAqTFUoK/2dqMgYZ5jNALrT4R0U78T+Vq5Y6B0UqB+0297pny C28A== X-Gm-Message-State: AHYfb5jIOkDKn3/+odqr2rf/mE7JK09dpwGdKqpmZxxgq7/JkBAY8kZI gOrlTkSH5DCunQ== X-Received: by 10.28.158.148 with SMTP id h142mr578886wme.102.1502109493263; Mon, 07 Aug 2017 05:38:13 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Mon, 7 Aug 2017 08:37:36 -0400 Message-Id: <1502109458-31251-5-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1502109458-31251-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1502109458-31251-1-git-send-email-pradeep.jagadeesh@huawei.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH V8 4/6] hmp: create a throttle initialization function for code reusability 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: qemu-devel@nongnu.org, jani kokkonen , alberto garcia , Pradeep Jagadeesh , "Dr. David Alan Gilbert" 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 creates a throttle initialization function to maximize the code reusability. The same code is also used by fsdev. Acked-by: Dr. David Alan Gilbert Signed-off-by: Pradeep Jagadeesh --- hmp.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hmp.c b/hmp.c index fd80dce..2dbfb80 100644 --- a/hmp.c +++ b/hmp.c @@ -1758,20 +1758,27 @@ 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->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); } --=20 1.8.3.1 From nobody Sun Apr 28 06:28:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502109780338858.8561159087252; Mon, 7 Aug 2017 05:43:00 -0700 (PDT) Received: from localhost ([::1]:37126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehN4-0007ea-Mc for importer@patchew.org; Mon, 07 Aug 2017 08:42:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehIb-0003EK-N9 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dehIV-0002yp-HF for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:21 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:35410) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dehIV-0002x4-7Q for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:15 -0400 Received: by mail-wr0-x244.google.com with SMTP id c24so259702wra.2 for ; Mon, 07 Aug 2017 05:38:15 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id v23sm7004777wrd.71.2017.08.07.05.38.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 05:38:13 -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=EJcJjxCgWmHn31EvLDVV3SAyWFfmgGQ9Av6WLohEJgQ=; b=E1kfY3wcA5RE46Du3N2vi7mcTgC65XKz++s0ZnUYrXo9fQ/qT/oTK5yODcGOnlqCDV YhKwka9X34AnlRoadrKWruFP10PTzQ2Epb8cct+OeTtWUhDUUERuaoTihWvypHM4bY3g +qJuySb7sjW7ijYj69eZI9A+KMafouw9u0Up7wZD39riV7hamAnaClJN1J0k1vvBjo06 nGQKGa/zTfu0/rXRSPW6arLBlwdZ+lj/3DrvEQdehMv2U2t92y2EFNdDkAHp5L+ceCuw 5rtSTSAxdELNB4LdrEaaaAM1MdBGE2ell8+bUlaYWaOoXp8IWMasiJZhM027ccl+lnrP sCpA== 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=EJcJjxCgWmHn31EvLDVV3SAyWFfmgGQ9Av6WLohEJgQ=; b=GHj7j6kxRseTACGtzVBzU8U3kJv2inVxaCpxfRiHdW0VVZtwqmbt+Sjh3cziX4RbrL WYuyKShKUXTp65azTHh5mndBUC6AndwLUEDSExSABQUYvusVb6tvPRoKzIbWTmdzzEad 8z6RYdxYf7cDD272I93BB8203vZmfM3Drv3Q7R/5fSUH1xBNg/9ouYdR/+E3gShuDwE5 8CIpQ0SRgIL7MAyZDeWX+TAigecAfFfwk7xMp1cojk021a6OogIe57evlhLyRCD1Ec8w OONGVXv/7RwTvOWj2S/Fy4P30LhKQ31JbpJEy4sUdVO12EITY/f1Pr18BLQ2BD0UsOLw 2G5w== X-Gm-Message-State: AHYfb5gXPGGrWwIdPsr90ovR9QZ/W0Xd3mXK/d6HzBdM1XkDx8C7/3Dr R4Pqdy/5k4W36w== X-Received: by 10.223.130.229 with SMTP id 92mr271992wrc.119.1502109494056; Mon, 07 Aug 2017 05:38:14 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Mon, 7 Aug 2017 08:37:37 -0400 Message-Id: <1502109458-31251-6-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1502109458-31251-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1502109458-31251-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 V8 5/6] 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: alberto garcia , Markus Armbruster , qemu-devel@nongnu.org, "Dr. David Alan Gilbert" , Pradeep Jagadeesh , jani kokkonen 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 qmp interfaces for the fsdev devices. This provides two interfaces one 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 | 4 +++ fsdev/qemu-fsdev-dummy.c | 11 ++++++ fsdev/qemu-fsdev-throttle.c | 76 ++++++++++++++++++++++++++++++++++++++++ fsdev/qemu-fsdev-throttle.h | 8 +++-- fsdev/qemu-fsdev.c | 38 ++++++++++++++++++++ monitor.c | 5 +++ qapi-schema.json | 3 ++ qapi/fsdev.json | 84 +++++++++++++++++++++++++++++++++++++++++= ++++ qmp.c | 14 ++++++++ 9 files changed, 241 insertions(+), 2 deletions(-) create mode 100644 qapi/fsdev.json diff --git a/Makefile b/Makefile index 97a58a0..5af92cb 100644 --- a/Makefile +++ b/Makefile @@ -416,6 +416,10 @@ qapi-modules =3D $(SRC_PATH)/qapi-schema.json $(SRC_PA= TH)/qapi/common.json \ $(SRC_PATH)/qapi/crypto.json $(SRC_PATH)/qapi/rocker.json \ $(SRC_PATH)/qapi/trace.json =20 +ifdef CONFIG_VIRTFS +qapi-modules +=3D $(SRC_PATH)/qapi/fsdev.json +endif + qapi-types.c qapi-types.h :\ $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ diff --git a/fsdev/qemu-fsdev-dummy.c b/fsdev/qemu-fsdev-dummy.c index 6dc0fbc..28c82d2 100644 --- a/fsdev/qemu-fsdev-dummy.c +++ b/fsdev/qemu-fsdev-dummy.c @@ -14,8 +14,19 @@ #include "qemu-fsdev.h" #include "qemu/config-file.h" #include "qemu/module.h" +#include "qmp-commands.h" =20 int qemu_fsdev_add(QemuOpts *opts) { return 0; } + +void qmp_fsdev_set_io_throttle(IOThrottle *arg, Error **errp) +{ + return; +} + +IOThrottleList *qmp_query_fsdev_io_throttle(Error **errp) +{ + return NULL; +} diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index 0e6fb86..184ed4c 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -16,6 +16,7 @@ #include "qemu/error-report.h" #include "qemu-fsdev-throttle.h" #include "qemu/iov.h" +#include "qemu/main-loop.h" #include "qemu/throttle-options.h" =20 static void fsdev_throttle_read_timer_cb(void *opaque) @@ -30,6 +31,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 e418643..1db9125 100644 --- a/fsdev/qemu-fsdev-throttle.h +++ b/fsdev/qemu-fsdev-throttle.h @@ -15,8 +15,6 @@ #ifndef _FSDEV_THROTTLE_H #define _FSDEV_THROTTLE_H =20 -#include "block/aio.h" -#include "qemu/main-loop.h" #include "qemu/coroutine.h" #include "qapi/error.h" #include "qemu/throttle.h" @@ -36,4 +34,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..63dc1b5 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,40 @@ 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) { + error_setg(errp, "Not a valid fsdev device"); + return; + } + + fsdev_set_io_throttle(arg, &fse->fst, errp); +} + +IOThrottleList *qmp_query_fsdev_io_throttle(Error **errp) +{ + IOThrottleList *head =3D NULL, *p_next; + struct FsDriverListEntry *fsle; + Error *local_err =3D NULL; + + QTAILQ_FOREACH(fsle, &fsdriver_entries, next) { + p_next =3D g_new0(IOThrottleList, 1); + fsdev_get_io_throttle(&fsle->fse.fst, &p_next->value, + fsle->fse.fsdev_id, &local_err); + if (local_err) { + error_propagate(errp, local_err); + g_free(p_next); + qapi_free_IOThrottleList(head); + return NULL; + } + + p_next->next =3D head; + head =3D p_next; + } + return head; +} diff --git a/monitor.c b/monitor.c index e0f8801..eebda1c 100644 --- a/monitor.c +++ b/monitor.c @@ -998,6 +998,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 802ea53..8cf8140 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..48020fb --- /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, GenericError +# +# 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 I/O throttle +# values of each fsdev 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 b86201e..eed91e5 100644 --- a/qmp.c +++ b/qmp.c @@ -130,6 +130,20 @@ void qmp_cpu_add(int64_t id, Error **errp) } } =20 +#if defined(_WIN64) || defined(_WIN32) || defined(__FreeBSD__) + +void qmp_fsdev_set_io_throttle(IOThrottle *arg, Error **errp) +{ + return; +} + +IOThrottleList *qmp_query_fsdev_io_throttle(Error **errp) +{ + return NULL; +} + +#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 From nobody Sun Apr 28 06:28:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150210984750444.181835199530155; Mon, 7 Aug 2017 05:44:07 -0700 (PDT) Received: from localhost ([::1]:37129 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehO9-0000J0-VD for importer@patchew.org; Mon, 07 Aug 2017 08:44:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehIb-0003EB-Hc for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dehIW-0002zT-91 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:21 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:35940) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dehIV-0002ye-VW for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:16 -0400 Received: by mail-wr0-x242.google.com with SMTP id y67so255140wrb.3 for ; Mon, 07 Aug 2017 05:38:15 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id v23sm7004777wrd.71.2017.08.07.05.38.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 05:38:14 -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=eKrlh9zg8th8mFz103ypbzRThDmre+y56U3DVu642Qs=; b=o8eXKx3EZIvwJn46cWPW3jkE3kISzmrJ/1IYbyEyDY+FgCD4YCY+LiVkMaH49IwNmY t/yXNCwtGBZp1W/Xq0ogZwgXorCYn0JEpeqNemDoKEdjI0klXJes36AQ8AgDCKvAsTHc Kp5Uj9a1/GQsX2Qo9D3AbYimyQgnsYY/WuOX4KJ9gemm2+WIDDJUNOGjhP5OPs0kYm50 N2cti37dvMJe3l0N69wh4NmyHYiqxbS76s46hOLVE3T3y4zcgDC8G0FgnG02L5xZF3UX epwg7l+cdHTroaUMamQu79VPVOfRgyhH6+GFHUz3UEqADxvl+A9kqxbMxU8GPvTvvqWI +MIw== 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=eKrlh9zg8th8mFz103ypbzRThDmre+y56U3DVu642Qs=; b=RADszSi+Mf8UQKCAVVxkw28Cou7LO012thA7RmuoqQw1haFBCA2kwuTg5c1n0lWido DfFSqu8pgJv/1n1i10Q7AsDk0DMggRj8xiYXcznjCOtjYBaqLOv5A78bbelcYzsTrTxV IzZYki21ixEA25dX7SToXjBm3DDwRJYICFAZEJHQlFerMRylzyYPDkRBfGt1KEFBaWrv UIbu8Sv3pZnbUx9Qu2nXBTUw8fElmAUfmz/erhc0XGFq/o5Zrsq4YO9VIPUYWF4w8zUx iZaPfeD0AkXfwuBqLXg6PPUoa9OePiOqtkgBTp3pjOCBZ4QGGQz8lCQYd8x9pNxsHL/D iNXw== X-Gm-Message-State: AHYfb5j4mIXUE0QF/BDYP1GY704kn+zle1c9pWZK2Pf71A5vfsJzDm3T Knv3kKpfdyOdbUuh X-Received: by 10.223.139.154 with SMTP id o26mr342448wra.178.1502109494937; Mon, 07 Aug 2017 05:38:14 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Mon, 7 Aug 2017 08:37:38 -0400 Message-Id: <1502109458-31251-7-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1502109458-31251-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1502109458-31251-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 V8 6/6] 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: qemu-devel@nongnu.org, jani kokkonen , alberto garcia , Pradeep Jagadeesh , "Dr. David Alan Gilbert" 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 devices. Signed-off-by: Pradeep Jagadeesh --- hmp-commands-info.hx | 18 +++++++++++++++ hmp-commands.hx | 19 ++++++++++++++++ hmp.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ hmp.h | 4 ++++ 4 files changed, 103 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index d9df238..07ed338 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 "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 "block-jobs", .args_type =3D "", diff --git a/hmp-commands.hx b/hmp-commands.hx index 1941e19..aef9f79 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1680,6 +1680,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 2dbfb80..712c6a3 100644 --- a/hmp.c +++ b/hmp.c @@ -1783,6 +1783,68 @@ void hmp_block_set_io_throttle(Monitor *mon, const Q= Dict *qdict) hmp_handle_error(mon, &err); } =20 +#ifdef CONFIG_VIRTFS + +void hmp_fsdev_set_io_throttle(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + IOThrottle throttle =3D { + .has_id =3D true, + .id =3D (char *) qdict_get_str(qdict, "device"), + }; + + 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) +{ + 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); + hmp_handle_error(mon, &err); +} + +void hmp_info_fsdev_iothrottle(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + IOThrottleList *fsdev_list, *info; + fsdev_list =3D qmp_query_fsdev_io_throttle(&err); + + for (info =3D fsdev_list; info; info =3D info->next) { + print_fsdev_throttle_config(mon, info->value, err); + } + qapi_free_IOThrottleList(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 1ff4552..d700d7d 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_info_fsdev_iothrottle(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