From 2024c1df43eae0d2e35663da0c6e8c51290a386e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Mon, 2 Sep 2013 14:14:41 +0200 Subject: 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 Signed-off-by: Stefan Hajnoczi --- blockdev.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'blockdev.c') 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; @@ -2037,6 +2044,10 @@ QemuOptsList qemu_common_drive_opts = { .name = "throttling.bps-write-max", .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, -- cgit v1.2.3