Don't allow burst limits to be lower than the normal limits
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
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 | 6 ++++++ 2 files changed, 14 insertions(+)
Signature · 1 line
2.8.1
PATCH 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 | 6 ++++++ 1 file changed, 6 insertions(+)
util/throttle.c +6 -0
@@ -348,6 +348,12 @@ 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,"if bps_max/iops_max is set it cannot be lower" +" than the bps/iops values" ); +return false; + } }return true;
Signature · 1 line
2.8.1
Re: [Qemu-devel] [PATCH for-2.7 1/2] throttle: Don't allow burst limits to be lower than the normal limits
Quoted 18 lines · Alberto Garcia
Setting
FOO_maxto a value that is lower than FOO does not make sense, and it produces odd results depending on the value ofFOO_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
Signed-off-by Alberto Garcia <[email protected]>Reported-by Gu Nini <[email protected]>--- util/throttle.c | 6 ++++++ 1 file changed, 6 insertions(+)util/throttle.c +0
-0
util/throttle.c bool throttle_is_valid(ThrottleConfig *cfg, Error **errp) · line 354
Quoted 7 lines
util/throttle.c +4
-0@@ -348,6 +348,12 @@ 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,"if bps_max/iops_max is set it cannot be lower" +" than the bps/iops values" );
Feels a bit long, I'd be fine with "bps_max/iops_max must not be lower than bps/iops values". But the idea makes sense.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH for-2.7 1/2] throttle: Don't allow burst limits to be lower than the normal limits
Quoted 6 lines · Eric Blake
util/throttle.c bool throttle_is_valid(ThrottleConfig *cfg, Error **errp) · line 354
Quoted 3 lines
util/throttle.c +3
-0+if (cfg->buckets[i].max && cfg->buckets[i].max < cfg->buckets[i].avg) { +error_setg (errp,"if bps_max/iops_max is set it cannot be lower" +" than the bps/iops values" );Feels a bit long, I'd be fine with "bps_max/iops_max must not be lower than bps/iops values". But the idea makes sense.
That's not strictly true since the default value of bps_max is 0 (unless we forbid setting it explicitly to 0 as well).
Berto
Re: [Qemu-devel] [PATCH for-2.7 1/2] throttle: Don't allow burst limits to be lower than the normal limits
Quoted 10 lines · Alberto Garcia
Quoted 6 lines · Eric Blake
util/throttle.c bool throttle_is_valid(ThrottleConfig *cfg, Error **errp) · line 354
Quoted 3 lines
util/throttle.c +3
-0+if (cfg->buckets[i].max && cfg->buckets[i].max < cfg->buckets[i].avg) { +error_setg (errp,"if bps_max/iops_max is set it cannot be lower" +" than the bps/iops values" );Feels a bit long, I'd be fine with "bps_max/iops_max must not be lower than bps/iops values". But the idea makes sense.
That's not strictly true since the default value of
bps_maxis 0 (unless we forbid setting it explicitly to 0 as well).
The message can only be emitted if bps_max was set. If bps_max is its default value of 0 (or even if the user explicitly set it to zero), then this message won't appear. Therefore, telling the user that "if this is set" is redundant, because the error is only issued when it IS set.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 2/2 throttle: Test burst limits lower than the normal limits
In reply to Alberto GarciaThis 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
@@ -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