From nobody Sat May 4 23:02:31 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 1505385870958862.2423420405096; Thu, 14 Sep 2017 03:44:30 -0700 (PDT) Received: from localhost ([::1]:46876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRdG-0001u8-7O for importer@patchew.org; Thu, 14 Sep 2017 06:44:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRZh-0006pt-Qh for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsRZd-0001xH-9T for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:49 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:34288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dsRZc-0001ul-S8 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:45 -0400 Received: by mail-wm0-x243.google.com with SMTP id i131so2887433wma.1 for ; Thu, 14 Sep 2017 03:40:43 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id w14sm742801wmf.13.2017.09.14.03.40.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 03:40: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=5JEgF++of2HEY1tgWrx2rTNG/tiuHdfoeMqx9yD0dmw=; b=FWV7Kvt3qzhI079pfZ6moTAwWcpEgSMchWn+bgZitl76/QYl/B5ZmYUnAaK8NAV4yI /X6unOc53pvTqV0FJojZnLWD2ZCyxhlfzOt13rcNMvLo117ubYHpBUdmv26GJ2GW7xce LONKuQB1mhtIAy/f9i+ce8VnBF4odXf9hlJwah1bsFlXUDDOHBIWOHCocNh9EE9qoYgB KNMfZUYzw+E2UjX5/VOnjy+LJ79dCKlLkB8ycrGd/UYO1MebpRRift8+b72QMhnyE6Vl HEPMuknlb2nLWXjEypj18WjltLsXokf/b79ztKVS5pTn3yBZTRGun2HjkerSa8t+6fOb mq4g== 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=5JEgF++of2HEY1tgWrx2rTNG/tiuHdfoeMqx9yD0dmw=; b=F4QNmydl3CkdfDcn04TvUePNTt7i04+JydFvICo+UMD6WvXsUWCbpnQ1MT3OKSNgaK MBj0zgCISopAWx92abSK1HVRu2op4GrHh/ijdjH+e+ygJZrg91Uezc5/fjCZw0cG6HQ8 Xz2MPSlvx4UAT/Zv0wwvPSHX6aDAMCqLmBVyWwcyEna6eWTc7laGmMciQSaveYNbZKpA nOWfWwLuM9zufwZzEpgIOblqdyBi6+vpr+KRUVtxOwW6pN7/0Y1i09Avpcd4Vin1D2Db PPAqwPaUFtaMDjJOYoweVEmYSZto1kdiS4MKOymdDKd3vP3/ATlOGg9gbDjdUv9HuOJ3 o8VA== X-Gm-Message-State: AHPjjUiBEhC6atsEGM6swSDQDI8kDE2Vl0gGaYNmxSd8YageLibSF5Iw QY0JVMcAeHn/Bg== X-Google-Smtp-Source: AOwi7QBi6CEMlEf1o5wOL9wW3Fq2HqV983iH7EiPBCg5pMGCcT7NnQ9sizkPm2qYAPuX9EoVakf+TA== X-Received: by 10.28.154.19 with SMTP id c19mr1706992wme.59.1505385642411; Thu, 14 Sep 2017 03:40:42 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Thu, 14 Sep 2017 06:40:05 -0400 Message-Id: <1505385610-35529-2-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1505385610-35529-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1505385610-35529-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 v11 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 factors out the duplicate throttle code that was still present in block and fsdev devices. Signed-off-by: Pradeep Jagadeesh Reviewed-by: Alberto Garcia Reviewed-by: Greg Kurz Reviewed-by: Eric Blake --- blockdev.c | 44 +--------------------------------- fsdev/qemu-fsdev-throttle.c | 44 ++-------------------------------- include/qemu/throttle-options.h | 3 +++ include/qemu/throttle.h | 4 ++-- include/qemu/typedefs.h | 1 + util/throttle.c | 52 +++++++++++++++++++++++++++++++++++++= ++++ 6 files changed, 61 insertions(+), 87 deletions(-) diff --git a/blockdev.c b/blockdev.c index 56a6b24..9d33c25 100644 --- a/blockdev.c +++ b/blockdev.c @@ -387,49 +387,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 3528a8f..9709dcd 100644 --- a/include/qemu/throttle-options.h +++ b/include/qemu/throttle-options.h @@ -9,6 +9,7 @@ */ #ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H +#include "typedefs.h" =20 #define QEMU_OPT_IOPS_TOTAL "iops-total" #define QEMU_OPT_IOPS_TOTAL_MAX "iops-total-max" @@ -111,4 +112,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 8c93237..b6ebc6d 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 06bf916..9ef28c4 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 * @@ -635,3 +636,54 @@ void throttle_config_to_limits(ThrottleConfig *cfg, Th= rottleLimits *var) var->has_iops_write_max_length =3D true; var->has_iops_size =3D true; } + +/* parse the throttle options + * + * @opts: qemu options + * @throttle_cfg: throttle configuration + */ +void throttle_parse_options(ThrottleConfig *throttle_cfg, QemuOpts *opts) +{ + throttle_config_init(throttle_cfg); + throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg =3D + qemu_opt_get_number(opts, "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 Sat May 4 23:02:31 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 1505385741921616.1787548130503; Thu, 14 Sep 2017 03:42:21 -0700 (PDT) Received: from localhost ([::1]:46869 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRbA-0008C6-Ct for importer@patchew.org; Thu, 14 Sep 2017 06:42:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRZh-0006pr-IK for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsRZd-0001wt-0I for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:49 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:38267) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dsRZc-0001vu-Gd for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:44 -0400 Received: by mail-wm0-x242.google.com with SMTP id x17so2867582wmd.5 for ; Thu, 14 Sep 2017 03:40:44 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id w14sm742801wmf.13.2017.09.14.03.40.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 03:40: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=1x16PabO960ttIVHJ5euH4mKWmdMjRWOyXL9dHWHGcE=; b=M+uV3M5p5Z1XaUDjy6W+GeSAler1KB547bqLOYkvBya8aMVSdyAjTY4CELmCc4mYzR UUFUdWKZnhJFnqm48Xrj3i9ZTVdO489oFNvHRcyVutGexj5SxsRnKXhctn7CllBdPFfL o3wOfEEjuDejucEAaV4pEKmp2kaFfTsX0wPBZL3OpmsBh27k2LyEClwtDaJi4r7Y5QZI ZcR2uWFo7fWtvE3ZCMANYXpVX12rcUZ70eRuujcFTqKsPQGLmU6+NH3DId/gjzlOE8OH x7mj1/mH5hokooRJNu9QIiXeEP2QZSWS157lqulA3H7Jf9np0jv0OI1KkavFBn9d2e9G wFqA== 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=1x16PabO960ttIVHJ5euH4mKWmdMjRWOyXL9dHWHGcE=; b=QjskGbCDPZidXtMMqg9YOPwNz7cCVinVVGEX8XP7fY76cyGHofUcxl2SKVJC4sb2S9 3TMzmWVG81gHIItirUwpCBSRFGzd57rxPUIHAENs+aBPO9cNORWgvcML6ihD8NPQQ5pQ bSZ6k37gfqyiFjgyD9V8o7UFt7oWfF0QVhTe5CxCcUoIgNkzEtGQLWx2obkm+XGW85OW cjc0Dl3YN6RNkI7bEWnJi6BRtIMajaY9DwmRYMmWkNZfcBGa8Wx7GHVAKa4qtHWQsOrU fYPXmzt6LzE/msA9Cjo/D6UkmiARIN+NAMYwxSEMNYCSSpb3vheu4zmNrjeBPLOmrpov Jjkw== X-Gm-Message-State: AHPjjUiTR2dR5s2jlnJTwYhGgpgBdZIDZK6yCL2gpYrkYpxZi3UBSrpk /ygOLsT5Ha0U7w== X-Google-Smtp-Source: AOwi7QAOIpTrJzLl4Z5ML1LMB4tT+0goeNCh/cXAvjT5lCrSiMMxhVbIBh7CaIZccNKk9WxzTTFv7A== X-Received: by 10.28.164.68 with SMTP id n65mr1463066wme.23.1505385643398; Thu, 14 Sep 2017 03:40:43 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Thu, 14 Sep 2017 06:40:06 -0400 Message-Id: <1505385610-35529-3-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1505385610-35529-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1505385610-35529-1-git-send-email-pradeep.jagadeesh@huawei.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH v11 2/6] qmp: Use ThrottleLimits 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 factors out code to use the ThrottleLimits strurcture. Signed-off-by: Pradeep Jagadeesh Reviewed-by: Greg Kurz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia Reviewed-by: Markus Armbruster --- qapi/block-core.json | 78 +++---------------------------------------------= ---- 1 file changed, 4 insertions(+), 74 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index bb11815..d0ccfda 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1826,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': 'ThrottleLimits', + 'data': { '*device': 'str', '*group': 'str' } } =20 ## # @ThrottleLimits: @@ -1913,6 +1842,7 @@ # transaction. All fields are optional. When setting limits, if a field is # missing the current value is not changed. # +# @id: device id # @iops-total: limit total I/O operations per second # @iops-total-max: I/O operations burst # @iops-total-max-length: length of the iops-total-max burst period, in s= econds @@ -1942,7 +1872,7 @@ # Since: 2.11 ## { 'struct': 'ThrottleLimits', - 'data': { '*iops-total' : 'int', '*iops-total-max' : 'int', + 'data': { '*id' : 'str', '*iops-total' : 'int', '*iops-total-max' : 'int= ', '*iops-total-max-length' : 'int', '*iops-read' : 'int', '*iops-read-max' : 'int', '*iops-read-max-length' : 'int', '*iops-write' : 'int', '*iops-write-max' : 'int', --=20 1.8.3.1 From nobody Sat May 4 23:02:31 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 1505385743965766.2016888425225; Thu, 14 Sep 2017 03:42:23 -0700 (PDT) Received: from localhost ([::1]:46871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRbD-0008IV-3b for importer@patchew.org; Thu, 14 Sep 2017 06:42:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRZi-0006pz-15 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsRZd-0001xp-OK for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:50 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:37356) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dsRZd-0001wd-DV for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:45 -0400 Received: by mail-wr0-x244.google.com with SMTP id u48so1465652wrf.4 for ; Thu, 14 Sep 2017 03:40:45 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id w14sm742801wmf.13.2017.09.14.03.40.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 03:40: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=D8G1QRbFFpH0lZ2paMxJ5yLCN5Sk1RphI2r5zE6ycjY=; b=mmancngt8wxn4gzZn6jEqdkYdAD/4fjB9GXztfBRyQISXAgDGjhkEVdM3ADgPrilYK aO7cr1vfCWQCFUT3zE++D8r0+iQuFABstpBOWpjSNZTBByw105QWfeGInhA6giSN1zfr 4vbTuy83NJGU/zchIseNQfXF9MOMVWQzdLeWy8AnIok5PwWiNEjbmOi6Z5qISQrRnoH+ nn3OSqdMnBRtOxsPdnaUA1CDpX2imRz9tNwY4nbIEi7jE6foFES0aTNlE6yFwgwoIkI2 EofK5ZEzdy2UtT6YqZdsRkuut2HqMEq1l6ZBFEZvog4qy9Vj6C+FUPjDJRE2hitOHbt8 3sDA== 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=D8G1QRbFFpH0lZ2paMxJ5yLCN5Sk1RphI2r5zE6ycjY=; b=rxfhp+7c1MeRLZU240UHIs1X89TWuZo27i4LsxOxfJoz39eTc/2Ndy1am8CA4lkZCx 6WKNpKwg6qCDxrR+E+tGUOnxxFjwHhgXfr1i2scVdSWO0870QbJR+PU4u6py+5vgQiR5 gKGEyyYoXhetj9NxSpg75NZhlVidYxBiLOkoTSwUTjqcebGQ5bQoOkb8V3Ck8PxOmQZ/ +vPaizamkB88bl4ZzPIlLEs4WonX5G+cDeQiL0vcGkgYrJvx0HEV6UOCUWFpi4rbMDub 6aj+gkPrpiTzCVAoD9oIbkn74qd1SplcTfb6ZaPb2qzLL/XVABDbIzewBUKyXcsTeAmx 9Bjw== X-Gm-Message-State: AHPjjUhoQNkY2fBXc+GTiJKyxKxj9hyz/QOlFE7VU5mJp9kp9xa0ejK8 0shR4XihZQ9+Gg== X-Google-Smtp-Source: ADKCNb4dG2ZoDsZqq7Gw1NQqkbbUheuVAaNBHQd1UmJh+JxObulCFGV2AunBX9yJGThMEgTWQqxWxA== X-Received: by 10.223.136.170 with SMTP id f39mr17693803wrf.164.1505385644286; Thu, 14 Sep 2017 03:40:44 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Thu, 14 Sep 2017 06:40:07 -0400 Message-Id: <1505385610-35529-4-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1505385610-35529-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1505385610-35529-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 v11 3/6] qmp: factor out throttle code to reuse code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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 reuses the code to set throttle limits. Signed-off-by: Pradeep Jagadeesh Reviewed-by: Alberto Garcia Reviewed-by: Greg Kurz --- blockdev.c | 53 +++-------------------------------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/blockdev.c b/blockdev.c index 9d33c25..2bd8ebd 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2569,6 +2569,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, = Error **errp) BlockDriverState *bs; BlockBackend *blk; AioContext *aio_context; + ThrottleLimits *tlimit; =20 blk =3D qmp_get_blk(arg->has_device ? arg->device : NULL, arg->has_id ? arg->id : NULL, @@ -2586,56 +2587,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; - } + tlimit =3D qapi_BlockIOThrottle_base(arg); + throttle_config_to_limits(&cfg, tlimit); =20 if (!throttle_is_valid(&cfg, errp)) { goto out; --=20 1.8.3.1 From nobody Sat May 4 23:02:31 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 1505385954603772.7126996383628; Thu, 14 Sep 2017 03:45:54 -0700 (PDT) Received: from localhost ([::1]:46889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsReb-0003YM-HC for importer@patchew.org; Thu, 14 Sep 2017 06:45:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRZk-0006rt-CR for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsRZe-0001yk-FH for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:52 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:33548) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dsRZe-0001xd-3v for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:46 -0400 Received: by mail-wr0-x244.google.com with SMTP id b9so1474740wra.0 for ; Thu, 14 Sep 2017 03:40:45 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id w14sm742801wmf.13.2017.09.14.03.40.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 03:40: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=ScPvH4Obbnvmv7xQmJQ5gebpCp1S8MORUcIB7ELURNk=; b=n+MKWcMW+luSQf0Nr5S7IzZLCZuENZaMAMYeOPvR0F/8kMOPjbh0XIlU0CpPPkIAbH jrIQVhuvqVYaY635eOS3Kch+1hnCf9q3V+ldgXcY57emziX/M1KdhGphwJVc9wHFoCDO 0dqavPo/BG1wXx/KG5SAwJ6YPmPmpo/yktpTsSaPqyrqAtVprqgnW8JfkMZtvkW+Lz9e OGzJ4S45PdGhcJXUI7nZjSg57keyDsBeyH+uBnZaIBCq5xRvbFmzV7fajsS1HfzV8Z2E PA9VmTP8lMLXE9/OUur6xSGfs7gDEpl71UolMAAsbkWfnY3xHRmRyuOBeZqK8CeLq+U8 tMOA== 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=ScPvH4Obbnvmv7xQmJQ5gebpCp1S8MORUcIB7ELURNk=; b=rGlcv86zXnJztXiEi6KIMHxmnju6eNbygmRg/9RcEV7Yn/chUzyuxDM1pleIYFhvIn 49+hAC7CaOUbjDG6J30iWwYK7DdnwQ3kbtcZ1k7N9aFyUMrZ5pgVlU6vo8tVpYERKHmF BWpp5w5fC9ygxqXYqptESPfMJmz93CpiIQPa6CzBrA7FtvmW5EKSxYlyGTSrsIERlHAQ CPPZdH1qYl56q6yuyYyfWvY+C5YAjFU9pRq3fN7IeJ20paYUXSxjn9htsvnkXkcv7u56 yUOFtRAWN5Hu84IO3j02Ba5FZQP7EwtHxhfSwl+FwV1wilpr6ie6JTL5lfvv+GhPZwXq 43Vg== X-Gm-Message-State: AHPjjUjhBMmjEg9aTB1fC2t6ps1/7UVCv2MV7UkPJOO7D6oW3SKNVE3p 43lTaKJlPFIjnA== X-Google-Smtp-Source: ADKCNb4/NW9EiKAouna483H+g0/SPigqd0t8heOCvuXwVCqgRhyB7l6a6DwrXU9RMXYQvEtKU/ikRA== X-Received: by 10.223.172.228 with SMTP id o91mr17060830wrc.259.1505385645092; Thu, 14 Sep 2017 03:40:45 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Thu, 14 Sep 2017 06:40:08 -0400 Message-Id: <1505385610-35529-5-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1505385610-35529-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1505385610-35529-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 v11 4/6] hmp: create a throttle initialization function for code reuse X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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. Signed-off-by: Pradeep Jagadeesh Reviewed-by: Alberto Garcia Reviewed-by: Greg Kurz Acked-by: Dr. David Alan Gilbert --- hmp.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/hmp.c b/hmp.c index cd046c6..acaf0e6 100644 --- a/hmp.c +++ b/hmp.c @@ -1752,20 +1752,28 @@ void hmp_change(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } =20 +static void hmp_initialize_throttle_limits(ThrottleLimits *iot, + const QDict *qdict) +{ + iot->bps_total =3D qdict_get_int(qdict, "bps"); + iot->bps_read =3D qdict_get_int(qdict, "bps_rd"); + iot->bps_write =3D qdict_get_int(qdict, "bps_wr"); + iot->iops_total =3D qdict_get_int(qdict, "iops"); + iot->iops_read =3D qdict_get_int(qdict, "iops_rd"); + iot->iops_write =3D qdict_get_int(qdict, "iops_wr"); +} + void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; + ThrottleLimits *tlimits; 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 + tlimits =3D qapi_BlockIOThrottle_base(&throttle); + hmp_initialize_throttle_limits(tlimits, qdict); qmp_block_set_io_throttle(&throttle, &err); hmp_handle_error(mon, &err); } --=20 1.8.3.1 From nobody Sat May 4 23:02:31 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 1505385873975161.7494202881279; Thu, 14 Sep 2017 03:44:33 -0700 (PDT) Received: from localhost ([::1]:46878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRdJ-0001wA-7P for importer@patchew.org; Thu, 14 Sep 2017 06:44:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRZi-0006q5-38 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsRZf-000207-VP for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:50 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:38375) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dsRZf-0001z0-8P for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:47 -0400 Received: by mail-wr0-x244.google.com with SMTP id p37so1458586wrb.5 for ; Thu, 14 Sep 2017 03:40:47 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id w14sm742801wmf.13.2017.09.14.03.40.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 03:40: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=HXYTlBtDvBwPDvW/trOYGphlLOm+RwMuPARdOH0lE44=; b=BgCPh1bvZTTHf20a2WYJ0eI8AnEmeyMfSBixVunb9MaC++woRI2cHx244KjBCQmYmw 6ZZ3zPz6obOWundRVooOvX3nWex8d/Anf+mlGIIYi4SePoRUIMI4Xebc0+nAeKbTF/9Z TrqqliLm9wHJq+saOpKrUK+yIR+Ds93JQUM0nngnnl3ahMlDzSOlQAZZwCm8JhqXP5lh wRdh85GgnoKyx8MQVsuiv+HjkplNFw9QjsOdbWLIB7BfS8c0wlflgYMRYC1g/jwkLOvZ rXx56GRkiwRopaKpr3hLb9mmarfrZm8nznFPl5RUK/AmpWX3baP72mRzU3FdPNFt1enC f3XA== 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=HXYTlBtDvBwPDvW/trOYGphlLOm+RwMuPARdOH0lE44=; b=X3gaKT6ekHVHbMs3GmmRk+3vNtsHAWrZXEXb++6uq1kyZ517oMPm4BlZ0MzGAfUNqU oBEAkQ6aJvrkqmnHA6ya8j8CLp9BE7NxTt3pL6dhjxB2q2ejmDNDM7AxuYJfpQmUTaqY WAYuwi9l4NGky5s2oYoskYa+/eh8pHf1n8X+Jjc77khRvwgm0zpNzLxnWAcnA2NFUVWd e4as/oOEIZRZ11lL7V/exCjVQbu8+ZOSHkw3IyXqlN2BKH1ddSb4XsUzdhrQ/AeBuDa9 mpLLvQuuEnRJa+XDqPgCyIENVGgcOmQRsk78rMjwb+MusFtATUPG/i0HClOte+W6Ba6k mNwQ== X-Gm-Message-State: AHPjjUjQXnIh7O5Hurupc7GtPNzqygfC7w4hS6Cw/ibT7YCNYdC5eqga N9XHZxvqJlFRWw== X-Google-Smtp-Source: ADKCNb5/dpvBUhGf8xrYgly2+Q/pjN/Yq0PUIO5Rq04dBtHRDJHTUO4P3kD37M4KfUt+p76MLJzIYA== X-Received: by 10.223.196.170 with SMTP id m39mr17851045wrf.44.1505385646065; Thu, 14 Sep 2017 03:40:46 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Thu, 14 Sep 2017 06:40:09 -0400 Message-Id: <1505385610-35529-6-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1505385610-35529-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1505385610-35529-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 v11 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 Reviewed-by: Dr. David Alan Gilbert --- Makefile | 3 +- fsdev/qemu-fsdev-dummy.c | 11 ++++++ fsdev/qemu-fsdev-throttle.c | 96 +++++++++++++++++++++++++++++++++++++++++= +--- fsdev/qemu-fsdev-throttle.h | 9 ++++- fsdev/qemu-fsdev.c | 30 ++++++++++++++ monitor.c | 5 +++ qapi-schema.json | 4 ++ qapi/fsdev.json | 81 ++++++++++++++++++++++++++++++++++++++ qmp.c | 14 +++++++ 9 files changed, 244 insertions(+), 9 deletions(-) create mode 100644 qapi/fsdev.json diff --git a/Makefile b/Makefile index 337a1f6..6556dbf 100644 --- a/Makefile +++ b/Makefile @@ -421,7 +421,8 @@ qapi-modules =3D $(SRC_PATH)/qapi-schema.json $(SRC_PAT= H)/qapi/common.json \ $(SRC_PATH)/qapi/tpm.json \ $(SRC_PATH)/qapi/trace.json \ $(SRC_PATH)/qapi/transaction.json \ - $(SRC_PATH)/qapi/ui.json + $(SRC_PATH)/qapi/ui.json \ + $(SRC_PATH)/qapi/fsdev.json =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..dc5cb6c 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(ThrottleLimits *arg, Error **errp) +{ + return; +} + +ThrottleLimitsList *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..fb7a6fa 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,92 @@ static void fsdev_throttle_write_timer_cb(void *opaque) qemu_co_enter_next(&fst->throttled_reqs[true]); } =20 +typedef struct { + FsThrottle *fst; + bool is_write; +} RestartData; + +static bool coroutine_fn throttle_co_restart_queue(FsThrottle *fst, + bool is_write) +{ + return qemu_co_queue_next(&fst->throttled_reqs[is_write]); +} + +static void schedule_next_request(FsThrottle *fst, bool is_write) +{ + bool must_wait =3D throttle_schedule_timer(&fst->ts, &fst->tt, is_writ= e); + if (!must_wait) { + if (qemu_in_coroutine() && + throttle_co_restart_queue(fst, is_write)) { + return; + } else { + int64_t now =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); + timer_mod(fst->tt.timers[is_write], now); + } + } +} + +static void coroutine_fn throttle_restart_queue_entry(void *opaque) +{ + RestartData *data =3D opaque; + bool is_write =3D data->is_write; + bool empty_queue =3D !throttle_co_restart_queue(data->fst, is_write); + if (empty_queue) { + schedule_next_request(data->fst, is_write); + } +} + +static void throttle_restart_queues(FsThrottle *fst) +{ + Coroutine *co; + RestartData rd =3D { + .fst =3D fst, + .is_write =3D true + }; + + co =3D qemu_coroutine_create(throttle_restart_queue_entry, &rd); + aio_co_enter(fst->ctx, co); + + rd.is_write =3D false; + + co =3D qemu_coroutine_create(throttle_restart_queue_entry, &rd); + aio_co_enter(fst->ctx, co); +} + +static void coroutine_fn fsdev_throttle_config(FsThrottle *fst) +{ + if (throttle_enabled(&fst->cfg)) { + throttle_config(&fst->ts, QEMU_CLOCK_REALTIME, &fst->cfg); + } else { + throttle_restart_queues(fst); + } +} + +void fsdev_set_io_throttle(ThrottleLimits *arg, FsThrottle *fst, Error **e= rrp) +{ + ThrottleConfig cfg; + + throttle_get_config(&fst->ts, &cfg); + throttle_limits_to_config(arg, &cfg, errp); + + if (throttle_is_valid(&cfg, errp)) { + fst->cfg =3D cfg; + fsdev_throttle_config(fst); + } +} + +void fsdev_get_io_throttle(FsThrottle *fst, ThrottleLimits **fs9pcfg, + char *fsdevice) +{ + ThrottleConfig cfg =3D fst->cfg; + ThrottleLimits *fscfg =3D g_malloc0(sizeof(*fscfg)); + + fscfg->has_id =3D true; + fscfg->id =3D g_strdup(fsdevice); + throttle_config_to_limits(&cfg, fscfg); + *fs9pcfg =3D fscfg; +} + void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **er= rp) { throttle_parse_options(&fst->cfg, opts); @@ -40,8 +127,9 @@ void fsdev_throttle_init(FsThrottle *fst) { if (throttle_enabled(&fst->cfg)) { throttle_init(&fst->ts); + fst->ctx =3D qemu_get_aio_context(); throttle_timers_init(&fst->tt, - qemu_get_aio_context(), + fst->ctx, QEMU_CLOCK_REALTIME, fsdev_throttle_read_timer_cb, fsdev_throttle_write_timer_cb, @@ -62,11 +150,7 @@ void coroutine_fn fsdev_co_throttle_request(FsThrottle = *fst, bool is_write, } =20 throttle_account(&fst->ts, is_write, iov_size(iov, iovcnt)); - - if (!qemu_co_queue_empty(&fst->throttled_reqs[is_write]) && - !throttle_schedule_timer(&fst->ts, &fst->tt, is_write)) { - qemu_co_queue_next(&fst->throttled_reqs[is_write]); - } + schedule_next_request(fst, is_write); } } =20 diff --git a/fsdev/qemu-fsdev-throttle.h b/fsdev/qemu-fsdev-throttle.h index e418643..fc7409c 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" @@ -25,6 +23,7 @@ typedef struct FsThrottle { ThrottleState ts; ThrottleTimers tt; ThrottleConfig cfg; + AioContext *ctx; CoQueue throttled_reqs[2]; } FsThrottle; =20 @@ -36,4 +35,10 @@ void coroutine_fn fsdev_co_throttle_request(FsThrottle *= , bool , struct iovec *, int); =20 void fsdev_throttle_cleanup(FsThrottle *); + +void fsdev_set_io_throttle(ThrottleLimits *, FsThrottle *, Error **errp); + +void fsdev_get_io_throttle(FsThrottle *, ThrottleLimits **iothp, + char *); + #endif /* _FSDEV_THROTTLE_H */ diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index 266e442..07bb005 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,32 @@ FsDriverEntry *get_fsdev_fsentry(char *id) } return NULL; } + +void qmp_fsdev_set_io_throttle(ThrottleLimits *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); +} + +ThrottleLimitsList *qmp_query_fsdev_io_throttle(Error **errp) +{ + ThrottleLimitsList *head =3D NULL, *p_next; + struct FsDriverListEntry *fsle; + + QTAILQ_FOREACH(fsle, &fsdriver_entries, next) { + p_next =3D g_new0(ThrottleLimitsList, 1); + fsdev_get_io_throttle(&fsle->fse.fst, &p_next->value, + fsle->fse.fsdev_id); + p_next->next =3D head; + head =3D p_next; + } + return head; +} diff --git a/monitor.c b/monitor.c index 9239f7a..d12334f 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 f3af2cb..bd55190 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -93,6 +93,10 @@ { 'include': 'qapi/trace.json' } { 'include': 'qapi/introspect.json' } =20 +# QAPI fsdev definitions +{ 'include': 'qapi/fsdev.json' } + + ## # =3D Miscellanea ## diff --git a/qapi/fsdev.json b/qapi/fsdev.json new file mode 100644 index 0000000..7babc30 --- /dev/null +++ b/qapi/fsdev.json @@ -0,0 +1,81 @@ +# -*- Mode: Python -*- + +## +# =3D=3D QAPI fsdev definitions +## + +## +# @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.11 +# +# 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': 'ThrottleLimits' } +## +# @query-fsdev-io-throttle: +# +# Returns: a list of @IOThrottle describing I/O throttle +# values of each fsdev device +# +# Since: 2.11 +# +# 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': [ 'ThrottleLimits' ] } diff --git a/qmp.c b/qmp.c index b86201e..8de2e23 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(ThrottleLimits *arg, Error **errp) +{ + return; +} + +ThrottleLimitsList *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 Sat May 4 23:02:31 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 1505385743216405.52558504144554; Thu, 14 Sep 2017 03:42:23 -0700 (PDT) Received: from localhost ([::1]:46870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRbC-0008Hm-Cj for importer@patchew.org; Thu, 14 Sep 2017 06:42:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRZi-0006q1-19 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsRZg-000212-Pb for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:50 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:33675) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dsRZg-0001zr-F0 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:48 -0400 Received: by mail-wm0-x242.google.com with SMTP id 187so2884675wmn.0 for ; Thu, 14 Sep 2017 03:40:48 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id w14sm742801wmf.13.2017.09.14.03.40.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 03:40:46 -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=clxHdF063gSl2z+SG1HGpEXg4uKErp3vr8lBkxlZfZg=; b=jZFI9QVYbMPVQaWRqfIgsdWr23TVPfkrS1NhDObGq6GA1m4pNH3XskLyoRDaApqoX2 JpLr20yd5c6GFYqdjTntHFHncBm0F630999MgKof2gqW7MHh+U6Lx6Kef80le0qjml3e 4d7HkwhOY1T54ig945qllf4GpQPhvBESBwf2hD+FSEpyCHU/Xm+zX/ip69l72wabITzO f1bQQqhIjK6VJOTplaz+/pANnJkIUiMtbpBe2JhKzG8gsptULLR8AKz2b+2xsAasL4Ke 4TrbrNPzEwwxioOhWaDNmBiSuEDwNVfYt07fHUhKDeGwXscct1sWbfm4z7SnTlvanuVW mHYA== 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=clxHdF063gSl2z+SG1HGpEXg4uKErp3vr8lBkxlZfZg=; b=VCSaEqcgVlPf787LobkgoPPRVRpLGa7ludKbyg1nlmbTiYOMgR1di8+uJ0PbllGTz/ xrgRziOMtjBP7k7VzCIswImhgtK9JFviCpizMBI6qc7ZFZ//JBAsLphbSLiLM0r2i7RD sZud8Ek0HSpO5hbqcia+BHoEaR2y68Y0cn2u/tHL1Dv0X6uYPZrpqBY/okC1vzJLkRqZ GnwUZY2fEsAYR7BWlSoda7xocsX9DtTi7WL2fsF11gA1YSNS/bqATXwqPtI/8jlTQ3Ha 82QjXx8QuLf+RfyRBoToM8QCWHgRB8T97VM/mCMheHPDRDE1uX/Z3RnY1xPMQ+hNrcht mJTw== X-Gm-Message-State: AHPjjUiGocrIBMBWei3FNYpUachgndVm/oALNvRCNqJHjOW2MBimVs+6 O7y/EAalfq42ADnZ X-Google-Smtp-Source: AOwi7QA8fhnNT6tH/3vFVmzaGjIuu2TbbJGfYL5L65spH7agQLJXsPNRgTWGjc4ueTvw5y5nGgAvGQ== X-Received: by 10.28.111.196 with SMTP id c65mr1394118wmi.18.1505385647356; Thu, 14 Sep 2017 03:40:47 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Thu, 14 Sep 2017 06:40:10 -0400 Message-Id: <1505385610-35529-7-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1505385610-35529-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1505385610-35529-1-git-send-email-pradeep.jagadeesh@huawei.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH v11 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 Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Alberto Garcia --- hmp-commands-info.hx | 18 ++++++++++++++++ hmp-commands.hx | 19 +++++++++++++++++ hmp.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ hmp.h | 4 ++++ 4 files changed, 100 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 4ab7fce..54f1968 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 acaf0e6..ceec6c9 100644 --- a/hmp.c +++ b/hmp.c @@ -1778,6 +1778,65 @@ 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; + ThrottleLimits throttle =3D { + .has_id =3D true, + .id =3D (char *) qdict_get_str(qdict, "device"), + }; + + hmp_initialize_throttle_limits(&throttle, qdict); + qmp_fsdev_set_io_throttle(&throttle, &err); + hmp_handle_error(mon, &err); +} + +static void print_fsdev_throttle_config(Monitor *mon, ThrottleLimits *fscf= g) +{ + 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_total, + fscfg->bps_read, + fscfg->bps_write, + fscfg->bps_total_max, + fscfg->bps_read_max, + fscfg->bps_write_max, + fscfg->iops_total, + fscfg->iops_read, + fscfg->iops_write, + fscfg->iops_total_max, + fscfg->iops_read_max, + fscfg->iops_write_max, + fscfg->iops_size); +} + +void hmp_info_fsdev_iothrottle(Monitor *mon, const QDict *qdict) +{ + ThrottleLimitsList *fsdev_list, *info; + fsdev_list =3D qmp_query_fsdev_io_throttle(NULL); + + for (info =3D fsdev_list; info; info =3D info->next) { + print_fsdev_throttle_config(mon, info->value); + } + qapi_free_ThrottleLimitsList(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