Skip to contentSkip to conversation

Don't allow burst limits to be lower than the normal limits

PATCH Applied Alberto Garcia 3 participants 5 messages Jul 28, 2016 – Aug 4, 2016

lore
Share & tools
lore
#0 lore raw

v2 cover Don't allow burst limits to be lower than the normal limits

Hello,

Gu Nini found this problem and reported it in

https://bugzilla.redhat.com/show_bug.cgi?id=1355665

When setting the throttling configuration, the burst limits can be lower than the normal limits. This does not making any sense and behaves oddly, so let's forbid it.

Berto

v2:
- Simplify error message [Eric]

Alberto Garcia (2):
throttle: Don't allow burst limits to be lower than the normal limits
throttle: Test burst limits lower than the normal limits

 tests/test-throttle.c | 8 ++++++++
 util/throttle.c       | 5 +++++
 2 files changed, 13 insertions(+)
Signature · 1 line
2.8.1
#1 lore raw

PATCH v2 1/2 throttle: Don't allow burst limits to be lower than the normal limits

Setting FOO_max to a value that is lower than FOO does not make sense, and it produces odd results depending on the value of FOO_max_length. Although the user should not set that configuration in the first place it's better to reject it explicitly.

https://bugzilla.redhat.com/show_bug.cgi?id=1355665

---
 util/throttle.c | 5 +++++
 1 file changed, 5 insertions(+)
util/throttle.c +5 -0
index 654f95c..3817d9b 100644
@@ -348,6 +348,11 @@ bool throttle_is_valid(ThrottleConfig *cfg, Error **errp)
                        " bps/iops values");
             return false;
         }
+
+        if (cfg->buckets[i].max && cfg->buckets[i].max < cfg->buckets[i].avg) {
+            error_setg(errp, "bps_max/iops_max cannot be lower than bps/iops");
+            return false;
+        }
     }
 
     return true;
Signature · 1 line
2.8.1
#2 lore raw

PATCH v2 2/2 throttle: Test burst limits lower than the normal limits

In reply to Alberto Garcia

This checks that making FOO_max lower than FOO is not allowed.

We could also forbid having FOO_max == FOO, but that doesn't have any odd side effects and it would require us to update several other tests, so let's keep it simple.

---
 tests/test-throttle.c | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/test-throttle.c +8 -0
index afe094b..363b59a 100644
@@ -394,6 +394,14 @@ static void test_max_is_missing_limit(void)
         cfg.buckets[i].max = 0;
         cfg.buckets[i].avg = 100;
         g_assert(throttle_is_valid(&cfg, NULL));
+
+        cfg.buckets[i].max = 30;
+        cfg.buckets[i].avg = 100;
+        g_assert(!throttle_is_valid(&cfg, NULL));
+
+        cfg.buckets[i].max = 100;
+        cfg.buckets[i].avg = 100;
+        g_assert(throttle_is_valid(&cfg, NULL));
     }
 }
 
Signature · 1 line
2.8.1
Reviewed-by on the v2 series
#3 lore raw
In reply to Alberto Garcia
Quoted 10 lines · Alberto Garcia

Hello,

Gu Nini found this problem and reported it in

https://bugzilla.redhat.com/show_bug.cgi?id=1355665

When setting the throttling configuration, the burst limits can be lower than the normal limits. This does not making any sense and behaves oddly, so let's forbid it.

Quoted 8 lines

Berto

v2:
- Simplify error message [Eric]

Alberto Garcia (2):
throttle: Don't allow burst limits to be lower than the normal limits
throttle: Test burst limits lower than the normal limits

Quoted 5 lines
 tests/test-throttle.c | 8 ++++++++
 util/throttle.c       | 5 +++++
 2 files changed, 13 insertions(+)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#4 lore raw
In reply to Alberto Garcia
Quoted 15 lines · Alberto Garcia

Hello,

Gu Nini found this problem and reported it in

https://bugzilla.redhat.com/show_bug.cgi?id=1355665

When setting the throttling configuration, the burst limits can be lower than the normal limits. This does not making any sense and behaves oddly, so let's forbid it.

Berto

v2:
- Simplify error message [Eric]

Quoted 11 lines

Alberto Garcia (2):
throttle: Don't allow burst limits to be lower than the normal limits
throttle: Test burst limits lower than the normal limits

 tests/test-throttle.c | 8 ++++++++
 util/throttle.c       | 5 +++++
 2 files changed, 13 insertions(+)
Signature · 1 line
2.8.1

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan