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 <stefanha@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Message-id: 1438683733-21111-2-git-send-email-stefanha@redhat.com
This commit is contained in:
parent
2be4f242b5
commit
ee2bdc33c9
|
@ -337,6 +337,12 @@ static bool check_throttle_config(ThrottleConfig *cfg, Error **errp)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (throttle_max_is_missing_limit(cfg)) {
|
||||||
|
error_setg(errp, "bps_max/iops_max require corresponding"
|
||||||
|
" bps/iops values");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,8 @@ bool throttle_conflicting(ThrottleConfig *cfg);
|
||||||
|
|
||||||
bool throttle_is_valid(ThrottleConfig *cfg);
|
bool throttle_is_valid(ThrottleConfig *cfg);
|
||||||
|
|
||||||
|
bool throttle_max_is_missing_limit(ThrottleConfig *cfg);
|
||||||
|
|
||||||
void throttle_config(ThrottleState *ts,
|
void throttle_config(ThrottleState *ts,
|
||||||
ThrottleTimers *tt,
|
ThrottleTimers *tt,
|
||||||
ThrottleConfig *cfg);
|
ThrottleConfig *cfg);
|
||||||
|
|
|
@ -300,6 +300,21 @@ bool throttle_is_valid(ThrottleConfig *cfg)
|
||||||
return !invalid;
|
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 */
|
/* fix bucket parameters */
|
||||||
static void throttle_fix_bucket(LeakyBucket *bkt)
|
static void throttle_fix_bucket(LeakyBucket *bkt)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue