summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorPeter Maydell2017-09-07 11:45:18 +0200
committerPeter Maydell2017-09-07 11:45:18 +0200
commit8ee5f9b3ecc94e3eb7a8235f4b2c3ec9024807f6 (patch)
tree302d6285c803b2317a41bcd1dc5ffc67c0959776 /util
parentMerge remote-tracking branch 'remotes/juanquintela/tags/tests/20170906' into ... (diff)
parentqcow2: move qcow2_store_persistent_dirty_bitmaps() before cache flushing (diff)
downloadqemu-8ee5f9b3ecc94e3eb7a8235f4b2c3ec9024807f6.tar.gz
qemu-8ee5f9b3ecc94e3eb7a8235f4b2c3ec9024807f6.tar.xz
qemu-8ee5f9b3ecc94e3eb7a8235f4b2c3ec9024807f6.zip
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches # gpg: Signature made Wed 06 Sep 2017 14:44:41 BST # gpg: using RSA key 0x7F09B272C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: qcow2: move qcow2_store_persistent_dirty_bitmaps() before cache flushing qemu-iotests: add 184 for throttle filter driver block: add throttle block filter driver block: convert ThrottleGroup to object with QOM block: tidy ThrottleGroupMember initializations block: add aio_context field in ThrottleGroupMember block: move ThrottleGroup membership to ThrottleGroupMember block: document semantics of bdrv_co_preadv|pwritev qcow: Check failure of bdrv_getlength() and bdrv_truncate() qcow: Change signature of get_cluster_offset() block: add default implementations for bdrv_co_get_block_status() block: remove bdrv_truncate callback in blkdebug block: remove unused bdrv_media_changed block: pass bdrv_* methods to bs->file by default in block filters Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'util')
-rw-r--r--util/throttle.c151
1 files changed, 151 insertions, 0 deletions
diff --git a/util/throttle.c b/util/throttle.c
index b8c524336c..06bf916adc 100644
--- a/util/throttle.c
+++ b/util/throttle.c
@@ -484,3 +484,154 @@ void throttle_account(ThrottleState *ts, bool is_write, uint64_t size)
}
}
+/* return a ThrottleConfig based on the options in a ThrottleLimits
+ *
+ * @arg: the ThrottleLimits object to read from
+ * @cfg: the ThrottleConfig to edit
+ * @errp: error object
+ */
+void throttle_limits_to_config(ThrottleLimits *arg, ThrottleConfig *cfg,
+ Error **errp)
+{
+ if (arg->has_bps_total) {
+ cfg->buckets[THROTTLE_BPS_TOTAL].avg = arg->bps_total;
+ }
+ if (arg->has_bps_read) {
+ cfg->buckets[THROTTLE_BPS_READ].avg = arg->bps_read;
+ }
+ if (arg->has_bps_write) {
+ cfg->buckets[THROTTLE_BPS_WRITE].avg = arg->bps_write;
+ }
+
+ if (arg->has_iops_total) {
+ cfg->buckets[THROTTLE_OPS_TOTAL].avg = arg->iops_total;
+ }
+ if (arg->has_iops_read) {
+ cfg->buckets[THROTTLE_OPS_READ].avg = arg->iops_read;
+ }
+ if (arg->has_iops_write) {
+ cfg->buckets[THROTTLE_OPS_WRITE].avg = arg->iops_write;
+ }
+
+ if (arg->has_bps_total_max) {
+ cfg->buckets[THROTTLE_BPS_TOTAL].max = arg->bps_total_max;
+ }
+ if (arg->has_bps_read_max) {
+ cfg->buckets[THROTTLE_BPS_READ].max = arg->bps_read_max;
+ }
+ if (arg->has_bps_write_max) {
+ cfg->buckets[THROTTLE_BPS_WRITE].max = arg->bps_write_max;
+ }
+ if (arg->has_iops_total_max) {
+ cfg->buckets[THROTTLE_OPS_TOTAL].max = arg->iops_total_max;
+ }
+ if (arg->has_iops_read_max) {
+ cfg->buckets[THROTTLE_OPS_READ].max = arg->iops_read_max;
+ }
+ if (arg->has_iops_write_max) {
+ cfg->buckets[THROTTLE_OPS_WRITE].max = arg->iops_write_max;
+ }
+
+ if (arg->has_bps_total_max_length) {
+ if (arg->bps_total_max_length > UINT_MAX) {
+ error_setg(errp, "bps-total-max-length value must be in"
+ " the range [0, %u]", UINT_MAX);
+ return;
+ }
+ cfg->buckets[THROTTLE_BPS_TOTAL].burst_length = arg->bps_total_max_length;
+ }
+ if (arg->has_bps_read_max_length) {
+ if (arg->bps_read_max_length > UINT_MAX) {
+ error_setg(errp, "bps-read-max-length value must be in"
+ " the range [0, %u]", UINT_MAX);
+ return;
+ }
+ cfg->buckets[THROTTLE_BPS_READ].burst_length = arg->bps_read_max_length;
+ }
+ if (arg->has_bps_write_max_length) {
+ if (arg->bps_write_max_length > UINT_MAX) {
+ error_setg(errp, "bps-write-max-length value must be in"
+ " the range [0, %u]", UINT_MAX);
+ return;
+ }
+ cfg->buckets[THROTTLE_BPS_WRITE].burst_length = arg->bps_write_max_length;
+ }
+ if (arg->has_iops_total_max_length) {
+ if (arg->iops_total_max_length > UINT_MAX) {
+ error_setg(errp, "iops-total-max-length value must be in"
+ " the range [0, %u]", UINT_MAX);
+ return;
+ }
+ cfg->buckets[THROTTLE_OPS_TOTAL].burst_length = arg->iops_total_max_length;
+ }
+ if (arg->has_iops_read_max_length) {
+ if (arg->iops_read_max_length > UINT_MAX) {
+ error_setg(errp, "iops-read-max-length value must be in"
+ " the range [0, %u]", UINT_MAX);
+ return;
+ }
+ cfg->buckets[THROTTLE_OPS_READ].burst_length = arg->iops_read_max_length;
+ }
+ if (arg->has_iops_write_max_length) {
+ if (arg->iops_write_max_length > UINT_MAX) {
+ error_setg(errp, "iops-write-max-length value must be in"
+ " the range [0, %u]", UINT_MAX);
+ return;
+ }
+ cfg->buckets[THROTTLE_OPS_WRITE].burst_length = arg->iops_write_max_length;
+ }
+
+ if (arg->has_iops_size) {
+ cfg->op_size = arg->iops_size;
+ }
+
+ throttle_is_valid(cfg, errp);
+}
+
+/* write the options of a ThrottleConfig to a ThrottleLimits
+ *
+ * @cfg: the ThrottleConfig to read from
+ * @var: the ThrottleLimits to write to
+ */
+void throttle_config_to_limits(ThrottleConfig *cfg, ThrottleLimits *var)
+{
+ var->bps_total = cfg->buckets[THROTTLE_BPS_TOTAL].avg;
+ var->bps_read = cfg->buckets[THROTTLE_BPS_READ].avg;
+ var->bps_write = cfg->buckets[THROTTLE_BPS_WRITE].avg;
+ var->iops_total = cfg->buckets[THROTTLE_OPS_TOTAL].avg;
+ var->iops_read = cfg->buckets[THROTTLE_OPS_READ].avg;
+ var->iops_write = cfg->buckets[THROTTLE_OPS_WRITE].avg;
+ var->bps_total_max = cfg->buckets[THROTTLE_BPS_TOTAL].max;
+ var->bps_read_max = cfg->buckets[THROTTLE_BPS_READ].max;
+ var->bps_write_max = cfg->buckets[THROTTLE_BPS_WRITE].max;
+ var->iops_total_max = cfg->buckets[THROTTLE_OPS_TOTAL].max;
+ var->iops_read_max = cfg->buckets[THROTTLE_OPS_READ].max;
+ var->iops_write_max = cfg->buckets[THROTTLE_OPS_WRITE].max;
+ var->bps_total_max_length = cfg->buckets[THROTTLE_BPS_TOTAL].burst_length;
+ var->bps_read_max_length = cfg->buckets[THROTTLE_BPS_READ].burst_length;
+ var->bps_write_max_length = cfg->buckets[THROTTLE_BPS_WRITE].burst_length;
+ var->iops_total_max_length = cfg->buckets[THROTTLE_OPS_TOTAL].burst_length;
+ var->iops_read_max_length = cfg->buckets[THROTTLE_OPS_READ].burst_length;
+ var->iops_write_max_length = cfg->buckets[THROTTLE_OPS_WRITE].burst_length;
+ var->iops_size = cfg->op_size;
+
+ var->has_bps_total = true;
+ var->has_bps_read = true;
+ var->has_bps_write = true;
+ var->has_iops_total = true;
+ var->has_iops_read = true;
+ var->has_iops_write = true;
+ var->has_bps_total_max = true;
+ var->has_bps_read_max = true;
+ var->has_bps_write_max = true;
+ var->has_iops_total_max = true;
+ var->has_iops_read_max = true;
+ var->has_iops_write_max = true;
+ var->has_bps_read_max_length = true;
+ var->has_bps_total_max_length = true;
+ var->has_bps_write_max_length = true;
+ var->has_iops_total_max_length = true;
+ var->has_iops_read_max_length = true;
+ var->has_iops_write_max_length = true;
+ var->has_iops_size = true;
+}