mirror of https://gitee.com/openkylin/qemu.git
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1 iQEcBAABAgAGBQJVzf4KAAoJEJykq7OBq3PIqngH+gN2vOlU0jiGF7Ch66EZRDM5 uRNWdyPtqyEC+knA75njQoxM9djZ6OfbPZRe2VILjRnSctlIIE1SqbG4utcoEHcW iLxo4DJARZswTP+hTJmXQJxTFUFu1vT6jNkRNS1/Sl4lqFFwwj6tSlcQSF5QfnZQ Ah/JnsAO0MNw6Y1lftGRhEu+RhjIwy9ZEMdBcStN/lQReA+gBI/u4px/kkbA5+r/ jQ8P9uGS19I0NF9oqr41CsivZ2mTjE4zz+ZjvI/vGY1a/9SzzqOLZ5eZjGif00Ky EkbPCI2n08WTpyCgUfm/hfFzQa2Y0CKwLYGCulM5aMQyojZElk+l7iOC5LMs65A= =3XXL -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging # gpg: Signature made Fri 14 Aug 2015 15:41:14 BST using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" * remotes/stefanha/tags/block-pull-request: throttle: add throttle_max_is_missing_limit() test throttle: refuse bps_max/iops_max without bps/iops Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
8e0adf6414
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -329,6 +329,26 @@ static void test_is_valid(void)
|
|||
test_is_valid_for_value(1, true);
|
||||
}
|
||||
|
||||
static void test_max_is_missing_limit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BUCKETS_COUNT; i++) {
|
||||
memset(&cfg, 0, sizeof(cfg));
|
||||
cfg.buckets[i].max = 100;
|
||||
cfg.buckets[i].avg = 0;
|
||||
g_assert(throttle_max_is_missing_limit(&cfg));
|
||||
|
||||
cfg.buckets[i].max = 0;
|
||||
cfg.buckets[i].avg = 0;
|
||||
g_assert(!throttle_max_is_missing_limit(&cfg));
|
||||
|
||||
cfg.buckets[i].max = 0;
|
||||
cfg.buckets[i].avg = 100;
|
||||
g_assert(!throttle_max_is_missing_limit(&cfg));
|
||||
}
|
||||
}
|
||||
|
||||
static void test_have_timer(void)
|
||||
{
|
||||
/* zero structures */
|
||||
|
@ -591,6 +611,7 @@ int main(int argc, char **argv)
|
|||
g_test_add_func("/throttle/config/enabled", test_enabled);
|
||||
g_test_add_func("/throttle/config/conflicting", test_conflicting_config);
|
||||
g_test_add_func("/throttle/config/is_valid", test_is_valid);
|
||||
g_test_add_func("/throttle/config/max", test_max_is_missing_limit);
|
||||
g_test_add_func("/throttle/config_functions", test_config_functions);
|
||||
g_test_add_func("/throttle/accounting", test_accounting);
|
||||
g_test_add_func("/throttle/groups", test_groups);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue