fsdev: qmp interface for io throttling
v10 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 (6):
throttle: factor out duplicate code
qmp: Create IOThrottle structure
throttle: move out function to reuse the code
hmp: create a throttle initialization function for code reusability
fsdev: QMP interface for throttling
fsdev: hmp interface for throttling
Makefile | 4 + blockdev.c | 97 +-------------------- fsdev/qemu-fsdev-dummy.c | 11 +++ fsdev/qemu-fsdev-throttle.c | 189 ++++++++++++++++++++++++++++++---------- fsdev/qemu-fsdev-throttle.h | 9 +- fsdev/qemu-fsdev.c | 30 +++++++ hmp-commands-info.hx | 18 ++++ hmp-commands.hx | 19 ++++ hmp.c | 79 +++++++++++++++-- hmp.h | 4 + include/qemu/throttle-options.h | 6 ++ include/qemu/throttle.h | 4 +- include/qemu/typedefs.h | 1 + monitor.c | 5 ++ qapi-schema.json | 3 + qapi/block-core.json | 34 ++++++-- qapi/fsdev.json | 81 +++++++++++++++++ qmp.c | 14 +++ util/throttle.c | 110 +++++++++++++++++++++++ 19 files changed, 558 insertions(+), 160 deletions(-) create mode 100644 qapi/fsdev.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
v5 -> v6:
Addressed comments from Greg Kurz and Markus Armbruster Split the commits to specific to hmp and throttle as suggested by Greg Moved ThrottleConfig typedef to qemu/typedefs.h
Addressed compilation issue on FreeBSD by adding flags in qmp.c
v6 -> v7:
Addressed comments from Albert Garcia and Dr. David Alan Gilbert Fixed the hmp-commands-info.hx and hmp-commands.hx as per Dr. David's comments.
Fixed the bug with the hmp fsdev_set_io_throttle and info fsdev_iothrottle
v7 -> v8:
Addressed comments from Markus Armbruster and Eric Blake Removed unwanted headers from qmp-fsdev-throttle.h
v8 -> v9:
Addressed comments from Markus Armbruster and Eric Blake Removed the iothrottle.json and pushed the iothrottle struct to block-core.json
v9 -> v10:
Addressed comments from Albert Garcia
Fixed issue related to dynamically passing throttle configuration Removed some unused code
Signature · 1 line
1.8.3.1
PATCH v10 1/6 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 | 44 ++--------------------------------- include/qemu/throttle-options.h | 4 ++++ include/qemu/throttle.h | 4 ++-- include/qemu/typedefs.h | 1 + util/throttle.c | 51 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 61 insertions(+), 87 deletions(-)
blockdev.c +1 -43
@@ -388,49 +388,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 +2 -42
56 lines not on this page · raw message
include/qemu/throttle-options.h +4 -0
@@ -10,6 +10,8 @@#ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H +#include "typedefs.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
include/qemu/throttle.h +2 -2
@@ -89,10 +89,10 @@ typedef struct LeakyBucket {* However it allows to keep the code clean and the bucket field is reset to * zero at the right time. */ -typedef struct ThrottleConfig { +struct ThrottleConfig {LeakyBucket buckets[BUCKETS_COUNT ];/* leaky buckets */ uint64_t op_size;/* size of an operation in bytes */ -}ThrottleConfig ; +}; typedef struct ThrottleState { ThrottleConfig cfg; /* configuration */
include/qemu/typedefs.h +1 -0
@@ -100,6 +100,7 @@ typedef struct uWireSlave uWireSlave;typedef struct VirtIODevice VirtIODevice ;typedef struct Visitor Visitor ;typedef struct node_info NodeInfo ; +typedef struct ThrottleConfig ThrottleConfig ;typedef void SaveStateHandler (QEMUFile *f,void *opaque);typedef int LoadStateHandler (QEMUFile *f,void *opaque,int version_id);
util/throttle.c +51 -0
60 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v10 1/6] throttle: factor out duplicate code
With this patch applied, we get:
$ git log --no-decorate --oneline include/qemu/throttle-options.h a54046b857be throttle: factor out duplicate code a2a7862ca9ab throttle: factor out duplicate code
Maybe better to change the patch title to:
throttle: factor out more duplicate code
Quoted 1 line · On Mon, 4 Sep 2017 12:07:42 -0400 Pradeep Jagadeesh…
This patch factor out the duplicate throttle code that was present in
This patch factors out the duplicate throttle code that was still present in
Quoted 4 lines
block and fsdev devices.
Signed-off-by Pradeep Jagadeesh <[email protected]>Reviewed-by Alberto Garcia <[email protected]>
With the above fixed.
Quoted 241 lines
--- blockdev.c | 44 +---------------------------------- fsdev/qemu-fsdev-throttle.c | 44 ++--------------------------------- include/qemu/throttle-options.h | 4 ++++ include/qemu/throttle.h | 4 ++-- include/qemu/typedefs.h | 1 + util/throttle.c | 51 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 61 insertions(+), 87 deletions(-)blockdev.c +1
-43@@ -388,49 +388,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 +2
-42@@ -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 (&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); }include/qemu/throttle-options.h +4
-0@@ -10,6 +10,8 @@#ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H +#include "typedefs.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 include/qemu/throttle.h +2
-2@@ -89,10 +89,10 @@ typedef struct LeakyBucket {* However it allows to keep the code clean and the bucket field is reset to * zero at the right time. */ -typedef struct ThrottleConfig { +struct ThrottleConfig {LeakyBucket buckets[BUCKETS_COUNT ];/* leaky buckets */ uint64_t op_size;/* size of an operation in bytes */ -}ThrottleConfig ; +}; typedef struct ThrottleState { ThrottleConfig cfg; /* configuration */include/qemu/typedefs.h +1
-0@@ -100,6 +100,7 @@ typedef struct uWireSlave uWireSlave;typedef struct VirtIODevice VirtIODevice ;typedef struct Visitor Visitor ;typedef struct node_info NodeInfo ; +typedef struct ThrottleConfig ThrottleConfig ;typedef void SaveStateHandler (QEMUFile *f,void *opaque);typedef int LoadStateHandler (QEMUFile *f,void *opaque,int version_id);util/throttle.c +51
-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 * @@ -502,3 +503,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 ); +}
PATCH v10 2/6 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 | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)
qapi/block-core.json +25 -9
@@ -1819,11 +1819,13 @@ 'data': 'BlockIOThrottle' } ## -# @BlockIOThrottle: -# -# A set of parameters describing block throttling. +# == QAPI IOThrottle definitions +## + +## +# @IOThrottle: # -# @device: Block device name (deprecated, use @id instead) +# A set of parameters describing IO throttling # # @id: The name or QOM path of the guest device (since: 2.8) #
@@ -1889,12 +1891,11 @@ # # @iops_size: an I/O size in bytes (Since 1.7) # -# @group: throttle group name (Since 2.4) # -# Since: 1.1 +# Since: 2.11 ## -{ 'struct': 'BlockIOThrottle', - 'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int', +{ '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',
@@ -1902,7 +1903,22 @@ '*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' } } + '*iops_size': 'int' } } + +## +# @BlockIOThrottle: +# +# A set of parameters describing block throttling. +# +# @device: Block device name (deprecated, use @id instead) +# +# @group: throttle group name (Since 2.4) +# +# Since: 1.1 +## +{ 'struct': 'BlockIOThrottle', + 'base': 'IOThrottle', + 'data': { '*device': 'str', '*group': 'str' } } ## # @block-stream:
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v10 2/6] qmp: Create IOThrottle structure
Quoted 4 lines · 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.
Recommend to consistently wrap commit message lines around colum 70.
Quoted 4 lines
Signed-off-by Pradeep Jagadeesh <[email protected]>Reviewed-by Greg Kurz <[email protected]>Reviewed-by Eric Blake <[email protected]>Reviewed-by Alberto Garcia <[email protected]>
PATCH v10 3/6 throttle: move out function to reuse the code
In reply to Pradeep JagadeeshThis patch move out the throttle code to util/throttle.c to maximize the reusability of the code.The same code is also used by fsdev.
--- blockdev.c | 53 +++--------------------------------- include/qemu/throttle-options.h | 2 ++ util/throttle.c | 59 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 50 deletions(-)
blockdev.c +3 -50
@@ -2571,6 +2571,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,
@@ -2588,56 +2589,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;
include/qemu/throttle-options.h +2 -0
@@ -11,6 +11,7 @@#define THROTTLE_OPTIONS_H #include "typedefs.h" +#include "qapi-types.h" #define THROTTLE_OPTS \ { \
@@ -92,5 +93,6 @@ }void throttle_parse_options (ThrottleConfig *,QemuOpts *); +void throttle_set_io_limits (ThrottleConfig *,IOThrottle *);#endif
util/throttle.c +59 -0
62 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v10 3/6] throttle: move out function to reuse the code
Quoted 2 lines · On Mon, 4 Sep 2017 12:07:44 -0400 Pradeep Jagadeesh…
This patch move out the throttle code to
util/throttle.cto maximize the reusability of the code.The same code is also used by fsdev.
s/.The same code is also used by fsdev/. The same code will also be used by fsdev/
Quoted 2 lines
Signed-off-by Pradeep Jagadeesh <[email protected]>Reviewed-by Alberto Garcia <[email protected]>
Quoted 163 lines
--- blockdev.c | 53 +++--------------------------------- include/qemu/throttle-options.h | 2 ++ util/throttle.c | 59 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 50 deletions(-)blockdev.c +3
-50@@ -2571,6 +2571,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,@@ -2588,56 +2589,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;include/qemu/throttle-options.h +2
-0@@ -11,6 +11,7 @@#define THROTTLE_OPTIONS_H #include "typedefs.h" +#include "qapi-types.h" #define THROTTLE_OPTS \ { \@@ -92,5 +93,6 @@ }void throttle_parse_options (ThrottleConfig *,QemuOpts *); +void throttle_set_io_limits (ThrottleConfig *,IOThrottle *);#endif util/throttle.c +59
-0@@ -553,3 +553,62 @@ void throttle_parse_options(ThrottleConfig *throttle_cfg, QemuOpts *opts) throttle_cfg->op_size =qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); } + +/* Initialize a throttle config from an IOThrottle structure +* +* @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 v10 4/6 hmp: create a throttle initialization function for code reusability
In reply to Pradeep JagadeeshThis patch creates a throttle initialization function to maximize the code reusability. The same code is also used by fsdev.
--- hmp.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
hmp.c +13 -6
@@ -1758,20 +1758,27 @@ 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->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); }
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v10 4/6] hmp: create a throttle initialization function for code reusability
Quoted 5 lines · Pradeep Jagadeesh
This patch creates a throttle initialization function to maximize the code reusability. The same code is also used by fsdev.
Signed-off-by Pradeep Jagadeesh <[email protected]>
I had already reviewed this patch when you sent v8 -the first v8 :)-
Berto
Re: [Qemu-devel] [PATCH v10 4/6] hmp: create a throttle initialization function for code reusability
In reply to Pradeep JagadeeshQuoted 3 lines · On Mon, 4 Sep 2017 12:07:45 -0400 Pradeep Jagadeesh…
This patch creates a throttle initialization function to maximize the code reusability. The same code is also used by fsdev.
s/is also/will also be/
Quoted 3 lines
Signed-off-by Pradeep Jagadeesh <[email protected]>---
Quoted 41 lines
hmp.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)hmp.c +13
-6@@ -1758,20 +1758,27 @@ 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->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); }
PATCH v10 5/6 fsdev: QMP interface for throttling
In reply to Pradeep JagadeeshThis patch introduces 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 | 4 ++ fsdev/qemu-fsdev-dummy.c | 11 ++++ fsdev/qemu-fsdev-throttle.c | 145 ++++++++++++++++++++++++++++++++++++++++++-- fsdev/qemu-fsdev-throttle.h | 9 ++- fsdev/qemu-fsdev.c | 30 +++++++++ monitor.c | 5 ++ qapi-schema.json | 3 + qapi/fsdev.json | 81 +++++++++++++++++++++++++ qmp.c | 14 +++++ 9 files changed, 294 insertions(+), 8 deletions(-) create mode 100644 qapi/fsdev.json
Makefile +4 -0
@@ -414,6 +414,10 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.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) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
fsdev/qemu-fsdev-dummy.c +11 -0
@@ -14,8 +14,19 @@#include "qemu-fsdev.h" #include "qemu/config-file.h" #include "qemu/module.h" +#include "qmp-commands.h" 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) +{ +return NULL ; +}
fsdev/qemu-fsdev-throttle.c +139 -6
170 lines not on this page · raw message
fsdev/qemu-fsdev-throttle.h +7 -2
@@ -15,8 +15,6 @@#ifndef _FSDEV_THROTTLE_H#define _FSDEV_THROTTLE_H -#include "block/aio.h" -#include "qemu/main-loop.h" #include "qemu/coroutine.h" #include "qapi/error.h" #include "qemu/throttle.h"
@@ -25,6 +23,7 @@ typedef struct FsThrottle {ThrottleState ts;ThrottleTimers tt;ThrottleConfig cfg; +AioContext *ctx;CoQueue throttled_reqs[2 ]; } FsThrottle;
@@ -36,4 +35,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 *); +#endif /* _FSDEV_THROTTLE_H */
fsdev/qemu-fsdev.c +30 -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,32 @@ 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) { +error_setg (errp,"Not a valid fsdev device" ); +return ; + } + +fsdev_set_io_throttle (arg, &fse->fst, errp); +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +IOThrottleList *head =NULL , *p_next; +struct FsDriverListEntry *fsle; + + QTAILQ_FOREACH(fsle, &fsdriver_entries, next) { + p_next =g_new0 (IOThrottleList,1 ); +fsdev_get_io_throttle (&fsle->fse.fst, &p_next->value, + fsle->fse.fsdev_id); + p_next->next = head; + head = p_next; + } +return head; +}
monitor.c +5 -0
@@ -998,6 +998,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 +81 -0
81 lines not on this page · raw message
qmp.c +14 -0
@@ -130,6 +130,20 @@ void qmp_cpu_add(int64_t id, Error **errp) } } +#if defined(_WIN64) || defined(_WIN32) || defined(__FreeBSD__) + +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ +return ; +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +return NULL ; +} + +#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
Re: [Qemu-devel] [PATCH v10 5/6] fsdev: QMP interface for throttling
Quoted 24 lines · Pradeep Jagadeesh
This patch introduces 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]>--- Makefile | 4 ++ fsdev/qemu-fsdev-dummy.c | 11 ++++ fsdev/qemu-fsdev-throttle.c | 145 ++++++++++++++++++++++++++++++++++++++++++-- fsdev/qemu-fsdev-throttle.h | 9 ++- fsdev/qemu-fsdev.c | 30 +++++++++ monitor.c | 5 ++ qapi-schema.json | 3 + qapi/fsdev.json | 81 +++++++++++++++++++++++++ qmp.c | 14 +++++ 9 files changed, 294 insertions(+), 8 deletions(-) create mode 100644 qapi/fsdev.jsonMakefile +0
-0
Makefile qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ · line 420
Quoted 7 lines
Makefile +4
-0@@ -414,6 +414,10 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.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 +
The ifdef is a *lie*: qapi.py *will* include this file no matter what. Lying to make is not a good idea. Drop the ifdef.
Quoted 17 lines
Makefile +0
-0qapi-types.c qapi-types.h :\ $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \fsdev/qemu-fsdev-dummy.c +1
-0@@ -14,8 +14,19 @@#include "qemu-fsdev.h" #include "qemu/config-file.h" #include "qemu/module.h" +#include "qmp-commands.h" int qemu_fsdev_add (QemuOpts *opts) {return 0 ; }
fsdev/qemu-fsdev-dummy.c line 32
Quoted 10 lines
fsdev/qemu-fsdev-dummy.c +10
-0+ +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ +return ; +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +return NULL ; +}
Predates this patch: should this be in stubs/? Might simplify fsdev/Makefile.objs.
fsdev/qemu-fsdev-throttle.c
Quoted 4 lines
fsdev/qemu-fsdev-throttle.c +0
-0
[Skipping this one...]
Quoted 22 lines
fsdev/qemu-fsdev-throttle.h +1
-2@@ -15,8 +15,6 @@#ifndef _FSDEV_THROTTLE_H#define _FSDEV_THROTTLE_H -#include "block/aio.h" -#include "qemu/main-loop.h" #include "qemu/coroutine.h" #include "qapi/error.h" #include "qemu/throttle.h" @@ -25,6 +23,7 @@ typedef struct FsThrottle {ThrottleState ts;ThrottleTimers tt;ThrottleConfig cfg; +AioContext *ctx;CoQueue throttled_reqs[2 ]; } FsThrottle;
fsdev/qemu-fsdev-throttle.h void coroutine_fn fsdev_co_throttle_request(FsThrottle *, bool , · line 42
Quoted 8 lines
fsdev/qemu-fsdev-throttle.h +5
-0@@ -36,4 +35,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 *);
Include the last parameter's name, for consistency with the other parameter declarations.
Quoted 15 lines
fsdev/qemu-fsdev-throttle.h +1
-0+#endif /* _FSDEV_THROTTLE_H */ fsdev/qemu-fsdev.c +1
-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);
fsdev/qemu-fsdev.c FsDriverEntry *get_fsdev_fsentry(char *id) · line 108
Quoted 10 lines
fsdev/qemu-fsdev.c +7
-0@@ -98,3 +99,32 @@ 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 );
!arg->has_id implies !arg->id. Therefore, Just arg->id would do, no need to check arg->has_id first. It's not wrong, though.
Quoted 67 lines
fsdev/qemu-fsdev.c +22
-0+if (!fse) { +error_setg (errp,"Not a valid fsdev device" ); +return ; + } + +fsdev_set_io_throttle (arg, &fse->fst, errp); +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +IOThrottleList *head =NULL , *p_next; +struct FsDriverListEntry *fsle; + + QTAILQ_FOREACH(fsle, &fsdriver_entries, next) { + p_next =g_new0 (IOThrottleList,1 ); +fsdev_get_io_throttle (&fsle->fse.fst, &p_next->value, + fsle->fse.fsdev_id); + p_next->next = head; + head = p_next; + } +return head; +}monitor.c +5
-0@@ -998,6 +998,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 +9
-0@@ -0,0 +1,81 @@ +# -*- Mode: Python -*- + +## +# == QAPI fsdev definitions +## + +## +# @fsdev-set-io-throttle: +#
qapi/fsdev.json line 19
Quoted 10 lines
qapi/fsdev.json new file +10
-0+# Change I/O limits for a 9p/fsdev device. +# +# I/O limits can be enabled by setting throttle value to non-zero number. +# +# I/O limits can be disabled by setting all throttle values to 0. +# +# Returns: Nothing on success +# If @device is not a valid fsdev device, GenericError +# +# Since: 2.10
2.11
Quoted 20 lines
qapi/fsdev.json new file +20
-0+# +# Example: +# +# -> { "execute": "fsdev-set-io-throttle", +# "arguments": { "id": "id0-1-0", +# "bps": 1000000, +# "bps_rd": 0, +# "bps_wr": 0, +# "iops": 0, +# "iops_rd": 0, +# "iops_wr": 0, +# "bps_max": 8000000, +# "bps_rd_max": 0, +# "bps_wr_max": 0, +# "iops_max": 0, +# "iops_rd_max": 0, +# "iops_wr_max": 0, +# "bps_max_length": 60, +# "iops_size": 0 } } +# <- { "returns": {} }
qapi/fsdev.json line 49
Quoted 10 lines
qapi/fsdev.json new file +10
-0+## +{ 'command': 'fsdev-set-io-throttle', 'boxed': true, + 'data': 'IOThrottle' } +## +# @query-fsdev-io-throttle: +# +# Returns: a list of @IOThrottle describing I/O throttle +# values of each fsdev device +# +# Since: 2.10
2.11
IOThrottle serves both as parameter of fsdev-set-io-throttle and as result of query-fsdev-io-throttle.
The former needs many of its members to be optional.
Which of the optional members are *actually* optional in the result of query-fsdev-io-throttle? Under what conditions can they be absent?
For what it's worth, the corresponding block layer query doesn't reuse IOThrottle. Instead, it repeats the throttling stuff in BlockDeviceInfo, with the same members optional. BlockDeviceInfo documentation neglects to specify under what conditions they can be absent. Berto?
Quoted 47 lines
qapi/fsdev.json new file +32
-0+# +# Example: +# +# -> { "Execute": "query-fsdev-io-throttle" } +# <- { "returns" : [ +# { +# "id": "id0-hd0", +# "bps":1000000, +# "bps_rd":0, +# "bps_wr":0, +# "iops":1000000, +# "iops_rd":0, +# "iops_wr":0, +# "bps_max": 8000000, +# "bps_rd_max": 0, +# "bps_wr_max": 0, +# "iops_max": 0, +# "iops_rd_max": 0, +# "iops_wr_max": 0, +# "bps_max_length": 0, +# "bps_rd_max_length": 0, +# "bps_wr_max_length": 0, +# "iops_max_length": 0, +# "iops_rd_max_length": 0, +# "iops_wr_max_length": 0, +# "iops_size": 0 +# } +# ] +# } +# +## +{ 'command': 'query-fsdev-io-throttle', 'returns': [ 'IOThrottle' ] }qmp.c +7
-0@@ -130,6 +130,20 @@ void qmp_cpu_add(int64_t id, Error **errp) } } +#if defined(_WIN64) || defined(_WIN32) || defined(__FreeBSD__) + +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ +return ; +} +
qmp.c void qmp_cpu_add(int64_t id, Error **errp) · line 149
Quoted 10 lines
qmp.c +7
-0+IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +return NULL ; +} + +#endif +#ifndef CONFIG_VNC /* If VNC support is enabled, the "true" query-vnc command is defined in the VNC subsystem */
Why do we need *two* stubs for these functions, one here and one in fsdev/qemu-fsdev-dummy.c?
Re: [Qemu-devel] [PATCH v10 5/6] fsdev: QMP interface for throttling
Quoted 3 lines · Markus Armbruster
Quoted 1 line
+ fse =
get_fsdev_fsentry(arg->has_id ? arg->id : NULL);!arg->has_id implies !arg->id.
Hey Markus,
I have the impression that I've also written code that never uses arg->foo when arg->has_foo is false.
Can we then assume that to be NULL/0 in all cases? Also for other data types (int, bool, ...)?
Berto
Re: [Qemu-devel] [PATCH v10 5/6] fsdev: QMP interface for throttling
Quoted 6 lines · Alberto Garcia
Quoted 3 lines · Markus Armbruster
Quoted 1 line
+ fse =
get_fsdev_fsentry(arg->has_id ? arg->id : NULL);!arg->has_id implies !arg->id.
Quoted 7 lines
Hey Markus,
I have the impression that I've also written code that never uses
arg->foowhenarg->has_foois false.Can we then assume that to be NULL/0 in all cases? Also for other data types (int, bool, ...)?
QAPI code always passes zero FOOs along with false has_FOOs. Anything that doesn't is a bug. This is particular important when FOO is a pointer; we don't want to pass around pointers pointing to random junk in the hope that everybody will obediently check their has_FOO before dereferencing.
Other code might not always be as well-behaved. In random context, checking has_FOO is probably safer.
I still want to eliminate has_FOO for pointer-valued FOO. So much to do, so little time!
Re: [Qemu-devel] [PATCH v10 5/6] fsdev: QMP interface for throttling
In reply to Markus ArmbrusterQuoted 29 lines · Markus Armbruster
Quoted 27 lines · Pradeep Jagadeesh
This patch introduces 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]>--- Makefile | 4 ++ fsdev/qemu-fsdev-dummy.c | 11 ++++ fsdev/qemu-fsdev-throttle.c | 145 ++++++++++++++++++++++++++++++++++++++++++-- fsdev/qemu-fsdev-throttle.h | 9 ++- fsdev/qemu-fsdev.c | 30 +++++++++ monitor.c | 5 ++ qapi-schema.json | 3 + qapi/fsdev.json | 81 +++++++++++++++++++++++++ qmp.c | 14 +++++ 9 files changed, 294 insertions(+), 8 deletions(-) create mode 100644 qapi/fsdev.jsonMakefile +0
-0@@ -414,6 +414,10 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ $(SRC_PATH)/qapi/crypto.json $(SRC_PATH)/qapi/rocker.json \ $(SRC_PATH)/qapi/trace.json
Quoted 7 lines
Makefile qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ · line 420
Quoted 4 lines
Makefile +4
-0+ifdef CONFIG_VIRTFS +qapi-modules += $(SRC_PATH)/qapi/fsdev.json +endif +The ifdef is a *lie*:
qapi.py*will* include this file no matter what. Lying to make is not a good idea. Drop the ifdef.
Yes, thats right. As of these are useless.
For the same reason I have these dummy functions in two different places.
Quoted 23 lines
Quoted 23 lines
Makefile +0
-0qapi-types.c qapi-types.h :\ $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \fsdev/qemu-fsdev-dummy.c +6
-0@@ -14,8 +14,19 @@#include "qemu-fsdev.h" #include "qemu/config-file.h" #include "qemu/module.h" +#include "qmp-commands.h" int qemu_fsdev_add (QemuOpts *opts) {return 0 ; } + +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ +return ; +}
Quoted 8 lines
fsdev/qemu-fsdev-dummy.c line 32
Quoted 5 lines
fsdev/qemu-fsdev-dummy.c +5
-0+ +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +return NULL ; +}Predates this patch: should this be in stubs/? Might simplify fsdev/Makefile.objs.
Explained above
Quoted 30 lines
fsdev/qemu-fsdev-throttle.c
Quoted 5 lines
fsdev/qemu-fsdev-throttle.c +0
-0[Skipping this one...]
Quoted 24 lines
fsdev/qemu-fsdev-throttle.h +1
-2@@ -15,8 +15,6 @@#ifndef _FSDEV_THROTTLE_H#define _FSDEV_THROTTLE_H -#include "block/aio.h" -#include "qemu/main-loop.h" #include "qemu/coroutine.h" #include "qapi/error.h" #include "qemu/throttle.h" @@ -25,6 +23,7 @@ typedef struct FsThrottle {ThrottleState ts;ThrottleTimers tt;ThrottleConfig cfg; +AioContext *ctx;CoQueue throttled_reqs[2 ]; } FsThrottle;@@ -36,4 +35,10 @@ void coroutine_fn fsdev_co_throttle_request(FsThrottle *, bool , struct iovec *, int);
Quoted 9 lines
fsdev/qemu-fsdev-throttle.h void coroutine_fn fsdev_co_throttle_request(FsThrottle *, bool , · line 42
Quoted 6 lines
fsdev/qemu-fsdev-throttle.h +5
-0void fsdev_throttle_cleanup (FsThrottle *); + +void fsdev_set_io_throttle (IOThrottle *,FsThrottle *,Error **errp); + +void fsdev_get_io_throttle (FsThrottle *,IOThrottle **iothp, +char *);Include the last parameter's name, for consistency with the other parameter declarations.
OK
Quoted 101 lines
Quoted 16 lines
fsdev/qemu-fsdev-throttle.h +1
-0+#endif /* _FSDEV_THROTTLE_H */ fsdev/qemu-fsdev.c +1
-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);fsdev/qemu-fsdev.c FsDriverEntry *get_fsdev_fsentry(char *id) · line 108
Quoted 10 lines
fsdev/qemu-fsdev.c +7
-0@@ -98,3 +99,32 @@ 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 );!arg->has_id implies !arg->id. Therefore, Just
arg->idwould do, no need to checkarg->has_idfirst. It's not wrong, though.Quoted 71 lines
fsdev/qemu-fsdev.c +22
-0+if (!fse) { +error_setg (errp,"Not a valid fsdev device" ); +return ; + } + +fsdev_set_io_throttle (arg, &fse->fst, errp); +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +IOThrottleList *head =NULL , *p_next; +struct FsDriverListEntry *fsle; + + QTAILQ_FOREACH(fsle, &fsdriver_entries, next) { + p_next =g_new0 (IOThrottleList,1 ); +fsdev_get_io_throttle (&fsle->fse.fst, &p_next->value, + fsle->fse.fsdev_id); + p_next->next = head; + head = p_next; + } +return head; +}monitor.c +5
-0@@ -998,6 +998,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 +13
-0@@ -0,0 +1,81 @@ +# -*- Mode: Python -*- + +## +# == QAPI fsdev definitions +## + +## +# @fsdev-set-io-throttle: +# +# Change I/O limits for a 9p/fsdev device. +# +# I/O limits can be enabled by setting throttle value to non-zero number. +#
Quoted 9 lines
qapi/fsdev.json line 19
Quoted 6 lines
qapi/fsdev.json new file +6
-0+# I/O limits can be disabled by setting all throttle values to 0. +# +# Returns: Nothing on success +# If @device is not a valid fsdev device, GenericError +# +# Since: 2.102.11
ok
Quoted 99 lines
Quoted 20 lines
qapi/fsdev.json new file +20
-0+# +# Example: +# +# -> { "execute": "fsdev-set-io-throttle", +# "arguments": { "id": "id0-1-0", +# "bps": 1000000, +# "bps_rd": 0, +# "bps_wr": 0, +# "iops": 0, +# "iops_rd": 0, +# "iops_wr": 0, +# "bps_max": 8000000, +# "bps_rd_max": 0, +# "bps_wr_max": 0, +# "iops_max": 0, +# "iops_rd_max": 0, +# "iops_wr_max": 0, +# "bps_max_length": 60, +# "iops_size": 0 } } +# <- { "returns": {} }qapi/fsdev.json line 49
Quoted 10 lines
qapi/fsdev.json new file +10
-0+## +{ 'command': 'fsdev-set-io-throttle', 'boxed': true, + 'data': 'IOThrottle' } +## +# @query-fsdev-io-throttle: +# +# Returns: a list of @IOThrottle describing I/O throttle +# values of each fsdev device +# +# Since: 2.102.11
IOThrottle serves both as parameter of fsdev-set-io-throttle and as result of query-fsdev-io-throttle.
The former needs many of its members to be optional.
Which of the optional members are *actually* optional in the result of query-fsdev-io-throttle? Under what conditions can they be absent?
For what it's worth, the corresponding block layer query doesn't reuse IOThrottle. Instead, it repeats the throttling stuff in BlockDeviceInfo, with the same members optional. BlockDeviceInfo documentation neglects to specify under what conditions they can be absent. Berto?
Quoted 52 lines
qapi/fsdev.json new file +32
-0+# +# Example: +# +# -> { "Execute": "query-fsdev-io-throttle" } +# <- { "returns" : [ +# { +# "id": "id0-hd0", +# "bps":1000000, +# "bps_rd":0, +# "bps_wr":0, +# "iops":1000000, +# "iops_rd":0, +# "iops_wr":0, +# "bps_max": 8000000, +# "bps_rd_max": 0, +# "bps_wr_max": 0, +# "iops_max": 0, +# "iops_rd_max": 0, +# "iops_wr_max": 0, +# "bps_max_length": 0, +# "bps_rd_max_length": 0, +# "bps_wr_max_length": 0, +# "iops_max_length": 0, +# "iops_rd_max_length": 0, +# "iops_wr_max_length": 0, +# "iops_size": 0 +# } +# ] +# } +# +## +{ 'command': 'query-fsdev-io-throttle', 'returns': [ 'IOThrottle' ] }qmp.c +12
-0@@ -130,6 +130,20 @@ void qmp_cpu_add(int64_t id, Error **errp) } } +#if defined(_WIN64) || defined(_WIN32) || defined(__FreeBSD__) + +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ +return ; +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +return NULL ; +} +
Quoted 8 lines
qmp.c void qmp_cpu_add(int64_t id, Error **errp) · line 149
Quoted 5 lines
qmp.c +2
-0+#endif +#ifndef CONFIG_VNC /* If VNC support is enabled, the "true" query-vnc command is defined in the VNC subsystem */ Why do we need *two* stubs for these functions, one here and one in
fsdev/qemu-fsdev-dummy.c?
At two different platforms the build fails. So, there are needed.
-Pradeep
Quoted 1 line
Re: [Qemu-devel] [PATCH v10 5/6] fsdev: QMP interface for throttling
Quoted 2 lines · Pradeep Jagadeesh
Quoted 1 line · Markus Armbruster
Pradeep Jagadeesh <[email protected]> writes:
[...]
Quoted 28 lines
Quoted 20 lines
Quoted 20 lines
qmp.c +12
-0@@ -130,6 +130,20 @@ void qmp_cpu_add(int64_t id, Error **errp) } } +#if defined(_WIN64) || defined(_WIN32) || defined(__FreeBSD__) + +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ +return ; +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +return NULL ; +} +Quoted 8 lines
qmp.c void qmp_cpu_add(int64_t id, Error **errp) · line 149
Quoted 5 lines
qmp.c +2
-0+#endif +#ifndef CONFIG_VNC /* If VNC support is enabled, the "true" query-vnc command is defined in the VNC subsystem */ Why do we need *two* stubs for these functions, one here and one in
fsdev/qemu-fsdev-dummy.c?
Quoted 1 line
At two different platforms the build fails. So, there are needed.
We don't add stubs to random places until the linker succeeds for all the configurations we happen to test. We figure out *how* the linker fails to correct our idea of where a certain stub belongs until we find the one appropriate home for it.
If you can't figure that out, that's okay, just tell us how exactly the linker fails for you, and we'll be happy to help.
Re: [Qemu-devel] [PATCH v10 5/6] fsdev: QMP interface for throttling
Quoted 33 lines · Markus Armbruster
Quoted 2 lines · Pradeep Jagadeesh
Quoted 1 line · Markus Armbruster
Pradeep Jagadeesh <[email protected]> writes:
[...]
Quoted 28 lines
Quoted 28 lines
Quoted 15 lines
qmp.c +7
-0@@ -130,6 +130,20 @@ void qmp_cpu_add(int64_t id, Error **errp) } } +#if defined(_WIN64) || defined(_WIN32) || defined(__FreeBSD__) + +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ +return ; +} +qmp.c void qmp_cpu_add(int64_t id, Error **errp) · line 149
Quoted 10 lines
qmp.c +7
-0+IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +return NULL ; +} + +#endif +#ifndef CONFIG_VNC /* If VNC support is enabled, the "true" query-vnc command is defined in the VNC subsystem */ Why do we need *two* stubs for these functions, one here and one in
fsdev/qemu-fsdev-dummy.c?
Quoted 7 lines
Quoted 1 line
At two different platforms the build fails. So, there are needed.
We don't add stubs to random places until the linker succeeds for all the configurations we happen to test. We figure out *how* the linker fails to correct our idea of where a certain stub belongs until we find the one appropriate home for it.
OK, I will figure it out and send it across. But these were discussed since the v1, now I do not remember on top of my mind. I will have to dig my old emails and send it across or I should reproduce them again.
Quoted 2 lines
If you can't figure that out, that's okay, just tell us how exactly the linker fails for you, and we'll be happy to help.
Thanks for offering help!
-Pradeep
Quoted 1 line
Re: [Qemu-devel] [PATCH v10 5/6] fsdev: QMP interface for throttling
In reply to Markus ArmbrusterQuoted 35 lines · Markus Armbruster
Quoted 2 lines · Pradeep Jagadeesh
Quoted 1 line · Markus Armbruster
Pradeep Jagadeesh <[email protected]> writes:
[...]
Quoted 28 lines
Quoted 20 lines
Quoted 20 lines
qmp.c +12
-0@@ -130,6 +130,20 @@ void qmp_cpu_add(int64_t id, Error **errp) } } +#if defined(_WIN64) || defined(_WIN32) || defined(__FreeBSD__) + +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ +return ; +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +return NULL ; +} +Quoted 8 lines
qmp.c void qmp_cpu_add(int64_t id, Error **errp) · line 149
Quoted 5 lines
qmp.c +2
-0+#endif +#ifndef CONFIG_VNC /* If VNC support is enabled, the "true" query-vnc command is defined in the VNC subsystem */ Why do we need *two* stubs for these functions, one here and one in
fsdev/qemu-fsdev-dummy.c?Quoted 1 line
At two different platforms the build fails. So, there are needed.
Quoted 7 lines
We don't add stubs to random places until the linker succeeds for all the configurations we happen to test. We figure out *how* the linker fails to correct our idea of where a certain stub belongs until we find the one appropriate home for it.
If you can't figure that out, that's okay, just tell us how exactly the linker fails for you, and we'll be happy to help.
If I do not have those stubs in qmp.c.The linking fails when I compile like "make docker-test-mingw@fedora"
The stubs in qemu-fsdev-dummy.c required because when I configure on x86 as --disable-virtfs, then the compilation fails.
So, I need the stubs at both the places. Please let me know if I can avoid some how.
Regards,
Pradeep
PATCH v10 6/6 fsdev: hmp interface for throttling
In reply to Pradeep JagadeeshThis patch introduces hmp interfaces for the fsdev devices.
--- hmp-commands-info.hx | 18 ++++++++++++++++ hmp-commands.hx | 19 +++++++++++++++++ hmp.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hmp.h | 4 ++++ 4 files changed, 101 insertions(+)
hmp-commands-info.hx +18 -0
@@ -84,6 +84,24 @@ STEXI Show block device statistics. ETEXI +#if defined(CONFIG_VIRTFS) + + { + .name = "fsdev_iothrottle", + .args_type = "", + .params = "", + .help = "show fsdev iothrottle information", + .cmd = hmp_info_fsdev_iothrottle, + }, + +#endif + +STEXI +@item info fsdev_iothrottle +@findex fsdev_iothrottle +Show fsdev device throttle info. +ETEXI + { .name = "block-jobs", .args_type = "",
hmp-commands.hx +19 -0
@@ -1680,6 +1680,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 +60 -0
66 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_info_fsdev_iothrottle (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
Re: [Qemu-devel] [PATCH v10 6/6] fsdev: hmp interface for throttling
hmp.c void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) · line 1842
Quoted 11 lines · Pradeep Jagadeesh
hmp.c +11
-0+void hmp_info_fsdev_iothrottle (Monitor *mon,const QDict *qdict) +{ +Error *err =NULL ; +IOThrottleList *fsdev_list, *info; + fsdev_list =qmp_query_fsdev_io_throttle (&err); + +for (info = fsdev_list; info; info = info->next) { +print_fsdev_throttle_config (mon, info->value); + } +qapi_free_IOThrottleList (fsdev_list); +}
You're passing an Error to qmp_query_fsdev_io_throttle() but then you don't handle it. Use hmp_handle_error() as I said in my previous e-mail.
I know that with the current code qmp_query_fsdev_io_throttle() is never going to fail, but that's no reason to declare an Error and then ignore it.
Berto
Re: [Qemu-devel] [PATCH v10 6/6] fsdev: hmp interface for throttling
Quoted 16 lines · Alberto Garcia
hmp.c void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) · line 1842
Quoted 11 lines · Pradeep Jagadeesh
hmp.c +11
-0+void hmp_info_fsdev_iothrottle (Monitor *mon,const QDict *qdict) +{ +Error *err =NULL ; +IOThrottleList *fsdev_list, *info; + fsdev_list =qmp_query_fsdev_io_throttle (&err); + +for (info = fsdev_list; info; info = info->next) { +print_fsdev_throttle_config (mon, info->value); + } +qapi_free_IOThrottleList (fsdev_list); +}You're passing an Error to
qmp_query_fsdev_io_throttle()but then you don't handle it. Usehmp_handle_error()as I said in my previous e-mail.
OK I will handle it.
Quoted 4 lines
I know that with the current code
qmp_query_fsdev_io_throttle()is never going to fail, but that's no reason to declare an Error and then ignore it.
I need to pass err because the function qmp_query_fsdev_io_throttle(Error *) is created by the scripts. So, I have to declare and pass it. I do not is there any way to avoid this.
-Pradeep
Quoted 3 lines
Berto
Re: [Qemu-devel] [PATCH v10 6/6] fsdev: hmp interface for throttling
Quoted 17 lines · On Tue, 5 Sep 2017 10:28:02 +0200 Pradeep Jagadeesh…
Quoted 16 lines · Alberto Garcia
hmp.c void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) · line 1842
Quoted 11 lines · Pradeep Jagadeesh
hmp.c +11
-0+void hmp_info_fsdev_iothrottle (Monitor *mon,const QDict *qdict) +{ +Error *err =NULL ; +IOThrottleList *fsdev_list, *info; + fsdev_list =qmp_query_fsdev_io_throttle (&err); + +for (info = fsdev_list; info; info = info->next) { +print_fsdev_throttle_config (mon, info->value); + } +qapi_free_IOThrottleList (fsdev_list); +}You're passing an Error to
qmp_query_fsdev_io_throttle()but then you don't handle it. Usehmp_handle_error()as I said in my previous e-mail.
Quoted 7 lines
OK I will handle it.
Quoted 4 lines
I know that with the current code
qmp_query_fsdev_io_throttle()is never going to fail, but that's no reason to declare an Error and then ignore it.I need to pass err because the function
qmp_query_fsdev_io_throttle(Error *)is created by the scripts. So, I
It isn't created by the scripts, it is introduced by patch 5 of this series. But yes, the generated code expects this function to have an Error ** (not Error *) argument.
Quoted 2 lines
have to declare and pass it. I do not is there any way to avoid this.
If you don't care for errors (because you know that the function can't fail), then you just need to pass NULL. But as Berto is saying, if you do pass an non-null Error ** then you should handle it.
Cheers,
--
Greg
Quoted 5 lines
-Pradeep
Quoted 3 lines
Berto
Re: [Qemu-devel] [PATCH v10 6/6] fsdev: hmp interface for throttling
In reply to Pradeep JagadeeshQuoted 16 lines · Pradeep Jagadeesh
Quoted 6 lines
Quoted 6 lines
hmp.c +6
-0+void hmp_info_fsdev_iothrottle (Monitor *mon,const QDict *qdict) +{ +Error *err =NULL ; +IOThrottleList *fsdev_list, *info; + fsdev_list =qmp_query_fsdev_io_throttle (&err); +Quoted 8 lines
hmp.c void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) · line 1842
Quoted 5 lines
hmp.c +5
-0+for (info = fsdev_list; info; info = info->next) { +print_fsdev_throttle_config (mon, info->value); + } +qapi_free_IOThrottleList (fsdev_list); +}You're passing an Error to
qmp_query_fsdev_io_throttle()but then you don't handle it. Usehmp_handle_error()as I said in my previous e-mail.OK I will handle it.
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
I know that with the current code
qmp_query_fsdev_io_throttle()is never going to fail, but that's no reason to declare an Error and then ignore it.I need to pass err because the function
qmp_query_fsdev_io_throttle(Error *)is created by the scripts. So, I have to declare and pass it. I do not is there any way to avoid this.
When a function takes an Error ** like qmp_query_fsdev_io_throttle() and many others do, there are two alternatives:
a) Declare an Error, pass it _and then handle it_ (if you don't handle it, you're leaking it):
Error *err = NULL;
some_function(&err);
if (err) {
/* handle err */
}b) Don't declare the Error and pass NULL instead:
some_function(NULL);
Note that (b) is perfectly valid, but if the function you're calling tries to set an Error then you won't get it. It's ok if you know what you're doing (which usually means: you have other way to determine if the function failed, _or_ you don't care if the function failed).
Here you have no other way to know if qmp_query_fsdev_io_throttle() fails, so you should choose (a).
I know that at the moment qmp_query_fsdev_io_throttle() can never fail so in practice this doesn't matter much _now_, but if in the future that function can fail then your code should be ready to handle it.
Berto
Re: [Qemu-devel] [PATCH v10 6/6] fsdev: hmp interface for throttling
Quoted 46 lines · Alberto Garcia
Quoted 16 lines · Pradeep Jagadeesh
Quoted 6 lines
Quoted 6 lines
hmp.c +6
-0+void hmp_info_fsdev_iothrottle (Monitor *mon,const QDict *qdict) +{ +Error *err =NULL ; +IOThrottleList *fsdev_list, *info; + fsdev_list =qmp_query_fsdev_io_throttle (&err); +Quoted 8 lines
hmp.c void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) · line 1842
Quoted 5 lines
hmp.c +5
-0+for (info = fsdev_list; info; info = info->next) { +print_fsdev_throttle_config (mon, info->value); + } +qapi_free_IOThrottleList (fsdev_list); +}You're passing an Error to
qmp_query_fsdev_io_throttle()but then you don't handle it. Usehmp_handle_error()as I said in my previous e-mail.OK I will handle it.
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
I know that with the current code
qmp_query_fsdev_io_throttle()is never going to fail, but that's no reason to declare an Error and then ignore it.I need to pass err because the function
qmp_query_fsdev_io_throttle(Error *)is created by the scripts. So, I have to declare and pass it. I do not is there any way to avoid this.When a function takes an Error ** like
qmp_query_fsdev_io_throttle()and many others do, there are two alternatives:a) Declare an Error, pass it
_andthen handleit_(if you don't handle it, you're leaking it):Error *err = NULL; some_function(&err); if (err) { /* handle err */ }b) Don't declare the Error and pass NULL instead:
some_function(NULL);Note that (b) is perfectly valid, but if the function you're calling tries to set an Error then you won't get it. It's ok if you know what you're doing (which usually means: you have other way to determine if the function failed, _or_ you don't care if the function failed).
Quoted 6 lines
Here you have no other way to know if
qmp_query_fsdev_io_throttle()fails, so you should choose (a).I know that at the moment
qmp_query_fsdev_io_throttle()can never fail so in practice this doesn't matter much _now_, but if in the future that function can fail then your code should be ready to handle it.
OK, I will pass NULL.
-Pradeep
Quoted 3 lines
Berto
Re: [Qemu-devel] [PATCH v10 6/6] fsdev: hmp interface for throttling
Quoted 7 lines · Pradeep Jagadeesh
Quoted 6 lines
a) Declare an Error, pass it
_andthen handleit_(if you don't handle it, you're leaking it):Here you have no other way to know if
qmp_query_fsdev_io_throttle()fails, so you should choose (a).OK, I will pass NULL.
:-)
(it's ok I guess, I don't see how that function can ever be made to fail in the future)
Berto
Re: [Qemu-devel] [PATCH v10 6/6] fsdev: hmp interface for throttling
Quoted 7 lines · Alberto Garcia
Quoted 6 lines · Pradeep Jagadeesh
Quoted 6 lines
a) Declare an Error, pass it
_andthen handleit_(if you don't handle it, you're leaking it):Here you have no other way to know if
qmp_query_fsdev_io_throttle()fails, so you should choose (a).
Quoted 6 lines
Quoted 1 line
OK, I will pass NULL.
:-)
(it's ok I guess, I don't see how that function can ever be made to fail in the future)
:) Agreed.
-Pradeep
Quoted 3 lines
Berto
Re: [Qemu-devel] [PATCH v10 6/6] fsdev: hmp interface for throttling
In reply to Pradeep JagadeeshQuoted 55 lines · * Pradeep Jagadeesh ([email protected]) wrote:
This patch introduces hmp interfaces for the fsdev devices.
Signed-off-by Pradeep Jagadeesh <[email protected]>--- hmp-commands-info.hx | 18 ++++++++++++++++ hmp-commands.hx | 19 +++++++++++++++++ hmp.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hmp.h | 4 ++++ 4 files changed, 101 insertions(+)hmp-commands-info.hx +18
-0@@ -84,6 +84,24 @@ STEXI Show block device statistics. ETEXI +#if defined(CONFIG_VIRTFS) + + { + .name = "fsdev_iothrottle", + .args_type = "", + .params = "", + .help = "show fsdev iothrottle information", + .cmd = hmp_info_fsdev_iothrottle, + }, + +#endif + +STEXI +@item info fsdev_iothrottle +@findex fsdev_iothrottle +Show fsdev device throttle info. +ETEXI + { .name = "block-jobs", .args_type = "",hmp-commands.hx +7
-0@@ -1680,6 +1680,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",
hmp-commands.hx STEXI · line 1699
Quoted 10 lines
hmp-commands.hx +10
-0+ .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
I'm OK with this, and I see it's a copy of the equivalent block_set_io_throttle, but can you clarify the meaning - for example if a value is 0 what does it mean? Does it mean there's no throttle set for that variable?
Also is the 'bps' bytes/second (as opposed to bits or blocks). Clarifying both of these in the text would be good.
Dave
Quoted 94 lines
hmp-commands.hx +2
-0+ + { .name = "set_password", .args_type = "protocol:s,password:s,connected:s?",hmp.c +60
-0@@ -1783,6 +1783,66 @@ void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +#ifdef CONFIG_VIRTFS + +void hmp_fsdev_set_io_throttle (Monitor *mon,const QDict *qdict) +{ +Error *err =NULL ; +IOThrottle throttle = { + .has_id = true, + .id = (char *)qdict_get_str (qdict,"device" ), + }; + +hmp_initialize_io_throttle (&throttle, qdict); +qmp_fsdev_set_io_throttle (&throttle, &err); +hmp_handle_error (mon, &err); +} + +static void print_fsdev_throttle_config (Monitor *mon,IOThrottle *fscfg) +{ +monitor_printf (mon,"%s" , fscfg->id); +monitor_printf (mon," I/O throttling:" +" bps=%" PRId64 +" bps_rd=%" PRId64" bps_wr=%" PRId64 +" bps_max=%" PRId64 +" bps_rd_max=%" PRId64 +" bps_wr_max=%" PRId64 +" iops=%" PRId64" iops_rd=%" PRId64 +" iops_wr=%" PRId64 +" iops_max=%" PRId64 +" iops_rd_max=%" PRId64 +" iops_wr_max=%" PRId64 +" iops_size=%" PRId64 +"\n" , + fscfg->bps, + fscfg->bps_rd, + fscfg->bps_wr, + fscfg->bps_max, + fscfg->bps_rd_max, + fscfg->bps_wr_max, + fscfg->iops, + fscfg->iops_rd, + fscfg->iops_wr, + fscfg->iops_max, + fscfg->iops_rd_max, + fscfg->iops_wr_max, + fscfg->iops_size); +} + +void hmp_info_fsdev_iothrottle (Monitor *mon,const QDict *qdict) +{ +Error *err =NULL ; +IOThrottleList *fsdev_list, *info; + fsdev_list =qmp_query_fsdev_io_throttle (&err); + +for (info = fsdev_list; info; info = info->next) { +print_fsdev_throttle_config (mon, info->value); + } +qapi_free_IOThrottleList (fsdev_list); +} + +#endif +void hmp_block_stream (Monitor *mon,const QDict *qdict) {Error *error =NULL ;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_info_fsdev_iothrottle (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
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 6 lines · Pradeep Jagadeesh
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.
Quoted 7 lines
Pradeep Jagadeesh (6):
throttle: factor out duplicate code
qmp: Create IOThrottle structure
throttle: move out function to reuse the code
hmp: create a throttle initialization function for code reusability
fsdev: QMP interface for throttling
fsdev: hmp interface for throttling
I know you're already up to v10, but your code changes conflict with Manos throttling work, which has now landed on Kevin's branch:
https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg01051.html
T: git git://repo.or.cz/qemu/kevin.git block
How hard is it for you to post a rebased v11 on top of Manos' work?
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 15 lines · Eric Blake
Quoted 6 lines · Pradeep Jagadeesh
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.
Quoted 7 lines
Pradeep Jagadeesh (6):
throttle: factor out duplicate code
qmp: Create IOThrottle structure
throttle: move out function to reuse the code
hmp: create a throttle initialization function for code reusability
fsdev: QMP interface for throttling
fsdev: hmp interface for throttling
Quoted 9 lines
I know you're already up to v10, but your code changes conflict with Manos throttling work, which has now landed on Kevin's branch:
https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg01051.html
T: git
git://repo.or.cz/qemu/kevin.gitblockHow hard is it for you to post a rebased v11 on top of Manos' work?
Hmm, I will try. No idea, how long its gonna take.
-Pradeep