Skip to content

Commit

Permalink
throttle: Make throttle_max_is_missing_limit() set errp
Browse files Browse the repository at this point in the history
The caller does not need to set it, and this will allow us to refactor
this function later.

Signed-off-by: Alberto Garcia <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
bertogg authored and kevmw committed Feb 22, 2016
1 parent 6921b18 commit 45b2d41
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 1 addition & 3 deletions blockdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,7 @@ 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");
if (throttle_max_is_missing_limit(cfg, errp)) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion include/qemu/throttle.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ bool throttle_conflicting(ThrottleConfig *cfg, Error **errp);

bool throttle_is_valid(ThrottleConfig *cfg);

bool throttle_max_is_missing_limit(ThrottleConfig *cfg);
bool throttle_max_is_missing_limit(ThrottleConfig *cfg, Error **errp);

void throttle_config(ThrottleState *ts,
ThrottleTimers *tt,
Expand Down
6 changes: 3 additions & 3 deletions tests/test-throttle.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,15 @@ static void test_max_is_missing_limit(void)
memset(&cfg, 0, sizeof(cfg));
cfg.buckets[i].max = 100;
cfg.buckets[i].avg = 0;
g_assert(throttle_max_is_missing_limit(&cfg));
g_assert(throttle_max_is_missing_limit(&cfg, NULL));

cfg.buckets[i].max = 0;
cfg.buckets[i].avg = 0;
g_assert(!throttle_max_is_missing_limit(&cfg));
g_assert(!throttle_max_is_missing_limit(&cfg, NULL));

cfg.buckets[i].max = 0;
cfg.buckets[i].avg = 100;
g_assert(!throttle_max_is_missing_limit(&cfg));
g_assert(!throttle_max_is_missing_limit(&cfg, NULL));
}
}

Expand Down
5 changes: 4 additions & 1 deletion util/throttle.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,16 @@ bool throttle_is_valid(ThrottleConfig *cfg)

/* check if bps_max/iops_max is used without bps/iops
* @cfg: the throttling configuration to inspect
* @errp: error object
*/
bool throttle_max_is_missing_limit(ThrottleConfig *cfg)
bool throttle_max_is_missing_limit(ThrottleConfig *cfg, Error **errp)
{
int i;

for (i = 0; i < BUCKETS_COUNT; i++) {
if (cfg->buckets[i].max && !cfg->buckets[i].avg) {
error_setg(errp, "bps_max/iops_max require corresponding"
" bps/iops values");
return true;
}
}
Expand Down

0 comments on commit 45b2d41

Please sign in to comment.