/* functions to test the throttle_is_valid function */ static void test_is_valid_for_value(int value, bool should_be_valid) { int is_max, index; for (is_max = 0; is_max < 2; is_max++) { for (index = 0; index < BUCKETS_COUNT; index++) { memset(&cfg, 0, sizeof(cfg)); set_cfg_value(is_max, index, value); g_assert(throttle_is_valid(&cfg) == should_be_valid); } } }
void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp) { throttle_config_init(&fst->cfg); fst->cfg.buckets[THROTTLE_BPS_TOTAL].avg = qemu_opt_get_number(opts, "throttling.bps-total", 0); fst->cfg.buckets[THROTTLE_BPS_READ].avg = qemu_opt_get_number(opts, "throttling.bps-read", 0); fst->cfg.buckets[THROTTLE_BPS_WRITE].avg = qemu_opt_get_number(opts, "throttling.bps-write", 0); fst->cfg.buckets[THROTTLE_OPS_TOTAL].avg = qemu_opt_get_number(opts, "throttling.iops-total", 0); fst->cfg.buckets[THROTTLE_OPS_READ].avg = qemu_opt_get_number(opts, "throttling.iops-read", 0); fst->cfg.buckets[THROTTLE_OPS_WRITE].avg = qemu_opt_get_number(opts, "throttling.iops-write", 0); fst->cfg.buckets[THROTTLE_BPS_TOTAL].max = qemu_opt_get_number(opts, "throttling.bps-total-max", 0); fst->cfg.buckets[THROTTLE_BPS_READ].max = qemu_opt_get_number(opts, "throttling.bps-read-max", 0); fst->cfg.buckets[THROTTLE_BPS_WRITE].max = qemu_opt_get_number(opts, "throttling.bps-write-max", 0); fst->cfg.buckets[THROTTLE_OPS_TOTAL].max = qemu_opt_get_number(opts, "throttling.iops-total-max", 0); fst->cfg.buckets[THROTTLE_OPS_READ].max = qemu_opt_get_number(opts, "throttling.iops-read-max", 0); fst->cfg.buckets[THROTTLE_OPS_WRITE].max = qemu_opt_get_number(opts, "throttling.iops-write-max", 0); fst->cfg.buckets[THROTTLE_BPS_TOTAL].burst_length = qemu_opt_get_number(opts, "throttling.bps-total-max-length", 1); fst->cfg.buckets[THROTTLE_BPS_READ].burst_length = qemu_opt_get_number(opts, "throttling.bps-read-max-length", 1); fst->cfg.buckets[THROTTLE_BPS_WRITE].burst_length = qemu_opt_get_number(opts, "throttling.bps-write-max-length", 1); fst->cfg.buckets[THROTTLE_OPS_TOTAL].burst_length = qemu_opt_get_number(opts, "throttling.iops-total-max-length", 1); fst->cfg.buckets[THROTTLE_OPS_READ].burst_length = qemu_opt_get_number(opts, "throttling.iops-read-max-length", 1); fst->cfg.buckets[THROTTLE_OPS_WRITE].burst_length = qemu_opt_get_number(opts, "throttling.iops-write-max-length", 1); fst->cfg.op_size = qemu_opt_get_number(opts, "throttling.iops-size", 0); throttle_is_valid(&fst->cfg, errp); }