From ee2bdc33c913b7d765baa5aa338c29fb30a05c9a Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 4 Aug 2015 11:22:12 +0100 Subject: throttle: refuse bps_max/iops_max without bps/iops The bps_max/iops_max values are meaningless without corresponding bps/iops values. Reported an error if bps_max/iops_max is given without bps/iops. Signed-off-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia Message-id: 1438683733-21111-2-git-send-email-stefanha@redhat.com --- util/throttle.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'util/throttle.c') diff --git a/util/throttle.c b/util/throttle.c index 706c131..1113671 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -300,6 +300,21 @@ bool throttle_is_valid(ThrottleConfig *cfg) return !invalid; } +/* check if bps_max/iops_max is used without bps/iops + * @cfg: the throttling configuration to inspect + */ +bool throttle_max_is_missing_limit(ThrottleConfig *cfg) +{ + int i; + + for (i = 0; i < BUCKETS_COUNT; i++) { + if (cfg->buckets[i].max && !cfg->buckets[i].avg) { + return true; + } + } + return false; +} + /* fix bucket parameters */ static void throttle_fix_bucket(LeakyBucket *bkt) { -- cgit v1.1