int write)
{
memset(&cfg, 0, sizeof(cfg));
- g_assert(!throttle_conflicting(&cfg));
+ g_assert(!throttle_conflicting(&cfg, NULL));
set_cfg_value(is_max, total, 1);
set_cfg_value(is_max, read, 1);
- g_assert(throttle_conflicting(&cfg));
+ g_assert(throttle_conflicting(&cfg, NULL));
memset(&cfg, 0, sizeof(cfg));
set_cfg_value(is_max, total, 1);
set_cfg_value(is_max, write, 1);
- g_assert(throttle_conflicting(&cfg));
+ g_assert(throttle_conflicting(&cfg, NULL));
memset(&cfg, 0, sizeof(cfg));
set_cfg_value(is_max, total, 1);
set_cfg_value(is_max, read, 1);
set_cfg_value(is_max, write, 1);
- g_assert(throttle_conflicting(&cfg));
+ g_assert(throttle_conflicting(&cfg, NULL));
memset(&cfg, 0, sizeof(cfg));
set_cfg_value(is_max, total, 1);
- g_assert(!throttle_conflicting(&cfg));
+ g_assert(!throttle_conflicting(&cfg, NULL));
memset(&cfg, 0, sizeof(cfg));
set_cfg_value(is_max, read, 1);
set_cfg_value(is_max, write, 1);
- g_assert(!throttle_conflicting(&cfg));
+ g_assert(!throttle_conflicting(&cfg, NULL));
}
static void test_conflicting_config(void)
*
* @cfg: the throttling configuration to inspect
* @ret: true if any conflict detected else false
+ * @errp: error object
*/
-bool throttle_conflicting(ThrottleConfig *cfg)
+bool throttle_conflicting(ThrottleConfig *cfg, Error **errp)
{
bool bps_flag, ops_flag;
bool bps_max_flag, ops_max_flag;
(cfg->buckets[THROTTLE_OPS_READ].max ||
cfg->buckets[THROTTLE_OPS_WRITE].max);
- return bps_flag || ops_flag || bps_max_flag || ops_max_flag;
+ if (bps_flag || ops_flag || bps_max_flag || ops_max_flag) {
+ error_setg(errp, "bps/iops/max total values and read/write values"
+ " cannot be used at the same time");
+ return true;
+ }
+
+ return false;
}
/* check if a throttling configuration is valid