summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlberto Garcia <berto@igalia.com>2016-02-18 12:26:58 +0200
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:45:30 -0600
commit9732238ed90bfdd06382f713b2b2d0c7671a7726 (patch)
tree2f99edddba3b9c7487a5b2c4431241b9d3d97511
parent45a97a86738600fcb93eb1ce763a743acb630db6 (diff)
downloadhqemu-9732238ed90bfdd06382f713b2b2d0c7671a7726.zip
hqemu-9732238ed90bfdd06382f713b2b2d0c7671a7726.tar.gz
throttle: Set always an average value when setting a maximum value
When testing the ranges of valid values, set_cfg_value() creates sometimes invalid throttling configurations by setting bucket.max while leaving bucket.avg uninitialized. While this doesn't break the current tests, it will as soon as we unify all functions that check the validity of the throttling configuration. This patch ensures that the value of bucket.avg is valid when setting bucket.max. Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--tests/test-throttle.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/test-throttle.c b/tests/test-throttle.c
index 0e7c7e0..3e208a8 100644
--- a/tests/test-throttle.c
+++ b/tests/test-throttle.c
@@ -222,6 +222,8 @@ static void set_cfg_value(bool is_max, int index, int value)
{
if (is_max) {
cfg.buckets[index].max = value;
+ /* If max is set, avg should never be 0 */
+ cfg.buckets[index].avg = MAX(cfg.buckets[index].avg, 1);
} else {
cfg.buckets[index].avg = value;
}
OpenPOWER on IntegriCloud