]> git.proxmox.com Git - mirror_qemu.git/commitdiff
throttle: Set always an average value when setting a maximum value
authorAlberto Garcia <berto@igalia.com>
Thu, 18 Feb 2016 10:26:58 +0000 (12:26 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 22 Feb 2016 13:08:05 +0000 (14:08 +0100)
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>
tests/test-throttle.c

index 0e7c7e0f3f73576fca2ddf5ff819657630094b7d..3e208a8024871b73d72074a8b243545f42a7757b 100644 (file)
@@ -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;
     }