qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pradeep Jagadeesh <pradeepkiruvale@gmail.com>
To: eric blake <eblake@redhat.com>, greg kurz <groug@kaod.org>
Cc: Pradeep Jagadeesh <pradeep.jagadeesh@huawei.com>,
	alberto garcia <berto@igalia.com>,
	Markus Armbruster <armbru@redhat.com>,
	jani kokkonen <jani.kokkonen@huawei.com>,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v13 3/6] qmp: factor out throttle code to reuse code
Date: Mon,  2 Oct 2017 10:33:29 -0400	[thread overview]
Message-ID: <1506954812-6552-4-git-send-email-pradeep.jagadeesh@huawei.com> (raw)
In-Reply-To: <1506954812-6552-1-git-send-email-pradeep.jagadeesh@huawei.com>

This patch reuses the code to set throttle limits.

Signed-off-by: Pradeep Jagadeesh <pradeep.jagadeesh@huawei.com>
---
 blockdev.c | 53 +++--------------------------------------------------
 1 file changed, 3 insertions(+), 50 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 43f706d..364df4d 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2570,6 +2570,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)
     BlockDriverState *bs;
     BlockBackend *blk;
     AioContext *aio_context;
+    ThrottleLimits *tlimit;
 
     blk = qmp_get_blk(arg->has_device ? arg->device : NULL,
                       arg->has_id ? arg->id : NULL,
@@ -2587,56 +2588,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)
         goto out;
     }
 
-    throttle_config_init(&cfg);
-    cfg.buckets[THROTTLE_BPS_TOTAL].avg = arg->bps;
-    cfg.buckets[THROTTLE_BPS_READ].avg  = arg->bps_rd;
-    cfg.buckets[THROTTLE_BPS_WRITE].avg = arg->bps_wr;
-
-    cfg.buckets[THROTTLE_OPS_TOTAL].avg = arg->iops;
-    cfg.buckets[THROTTLE_OPS_READ].avg  = arg->iops_rd;
-    cfg.buckets[THROTTLE_OPS_WRITE].avg = arg->iops_wr;
-
-    if (arg->has_bps_max) {
-        cfg.buckets[THROTTLE_BPS_TOTAL].max = arg->bps_max;
-    }
-    if (arg->has_bps_rd_max) {
-        cfg.buckets[THROTTLE_BPS_READ].max = arg->bps_rd_max;
-    }
-    if (arg->has_bps_wr_max) {
-        cfg.buckets[THROTTLE_BPS_WRITE].max = arg->bps_wr_max;
-    }
-    if (arg->has_iops_max) {
-        cfg.buckets[THROTTLE_OPS_TOTAL].max = arg->iops_max;
-    }
-    if (arg->has_iops_rd_max) {
-        cfg.buckets[THROTTLE_OPS_READ].max = arg->iops_rd_max;
-    }
-    if (arg->has_iops_wr_max) {
-        cfg.buckets[THROTTLE_OPS_WRITE].max = arg->iops_wr_max;
-    }
-
-    if (arg->has_bps_max_length) {
-        cfg.buckets[THROTTLE_BPS_TOTAL].burst_length = arg->bps_max_length;
-    }
-    if (arg->has_bps_rd_max_length) {
-        cfg.buckets[THROTTLE_BPS_READ].burst_length = arg->bps_rd_max_length;
-    }
-    if (arg->has_bps_wr_max_length) {
-        cfg.buckets[THROTTLE_BPS_WRITE].burst_length = arg->bps_wr_max_length;
-    }
-    if (arg->has_iops_max_length) {
-        cfg.buckets[THROTTLE_OPS_TOTAL].burst_length = arg->iops_max_length;
-    }
-    if (arg->has_iops_rd_max_length) {
-        cfg.buckets[THROTTLE_OPS_READ].burst_length = arg->iops_rd_max_length;
-    }
-    if (arg->has_iops_wr_max_length) {
-        cfg.buckets[THROTTLE_OPS_WRITE].burst_length = arg->iops_wr_max_length;
-    }
-
-    if (arg->has_iops_size) {
-        cfg.op_size = arg->iops_size;
-    }
+    tlimit = qapi_BlockIOThrottle_base(arg);
+    throttle_config_to_limits(&cfg, tlimit);
 
     if (!throttle_is_valid(&cfg, errp)) {
         goto out;
-- 
1.8.3.1

  parent reply	other threads:[~2017-10-02 14:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-02 14:33 [Qemu-devel] [PATCH v13 0/6] fsdev: qmp interface for io throttling Pradeep Jagadeesh
2017-10-02 14:33 ` [Qemu-devel] [PATCH v13 1/6] throttle: factor out duplicate code Pradeep Jagadeesh
2017-10-02 14:33 ` [Qemu-devel] [PATCH v13 2/6] qmp: Use ThrottleLimits structure Pradeep Jagadeesh
2017-10-13 14:16   ` Alberto Garcia
2017-10-13 14:26     ` Eric Blake
2017-11-02 10:25       ` Pradeep Jagadeesh
2017-11-06  9:35       ` Manos Pitsidianakis
2017-11-06 12:52         ` Pradeep Jagadeesh
2017-11-13 13:02       ` Pradeep Jagadeesh
2017-10-02 14:33 ` Pradeep Jagadeesh [this message]
2017-10-13 14:29   ` [Qemu-devel] [PATCH v13 3/6] qmp: factor out throttle code to reuse code Alberto Garcia
2017-11-02 10:55     ` Pradeep Jagadeesh
2017-11-02 11:00       ` Alberto Garcia
2017-11-02 12:03         ` Pradeep Jagadeesh
2017-10-02 14:33 ` [Qemu-devel] [PATCH v13 4/6] hmp: create a throttle initialization function for code reuse Pradeep Jagadeesh
2017-10-02 14:33 ` [Qemu-devel] [PATCH v13 5/6] fsdev: QMP interface for throttling Pradeep Jagadeesh
2017-10-02 14:33 ` [Qemu-devel] [PATCH v13 6/6] fsdev: hmp " Pradeep Jagadeesh
2017-10-13 13:55   ` Alberto Garcia
2017-10-02 15:34 ` [Qemu-devel] [PATCH v13 0/6] fsdev: qmp interface for io throttling no-reply
2017-12-06 16:07 ` Greg Kurz
2017-12-06 16:15   ` Pradeep Jagadeesh
2017-12-06 16:49     ` Eric Blake
2017-12-06 17:12       ` Pradeep Jagadeesh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1506954812-6552-4-git-send-email-pradeep.jagadeesh@huawei.com \
    --to=pradeepkiruvale@gmail.com \
    --cc=armbru@redhat.com \
    --cc=berto@igalia.com \
    --cc=eblake@redhat.com \
    --cc=groug@kaod.org \
    --cc=jani.kokkonen@huawei.com \
    --cc=pradeep.jagadeesh@huawei.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).