[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v12 3/6] qmp: factor out throttle code to reuse code
From: |
Pradeep Jagadeesh |
Subject: |
[Qemu-devel] [PATCH v12 3/6] qmp: factor out throttle code to reuse code |
Date: |
Fri, 22 Sep 2017 08:03:42 -0400 |
This patch reuses the code to set throttle limits.
Signed-off-by: Pradeep Jagadeesh <address@hidden>
---
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;
blk = 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;
}
- 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
- [Qemu-devel] [PATCH v12 0/6] fsdev: qmp interface for io throttling, Pradeep Jagadeesh, 2017/09/22
- [Qemu-devel] [PATCH v12 2/6] qmp: Use ThrottleLimits structure, Pradeep Jagadeesh, 2017/09/22
- [Qemu-devel] [PATCH v12 4/6] hmp: create a throttle initialization function for code reuse, Pradeep Jagadeesh, 2017/09/22
- [Qemu-devel] [PATCH v12 1/6] throttle: factor out duplicate code, Pradeep Jagadeesh, 2017/09/22
- [Qemu-devel] [PATCH v12 3/6] qmp: factor out throttle code to reuse code,
Pradeep Jagadeesh <=
- [Qemu-devel] [PATCH v12 6/6] fsdev: hmp interface for throttling, Pradeep Jagadeesh, 2017/09/22
- [Qemu-devel] [PATCH v12 5/6] fsdev: QMP interface for throttling, Pradeep Jagadeesh, 2017/09/22