summaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorBenoƮt Canet <benoit@irqsave.net>2013-09-02 14:14:41 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2013-09-06 15:25:07 +0200
commit2024c1df43eae0d2e35663da0c6e8c51290a386e (patch)
treefb92213d73ab06a296a0c83797735cd66aae1674 /blockdev.c
parent3e9fab690d59ac15956c3733fe0794ce1ae4c4af (diff)
downloadqemu-2024c1df43eae0d2e35663da0c6e8c51290a386e.tar.gz
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>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/blockdev.c b/blockdev.c
index 76e9308e17..fe2f3181d5 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -507,7 +507,7 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
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 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
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 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
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 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
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 @@ QemuOptsList qemu_common_drive_opts = {
.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",