[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v13 4/6] hmp: create a throttle initialization funct
From: |
Pradeep Jagadeesh |
Subject: |
[Qemu-devel] [PATCH v13 4/6] hmp: create a throttle initialization function for code reuse |
Date: |
Mon, 2 Oct 2017 10:33:30 -0400 |
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 <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Reviewed-by: Greg Kurz <address@hidden>
Acked-by: Dr. David Alan Gilbert <address@hidden>
---
hmp.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/hmp.c b/hmp.c
index ace729d..904fc4a 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1766,20 +1766,28 @@ void hmp_change(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, &err);
}
+static void hmp_initialize_throttle_limits(ThrottleLimits *iot,
+ const QDict *qdict)
+{
+ iot->bps_total = qdict_get_int(qdict, "bps");
+ iot->bps_read = qdict_get_int(qdict, "bps_rd");
+ iot->bps_write = qdict_get_int(qdict, "bps_wr");
+ iot->iops_total = qdict_get_int(qdict, "iops");
+ iot->iops_read = qdict_get_int(qdict, "iops_rd");
+ iot->iops_write = qdict_get_int(qdict, "iops_wr");
+}
+
void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
+ ThrottleLimits *tlimits;
BlockIOThrottle throttle = {
.has_device = true,
.device = (char *) qdict_get_str(qdict, "device"),
- .bps = qdict_get_int(qdict, "bps"),
- .bps_rd = qdict_get_int(qdict, "bps_rd"),
- .bps_wr = qdict_get_int(qdict, "bps_wr"),
- .iops = qdict_get_int(qdict, "iops"),
- .iops_rd = qdict_get_int(qdict, "iops_rd"),
- .iops_wr = qdict_get_int(qdict, "iops_wr"),
};
+ tlimits = qapi_BlockIOThrottle_base(&throttle);
+ hmp_initialize_throttle_limits(tlimits, qdict);
qmp_block_set_io_throttle(&throttle, &err);
hmp_handle_error(mon, &err);
}
--
1.8.3.1
- [Qemu-devel] [PATCH v13 0/6] fsdev: qmp interface for io throttling, Pradeep Jagadeesh, 2017/10/02
- [Qemu-devel] [PATCH v13 1/6] throttle: factor out duplicate code, Pradeep Jagadeesh, 2017/10/02
- [Qemu-devel] [PATCH v13 3/6] qmp: factor out throttle code to reuse code, Pradeep Jagadeesh, 2017/10/02
- [Qemu-devel] [PATCH v13 6/6] fsdev: hmp interface for throttling, Pradeep Jagadeesh, 2017/10/02
- [Qemu-devel] [PATCH v13 2/6] qmp: Use ThrottleLimits structure, Pradeep Jagadeesh, 2017/10/02
- [Qemu-devel] [PATCH v13 4/6] hmp: create a throttle initialization function for code reuse,
Pradeep Jagadeesh <=
- [Qemu-devel] [PATCH v13 5/6] fsdev: QMP interface for throttling, Pradeep Jagadeesh, 2017/10/02
- Re: [Qemu-devel] [PATCH v13 0/6] fsdev: qmp interface for io throttling, no-reply, 2017/10/02