fsdev: qmp interface for io throttling
v5 cover fsdev: qmp interface for io throttling
These patches provide the qmp interface, to query the io throttle status of the all fsdev devices that are present in a vm. also, it provides an interface to set the io throttle parameters of a fsdev to a required value. some of the patches also remove the duplicate code that was present in block and fsdev files.
Pradeep Jagadeesh (5):
throttle: factor out duplicate code
qmp: Create IOThrottle structure
qmp: refactor duplicate code
fsdev: hmp interface for throttling
fsdev: QMP interface for throttling
Makefile | 3 + blockdev.c | 97 ++------------------------------- fsdev/qemu-fsdev-dummy.c | 10 ++++ fsdev/qemu-fsdev-throttle.c | 118 ++++++++++++++++++++++++++-------------- fsdev/qemu-fsdev-throttle.h | 13 +++++ fsdev/qemu-fsdev.c | 37 +++++++++++++ hmp-commands-info.hx | 18 ++++++ hmp-commands.hx | 19 +++++++ hmp.c | 87 +++++++++++++++++++++++++++-- hmp.h | 4 ++ include/qemu/throttle-options.h | 7 +++ monitor.c | 5 ++ qapi-schema.json | 3 + qapi/block-core.json | 76 +------------------------- qapi/fsdev.json | 84 ++++++++++++++++++++++++++++ qapi/iothrottle.json | 88 ++++++++++++++++++++++++++++++ qmp.c | 15 +++++ util/throttle.c | 110 +++++++++++++++++++++++++++++++++++++ 18 files changed, 580 insertions(+), 214 deletions(-) create mode 100644 qapi/fsdev.json create mode 100644 qapi/iothrottle.json
v0 -> v1:
Addressed comments from Eric Blake, Greg Kurz and Daniel P.Berrange Mainly renaming the functions and removing the redundant code.
v1 -> v2:
Addressed comments from Eric Blake and Greg Kurz.
As per the suggestion I split the patches into smaller patches. Removed some more duplicate code.
v2 -> v3:
Addresssed comments from Alberto Garcia.
Changed the comment from block to iothrottle in the iothrottle.json Added the dummy functions in qemu-fsdev-dummy.c to address the compilation issues that were observed.
v3 -> v4:
Addressed comments from Eric Blake and Greg Kurz
Re-ordered the patches
Added the dummy functions in qmp.c to address the cross compilation issues
v4 -> v5:
Addressed comments from Eric Blake and Greg Kurz
Split the fsdev qmp patch into hmp and qmp related patches
Moved the common functionalities to throttle.c instead of creating a new file
Signature · 1 line
1.8.3.1
PATCH v5 1/5 throttle: factor out duplicate code
This patch factor out the duplicate throttle code that was present in block and fsdev devices.
--- blockdev.c | 44 +----------------------------------- fsdev/qemu-fsdev-throttle.c | 43 +---------------------------------- fsdev/qemu-fsdev-throttle.h | 1 + include/qemu/throttle-options.h | 4 ++++ util/throttle.c | 50 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 85 deletions(-)
blockdev.c +1 -43
@@ -386,49 +386,7 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, }if (throttle_cfg) { -throttle_config_init (throttle_cfg); - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].avg = -qemu_opt_get_number (opts,"throttling.bps-total" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].avg = -qemu_opt_get_number (opts,"throttling.bps-read" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].avg = -qemu_opt_get_number (opts,"throttling.bps-write" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].avg = -qemu_opt_get_number (opts,"throttling.iops-total" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].avg = -qemu_opt_get_number (opts,"throttling.iops-read" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].avg = -qemu_opt_get_number (opts,"throttling.iops-write" ,0 ); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].max = -qemu_opt_get_number (opts,"throttling.bps-total-max" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].max = -qemu_opt_get_number (opts,"throttling.bps-read-max" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].max = -qemu_opt_get_number (opts,"throttling.bps-write-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].max = -qemu_opt_get_number (opts,"throttling.iops-total-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].max = -qemu_opt_get_number (opts,"throttling.iops-read-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].max = -qemu_opt_get_number (opts,"throttling.iops-write-max" ,0 ); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-total-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-read-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-write-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-total-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-read-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-write-max-length" ,1 ); - - throttle_cfg->op_size = -qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); - +throttle_parse_options (throttle_cfg, opts);if (!throttle_is_valid (throttle_cfg, errp)) {return ; }
fsdev/qemu-fsdev-throttle.c +1 -42
49 lines not on this page · raw message
fsdev/qemu-fsdev-throttle.h +1 -0
@@ -20,6 +20,7 @@#include "qemu/coroutine.h" #include "qapi/error.h" #include "qemu/throttle.h" +#include "qemu/throttle-options.h" typedef struct FsThrottle { ThrottleState ts;
include/qemu/throttle-options.h +4 -0
@@ -10,6 +10,8 @@#ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H +#include "qemu/throttle.h" +#define THROTTLE_OPTS \ { \ .name = "throttling.iops-total",\
@@ -89,4 +91,6 @@ .help = "when limiting by iops max size of an I/O in bytes",\ } +void throttle_parse_options (ThrottleConfig *,QemuOpts *); +#endif
util/throttle.c +50 -0
53 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v5 1/5] throttle: factor out duplicate code
Quoted 5 lines · On Mon, 19 Jun 2017 09:11:32 -0400 Pradeep Jagadeesh…
This patch factor out the duplicate throttle code that was present in block and fsdev devices.
Signed-off-by Pradeep Jagadeesh <[email protected]>---
I guess this patch can be applied right away.
Cc'ing Markus (maintainer of blockdev.c)
Quoted 206 lines
blockdev.c | 44 +----------------------------------- fsdev/qemu-fsdev-throttle.c | 43 +---------------------------------- fsdev/qemu-fsdev-throttle.h | 1 + include/qemu/throttle-options.h | 4 ++++ util/throttle.c | 50 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 85 deletions(-)blockdev.c +1
-43@@ -386,49 +386,7 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, }if (throttle_cfg) { -throttle_config_init (throttle_cfg); - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].avg = -qemu_opt_get_number (opts,"throttling.bps-total" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].avg = -qemu_opt_get_number (opts,"throttling.bps-read" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].avg = -qemu_opt_get_number (opts,"throttling.bps-write" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].avg = -qemu_opt_get_number (opts,"throttling.iops-total" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].avg = -qemu_opt_get_number (opts,"throttling.iops-read" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].avg = -qemu_opt_get_number (opts,"throttling.iops-write" ,0 ); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].max = -qemu_opt_get_number (opts,"throttling.bps-total-max" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].max = -qemu_opt_get_number (opts,"throttling.bps-read-max" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].max = -qemu_opt_get_number (opts,"throttling.bps-write-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].max = -qemu_opt_get_number (opts,"throttling.iops-total-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].max = -qemu_opt_get_number (opts,"throttling.iops-read-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].max = -qemu_opt_get_number (opts,"throttling.iops-write-max" ,0 ); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-total-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-read-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-write-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-total-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-read-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-write-max-length" ,1 ); - - throttle_cfg->op_size = -qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); - +throttle_parse_options (throttle_cfg, opts);if (!throttle_is_valid (throttle_cfg, errp)) {return ; }fsdev/qemu-fsdev-throttle.c +1
-42@@ -31,48 +31,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque)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_parse_options (&fst->cfg, opts);throttle_is_valid (&fst->cfg, errp); }fsdev/qemu-fsdev-throttle.h +1
-0@@ -20,6 +20,7 @@#include "qemu/coroutine.h" #include "qapi/error.h" #include "qemu/throttle.h" +#include "qemu/throttle-options.h" typedef struct FsThrottle { ThrottleState ts;include/qemu/throttle-options.h +4
-0@@ -10,6 +10,8 @@#ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H +#include "qemu/throttle.h" +#define THROTTLE_OPTS \ { \ .name = "throttling.iops-total",\@@ -89,4 +91,6 @@ .help = "when limiting by iops max size of an I/O in bytes",\ } +void throttle_parse_options (ThrottleConfig *,QemuOpts *); +#endif util/throttle.c +50
-0@@ -514,3 +514,53 @@ void throttle_account(ThrottleState *ts, bool is_write, uint64_t size) } } +/* parse the throttle options +* +* @opts: qemu options +* @throttle_cfg: throttle configuration +*/ +void throttle_parse_options (ThrottleConfig *throttle_cfg,QemuOpts *opts) +{ +throttle_config_init (throttle_cfg); + throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].avg = +qemu_opt_get_number (opts,"throttling.bps-total" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_READ ].avg = +qemu_opt_get_number (opts,"throttling.bps-read" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_WRITE ].avg = +qemu_opt_get_number (opts,"throttling.bps-write" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].avg = +qemu_opt_get_number (opts,"throttling.iops-total" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_READ ].avg = +qemu_opt_get_number (opts,"throttling.iops-read" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_WRITE ].avg = +qemu_opt_get_number (opts,"throttling.iops-write" ,0 ); + + throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].max = +qemu_opt_get_number (opts,"throttling.bps-total-max" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_READ ].max = +qemu_opt_get_number (opts,"throttling.bps-read-max" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_WRITE ].max = +qemu_opt_get_number (opts,"throttling.bps-write-max" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].max = +qemu_opt_get_number (opts,"throttling.iops-total-max" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_READ ].max = +qemu_opt_get_number (opts,"throttling.iops-read-max" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_WRITE ].max = +qemu_opt_get_number (opts,"throttling.iops-write-max" ,0 ); + + throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = +qemu_opt_get_number (opts,"throttling.bps-total-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_BPS_READ ].burst_length = +qemu_opt_get_number (opts,"throttling.bps-read-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = +qemu_opt_get_number (opts,"throttling.bps-write-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = +qemu_opt_get_number (opts,"throttling.iops-total-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_OPS_READ ].burst_length = +qemu_opt_get_number (opts,"throttling.iops-read-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = +qemu_opt_get_number (opts,"throttling.iops-write-max-length" ,1 ); + + throttle_cfg->op_size = +qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); +}
Re: [Qemu-devel] [PATCH v5 1/5] throttle: factor out duplicate code
In reply to Pradeep JagadeeshQuoted 4 lines · Pradeep Jagadeesh
This patch factor out the duplicate throttle code that was present in block and fsdev devices.
Signed-off-by Pradeep Jagadeesh <[email protected]>
Berto
Re: [Qemu-devel] [PATCH v5 1/5] throttle: factor out duplicate code
Quoted 8 lines · On Wed, 21 Jun 2017 14:55:55 +0200 Alberto Garcia <[email protected]> wrote:
Quoted 4 lines · Pradeep Jagadeesh
This patch factor out the duplicate throttle code that was present in block and fsdev devices.
Signed-off-by Pradeep Jagadeesh <[email protected]>Reviewed-by Alberto Garcia <[email protected]>
Thanks ! Is it okay if this goes through my 9P tree ?
Quoted 1 line
Berto
Cc'ing Markus, for the same question.
Re: [Qemu-devel] [PATCH v5 1/5] throttle: factor out duplicate code
Quoted 4 lines · Greg Kurz
Quoted 1 line · On Wed, 21 Jun 2017 14:55:55 +0200 Alberto Garcia <[email protected]> wrote:
On Mon 19 Jun 2017 03:11:32 PM CEST, Pradeep Jagadeesh wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
This patch factor out the duplicate throttle code that was present in block and fsdev devices.
Signed-off-by Pradeep Jagadeesh <[email protected]>Reviewed-by Alberto Garcia <[email protected]>Thanks ! Is it okay if this goes through my 9P tree ?
No problem from my side.
Berto
Re: [Qemu-devel] [PATCH v5 1/5] throttle: factor out duplicate code
In reply to Pradeep JagadeeshQuoted 126 lines · Pradeep Jagadeesh
This patch factor out the duplicate throttle code that was present in block and fsdev devices.
Signed-off-by Pradeep Jagadeesh <[email protected]>--- blockdev.c | 44 +----------------------------------- fsdev/qemu-fsdev-throttle.c | 43 +---------------------------------- fsdev/qemu-fsdev-throttle.h | 1 + include/qemu/throttle-options.h | 4 ++++ util/throttle.c | 50 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 85 deletions(-)blockdev.c +1
-43@@ -386,49 +386,7 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, }if (throttle_cfg) { -throttle_config_init (throttle_cfg); - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].avg = -qemu_opt_get_number (opts,"throttling.bps-total" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].avg = -qemu_opt_get_number (opts,"throttling.bps-read" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].avg = -qemu_opt_get_number (opts,"throttling.bps-write" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].avg = -qemu_opt_get_number (opts,"throttling.iops-total" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].avg = -qemu_opt_get_number (opts,"throttling.iops-read" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].avg = -qemu_opt_get_number (opts,"throttling.iops-write" ,0 ); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].max = -qemu_opt_get_number (opts,"throttling.bps-total-max" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].max = -qemu_opt_get_number (opts,"throttling.bps-read-max" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].max = -qemu_opt_get_number (opts,"throttling.bps-write-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].max = -qemu_opt_get_number (opts,"throttling.iops-total-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].max = -qemu_opt_get_number (opts,"throttling.iops-read-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].max = -qemu_opt_get_number (opts,"throttling.iops-write-max" ,0 ); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-total-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-read-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-write-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-total-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-read-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-write-max-length" ,1 ); - - throttle_cfg->op_size = -qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); - +throttle_parse_options (throttle_cfg, opts);if (!throttle_is_valid (throttle_cfg, errp)) {return ; }fsdev/qemu-fsdev-throttle.c +1
-42@@ -31,48 +31,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque)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_parse_options (&fst->cfg, opts);throttle_is_valid (&fst->cfg, errp); }fsdev/qemu-fsdev-throttle.h +0
-0
fsdev/qemu-fsdev-throttle.h line 23
Quoted 4 lines
fsdev/qemu-fsdev-throttle.h +1
-0@@ -20,6 +20,7 @@#include "qemu/coroutine.h" #include "qapi/error.h" #include "qemu/throttle.h" +#include "qemu/throttle-options.h"
Why?
include/qemu/throttle-options.h line 14
Quoted 13 lines
fsdev/qemu-fsdev-throttle.h +0
-0typedef struct FsThrottle { ThrottleState ts;include/qemu/throttle-options.h +2
-0@@ -10,6 +10,8 @@#ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H +#include "qemu/throttle.h" +
Let's avoid this include: move the ThrottleConfig typedef to qemu/typedefs.h.
Quoted 58 lines
include/qemu/throttle-options.h +2
-0#define THROTTLE_OPTS \ { \ .name = "throttling.iops-total",\@@ -89,4 +91,6 @@ .help = "when limiting by iops max size of an I/O in bytes",\ } +void throttle_parse_options (ThrottleConfig *,QemuOpts *); +#endif util/throttle.c +40
-0@@ -514,3 +514,53 @@ void throttle_account(ThrottleState *ts, bool is_write, uint64_t size) } } +/* parse the throttle options +* +* @opts: qemu options +* @throttle_cfg: throttle configuration +*/ +void throttle_parse_options (ThrottleConfig *throttle_cfg,QemuOpts *opts) +{ +throttle_config_init (throttle_cfg); + throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].avg = +qemu_opt_get_number (opts,"throttling.bps-total" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_READ ].avg = +qemu_opt_get_number (opts,"throttling.bps-read" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_WRITE ].avg = +qemu_opt_get_number (opts,"throttling.bps-write" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].avg = +qemu_opt_get_number (opts,"throttling.iops-total" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_READ ].avg = +qemu_opt_get_number (opts,"throttling.iops-read" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_WRITE ].avg = +qemu_opt_get_number (opts,"throttling.iops-write" ,0 ); + + throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].max = +qemu_opt_get_number (opts,"throttling.bps-total-max" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_READ ].max = +qemu_opt_get_number (opts,"throttling.bps-read-max" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_WRITE ].max = +qemu_opt_get_number (opts,"throttling.bps-write-max" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].max = +qemu_opt_get_number (opts,"throttling.iops-total-max" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_READ ].max = +qemu_opt_get_number (opts,"throttling.iops-read-max" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_WRITE ].max = +qemu_opt_get_number (opts,"throttling.iops-write-max" ,0 ); + + throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = +qemu_opt_get_number (opts,"throttling.bps-total-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_BPS_READ ].burst_length = +qemu_opt_get_number (opts,"throttling.bps-read-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = +qemu_opt_get_number (opts,"throttling.bps-write-max-length" ,1 );
util/throttle.c void throttle_account(ThrottleState *ts, bool is_write, uint64_t size) · line 566
Quoted 10 lines
util/throttle.c +10
-0+ throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = +qemu_opt_get_number (opts,"throttling.iops-total-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_OPS_READ ].burst_length = +qemu_opt_get_number (opts,"throttling.iops-read-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = +qemu_opt_get_number (opts,"throttling.iops-write-max-length" ,1 ); + + throttle_cfg->op_size = +qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); +}
Looks good otherwise.
Re: [Qemu-devel] [PATCH v5 1/5] throttle: factor out duplicate code
Quoted 123 lines · On Thu, 22 Jun 2017 16:38:45 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 121 lines · Pradeep Jagadeesh
This patch factor out the duplicate throttle code that was present in block and fsdev devices.
Signed-off-by Pradeep Jagadeesh <[email protected]>--- blockdev.c | 44 +----------------------------------- fsdev/qemu-fsdev-throttle.c | 43 +---------------------------------- fsdev/qemu-fsdev-throttle.h | 1 + include/qemu/throttle-options.h | 4 ++++ util/throttle.c | 50 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 85 deletions(-)blockdev.c +1
-43@@ -386,49 +386,7 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, }if (throttle_cfg) { -throttle_config_init (throttle_cfg); - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].avg = -qemu_opt_get_number (opts,"throttling.bps-total" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].avg = -qemu_opt_get_number (opts,"throttling.bps-read" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].avg = -qemu_opt_get_number (opts,"throttling.bps-write" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].avg = -qemu_opt_get_number (opts,"throttling.iops-total" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].avg = -qemu_opt_get_number (opts,"throttling.iops-read" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].avg = -qemu_opt_get_number (opts,"throttling.iops-write" ,0 ); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].max = -qemu_opt_get_number (opts,"throttling.bps-total-max" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].max = -qemu_opt_get_number (opts,"throttling.bps-read-max" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].max = -qemu_opt_get_number (opts,"throttling.bps-write-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].max = -qemu_opt_get_number (opts,"throttling.iops-total-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].max = -qemu_opt_get_number (opts,"throttling.iops-read-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].max = -qemu_opt_get_number (opts,"throttling.iops-write-max" ,0 ); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-total-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-read-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-write-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-total-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-read-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-write-max-length" ,1 ); - - throttle_cfg->op_size = -qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); - +throttle_parse_options (throttle_cfg, opts);if (!throttle_is_valid (throttle_cfg, errp)) {return ; }fsdev/qemu-fsdev-throttle.c +1
-42@@ -31,48 +31,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque)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_parse_options (&fst->cfg, opts);throttle_is_valid (&fst->cfg, errp); }
Quoted 12 lines
fsdev/qemu-fsdev-throttle.h line 23
Quoted 9 lines
fsdev/qemu-fsdev-throttle.h +1
-0@@ -20,6 +20,7 @@#include "qemu/coroutine.h" #include "qapi/error.h" #include "qemu/throttle.h" +#include "qemu/throttle-options.h" Why?
Yeah, looking at the previous hunk, I guess it should rather go to fsdev/qemu-fsdev-throttle.c.
Quoted 87 lines
include/qemu/throttle-options.h line 14
Quoted 13 lines
fsdev/qemu-fsdev-throttle.h +0
-0typedef struct FsThrottle { ThrottleState ts;include/qemu/throttle-options.h +2
-0@@ -10,6 +10,8 @@#ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H +#include "qemu/throttle.h" +Let's avoid this include: move the ThrottleConfig typedef to
qemu/typedefs.h.Quoted 58 lines
include/qemu/throttle-options.h +2
-0#define THROTTLE_OPTS \ { \ .name = "throttling.iops-total",\@@ -89,4 +91,6 @@ .help = "when limiting by iops max size of an I/O in bytes",\ } +void throttle_parse_options (ThrottleConfig *,QemuOpts *); +#endif util/throttle.c +40
-0@@ -514,3 +514,53 @@ void throttle_account(ThrottleState *ts, bool is_write, uint64_t size) } } +/* parse the throttle options +* +* @opts: qemu options +* @throttle_cfg: throttle configuration +*/ +void throttle_parse_options (ThrottleConfig *throttle_cfg,QemuOpts *opts) +{ +throttle_config_init (throttle_cfg); + throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].avg = +qemu_opt_get_number (opts,"throttling.bps-total" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_READ ].avg = +qemu_opt_get_number (opts,"throttling.bps-read" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_WRITE ].avg = +qemu_opt_get_number (opts,"throttling.bps-write" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].avg = +qemu_opt_get_number (opts,"throttling.iops-total" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_READ ].avg = +qemu_opt_get_number (opts,"throttling.iops-read" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_WRITE ].avg = +qemu_opt_get_number (opts,"throttling.iops-write" ,0 ); + + throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].max = +qemu_opt_get_number (opts,"throttling.bps-total-max" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_READ ].max = +qemu_opt_get_number (opts,"throttling.bps-read-max" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_WRITE ].max = +qemu_opt_get_number (opts,"throttling.bps-write-max" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].max = +qemu_opt_get_number (opts,"throttling.iops-total-max" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_READ ].max = +qemu_opt_get_number (opts,"throttling.iops-read-max" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_WRITE ].max = +qemu_opt_get_number (opts,"throttling.iops-write-max" ,0 ); + + throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = +qemu_opt_get_number (opts,"throttling.bps-total-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_BPS_READ ].burst_length = +qemu_opt_get_number (opts,"throttling.bps-read-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = +qemu_opt_get_number (opts,"throttling.bps-write-max-length" ,1 );util/throttle.c void throttle_account(ThrottleState *ts, bool is_write, uint64_t size) · line 566
Quoted 10 lines
util/throttle.c +10
-0+ throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = +qemu_opt_get_number (opts,"throttling.iops-total-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_OPS_READ ].burst_length = +qemu_opt_get_number (opts,"throttling.iops-read-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = +qemu_opt_get_number (opts,"throttling.iops-write-max-length" ,1 ); + + throttle_cfg->op_size = +qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); +}Looks good otherwise.
Re: [Qemu-devel] [PATCH v5 1/5] throttle: factor out duplicate code
In reply to Markus ArmbrusterQuoted 123 lines · Markus Armbruster
Quoted 121 lines · Pradeep Jagadeesh
This patch factor out the duplicate throttle code that was present in block and fsdev devices.
Signed-off-by Pradeep Jagadeesh <[email protected]>--- blockdev.c | 44 +----------------------------------- fsdev/qemu-fsdev-throttle.c | 43 +---------------------------------- fsdev/qemu-fsdev-throttle.h | 1 + include/qemu/throttle-options.h | 4 ++++ util/throttle.c | 50 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 85 deletions(-)blockdev.c +1
-43@@ -386,49 +386,7 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, }if (throttle_cfg) { -throttle_config_init (throttle_cfg); - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].avg = -qemu_opt_get_number (opts,"throttling.bps-total" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].avg = -qemu_opt_get_number (opts,"throttling.bps-read" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].avg = -qemu_opt_get_number (opts,"throttling.bps-write" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].avg = -qemu_opt_get_number (opts,"throttling.iops-total" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].avg = -qemu_opt_get_number (opts,"throttling.iops-read" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].avg = -qemu_opt_get_number (opts,"throttling.iops-write" ,0 ); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].max = -qemu_opt_get_number (opts,"throttling.bps-total-max" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].max = -qemu_opt_get_number (opts,"throttling.bps-read-max" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].max = -qemu_opt_get_number (opts,"throttling.bps-write-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].max = -qemu_opt_get_number (opts,"throttling.iops-total-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].max = -qemu_opt_get_number (opts,"throttling.iops-read-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].max = -qemu_opt_get_number (opts,"throttling.iops-write-max" ,0 ); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-total-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-read-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-write-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-total-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-read-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-write-max-length" ,1 ); - - throttle_cfg->op_size = -qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); - +throttle_parse_options (throttle_cfg, opts);if (!throttle_is_valid (throttle_cfg, errp)) {return ; }fsdev/qemu-fsdev-throttle.c +1
-42@@ -31,48 +31,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque)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_parse_options (&fst->cfg, opts);throttle_is_valid (&fst->cfg, errp); }
Quoted 12 lines
fsdev/qemu-fsdev-throttle.h line 23
Quoted 9 lines
fsdev/qemu-fsdev-throttle.h +1
-0@@ -20,6 +20,7 @@#include "qemu/coroutine.h" #include "qapi/error.h" #include "qemu/throttle.h" +#include "qemu/throttle-options.h" Why?
Moved to qemu-fsdev-throttle.c
Quoted 11 lines
Quoted 11 lines
fsdev/qemu-fsdev-throttle.h +0
-0typedef struct FsThrottle { ThrottleState ts;include/qemu/throttle-options.h +0
-0@@ -10,6 +10,8 @@#ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H
Quoted 5 lines
include/qemu/throttle-options.h line 14
Quoted 2 lines
include/qemu/throttle-options.h +2
-0+#include "qemu/throttle.h" +Let's avoid this include: move the ThrottleConfig typedef to
qemu/typedefs.h.
OK
Quoted 72 lines
Quoted 59 lines
include/qemu/throttle-options.h +2
-0#define THROTTLE_OPTS \ { \ .name = "throttling.iops-total",\@@ -89,4 +91,6 @@ .help = "when limiting by iops max size of an I/O in bytes",\ } +void throttle_parse_options (ThrottleConfig *,QemuOpts *); +#endif util/throttle.c +40
-0@@ -514,3 +514,53 @@ void throttle_account(ThrottleState *ts, bool is_write, uint64_t size) } } +/* parse the throttle options +* +* @opts: qemu options +* @throttle_cfg: throttle configuration +*/ +void throttle_parse_options (ThrottleConfig *throttle_cfg,QemuOpts *opts) +{ +throttle_config_init (throttle_cfg); + throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].avg = +qemu_opt_get_number (opts,"throttling.bps-total" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_READ ].avg = +qemu_opt_get_number (opts,"throttling.bps-read" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_WRITE ].avg = +qemu_opt_get_number (opts,"throttling.bps-write" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].avg = +qemu_opt_get_number (opts,"throttling.iops-total" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_READ ].avg = +qemu_opt_get_number (opts,"throttling.iops-read" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_WRITE ].avg = +qemu_opt_get_number (opts,"throttling.iops-write" ,0 ); + + throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].max = +qemu_opt_get_number (opts,"throttling.bps-total-max" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_READ ].max = +qemu_opt_get_number (opts,"throttling.bps-read-max" ,0 ); + throttle_cfg->buckets[THROTTLE_BPS_WRITE ].max = +qemu_opt_get_number (opts,"throttling.bps-write-max" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].max = +qemu_opt_get_number (opts,"throttling.iops-total-max" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_READ ].max = +qemu_opt_get_number (opts,"throttling.iops-read-max" ,0 ); + throttle_cfg->buckets[THROTTLE_OPS_WRITE ].max = +qemu_opt_get_number (opts,"throttling.iops-write-max" ,0 ); + + throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = +qemu_opt_get_number (opts,"throttling.bps-total-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_BPS_READ ].burst_length = +qemu_opt_get_number (opts,"throttling.bps-read-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = +qemu_opt_get_number (opts,"throttling.bps-write-max-length" ,1 );util/throttle.c void throttle_account(ThrottleState *ts, bool is_write, uint64_t size) · line 566
Quoted 10 lines
util/throttle.c +10
-0+ throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = +qemu_opt_get_number (opts,"throttling.iops-total-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_OPS_READ ].burst_length = +qemu_opt_get_number (opts,"throttling.iops-read-max-length" ,1 ); + throttle_cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = +qemu_opt_get_number (opts,"throttling.iops-write-max-length" ,1 ); + + throttle_cfg->op_size = +qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); +}Looks good otherwise.
PATCH v5 2/5 qmp: Create IOThrottle structure
In reply to Pradeep JagadeeshThis patch enables qmp interfaces for the fsdev devices. This provides two interfaces one
for querying info of all the fsdev devices. The second one to set the IO limits for the required fsdev device.
--- qapi/block-core.json | 76 ++------------------------------------------- qapi/iothrottle.json | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 73 deletions(-) create mode 100644 qapi/iothrottle.json
qapi/block-core.json +3 -73
@@ -6,6 +6,7 @@ # QAPI common definitions { 'include': 'common.json' } +{ 'include': 'iothrottle.json' } ## # @SnapshotInfo:
@@ -1761,84 +1762,13 @@ # # @device: Block device name (deprecated, use @id instead) # -# @id: The name or QOM path of the guest device (since: 2.8) -# -# @bps: total throughput limit in bytes per second -# -# @bps_rd: read throughput limit in bytes per second -# -# @bps_wr: write throughput limit in bytes per second -# -# @iops: total I/O operations per second -# -# @iops_rd: read I/O operations per second -# -# @iops_wr: write I/O operations per second -# -# @bps_max: total throughput limit during bursts, -# in bytes (Since 1.7) -# -# @bps_rd_max: read throughput limit during bursts, -# in bytes (Since 1.7) -# -# @bps_wr_max: write throughput limit during bursts, -# in bytes (Since 1.7) -# -# @iops_max: total I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @iops_rd_max: read I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @iops_wr_max: write I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @bps_max_length: maximum length of the @bps_max burst -# period, in seconds. It must only -# be set if @bps_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @bps_rd_max_length: maximum length of the @bps_rd_max -# burst period, in seconds. It must only -# be set if @bps_rd_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @bps_wr_max_length: maximum length of the @bps_wr_max -# burst period, in seconds. It must only -# be set if @bps_wr_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_max_length: maximum length of the @iops burst -# period, in seconds. It must only -# be set if @iops_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_rd_max_length: maximum length of the @iops_rd_max -# burst period, in seconds. It must only -# be set if @iops_rd_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_wr_max_length: maximum length of the @iops_wr_max -# burst period, in seconds. It must only -# be set if @iops_wr_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_size: an I/O size in bytes (Since 1.7) -# # @group: throttle group name (Since 2.4) # # Since: 1.1 ## { 'struct': 'BlockIOThrottle', - 'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int', - 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', - '*bps_max': 'int', '*bps_rd_max': 'int', - '*bps_wr_max': 'int', '*iops_max': 'int', - '*iops_rd_max': 'int', '*iops_wr_max': 'int', - '*bps_max_length': 'int', '*bps_rd_max_length': 'int', - '*bps_wr_max_length': 'int', '*iops_max_length': 'int', - '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int', - '*iops_size': 'int', '*group': 'str' } } + 'base': 'IOThrottle', + 'data': { '*device': 'str', '*group': 'str' } } ## # @block-stream:
qapi/iothrottle.json new file +88 -0
88 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v5 2/5] qmp: Create IOThrottle structure
Quoted 7 lines · On Mon, 19 Jun 2017 09:11:33 -0400 Pradeep Jagadeesh…
This patch enables qmp interfaces for the fsdev devices. This provides two interfaces one
for querying info of all the fsdev devices. The second one to set the IO limits for the required fsdev device.Signed-off-by Pradeep Jagadeesh <[email protected]>
No blank line here.
Quoted 201 lines
Reviewed-by Greg Kurz <[email protected]>Reviewed-by Eric Blake <[email protected]>--- qapi/block-core.json | 76 ++------------------------------------------- qapi/iothrottle.json | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 73 deletions(-) create mode 100644 qapi/iothrottle.jsonqapi/block-core.json +3
-73@@ -6,6 +6,7 @@ # QAPI common definitions { 'include': 'common.json' } +{ 'include': 'iothrottle.json' } ## # @SnapshotInfo:@@ -1761,84 +1762,13 @@ # # @device: Block device name (deprecated, use @id instead) # -# @id: The name or QOM path of the guest device (since: 2.8) -# -# @bps: total throughput limit in bytes per second -# -# @bps_rd: read throughput limit in bytes per second -# -# @bps_wr: write throughput limit in bytes per second -# -# @iops: total I/O operations per second -# -# @iops_rd: read I/O operations per second -# -# @iops_wr: write I/O operations per second -# -# @bps_max: total throughput limit during bursts, -# in bytes (Since 1.7) -# -# @bps_rd_max: read throughput limit during bursts, -# in bytes (Since 1.7) -# -# @bps_wr_max: write throughput limit during bursts, -# in bytes (Since 1.7) -# -# @iops_max: total I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @iops_rd_max: read I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @iops_wr_max: write I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @bps_max_length: maximum length of the @bps_max burst -# period, in seconds. It must only -# be set if @bps_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @bps_rd_max_length: maximum length of the @bps_rd_max -# burst period, in seconds. It must only -# be set if @bps_rd_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @bps_wr_max_length: maximum length of the @bps_wr_max -# burst period, in seconds. It must only -# be set if @bps_wr_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_max_length: maximum length of the @iops burst -# period, in seconds. It must only -# be set if @iops_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_rd_max_length: maximum length of the @iops_rd_max -# burst period, in seconds. It must only -# be set if @iops_rd_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_wr_max_length: maximum length of the @iops_wr_max -# burst period, in seconds. It must only -# be set if @iops_wr_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_size: an I/O size in bytes (Since 1.7) -# # @group: throttle group name (Since 2.4) # # Since: 1.1 ## { 'struct': 'BlockIOThrottle', - 'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int', - 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', - '*bps_max': 'int', '*bps_rd_max': 'int', - '*bps_wr_max': 'int', '*iops_max': 'int', - '*iops_rd_max': 'int', '*iops_wr_max': 'int', - '*bps_max_length': 'int', '*bps_rd_max_length': 'int', - '*bps_wr_max_length': 'int', '*iops_max_length': 'int', - '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int', - '*iops_size': 'int', '*group': 'str' } } + 'base': 'IOThrottle', + 'data': { '*device': 'str', '*group': 'str' } } ## # @block-stream:qapi/iothrottle.json new file +88
-0@@ -0,0 +1,88 @@ +# -*- Mode: Python -*- + +## +# == QAPI IOThrottle definitions +## + +## +# @IOThrottle: +# +# A set of parameters describing IO throttling +# +# @id: The name or QOM path of the guest device (since: 2.8) +# +# @bps: total throughput limit in bytes per second +# +# @bps_rd: read throughput limit in bytes per second +# +# @bps_wr: write throughput limit in bytes per second +# +# @iops: total I/O operations per second +# +# @iops_rd: read I/O operations per second +# +# @iops_wr: write I/O operations per second +# +# @bps_max: total throughput limit during bursts, +# in bytes (Since 1.7) +# +# @bps_rd_max: read throughput limit during bursts, +# in bytes (Since 1.7) +# +# @bps_wr_max: write throughput limit during bursts, +# in bytes (Since 1.7) +# +# @iops_max: total I/O operations per second during bursts, +# in bytes (Since 1.7) +# +# @iops_rd_max: read I/O operations per second during bursts, +# in bytes (Since 1.7) +# +# @iops_wr_max: write I/O operations per second during bursts, +# in bytes (Since 1.7) +# +# @bps_max_length: maximum length of the @bps_max burst +# period, in seconds. It must only +# be set if @bps_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @bps_rd_max_length: maximum length of the @bps_rd_max +# burst period, in seconds. It must only +# be set if @bps_rd_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @bps_wr_max_length: maximum length of the @bps_wr_max +# burst period, in seconds. It must only +# be set if @bps_wr_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @iops_max_length: maximum length of the @iops burst +# period, in seconds. It must only +# be set if @iops_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @iops_rd_max_length: maximum length of the @iops_rd_max +# burst period, in seconds. It must only +# be set if @iops_rd_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @iops_wr_max_length: maximum length of the @iops_wr_max +# burst period, in seconds. It must only +# be set if @iops_wr_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @iops_size: an I/O size in bytes (Since 1.7) +# +# +# Since: 2.10 +## +{ 'struct': 'IOThrottle', + 'data': { '*id': 'str', 'bps': 'int', 'bps_rd': 'int', + 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', + '*bps_max': 'int', '*bps_rd_max': 'int', + '*bps_wr_max': 'int', '*iops_max': 'int', + '*iops_rd_max': 'int', '*iops_wr_max': 'int', + '*bps_max_length': 'int', '*bps_rd_max_length': 'int', + '*bps_wr_max_length': 'int', '*iops_max_length': 'int', + '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int', + '*iops_size': 'int' } }
PATCH v5 3/5 qmp: refactor duplicate code
In reply to Pradeep JagadeeshThis patch factor out the duplicate qmp throttle interface code that was present in both block and fsdev device files.
--- blockdev.c | 53 +++--------------------------------- hmp.c | 21 ++++++++++----- include/qemu/throttle-options.h | 3 +++ util/throttle.c | 60 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 56 deletions(-)
blockdev.c +3 -50
@@ -2593,6 +2593,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)BlockDriverState *bs;BlockBackend *blk;AioContext *aio_context; +IOThrottle *iothrottle; blk = qmp_get_blk(arg->has_device ? arg->device : NULL, arg->has_id ? arg->id : NULL,
@@ -2610,56 +2611,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp) goto out; } -throttle_config_init (&cfg); - cfg.buckets[THROTTLE_BPS_TOTAL ].avg = arg->bps; - cfg.buckets[THROTTLE_BPS_READ ].avg = arg->bps_rd; - cfg.buckets[THROTTLE_BPS_WRITE ].avg = arg->bps_wr; - - cfg.buckets[THROTTLE_OPS_TOTAL ].avg = arg->iops; - cfg.buckets[THROTTLE_OPS_READ ].avg = arg->iops_rd; - cfg.buckets[THROTTLE_OPS_WRITE ].avg = arg->iops_wr; - -if (arg->has_bps_max) { - cfg.buckets[THROTTLE_BPS_TOTAL ].max = arg->bps_max; - } -if (arg->has_bps_rd_max) { - cfg.buckets[THROTTLE_BPS_READ ].max = arg->bps_rd_max; - } -if (arg->has_bps_wr_max) { - cfg.buckets[THROTTLE_BPS_WRITE ].max = arg->bps_wr_max; - } -if (arg->has_iops_max) { - cfg.buckets[THROTTLE_OPS_TOTAL ].max = arg->iops_max; - } -if (arg->has_iops_rd_max) { - cfg.buckets[THROTTLE_OPS_READ ].max = arg->iops_rd_max; - } -if (arg->has_iops_wr_max) { - cfg.buckets[THROTTLE_OPS_WRITE ].max = arg->iops_wr_max; - } - -if (arg->has_bps_max_length) { - cfg.buckets[THROTTLE_BPS_TOTAL ].burst_length = arg->bps_max_length; - } -if (arg->has_bps_rd_max_length) { - cfg.buckets[THROTTLE_BPS_READ ].burst_length = arg->bps_rd_max_length; - } -if (arg->has_bps_wr_max_length) { - cfg.buckets[THROTTLE_BPS_WRITE ].burst_length = arg->bps_wr_max_length; - } -if (arg->has_iops_max_length) { - cfg.buckets[THROTTLE_OPS_TOTAL ].burst_length = arg->iops_max_length; - } -if (arg->has_iops_rd_max_length) { - cfg.buckets[THROTTLE_OPS_READ ].burst_length = arg->iops_rd_max_length; - } -if (arg->has_iops_wr_max_length) { - cfg.buckets[THROTTLE_OPS_WRITE ].burst_length = arg->iops_wr_max_length; - } - -if (arg->has_iops_size) { - cfg.op_size = arg->iops_size; - } + iothrottle =qapi_BlockIOThrottle_base (arg); +throttle_set_io_limits (&cfg, iothrottle);if (!throttle_is_valid (&cfg, errp)) { goto out;
hmp.c +15 -6
@@ -1749,20 +1749,29 @@ void hmp_change(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +static void hmp_initialize_io_throttle (IOThrottle *iot,const QDict *qdict) +{ + iot->has_id = true; + iot->id = (char *)qdict_get_str (qdict,"id" ); + iot->bps =qdict_get_int (qdict,"bps" ); + iot->bps_rd =qdict_get_int (qdict,"bps_rd" ); + iot->bps_wr =qdict_get_int (qdict,"bps_wr" ); + iot->iops =qdict_get_int (qdict,"iops" ); + iot->iops_rd =qdict_get_int (qdict,"iops_rd" ); + iot->iops_wr =qdict_get_int (qdict,"iops_wr" ); +} +void hmp_block_set_io_throttle (Monitor *mon,const QDict *qdict) {Error *err =NULL ; +IOThrottle *iothrottle;BlockIOThrottle throttle = { .has_device = true, .device = (char *)qdict_get_str (qdict,"device" ), - .bps =qdict_get_int (qdict,"bps" ), - .bps_rd =qdict_get_int (qdict,"bps_rd" ), - .bps_wr =qdict_get_int (qdict,"bps_wr" ), - .iops =qdict_get_int (qdict,"iops" ), - .iops_rd =qdict_get_int (qdict,"iops_rd" ), - .iops_wr =qdict_get_int (qdict,"iops_wr" ), }; + iothrottle =qapi_BlockIOThrottle_base (&throttle); +hmp_initialize_io_throttle (iothrottle, qdict);qmp_block_set_io_throttle (&throttle, &err);hmp_handle_error (mon, &err); }
include/qemu/throttle-options.h +3 -0
@@ -11,6 +11,7 @@#define THROTTLE_OPTIONS_H #include "qemu/throttle.h" +#include "qmp-commands.h" #define THROTTLE_OPTS \ { \
@@ -93,4 +94,6 @@void throttle_parse_options (ThrottleConfig *,QemuOpts *); +void throttle_set_io_limits (ThrottleConfig *,IOThrottle *); +#endif
util/throttle.c +60 -0
69 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v5 3/5] qmp: refactor duplicate code
Quoted 3 lines · On Mon, 19 Jun 2017 09:11:34 -0400 Pradeep Jagadeesh…
This patch factor out the duplicate qmp throttle interface code that was present in both block and fsdev device files.
The text is obviously wrong. I don't see any duplicate code below.
It is more something like: let's factor out the code that will be used by the existing QMP throttling API for block devices and the future QMP throttling API for fs devices.
Please move the HMP part to another patch, as asked during v4 review.
Also, blockdev.c and hmp.c do have maintainers. You should Cc: them each time because they know better than me and even if these patches are carried through my tree, I won't do it without an ack from them.
Cc'ing Markus for blockdev.c and David for hmp.c.
Quoted 213 lines
Signed-off-by Pradeep Jagadeesh <[email protected]>--- blockdev.c | 53 +++--------------------------------- hmp.c | 21 ++++++++++----- include/qemu/throttle-options.h | 3 +++ util/throttle.c | 60 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 56 deletions(-)blockdev.c +3
-50@@ -2593,6 +2593,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)BlockDriverState *bs;BlockBackend *blk;AioContext *aio_context; +IOThrottle *iothrottle; blk = qmp_get_blk(arg->has_device ? arg->device : NULL, arg->has_id ? arg->id : NULL,@@ -2610,56 +2611,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp) goto out; } -throttle_config_init (&cfg); - cfg.buckets[THROTTLE_BPS_TOTAL ].avg = arg->bps; - cfg.buckets[THROTTLE_BPS_READ ].avg = arg->bps_rd; - cfg.buckets[THROTTLE_BPS_WRITE ].avg = arg->bps_wr; - - cfg.buckets[THROTTLE_OPS_TOTAL ].avg = arg->iops; - cfg.buckets[THROTTLE_OPS_READ ].avg = arg->iops_rd; - cfg.buckets[THROTTLE_OPS_WRITE ].avg = arg->iops_wr; - -if (arg->has_bps_max) { - cfg.buckets[THROTTLE_BPS_TOTAL ].max = arg->bps_max; - } -if (arg->has_bps_rd_max) { - cfg.buckets[THROTTLE_BPS_READ ].max = arg->bps_rd_max; - } -if (arg->has_bps_wr_max) { - cfg.buckets[THROTTLE_BPS_WRITE ].max = arg->bps_wr_max; - } -if (arg->has_iops_max) { - cfg.buckets[THROTTLE_OPS_TOTAL ].max = arg->iops_max; - } -if (arg->has_iops_rd_max) { - cfg.buckets[THROTTLE_OPS_READ ].max = arg->iops_rd_max; - } -if (arg->has_iops_wr_max) { - cfg.buckets[THROTTLE_OPS_WRITE ].max = arg->iops_wr_max; - } - -if (arg->has_bps_max_length) { - cfg.buckets[THROTTLE_BPS_TOTAL ].burst_length = arg->bps_max_length; - } -if (arg->has_bps_rd_max_length) { - cfg.buckets[THROTTLE_BPS_READ ].burst_length = arg->bps_rd_max_length; - } -if (arg->has_bps_wr_max_length) { - cfg.buckets[THROTTLE_BPS_WRITE ].burst_length = arg->bps_wr_max_length; - } -if (arg->has_iops_max_length) { - cfg.buckets[THROTTLE_OPS_TOTAL ].burst_length = arg->iops_max_length; - } -if (arg->has_iops_rd_max_length) { - cfg.buckets[THROTTLE_OPS_READ ].burst_length = arg->iops_rd_max_length; - } -if (arg->has_iops_wr_max_length) { - cfg.buckets[THROTTLE_OPS_WRITE ].burst_length = arg->iops_wr_max_length; - } - -if (arg->has_iops_size) { - cfg.op_size = arg->iops_size; - } + iothrottle =qapi_BlockIOThrottle_base (arg); +throttle_set_io_limits (&cfg, iothrottle);if (!throttle_is_valid (&cfg, errp)) { goto out;hmp.c +15
-6@@ -1749,20 +1749,29 @@ void hmp_change(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +static void hmp_initialize_io_throttle (IOThrottle *iot,const QDict *qdict) +{ + iot->has_id = true; + iot->id = (char *)qdict_get_str (qdict,"id" ); + iot->bps =qdict_get_int (qdict,"bps" ); + iot->bps_rd =qdict_get_int (qdict,"bps_rd" ); + iot->bps_wr =qdict_get_int (qdict,"bps_wr" ); + iot->iops =qdict_get_int (qdict,"iops" ); + iot->iops_rd =qdict_get_int (qdict,"iops_rd" ); + iot->iops_wr =qdict_get_int (qdict,"iops_wr" ); +} +void hmp_block_set_io_throttle (Monitor *mon,const QDict *qdict) {Error *err =NULL ; +IOThrottle *iothrottle;BlockIOThrottle throttle = { .has_device = true, .device = (char *)qdict_get_str (qdict,"device" ), - .bps =qdict_get_int (qdict,"bps" ), - .bps_rd =qdict_get_int (qdict,"bps_rd" ), - .bps_wr =qdict_get_int (qdict,"bps_wr" ), - .iops =qdict_get_int (qdict,"iops" ), - .iops_rd =qdict_get_int (qdict,"iops_rd" ), - .iops_wr =qdict_get_int (qdict,"iops_wr" ), }; + iothrottle =qapi_BlockIOThrottle_base (&throttle); +hmp_initialize_io_throttle (iothrottle, qdict);qmp_block_set_io_throttle (&throttle, &err);hmp_handle_error (mon, &err); }include/qemu/throttle-options.h +3
-0@@ -11,6 +11,7 @@#define THROTTLE_OPTIONS_H #include "qemu/throttle.h" +#include "qmp-commands.h" #define THROTTLE_OPTS \ { \@@ -93,4 +94,6 @@void throttle_parse_options (ThrottleConfig *,QemuOpts *); +void throttle_set_io_limits (ThrottleConfig *,IOThrottle *); +#endif util/throttle.c +60
-0@@ -27,6 +27,7 @@#include "qemu/throttle.h" #include "qemu/timer.h" #include "block/aio.h" +#include "qemu/throttle-options.h" /* This function make a bucket leak * @@ -564,3 +565,62 @@ void throttle_parse_options(ThrottleConfig *throttle_cfg, QemuOpts *opts) throttle_cfg->op_size =qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); } + +/* set the throttle limits +* +* @arg: iothrottle limits +* @cfg: throttle configuration +*/ +void throttle_set_io_limits (ThrottleConfig *cfg,IOThrottle *arg) +{ +throttle_config_init (cfg); + cfg->buckets[THROTTLE_BPS_TOTAL ].avg = arg->bps; + cfg->buckets[THROTTLE_BPS_READ ].avg = arg->bps_rd; + cfg->buckets[THROTTLE_BPS_WRITE ].avg = arg->bps_wr; + + cfg->buckets[THROTTLE_OPS_TOTAL ].avg = arg->iops; + cfg->buckets[THROTTLE_OPS_READ ].avg = arg->iops_rd; + cfg->buckets[THROTTLE_OPS_WRITE ].avg = arg->iops_wr; + +if (arg->has_bps_max) { + cfg->buckets[THROTTLE_BPS_TOTAL ].max = arg->bps_max; + } +if (arg->has_bps_rd_max) { + cfg->buckets[THROTTLE_BPS_READ ].max = arg->bps_rd_max; + } +if (arg->has_bps_wr_max) { + cfg->buckets[THROTTLE_BPS_WRITE ].max = arg->bps_wr_max; + } +if (arg->has_iops_max) { + cfg->buckets[THROTTLE_OPS_TOTAL ].max = arg->iops_max; + } +if (arg->has_iops_rd_max) { + cfg->buckets[THROTTLE_OPS_READ ].max = arg->iops_rd_max; + } +if (arg->has_iops_wr_max) { + cfg->buckets[THROTTLE_OPS_WRITE ].max = arg->iops_wr_max; + } + +if (arg->has_bps_max_length) { + cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = arg->bps_max_length; + } +if (arg->has_bps_rd_max_length) { + cfg->buckets[THROTTLE_BPS_READ ].burst_length = arg->bps_rd_max_length; + } +if (arg->has_bps_wr_max_length) { + cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = arg->bps_wr_max_length; + } +if (arg->has_iops_max_length) { + cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = arg->iops_max_length; + } +if (arg->has_iops_rd_max_length) { + cfg->buckets[THROTTLE_OPS_READ ].burst_length = arg->iops_rd_max_length; + } +if (arg->has_iops_wr_max_length) { + cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = arg->iops_wr_max_length; + } + +if (arg->has_iops_size) { + cfg->op_size = arg->iops_size; + } +}
Re: [Qemu-devel] [PATCH v5 3/5] qmp: refactor duplicate code
Quoted 8 lines · Greg Kurz
Quoted 3 lines · On Mon, 19 Jun 2017 09:11:34 -0400 Pradeep Jagadeesh…
This patch factor out the duplicate qmp throttle interface code that was present in both block and fsdev device files.
The text is obviously wrong. I don't see any duplicate code below.
OK, I will fix this.
Quoted 6 lines
It is more something like: let's factor out the code that will be used by the existing QMP throttling API for block devices and the future QMP throttling API for fs devices.
Please move the HMP part to another patch, as asked during v4 review.
I have moved the hmp patches for the fsdev into a separate patch. Do you want me to push this also into a separate patch?
Quoted 4 lines
Also,
blockdev.candhmp.cdo have maintainers. You should Cc: them each time because they know better than me and even if these patches are carried through my tree, I won't do it without an ack from them.
OK, I will add them next time on.
-Pradeep
Quoted 216 lines
Cc'ing Markus for
blockdev.cand David forhmp.c.Quoted 213 lines
Signed-off-by Pradeep Jagadeesh <[email protected]>--- blockdev.c | 53 +++--------------------------------- hmp.c | 21 ++++++++++----- include/qemu/throttle-options.h | 3 +++ util/throttle.c | 60 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 56 deletions(-)blockdev.c +3
-50@@ -2593,6 +2593,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)BlockDriverState *bs;BlockBackend *blk;AioContext *aio_context; +IOThrottle *iothrottle; blk = qmp_get_blk(arg->has_device ? arg->device : NULL, arg->has_id ? arg->id : NULL,@@ -2610,56 +2611,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp) goto out; } -throttle_config_init (&cfg); - cfg.buckets[THROTTLE_BPS_TOTAL ].avg = arg->bps; - cfg.buckets[THROTTLE_BPS_READ ].avg = arg->bps_rd; - cfg.buckets[THROTTLE_BPS_WRITE ].avg = arg->bps_wr; - - cfg.buckets[THROTTLE_OPS_TOTAL ].avg = arg->iops; - cfg.buckets[THROTTLE_OPS_READ ].avg = arg->iops_rd; - cfg.buckets[THROTTLE_OPS_WRITE ].avg = arg->iops_wr; - -if (arg->has_bps_max) { - cfg.buckets[THROTTLE_BPS_TOTAL ].max = arg->bps_max; - } -if (arg->has_bps_rd_max) { - cfg.buckets[THROTTLE_BPS_READ ].max = arg->bps_rd_max; - } -if (arg->has_bps_wr_max) { - cfg.buckets[THROTTLE_BPS_WRITE ].max = arg->bps_wr_max; - } -if (arg->has_iops_max) { - cfg.buckets[THROTTLE_OPS_TOTAL ].max = arg->iops_max; - } -if (arg->has_iops_rd_max) { - cfg.buckets[THROTTLE_OPS_READ ].max = arg->iops_rd_max; - } -if (arg->has_iops_wr_max) { - cfg.buckets[THROTTLE_OPS_WRITE ].max = arg->iops_wr_max; - } - -if (arg->has_bps_max_length) { - cfg.buckets[THROTTLE_BPS_TOTAL ].burst_length = arg->bps_max_length; - } -if (arg->has_bps_rd_max_length) { - cfg.buckets[THROTTLE_BPS_READ ].burst_length = arg->bps_rd_max_length; - } -if (arg->has_bps_wr_max_length) { - cfg.buckets[THROTTLE_BPS_WRITE ].burst_length = arg->bps_wr_max_length; - } -if (arg->has_iops_max_length) { - cfg.buckets[THROTTLE_OPS_TOTAL ].burst_length = arg->iops_max_length; - } -if (arg->has_iops_rd_max_length) { - cfg.buckets[THROTTLE_OPS_READ ].burst_length = arg->iops_rd_max_length; - } -if (arg->has_iops_wr_max_length) { - cfg.buckets[THROTTLE_OPS_WRITE ].burst_length = arg->iops_wr_max_length; - } - -if (arg->has_iops_size) { - cfg.op_size = arg->iops_size; - } + iothrottle =qapi_BlockIOThrottle_base (arg); +throttle_set_io_limits (&cfg, iothrottle);if (!throttle_is_valid (&cfg, errp)) { goto out;hmp.c +15
-6@@ -1749,20 +1749,29 @@ void hmp_change(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +static void hmp_initialize_io_throttle (IOThrottle *iot,const QDict *qdict) +{ + iot->has_id = true; + iot->id = (char *)qdict_get_str (qdict,"id" ); + iot->bps =qdict_get_int (qdict,"bps" ); + iot->bps_rd =qdict_get_int (qdict,"bps_rd" ); + iot->bps_wr =qdict_get_int (qdict,"bps_wr" ); + iot->iops =qdict_get_int (qdict,"iops" ); + iot->iops_rd =qdict_get_int (qdict,"iops_rd" ); + iot->iops_wr =qdict_get_int (qdict,"iops_wr" ); +} +void hmp_block_set_io_throttle (Monitor *mon,const QDict *qdict) {Error *err =NULL ; +IOThrottle *iothrottle;BlockIOThrottle throttle = { .has_device = true, .device = (char *)qdict_get_str (qdict,"device" ), - .bps =qdict_get_int (qdict,"bps" ), - .bps_rd =qdict_get_int (qdict,"bps_rd" ), - .bps_wr =qdict_get_int (qdict,"bps_wr" ), - .iops =qdict_get_int (qdict,"iops" ), - .iops_rd =qdict_get_int (qdict,"iops_rd" ), - .iops_wr =qdict_get_int (qdict,"iops_wr" ), }; + iothrottle =qapi_BlockIOThrottle_base (&throttle); +hmp_initialize_io_throttle (iothrottle, qdict);qmp_block_set_io_throttle (&throttle, &err);hmp_handle_error (mon, &err); }include/qemu/throttle-options.h +3
-0@@ -11,6 +11,7 @@#define THROTTLE_OPTIONS_H #include "qemu/throttle.h" +#include "qmp-commands.h" #define THROTTLE_OPTS \ { \@@ -93,4 +94,6 @@void throttle_parse_options (ThrottleConfig *,QemuOpts *); +void throttle_set_io_limits (ThrottleConfig *,IOThrottle *); +#endif util/throttle.c +60
-0@@ -27,6 +27,7 @@#include "qemu/throttle.h" #include "qemu/timer.h" #include "block/aio.h" +#include "qemu/throttle-options.h" /* This function make a bucket leak * @@ -564,3 +565,62 @@ void throttle_parse_options(ThrottleConfig *throttle_cfg, QemuOpts *opts) throttle_cfg->op_size =qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); } + +/* set the throttle limits +* +* @arg: iothrottle limits +* @cfg: throttle configuration +*/ +void throttle_set_io_limits (ThrottleConfig *cfg,IOThrottle *arg) +{ +throttle_config_init (cfg); + cfg->buckets[THROTTLE_BPS_TOTAL ].avg = arg->bps; + cfg->buckets[THROTTLE_BPS_READ ].avg = arg->bps_rd; + cfg->buckets[THROTTLE_BPS_WRITE ].avg = arg->bps_wr; + + cfg->buckets[THROTTLE_OPS_TOTAL ].avg = arg->iops; + cfg->buckets[THROTTLE_OPS_READ ].avg = arg->iops_rd; + cfg->buckets[THROTTLE_OPS_WRITE ].avg = arg->iops_wr; + +if (arg->has_bps_max) { + cfg->buckets[THROTTLE_BPS_TOTAL ].max = arg->bps_max; + } +if (arg->has_bps_rd_max) { + cfg->buckets[THROTTLE_BPS_READ ].max = arg->bps_rd_max; + } +if (arg->has_bps_wr_max) { + cfg->buckets[THROTTLE_BPS_WRITE ].max = arg->bps_wr_max; + } +if (arg->has_iops_max) { + cfg->buckets[THROTTLE_OPS_TOTAL ].max = arg->iops_max; + } +if (arg->has_iops_rd_max) { + cfg->buckets[THROTTLE_OPS_READ ].max = arg->iops_rd_max; + } +if (arg->has_iops_wr_max) { + cfg->buckets[THROTTLE_OPS_WRITE ].max = arg->iops_wr_max; + } + +if (arg->has_bps_max_length) { + cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = arg->bps_max_length; + } +if (arg->has_bps_rd_max_length) { + cfg->buckets[THROTTLE_BPS_READ ].burst_length = arg->bps_rd_max_length; + } +if (arg->has_bps_wr_max_length) { + cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = arg->bps_wr_max_length; + } +if (arg->has_iops_max_length) { + cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = arg->iops_max_length; + } +if (arg->has_iops_rd_max_length) { + cfg->buckets[THROTTLE_OPS_READ ].burst_length = arg->iops_rd_max_length; + } +if (arg->has_iops_wr_max_length) { + cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = arg->iops_wr_max_length; + } + +if (arg->has_iops_size) { + cfg->op_size = arg->iops_size; + } +}
Re: [Qemu-devel] [PATCH v5 3/5] qmp: refactor duplicate code
Quoted 11 lines · On Wed, 21 Jun 2017 10:34:42 +0200 Pradeep Jagadeesh…
Quoted 8 lines · Greg Kurz
Quoted 3 lines · On Mon, 19 Jun 2017 09:11:34 -0400 Pradeep Jagadeesh…
This patch factor out the duplicate qmp throttle interface code that was present in both block and fsdev device files.
The text is obviously wrong. I don't see any duplicate code below.
OK, I will fix this.
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
It is more something like: let's factor out the code that will be used by the existing QMP throttling API for block devices and the future QMP throttling API for fs devices.
Please move the HMP part to another patch, as asked during v4 review.
I have moved the hmp patches for the fsdev into a separate patch. Do you want me to push this also into a separate patch?
Yes. These changes aren't related and theoretically belong to separate sub-maintainer trees.
Quoted 226 lines
Quoted 4 lines
Also,
blockdev.candhmp.cdo have maintainers. You should Cc: them each time because they know better than me and even if these patches are carried through my tree, I won't do it without an ack from them.OK, I will add them next time on.
-Pradeep
Quoted 216 lines
Cc'ing Markus for
blockdev.cand David forhmp.c.Quoted 213 lines
Signed-off-by Pradeep Jagadeesh <[email protected]>--- blockdev.c | 53 +++--------------------------------- hmp.c | 21 ++++++++++----- include/qemu/throttle-options.h | 3 +++ util/throttle.c | 60 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 56 deletions(-)blockdev.c +3
-50@@ -2593,6 +2593,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)BlockDriverState *bs;BlockBackend *blk;AioContext *aio_context; +IOThrottle *iothrottle; blk = qmp_get_blk(arg->has_device ? arg->device : NULL, arg->has_id ? arg->id : NULL,@@ -2610,56 +2611,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp) goto out; } -throttle_config_init (&cfg); - cfg.buckets[THROTTLE_BPS_TOTAL ].avg = arg->bps; - cfg.buckets[THROTTLE_BPS_READ ].avg = arg->bps_rd; - cfg.buckets[THROTTLE_BPS_WRITE ].avg = arg->bps_wr; - - cfg.buckets[THROTTLE_OPS_TOTAL ].avg = arg->iops; - cfg.buckets[THROTTLE_OPS_READ ].avg = arg->iops_rd; - cfg.buckets[THROTTLE_OPS_WRITE ].avg = arg->iops_wr; - -if (arg->has_bps_max) { - cfg.buckets[THROTTLE_BPS_TOTAL ].max = arg->bps_max; - } -if (arg->has_bps_rd_max) { - cfg.buckets[THROTTLE_BPS_READ ].max = arg->bps_rd_max; - } -if (arg->has_bps_wr_max) { - cfg.buckets[THROTTLE_BPS_WRITE ].max = arg->bps_wr_max; - } -if (arg->has_iops_max) { - cfg.buckets[THROTTLE_OPS_TOTAL ].max = arg->iops_max; - } -if (arg->has_iops_rd_max) { - cfg.buckets[THROTTLE_OPS_READ ].max = arg->iops_rd_max; - } -if (arg->has_iops_wr_max) { - cfg.buckets[THROTTLE_OPS_WRITE ].max = arg->iops_wr_max; - } - -if (arg->has_bps_max_length) { - cfg.buckets[THROTTLE_BPS_TOTAL ].burst_length = arg->bps_max_length; - } -if (arg->has_bps_rd_max_length) { - cfg.buckets[THROTTLE_BPS_READ ].burst_length = arg->bps_rd_max_length; - } -if (arg->has_bps_wr_max_length) { - cfg.buckets[THROTTLE_BPS_WRITE ].burst_length = arg->bps_wr_max_length; - } -if (arg->has_iops_max_length) { - cfg.buckets[THROTTLE_OPS_TOTAL ].burst_length = arg->iops_max_length; - } -if (arg->has_iops_rd_max_length) { - cfg.buckets[THROTTLE_OPS_READ ].burst_length = arg->iops_rd_max_length; - } -if (arg->has_iops_wr_max_length) { - cfg.buckets[THROTTLE_OPS_WRITE ].burst_length = arg->iops_wr_max_length; - } - -if (arg->has_iops_size) { - cfg.op_size = arg->iops_size; - } + iothrottle =qapi_BlockIOThrottle_base (arg); +throttle_set_io_limits (&cfg, iothrottle);if (!throttle_is_valid (&cfg, errp)) { goto out;hmp.c +15
-6@@ -1749,20 +1749,29 @@ void hmp_change(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +static void hmp_initialize_io_throttle (IOThrottle *iot,const QDict *qdict) +{ + iot->has_id = true; + iot->id = (char *)qdict_get_str (qdict,"id" ); + iot->bps =qdict_get_int (qdict,"bps" ); + iot->bps_rd =qdict_get_int (qdict,"bps_rd" ); + iot->bps_wr =qdict_get_int (qdict,"bps_wr" ); + iot->iops =qdict_get_int (qdict,"iops" ); + iot->iops_rd =qdict_get_int (qdict,"iops_rd" ); + iot->iops_wr =qdict_get_int (qdict,"iops_wr" ); +} +void hmp_block_set_io_throttle (Monitor *mon,const QDict *qdict) {Error *err =NULL ; +IOThrottle *iothrottle;BlockIOThrottle throttle = { .has_device = true, .device = (char *)qdict_get_str (qdict,"device" ), - .bps =qdict_get_int (qdict,"bps" ), - .bps_rd =qdict_get_int (qdict,"bps_rd" ), - .bps_wr =qdict_get_int (qdict,"bps_wr" ), - .iops =qdict_get_int (qdict,"iops" ), - .iops_rd =qdict_get_int (qdict,"iops_rd" ), - .iops_wr =qdict_get_int (qdict,"iops_wr" ), }; + iothrottle =qapi_BlockIOThrottle_base (&throttle); +hmp_initialize_io_throttle (iothrottle, qdict);qmp_block_set_io_throttle (&throttle, &err);hmp_handle_error (mon, &err); }include/qemu/throttle-options.h +3
-0@@ -11,6 +11,7 @@#define THROTTLE_OPTIONS_H #include "qemu/throttle.h" +#include "qmp-commands.h" #define THROTTLE_OPTS \ { \@@ -93,4 +94,6 @@void throttle_parse_options (ThrottleConfig *,QemuOpts *); +void throttle_set_io_limits (ThrottleConfig *,IOThrottle *); +#endif util/throttle.c +60
-0@@ -27,6 +27,7 @@#include "qemu/throttle.h" #include "qemu/timer.h" #include "block/aio.h" +#include "qemu/throttle-options.h" /* This function make a bucket leak * @@ -564,3 +565,62 @@ void throttle_parse_options(ThrottleConfig *throttle_cfg, QemuOpts *opts) throttle_cfg->op_size =qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); } + +/* set the throttle limits +* +* @arg: iothrottle limits +* @cfg: throttle configuration +*/ +void throttle_set_io_limits (ThrottleConfig *cfg,IOThrottle *arg) +{ +throttle_config_init (cfg); + cfg->buckets[THROTTLE_BPS_TOTAL ].avg = arg->bps; + cfg->buckets[THROTTLE_BPS_READ ].avg = arg->bps_rd; + cfg->buckets[THROTTLE_BPS_WRITE ].avg = arg->bps_wr; + + cfg->buckets[THROTTLE_OPS_TOTAL ].avg = arg->iops; + cfg->buckets[THROTTLE_OPS_READ ].avg = arg->iops_rd; + cfg->buckets[THROTTLE_OPS_WRITE ].avg = arg->iops_wr; + +if (arg->has_bps_max) { + cfg->buckets[THROTTLE_BPS_TOTAL ].max = arg->bps_max; + } +if (arg->has_bps_rd_max) { + cfg->buckets[THROTTLE_BPS_READ ].max = arg->bps_rd_max; + } +if (arg->has_bps_wr_max) { + cfg->buckets[THROTTLE_BPS_WRITE ].max = arg->bps_wr_max; + } +if (arg->has_iops_max) { + cfg->buckets[THROTTLE_OPS_TOTAL ].max = arg->iops_max; + } +if (arg->has_iops_rd_max) { + cfg->buckets[THROTTLE_OPS_READ ].max = arg->iops_rd_max; + } +if (arg->has_iops_wr_max) { + cfg->buckets[THROTTLE_OPS_WRITE ].max = arg->iops_wr_max; + } + +if (arg->has_bps_max_length) { + cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = arg->bps_max_length; + } +if (arg->has_bps_rd_max_length) { + cfg->buckets[THROTTLE_BPS_READ ].burst_length = arg->bps_rd_max_length; + } +if (arg->has_bps_wr_max_length) { + cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = arg->bps_wr_max_length; + } +if (arg->has_iops_max_length) { + cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = arg->iops_max_length; + } +if (arg->has_iops_rd_max_length) { + cfg->buckets[THROTTLE_OPS_READ ].burst_length = arg->iops_rd_max_length; + } +if (arg->has_iops_wr_max_length) { + cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = arg->iops_wr_max_length; + } + +if (arg->has_iops_size) { + cfg->op_size = arg->iops_size; + } +}
Re: [Qemu-devel] [PATCH v5 3/5] qmp: refactor duplicate code
Quoted 18 lines · Greg Kurz
Quoted 15 lines · On Wed, 21 Jun 2017 10:34:42 +0200 Pradeep Jagadeesh…
Quoted 8 lines · Greg Kurz
Quoted 3 lines · On Mon, 19 Jun 2017 09:11:34 -0400 Pradeep Jagadeesh…
This patch factor out the duplicate qmp throttle interface code that was present in both block and fsdev device files.
The text is obviously wrong. I don't see any duplicate code below.
OK, I will fix this.
Quoted 5 lines
It is more something like: let's factor out the code that will be used by the existing QMP throttling API for block devices and the future QMP throttling API for fs devices.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Please move the HMP part to another patch, as asked during v4 review.
I have moved the hmp patches for the fsdev into a separate patch. Do you want me to push this also into a separate patch?
Yes. These changes aren't related and theoretically belong to separate sub-maintainer trees.
OK, I will split the commit and make separate patches.
-Pradeep
Quoted 228 lines
Quoted 227 lines
Quoted 5 lines
Also,
blockdev.candhmp.cdo have maintainers. You should Cc: them each time because they know better than me and even if these patches are carried through my tree, I won't do it without an ack from them.OK, I will add them next time on.
-Pradeep
Quoted 216 lines
Cc'ing Markus for
blockdev.cand David forhmp.c.Quoted 213 lines
Signed-off-by Pradeep Jagadeesh <[email protected]>--- blockdev.c | 53 +++--------------------------------- hmp.c | 21 ++++++++++----- include/qemu/throttle-options.h | 3 +++ util/throttle.c | 60 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 56 deletions(-)blockdev.c +3
-50@@ -2593,6 +2593,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)BlockDriverState *bs;BlockBackend *blk;AioContext *aio_context; +IOThrottle *iothrottle; blk = qmp_get_blk(arg->has_device ? arg->device : NULL, arg->has_id ? arg->id : NULL,@@ -2610,56 +2611,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp) goto out; } -throttle_config_init (&cfg); - cfg.buckets[THROTTLE_BPS_TOTAL ].avg = arg->bps; - cfg.buckets[THROTTLE_BPS_READ ].avg = arg->bps_rd; - cfg.buckets[THROTTLE_BPS_WRITE ].avg = arg->bps_wr; - - cfg.buckets[THROTTLE_OPS_TOTAL ].avg = arg->iops; - cfg.buckets[THROTTLE_OPS_READ ].avg = arg->iops_rd; - cfg.buckets[THROTTLE_OPS_WRITE ].avg = arg->iops_wr; - -if (arg->has_bps_max) { - cfg.buckets[THROTTLE_BPS_TOTAL ].max = arg->bps_max; - } -if (arg->has_bps_rd_max) { - cfg.buckets[THROTTLE_BPS_READ ].max = arg->bps_rd_max; - } -if (arg->has_bps_wr_max) { - cfg.buckets[THROTTLE_BPS_WRITE ].max = arg->bps_wr_max; - } -if (arg->has_iops_max) { - cfg.buckets[THROTTLE_OPS_TOTAL ].max = arg->iops_max; - } -if (arg->has_iops_rd_max) { - cfg.buckets[THROTTLE_OPS_READ ].max = arg->iops_rd_max; - } -if (arg->has_iops_wr_max) { - cfg.buckets[THROTTLE_OPS_WRITE ].max = arg->iops_wr_max; - } - -if (arg->has_bps_max_length) { - cfg.buckets[THROTTLE_BPS_TOTAL ].burst_length = arg->bps_max_length; - } -if (arg->has_bps_rd_max_length) { - cfg.buckets[THROTTLE_BPS_READ ].burst_length = arg->bps_rd_max_length; - } -if (arg->has_bps_wr_max_length) { - cfg.buckets[THROTTLE_BPS_WRITE ].burst_length = arg->bps_wr_max_length; - } -if (arg->has_iops_max_length) { - cfg.buckets[THROTTLE_OPS_TOTAL ].burst_length = arg->iops_max_length; - } -if (arg->has_iops_rd_max_length) { - cfg.buckets[THROTTLE_OPS_READ ].burst_length = arg->iops_rd_max_length; - } -if (arg->has_iops_wr_max_length) { - cfg.buckets[THROTTLE_OPS_WRITE ].burst_length = arg->iops_wr_max_length; - } - -if (arg->has_iops_size) { - cfg.op_size = arg->iops_size; - } + iothrottle =qapi_BlockIOThrottle_base (arg); +throttle_set_io_limits (&cfg, iothrottle);if (!throttle_is_valid (&cfg, errp)) { goto out;hmp.c +15
-6@@ -1749,20 +1749,29 @@ void hmp_change(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +static void hmp_initialize_io_throttle (IOThrottle *iot,const QDict *qdict) +{ + iot->has_id = true; + iot->id = (char *)qdict_get_str (qdict,"id" ); + iot->bps =qdict_get_int (qdict,"bps" ); + iot->bps_rd =qdict_get_int (qdict,"bps_rd" ); + iot->bps_wr =qdict_get_int (qdict,"bps_wr" ); + iot->iops =qdict_get_int (qdict,"iops" ); + iot->iops_rd =qdict_get_int (qdict,"iops_rd" ); + iot->iops_wr =qdict_get_int (qdict,"iops_wr" ); +} +void hmp_block_set_io_throttle (Monitor *mon,const QDict *qdict) {Error *err =NULL ; +IOThrottle *iothrottle;BlockIOThrottle throttle = { .has_device = true, .device = (char *)qdict_get_str (qdict,"device" ), - .bps =qdict_get_int (qdict,"bps" ), - .bps_rd =qdict_get_int (qdict,"bps_rd" ), - .bps_wr =qdict_get_int (qdict,"bps_wr" ), - .iops =qdict_get_int (qdict,"iops" ), - .iops_rd =qdict_get_int (qdict,"iops_rd" ), - .iops_wr =qdict_get_int (qdict,"iops_wr" ), }; + iothrottle =qapi_BlockIOThrottle_base (&throttle); +hmp_initialize_io_throttle (iothrottle, qdict);qmp_block_set_io_throttle (&throttle, &err);hmp_handle_error (mon, &err); }include/qemu/throttle-options.h +3
-0@@ -11,6 +11,7 @@#define THROTTLE_OPTIONS_H #include "qemu/throttle.h" +#include "qmp-commands.h" #define THROTTLE_OPTS \ { \@@ -93,4 +94,6 @@void throttle_parse_options (ThrottleConfig *,QemuOpts *); +void throttle_set_io_limits (ThrottleConfig *,IOThrottle *); +#endif util/throttle.c +60
-0@@ -27,6 +27,7 @@#include "qemu/throttle.h" #include "qemu/timer.h" #include "block/aio.h" +#include "qemu/throttle-options.h" /* This function make a bucket leak * @@ -564,3 +565,62 @@ void throttle_parse_options(ThrottleConfig *throttle_cfg, QemuOpts *opts) throttle_cfg->op_size =qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); } + +/* set the throttle limits +* +* @arg: iothrottle limits +* @cfg: throttle configuration +*/ +void throttle_set_io_limits (ThrottleConfig *cfg,IOThrottle *arg) +{ +throttle_config_init (cfg); + cfg->buckets[THROTTLE_BPS_TOTAL ].avg = arg->bps; + cfg->buckets[THROTTLE_BPS_READ ].avg = arg->bps_rd; + cfg->buckets[THROTTLE_BPS_WRITE ].avg = arg->bps_wr; + + cfg->buckets[THROTTLE_OPS_TOTAL ].avg = arg->iops; + cfg->buckets[THROTTLE_OPS_READ ].avg = arg->iops_rd; + cfg->buckets[THROTTLE_OPS_WRITE ].avg = arg->iops_wr; + +if (arg->has_bps_max) { + cfg->buckets[THROTTLE_BPS_TOTAL ].max = arg->bps_max; + } +if (arg->has_bps_rd_max) { + cfg->buckets[THROTTLE_BPS_READ ].max = arg->bps_rd_max; + } +if (arg->has_bps_wr_max) { + cfg->buckets[THROTTLE_BPS_WRITE ].max = arg->bps_wr_max; + } +if (arg->has_iops_max) { + cfg->buckets[THROTTLE_OPS_TOTAL ].max = arg->iops_max; + } +if (arg->has_iops_rd_max) { + cfg->buckets[THROTTLE_OPS_READ ].max = arg->iops_rd_max; + } +if (arg->has_iops_wr_max) { + cfg->buckets[THROTTLE_OPS_WRITE ].max = arg->iops_wr_max; + } + +if (arg->has_bps_max_length) { + cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = arg->bps_max_length; + } +if (arg->has_bps_rd_max_length) { + cfg->buckets[THROTTLE_BPS_READ ].burst_length = arg->bps_rd_max_length; + } +if (arg->has_bps_wr_max_length) { + cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = arg->bps_wr_max_length; + } +if (arg->has_iops_max_length) { + cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = arg->iops_max_length; + } +if (arg->has_iops_rd_max_length) { + cfg->buckets[THROTTLE_OPS_READ ].burst_length = arg->iops_rd_max_length; + } +if (arg->has_iops_wr_max_length) { + cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = arg->iops_wr_max_length; + } + +if (arg->has_iops_size) { + cfg->op_size = arg->iops_size; + } +}
PATCH v5 4/5 fsdev: hmp interface for throttling
In reply to Pradeep JagadeeshThis patch introduces hmp interfaces for the fsdev throttle functionality
--- hmp-commands-info.hx | 18 ++++++++++++++ hmp-commands.hx | 19 +++++++++++++++ hmp.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hmp.h | 4 ++++ 4 files changed, 107 insertions(+)
hmp-commands-info.hx +18 -0
@@ -84,6 +84,24 @@ STEXI Show block device statistics. ETEXI +#if defined(CONFIG_VIRTFS) + + { + .name = "query-fsdev-iothrottle", + .args_type = "", + .params = "", + .help = "show fsdev device throttle information", + .cmd = hmp_fsdev_get_io_throttle, + }, + +#endif + +STEXI +@item info fsdev throttle +@findex fsdevthrottleinfo +Show fsdev device throttleinfo. +ETEXI + { .name = "block-jobs", .args_type = "",
hmp-commands.hx +19 -0
@@ -1662,6 +1662,25 @@ STEXI Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} ETEXI +#if defined(CONFIG_VIRTFS) + + { + .name = "fsdev-set-io-throttle", + .args_type = "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l,iops_wr:l", + .params = "device bps bps_rd bps_wr iops iops_rd iops_wr", + .help = "change I/O throttle limits for a fs devices", + .cmd = hmp_fsdev_set_io_throttle, + }, + +#endif + +STEXI +@item fsdev_set_io_throttle @var{device} @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} +@findex fsdev_set_io_throttle +Change I/O throttle limits for a fs devices to @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} +ETEXI + + { .name = "set_password", .args_type = "protocol:s,password:s,connected:s?",
hmp.c +66 -0
72 lines not on this page · raw message
hmp.h +4 -0
@@ -81,6 +81,10 @@ void hmp_set_password(Monitor *mon, const QDict *qdict);void hmp_expire_password (Monitor *mon,const QDict *qdict);void hmp_eject (Monitor *mon,const QDict *qdict);void hmp_change (Monitor *mon,const QDict *qdict); +#ifdef CONFIG_VIRTFS +void hmp_fsdev_set_io_throttle (Monitor *mon,const QDict *qdict); +void hmp_fsdev_get_io_throttle (Monitor *mon,const QDict *qdict); +#endif void hmp_block_set_io_throttle (Monitor *mon,const QDict *qdict);void hmp_block_stream (Monitor *mon,const QDict *qdict);void hmp_block_job_set_speed (Monitor *mon,const QDict *qdict);
Signature · 1 line
1.8.3.1
PATCH v5 5/5 fsdev: QMP interface for throttling
In reply to Pradeep JagadeeshThis patch enables qmp interfaces for the fsdev devices. This provides two interfaces one
for querying info of all the fsdev devices. The second one to set the IO limits for the required fsdev device.
--- Makefile | 3 ++ fsdev/qemu-fsdev-dummy.c | 10 ++++++ fsdev/qemu-fsdev-throttle.c | 75 ++++++++++++++++++++++++++++++++++++++++ fsdev/qemu-fsdev-throttle.h | 12 +++++++ fsdev/qemu-fsdev.c | 37 ++++++++++++++++++++ monitor.c | 5 +++ qapi-schema.json | 3 ++ qapi/fsdev.json | 84 +++++++++++++++++++++++++++++++++++++++++++++ qmp.c | 15 ++++++++ 9 files changed, 244 insertions(+) create mode 100644 qapi/fsdev.json
Makefile +3 -0
@@ -414,6 +414,9 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.json \ $(SRC_PATH)/qapi/crypto.json $(SRC_PATH)/qapi/rocker.json \ $(SRC_PATH)/qapi/trace.json +ifdef CONFIG_VIRTFS +qapi-modules += $(SRC_PATH)/qapi/fsdev.json +endif qapi-types.c qapi-types.h :\ $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
fsdev/qemu-fsdev-dummy.c +10 -0
@@ -19,3 +19,13 @@ int qemu_fsdev_add(QemuOpts *opts) {return 0 ; } + +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ +return ; +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +abort (); +}
fsdev/qemu-fsdev-throttle.c +75 -0
81 lines not on this page · raw message
fsdev/qemu-fsdev-throttle.h +12 -0
@@ -21,6 +21,12 @@#include "qapi/error.h" #include "qemu/throttle.h" #include "qemu/throttle-options.h" +#include "qapi/qmp/qerror.h" +#include "qapi/qmp/types.h" +#include "qapi-visit.h" +#include "qapi/qobject-output-visitor.h" +#include "qapi/util.h" +#include "qmp-commands.h" typedef struct FsThrottle { ThrottleState ts;
@@ -37,4 +43,10 @@ void coroutine_fn fsdev_co_throttle_request(FsThrottle *, bool , struct iovec *, int);void fsdev_throttle_cleanup (FsThrottle *); + +void fsdev_set_io_throttle (IOThrottle *,FsThrottle *,Error **errp); + +void fsdev_get_io_throttle (FsThrottle *,IOThrottle **iothp, +char *,Error **errp); +#endif /* _FSDEV_THROTTLE_H */
fsdev/qemu-fsdev.c +37 -0
@@ -16,6 +16,7 @@#include "qemu-common.h" #include "qemu/config-file.h" #include "qemu/error-report.h" +#include "qmp-commands.h" static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries =QTAILQ_HEAD_INITIALIZER (fsdriver_entries);
@@ -98,3 +99,39 @@ FsDriverEntry *get_fsdev_fsentry(char *id) }return NULL ; } + +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ + +FsDriverEntry *fse; + + fse =get_fsdev_fsentry (arg->has_id ? arg->id :NULL ); +if (!fse) { +return ; + } + +fsdev_set_io_throttle (arg, &fse->fst, errp); +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +IOThrottleList *head =NULL , **p_next = &head; +struct FsDriverListEntry *fsle; +Error *local_err =NULL ; + + QTAILQ_FOREACH(fsle, &fsdriver_entries, next) { +IOThrottleList *fscfg =g_malloc0 (sizeof (*fscfg)); +fsdev_get_io_throttle (&fsle->fse.fst, &fscfg->value, + fsle->fse.fsdev_id, &local_err); +if (local_err) { +error_propagate (errp, local_err); +g_free (fscfg); +qapi_free_IOThrottleList (head); +return NULL ; + } + + *p_next = fscfg; + p_next = &fscfg->next; + } +return head; +}
monitor.c +5 -0
@@ -997,6 +997,11 @@ static void qmp_unregister_commands_hack(void) && !defined(TARGET_S390X)qmp_unregister_command (&qmp_commands,"query-cpu-definitions" );#endif +#ifndef CONFIG_VIRTFS +qmp_unregister_command (&qmp_commands,"fsdev-set-io-throttle" ); +qmp_unregister_command (&qmp_commands,"query-fsdev-io-throttle" ); +#endif + }void monitor_init_qmp_commands (void )
qapi-schema.json +3 -0
@@ -81,6 +81,9 @@ # QAPI block definitions { 'include': 'qapi/block.json' } +# QAPI fsdev definitions +{ 'include': 'qapi/fsdev.json' } + # QAPI event definitions { 'include': 'qapi/event.json' }
qapi/fsdev.json new file +84 -0
84 lines not on this page · raw message
qmp.c +15 -0
@@ -130,6 +130,21 @@ void qmp_cpu_add(int64_t id, Error **errp) } } +#if defined(_WIN64) || defined(_WIN32) + +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ +return ; +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +abort (); +} + +#endif + +#ifndef CONFIG_VNC /* If VNC support is enabled, the "true" query-vnc command is defined in the VNC subsystem */
Signature · 1 line
1.8.3.1