block: Add iops_size to do the iops accounting for a given io size.
This feature can be used in case where users are avoiding the iops limit by
doing jumbo I/Os hammering the storage backend.
Signed-off-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
diff --git a/blockdev.c b/blockdev.c
index 76e9308..fe2f318 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -507,7 +507,7 @@
cfg.buckets[THROTTLE_OPS_WRITE].max =
qemu_opt_get_number(opts, "throttling.iops-write-max", 0);
- cfg.op_size = 0;
+ cfg.op_size = qemu_opt_get_number(opts, "throttling.iops-size", 0);
if (!check_throttle_config(&cfg, &error)) {
error_report("%s", error_get_pretty(error));
@@ -774,6 +774,9 @@
qemu_opt_rename(all_opts, "bps_rd_max", "throttling.bps-read-max");
qemu_opt_rename(all_opts, "bps_wr_max", "throttling.bps-write-max");
+ qemu_opt_rename(all_opts,
+ "iops_size", "throttling.iops-size");
+
qemu_opt_rename(all_opts, "readonly", "read-only");
value = qemu_opt_get(all_opts, "cache");
@@ -1273,7 +1276,9 @@
bool has_iops_rd_max,
int64_t iops_rd_max,
bool has_iops_wr_max,
- int64_t iops_wr_max, Error **errp)
+ int64_t iops_wr_max,
+ bool has_iops_size,
+ int64_t iops_size, Error **errp)
{
ThrottleConfig cfg;
BlockDriverState *bs;
@@ -1312,7 +1317,9 @@
cfg.buckets[THROTTLE_OPS_WRITE].max = iops_wr_max;
}
- cfg.op_size = 0;
+ if (has_iops_size) {
+ cfg.op_size = iops_size;
+ }
if (!check_throttle_config(&cfg, errp)) {
return;
@@ -2038,6 +2045,10 @@
.type = QEMU_OPT_NUMBER,
.help = "total bytes write burst",
},{
+ .name = "throttling.iops-size",
+ .type = QEMU_OPT_NUMBER,
+ .help = "when limiting by iops max size of an I/O in bytes",
+ },{
.name = "copy-on-read",
.type = QEMU_OPT_BOOL,
.help = "copy read data from backing file into image file",