diff options
-rw-r--r-- | blockdev.c | 6 | ||||
-rw-r--r-- | include/qemu/throttle.h | 2 | ||||
-rw-r--r-- | util/throttle.c | 15 |
3 files changed, 23 insertions, 0 deletions
diff --git a/blockdev.c b/blockdev.c index 62a4586cd6..4125ff642a 100644 --- a/blockdev.c +++ b/blockdev.c @@ -337,6 +337,12 @@ static bool check_throttle_config(ThrottleConfig *cfg, Error **errp) 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; } diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h index 995b2d5957..12faaad959 100644 --- a/include/qemu/throttle.h +++ b/include/qemu/throttle.h @@ -114,6 +114,8 @@ bool throttle_conflicting(ThrottleConfig *cfg); bool throttle_is_valid(ThrottleConfig *cfg); +bool throttle_max_is_missing_limit(ThrottleConfig *cfg); + void throttle_config(ThrottleState *ts, ThrottleTimers *tt, ThrottleConfig *cfg); diff --git a/util/throttle.c b/util/throttle.c index 706c13111e..1113671ecf 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) { |