From 8c228f56be3aed514a4922ce7464474701a36c39 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Wed, 8 Jun 2016 09:25:11 +0200 Subject: [PATCH 1/6] throttle: refuse iops-size without iops-total/read/write RH-Author: Stefan Hajnoczi Message-id: <1465377911-18687-2-git-send-email-stefanha@redhat.com> Patchwork-id: 70564 O-Subject: [RHEV-7.3 qemu-kvm-rhev PATCH 1/1] throttle: refuse iops-size without iops-total/read/write Bugzilla: 1342330 RH-Acked-by: Miroslav Rezanina RH-Acked-by: Max Reitz RH-Acked-by: John Snow In a similar vein to commit ee2bdc33c913b7d765baa5aa338c29fb30a05c9a ("throttle: refuse bps_max/iops_max without bps/iops") it is likely that the user made a configuration error if iops-size has been set but no iops limit has been set. Print an error message so the user can check their throttling configuration. They should either remove iops-size if they don't want any throttling or specify one of iops-total, iops-read, or iops-write. Signed-off-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia Message-id: 1464828031-25601-1-git-send-email-stefanha@redhat.com (cherry picked from commit 8860eabdee32f78d9a34273a340b8f74476bc9a0) Signed-off-by: Stefan Hajnoczi Signed-off-by: Miroslav Rezanina --- tests/test-throttle.c | 10 ++++++++++ util/throttle.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/tests/test-throttle.c b/tests/test-throttle.c index 744a524..526e0b1 100644 --- a/tests/test-throttle.c +++ b/tests/test-throttle.c @@ -397,6 +397,14 @@ static void test_max_is_missing_limit(void) } } +static void test_iops_size_is_missing_limit(void) +{ + /* A total/read/write iops limit is required */ + throttle_config_init(&cfg); + cfg.op_size = 4096; + g_assert(!throttle_is_valid(&cfg, NULL)); +} + static void test_have_timer(void) { /* zero structures */ @@ -647,6 +655,8 @@ int main(int argc, char **argv) g_test_add_func("/throttle/config/conflicting", test_conflicting_config); g_test_add_func("/throttle/config/is_valid", test_is_valid); g_test_add_func("/throttle/config/max", test_max_is_missing_limit); + g_test_add_func("/throttle/config/iops_size", + test_iops_size_is_missing_limit); g_test_add_func("/throttle/config_functions", test_config_functions); g_test_add_func("/throttle/accounting", test_accounting); g_test_add_func("/throttle/groups", test_groups); diff --git a/util/throttle.c b/util/throttle.c index 71246b2..654f95c 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -315,6 +315,14 @@ bool throttle_is_valid(ThrottleConfig *cfg, Error **errp) return false; } + if (cfg->op_size && + !cfg->buckets[THROTTLE_OPS_TOTAL].avg && + !cfg->buckets[THROTTLE_OPS_READ].avg && + !cfg->buckets[THROTTLE_OPS_WRITE].avg) { + error_setg(errp, "iops size requires an iops value to be set"); + return false; + } + for (i = 0; i < BUCKETS_COUNT; i++) { if (cfg->buckets[i].avg < 0 || cfg->buckets[i].max < 0 || -- 1.8.3.1