Re: [Qemu-devel] [PATCH v11 1/6] throttle: factor out duplicate code
On 9/23/2017 12:33 PM, Manos Pitsidianakis wrote: On Fri, Sep 22, 2017 at 01:31:58PM +0200, Pradeep Jagadeesh wrote: On 9/18/2017 6:20 PM, Manos Pitsidianakis wrote: On Thu, Sep 14, 2017 at 06:40:05AM -0400, Pradeep Jagadeesh wrote: This patch factors out the duplicate throttle code that was still present in block and fsdev devices. Signed-off-by: Pradeep JagadeeshReviewed-by: Alberto Garcia Reviewed-by: Greg Kurz Reviewed-by: Eric Blake --- blockdev.c | 44 +- fsdev/qemu-fsdev-throttle.c | 44 ++ include/qemu/throttle-options.h | 3 +++ include/qemu/throttle.h | 4 ++-- include/qemu/typedefs.h | 1 + util/throttle.c | 52 + 6 files changed, 61 insertions(+), 87 deletions(-) diff --git a/blockdev.c b/blockdev.c index 56a6b24..9d33c25 100644 --- a/blockdev.c +++ b/blockdev.c @@ -387,49 +387,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; } diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index 49eebb5..0e6fb86 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -16,6 +16,7 @@ #include "qemu/error-report.h" #include "qemu-fsdev-throttle.h" #include "qemu/iov.h" +#include "qemu/throttle-options.h" static void fsdev_throttle_read_timer_cb(void *opaque) { @@ -31,48 +32,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque) void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp) { -throttle_config_init(>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 = -
Re: [Qemu-devel] [PATCH v11 1/6] throttle: factor out duplicate code
On Fri, Sep 22, 2017 at 01:31:58PM +0200, Pradeep Jagadeesh wrote: On 9/18/2017 6:20 PM, Manos Pitsidianakis wrote: On Thu, Sep 14, 2017 at 06:40:05AM -0400, Pradeep Jagadeesh wrote: This patch factors out the duplicate throttle code that was still present in block and fsdev devices. Signed-off-by: Pradeep JagadeeshReviewed-by: Alberto Garcia Reviewed-by: Greg Kurz Reviewed-by: Eric Blake --- blockdev.c | 44 +- fsdev/qemu-fsdev-throttle.c | 44 ++ include/qemu/throttle-options.h | 3 +++ include/qemu/throttle.h | 4 ++-- include/qemu/typedefs.h | 1 + util/throttle.c | 52 + 6 files changed, 61 insertions(+), 87 deletions(-) diff --git a/blockdev.c b/blockdev.c index 56a6b24..9d33c25 100644 --- a/blockdev.c +++ b/blockdev.c @@ -387,49 +387,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; } diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index 49eebb5..0e6fb86 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -16,6 +16,7 @@ #include "qemu/error-report.h" #include "qemu-fsdev-throttle.h" #include "qemu/iov.h" +#include "qemu/throttle-options.h" static void fsdev_throttle_read_timer_cb(void *opaque) { @@ -31,48 +32,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque) void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp) { -throttle_config_init(>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);
Re: [Qemu-devel] [PATCH v11 1/6] throttle: factor out duplicate code
On 9/18/2017 6:20 PM, Manos Pitsidianakis wrote: On Thu, Sep 14, 2017 at 06:40:05AM -0400, Pradeep Jagadeesh wrote: This patch factors out the duplicate throttle code that was still present in block and fsdev devices. Signed-off-by: Pradeep JagadeeshReviewed-by: Alberto Garcia Reviewed-by: Greg Kurz Reviewed-by: Eric Blake --- blockdev.c | 44 +- fsdev/qemu-fsdev-throttle.c | 44 ++ include/qemu/throttle-options.h | 3 +++ include/qemu/throttle.h | 4 ++-- include/qemu/typedefs.h | 1 + util/throttle.c | 52 + 6 files changed, 61 insertions(+), 87 deletions(-) diff --git a/blockdev.c b/blockdev.c index 56a6b24..9d33c25 100644 --- a/blockdev.c +++ b/blockdev.c @@ -387,49 +387,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; } diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index 49eebb5..0e6fb86 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -16,6 +16,7 @@ #include "qemu/error-report.h" #include "qemu-fsdev-throttle.h" #include "qemu/iov.h" +#include "qemu/throttle-options.h" static void fsdev_throttle_read_timer_cb(void *opaque) { @@ -31,48 +32,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque) void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp) { -throttle_config_init(>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 = -
Re: [Qemu-devel] [PATCH v11 1/6] throttle: factor out duplicate code
On 9/18/2017 6:20 PM, Manos Pitsidianakis wrote: On Thu, Sep 14, 2017 at 06:40:05AM -0400, Pradeep Jagadeesh wrote: This patch factors out the duplicate throttle code that was still present in block and fsdev devices. Signed-off-by: Pradeep JagadeeshReviewed-by: Alberto Garcia Reviewed-by: Greg Kurz Reviewed-by: Eric Blake --- blockdev.c | 44 +- fsdev/qemu-fsdev-throttle.c | 44 ++ include/qemu/throttle-options.h | 3 +++ include/qemu/throttle.h | 4 ++-- include/qemu/typedefs.h | 1 + util/throttle.c | 52 + 6 files changed, 61 insertions(+), 87 deletions(-) diff --git a/blockdev.c b/blockdev.c index 56a6b24..9d33c25 100644 --- a/blockdev.c +++ b/blockdev.c @@ -387,49 +387,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; } diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index 49eebb5..0e6fb86 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -16,6 +16,7 @@ #include "qemu/error-report.h" #include "qemu-fsdev-throttle.h" #include "qemu/iov.h" +#include "qemu/throttle-options.h" static void fsdev_throttle_read_timer_cb(void *opaque) { @@ -31,48 +32,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque) void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp) { -throttle_config_init(>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 = -
Re: [Qemu-devel] [PATCH v11 1/6] throttle: factor out duplicate code
On Thu, Sep 14, 2017 at 06:40:05AM -0400, Pradeep Jagadeesh wrote: This patch factors out the duplicate throttle code that was still present in block and fsdev devices. Signed-off-by: Pradeep JagadeeshReviewed-by: Alberto Garcia Reviewed-by: Greg Kurz Reviewed-by: Eric Blake --- blockdev.c | 44 +- fsdev/qemu-fsdev-throttle.c | 44 ++ include/qemu/throttle-options.h | 3 +++ include/qemu/throttle.h | 4 ++-- include/qemu/typedefs.h | 1 + util/throttle.c | 52 + 6 files changed, 61 insertions(+), 87 deletions(-) diff --git a/blockdev.c b/blockdev.c index 56a6b24..9d33c25 100644 --- a/blockdev.c +++ b/blockdev.c @@ -387,49 +387,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; } diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index 49eebb5..0e6fb86 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -16,6 +16,7 @@ #include "qemu/error-report.h" #include "qemu-fsdev-throttle.h" #include "qemu/iov.h" +#include "qemu/throttle-options.h" static void fsdev_throttle_read_timer_cb(void *opaque) { @@ -31,48 +32,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque) void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp) { -throttle_config_init(>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,
Re: [Qemu-devel] [PATCH v11 1/6] throttle: factor out duplicate code
On Thu, 14 Sep 2017 06:40:05 -0400 Pradeep Jagadeeshwrote: > This patch factors out the duplicate throttle code that was still > present in block and fsdev devices. > > Signed-off-by: Pradeep Jagadeesh > Reviewed-by: Alberto Garcia > Reviewed-by: Greg Kurz I see you took my remarks into account, except for the patch title which is still the very same as commit: a2a7862ca9ab throttle: factor out duplicate code :-\ > Reviewed-by: Eric Blake > --- > blockdev.c | 44 +- > fsdev/qemu-fsdev-throttle.c | 44 ++ > include/qemu/throttle-options.h | 3 +++ > include/qemu/throttle.h | 4 ++-- > include/qemu/typedefs.h | 1 + > util/throttle.c | 52 > + > 6 files changed, 61 insertions(+), 87 deletions(-) > > diff --git a/blockdev.c b/blockdev.c > index 56a6b24..9d33c25 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -387,49 +387,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; > } > diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c > index 49eebb5..0e6fb86 100644 > --- a/fsdev/qemu-fsdev-throttle.c > +++ b/fsdev/qemu-fsdev-throttle.c > @@ -16,6 +16,7 @@ > #include "qemu/error-report.h" > #include "qemu-fsdev-throttle.h" > #include "qemu/iov.h" > +#include "qemu/throttle-options.h" > > static void fsdev_throttle_read_timer_cb(void *opaque) > { > @@ -31,48 +32,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque) > > void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp) > { > -throttle_config_init(>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); > -
[Qemu-devel] [PATCH v11 1/6] throttle: factor out duplicate code
This patch factors out the duplicate throttle code that was still present in block and fsdev devices. Signed-off-by: Pradeep JagadeeshReviewed-by: Alberto Garcia Reviewed-by: Greg Kurz Reviewed-by: Eric Blake --- blockdev.c | 44 +- fsdev/qemu-fsdev-throttle.c | 44 ++ include/qemu/throttle-options.h | 3 +++ include/qemu/throttle.h | 4 ++-- include/qemu/typedefs.h | 1 + util/throttle.c | 52 + 6 files changed, 61 insertions(+), 87 deletions(-) diff --git a/blockdev.c b/blockdev.c index 56a6b24..9d33c25 100644 --- a/blockdev.c +++ b/blockdev.c @@ -387,49 +387,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; } diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index 49eebb5..0e6fb86 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -16,6 +16,7 @@ #include "qemu/error-report.h" #include "qemu-fsdev-throttle.h" #include "qemu/iov.h" +#include "qemu/throttle-options.h" static void fsdev_throttle_read_timer_cb(void *opaque) { @@ -31,48 +32,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque) void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp) { -throttle_config_init(>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); -