fsdev: qmp interface for io throttling
v6 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: hmp interface for throttling
fsdev: QMP interface for throttling
Makefile | 4 ++ blockdev.c | 97 ++------------------------------- fsdev/qemu-fsdev-dummy.c | 10 ++++ fsdev/qemu-fsdev-throttle.c | 118 ++++++++++++++++++++++++++-------------- fsdev/qemu-fsdev-throttle.h | 13 +++++ fsdev/qemu-fsdev.c | 37 +++++++++++++ hmp-commands-info.hx | 18 ++++++ hmp-commands.hx | 19 +++++++ hmp.c | 87 +++++++++++++++++++++++++++-- hmp.h | 4 ++ include/qemu/throttle-options.h | 6 ++ include/qemu/throttle.h | 4 +- include/qemu/typedefs.h | 1 + monitor.c | 5 ++ qapi-schema.json | 3 + qapi/block-core.json | 76 +------------------------- qapi/fsdev.json | 84 ++++++++++++++++++++++++++++ qapi/iothrottle.json | 88 ++++++++++++++++++++++++++++++ qmp.c | 14 +++++ util/throttle.c | 110 +++++++++++++++++++++++++++++++++++++ 20 files changed, 582 insertions(+), 216 deletions(-) create mode 100644 qapi/fsdev.json create mode 100644 qapi/iothrottle.json
v0 -> v1:
Addressed comments from Eric Blake, Greg Kurz and Daniel P.Berrange Mainly renaming the functions and removing the redundant code.
v1 -> v2:
Addressed comments from Eric Blake and Greg Kurz.
As per the suggestion I split the patches into smaller patches. Removed some more duplicate code.
v2 -> v3:
Addresssed comments from Alberto Garcia.
Changed the comment from block to iothrottle in the iothrottle.json Added the dummy functions in qemu-fsdev-dummy.c to address the compilation issues that were observed.
v3 -> v4:
Addressed comments from Eric Blake and Greg Kurz
Re-ordered the patches
Added the dummy functions in qmp.c to address the cross compilation issues
v4 -> v5:
Addressed comments from Eric Blake and Greg Kurz
Split the fsdev qmp patch into hmp and qmp related patches Moved the common functionalities to throttle.c instead of creating a new file
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
Signature · 1 line
1.8.3.1
PATCH v6 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 | 2 ++ include/qemu/throttle.h | 4 ++-- include/qemu/typedefs.h | 1 + util/throttle.c | 51 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 59 insertions(+), 87 deletions(-)
blockdev.c +1 -43
@@ -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 ; }
fsdev/qemu-fsdev-throttle.c +2 -42
56 lines not on this page · raw message
include/qemu/throttle-options.h +2 -0
@@ -89,4 +89,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
@@ -97,6 +97,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
PATCH v6 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 | 76 ++------------------------------------------- qapi/iothrottle.json | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 73 deletions(-) create mode 100644 qapi/iothrottle.json
qapi/block-core.json +3 -73
@@ -6,6 +6,7 @@ # QAPI common definitions { 'include': 'common.json' } +{ 'include': 'iothrottle.json' } ## # @SnapshotInfo:
@@ -1761,84 +1762,13 @@ # # @device: Block device name (deprecated, use @id instead) # -# @id: The name or QOM path of the guest device (since: 2.8) -# -# @bps: total throughput limit in bytes per second -# -# @bps_rd: read throughput limit in bytes per second -# -# @bps_wr: write throughput limit in bytes per second -# -# @iops: total I/O operations per second -# -# @iops_rd: read I/O operations per second -# -# @iops_wr: write I/O operations per second -# -# @bps_max: total throughput limit during bursts, -# in bytes (Since 1.7) -# -# @bps_rd_max: read throughput limit during bursts, -# in bytes (Since 1.7) -# -# @bps_wr_max: write throughput limit during bursts, -# in bytes (Since 1.7) -# -# @iops_max: total I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @iops_rd_max: read I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @iops_wr_max: write I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @bps_max_length: maximum length of the @bps_max burst -# period, in seconds. It must only -# be set if @bps_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @bps_rd_max_length: maximum length of the @bps_rd_max -# burst period, in seconds. It must only -# be set if @bps_rd_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @bps_wr_max_length: maximum length of the @bps_wr_max -# burst period, in seconds. It must only -# be set if @bps_wr_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_max_length: maximum length of the @iops burst -# period, in seconds. It must only -# be set if @iops_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_rd_max_length: maximum length of the @iops_rd_max -# burst period, in seconds. It must only -# be set if @iops_rd_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_wr_max_length: maximum length of the @iops_wr_max -# burst period, in seconds. It must only -# be set if @iops_wr_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_size: an I/O size in bytes (Since 1.7) -# # @group: throttle group name (Since 2.4) # # Since: 1.1 ## { 'struct': 'BlockIOThrottle', - 'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int', - 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', - '*bps_max': 'int', '*bps_rd_max': 'int', - '*bps_wr_max': 'int', '*iops_max': 'int', - '*iops_rd_max': 'int', '*iops_wr_max': 'int', - '*bps_max_length': 'int', '*bps_rd_max_length': 'int', - '*bps_wr_max_length': 'int', '*iops_max_length': 'int', - '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int', - '*iops_size': 'int', '*group': 'str' } } + 'base': 'IOThrottle', + 'data': { '*device': 'str', '*group': 'str' } } ## # @block-stream:
qapi/iothrottle.json new file +88 -0
88 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v6 2/6] qmp: Create IOThrottle structure
Quoted 8 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.Signed-off-by Pradeep Jagadeesh <[email protected]>Reviewed-by Greg Kurz <[email protected]>Reviewed-by Eric Blake <[email protected]>
Berto
PATCH v6 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 | 4 +++ util/throttle.c | 59 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 50 deletions(-)
blockdev.c +3 -50
@@ -2579,6 +2579,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,
@@ -2596,56 +2597,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 +4 -0
@@ -10,6 +10,8 @@#ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H +#include "qmp-commands.h" +#define THROTTLE_OPTS \ { \ .name = "throttling.iops-total",\
@@ -91,4 +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 3/6] throttle: move out function to reuse the code
Quoted 9 lines · 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.Signed-off-by Pradeep Jagadeesh <[email protected]>index 659a410..ac4f221 100644
include/qemu/throttle-options.h line 14
Quoted 5 lines
include/qemu/throttle-options.h +2
-0@@ -10,6 +10,8 @@#ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H +#include "qmp-commands.h" +
Shouldn't this be qapi-types.h instead ?
Otherwise the patch looks fine.
Berto
PATCH v6 4/6 hmp: create a throttle initialization function
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 | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
hmp.c +15 -6
@@ -1749,20 +1749,29 @@ void hmp_change(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +static void hmp_initialize_io_throttle (IOThrottle *iot,const QDict *qdict) +{ + iot->has_id = true; + iot->id = (char *)qdict_get_str (qdict,"id" ); + iot->bps =qdict_get_int (qdict,"bps" ); + iot->bps_rd =qdict_get_int (qdict,"bps_rd" ); + iot->bps_wr =qdict_get_int (qdict,"bps_wr" ); + iot->iops =qdict_get_int (qdict,"iops" ); + iot->iops_rd =qdict_get_int (qdict,"iops_rd" ); + iot->iops_wr =qdict_get_int (qdict,"iops_wr" ); +} +void hmp_block_set_io_throttle (Monitor *mon,const QDict *qdict) {Error *err =NULL ; +IOThrottle *iothrottle;BlockIOThrottle throttle = { .has_device = true, .device = (char *)qdict_get_str (qdict,"device" ), - .bps =qdict_get_int (qdict,"bps" ), - .bps_rd =qdict_get_int (qdict,"bps_rd" ), - .bps_wr =qdict_get_int (qdict,"bps_wr" ), - .iops =qdict_get_int (qdict,"iops" ), - .iops_rd =qdict_get_int (qdict,"iops_rd" ), - .iops_wr =qdict_get_int (qdict,"iops_wr" ), }; + iothrottle =qapi_BlockIOThrottle_base (&throttle); +hmp_initialize_io_throttle (iothrottle, qdict);qmp_block_set_io_throttle (&throttle, &err);hmp_handle_error (mon, &err); }
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v6 4/6] hmp: create a throttle initialization function
Quoted 4 lines · * Pradeep Jagadeesh ([email protected]) wrote:
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]>
Quoted 47 lines
--- hmp.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)hmp.c +15
-6@@ -1749,20 +1749,29 @@ void hmp_change(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +static void hmp_initialize_io_throttle (IOThrottle *iot,const QDict *qdict) +{ + iot->has_id = true; + iot->id = (char *)qdict_get_str (qdict,"id" ); + iot->bps =qdict_get_int (qdict,"bps" ); + iot->bps_rd =qdict_get_int (qdict,"bps_rd" ); + iot->bps_wr =qdict_get_int (qdict,"bps_wr" ); + iot->iops =qdict_get_int (qdict,"iops" ); + iot->iops_rd =qdict_get_int (qdict,"iops_rd" ); + iot->iops_wr =qdict_get_int (qdict,"iops_wr" ); +} +void hmp_block_set_io_throttle (Monitor *mon,const QDict *qdict) {Error *err =NULL ; +IOThrottle *iothrottle;BlockIOThrottle throttle = { .has_device = true, .device = (char *)qdict_get_str (qdict,"device" ), - .bps =qdict_get_int (qdict,"bps" ), - .bps_rd =qdict_get_int (qdict,"bps_rd" ), - .bps_wr =qdict_get_int (qdict,"bps_wr" ), - .iops =qdict_get_int (qdict,"iops" ), - .iops_rd =qdict_get_int (qdict,"iops_rd" ), - .iops_wr =qdict_get_int (qdict,"iops_wr" ), }; + iothrottle =qapi_BlockIOThrottle_base (&throttle); +hmp_initialize_io_throttle (iothrottle, qdict);qmp_block_set_io_throttle (&throttle, &err);hmp_handle_error (mon, &err); }Signature · 1 line
1.8.3.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH v6 5/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 | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hmp.h | 4 ++++ 4 files changed, 107 insertions(+)
hmp-commands-info.hx +18 -0
@@ -84,6 +84,24 @@ STEXI Show block device statistics. ETEXI +#if defined(CONFIG_VIRTFS) + + { + .name = "query-fsdev-iothrottle", + .args_type = "", + .params = "", + .help = "show fsdev device throttle information", + .cmd = hmp_fsdev_get_io_throttle, + }, + +#endif + +STEXI +@item info fsdev throttle +@findex fsdevthrottleinfo +Show fsdev device throttleinfo. +ETEXI + { .name = "block-jobs", .args_type = "",
hmp-commands.hx +19 -0
@@ -1662,6 +1662,25 @@ STEXI Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} ETEXI +#if defined(CONFIG_VIRTFS) + + { + .name = "fsdev-set-io-throttle", + .args_type = "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l,iops_wr:l", + .params = "device bps bps_rd bps_wr iops iops_rd iops_wr", + .help = "change I/O throttle limits for a fs devices", + .cmd = hmp_fsdev_set_io_throttle, + }, + +#endif + +STEXI +@item fsdev_set_io_throttle @var{device} @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} +@findex fsdev_set_io_throttle +Change I/O throttle limits for a fs devices to @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} +ETEXI + + { .name = "set_password", .args_type = "protocol:s,password:s,connected:s?",
hmp.c +66 -0
72 lines not on this page · raw message
hmp.h +4 -0
@@ -81,6 +81,10 @@ void hmp_set_password(Monitor *mon, const QDict *qdict);void hmp_expire_password (Monitor *mon,const QDict *qdict);void hmp_eject (Monitor *mon,const QDict *qdict);void hmp_change (Monitor *mon,const QDict *qdict); +#ifdef CONFIG_VIRTFS +void hmp_fsdev_set_io_throttle (Monitor *mon,const QDict *qdict); +void hmp_fsdev_get_io_throttle (Monitor *mon,const QDict *qdict); +#endif void hmp_block_set_io_throttle (Monitor *mon,const QDict *qdict);void hmp_block_stream (Monitor *mon,const QDict *qdict);void hmp_block_job_set_speed (Monitor *mon,const QDict *qdict);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v6 5/6] fsdev: hmp interface for throttling
Quoted 16 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 | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hmp.h | 4 ++++ 4 files changed, 107 insertions(+)hmp-commands-info.hx +0
-0
hmp-commands-info.hx STEXI · line 90
Quoted 7 lines
hmp-commands-info.hx +4
-0@@ -84,6 +84,24 @@ STEXI Show block device statistics. ETEXI +#if defined(CONFIG_VIRTFS) + + { + .name = "query-fsdev-iothrottle",
This will end up as:
info query-fsdev-iothrottle
so the query- is unneeded since it's already info.
hmp-commands-info.hx STEXI · line 100
Quoted 10 lines
hmp-commands-info.hx +10
-0+ .args_type = "", + .params = "", + .help = "show fsdev device throttle information", + .cmd = hmp_fsdev_get_io_throttle, + }, + +#endif + +STEXI +@item info fsdev throttle
I think that's supposed to match the .name - i.e.
@item info query-fsdev-iothrottle
(or whatever it will become)
hmp-commands-info.hx STEXI · line 101
Quoted 1 line
hmp-commands-info.hx +1
-0+@findex fsdevthrottleinfo
again I think that's supposed to match the .name - see the other entries in that file.
hmp-commands-info.hx STEXI · line 102
Quoted 1 line
hmp-commands-info.hx +1
-0+Show fsdev device throttleinfo.
And we may as well make that text match the .help text.
Quoted 18 lines
hmp-commands-info.hx +2
-0+ETEXI + { .name = "block-jobs", .args_type = "",hmp-commands.hx +5
-0@@ -1662,6 +1662,25 @@ STEXI Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} ETEXI +#if defined(CONFIG_VIRTFS) + + { + .name = "fsdev-set-io-throttle", + .args_type = "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l,iops_wr:l",
hmp-commands.hx STEXI · line 1679
Quoted 10 lines
hmp-commands.hx +10
-0+ .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
Again I think the @item and @findex have to match the .name - so I think make the .name use _'s rather than -'s for HMP.
Quoted 51 lines
hmp-commands.hx +4
-0+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 +36
-0@@ -1776,6 +1776,72 @@ 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; + +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, +Error *err) +{ +if (fscfg->bps || fscfg->bps_rd || fscfg->bps_wr || + fscfg->iops || fscfg->iops_rd || fscfg->iops_wr) + { +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, + fscfg->bps, + fscfg->bps_rd, + fscfg->bps_wr, + fscfg->bps_max, + fscfg->bps_rd_max,
hmp.c void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) · line 1824
Quoted 10 lines
hmp.c +10
-0+ 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); + } +hmp_handle_error (mon, &err);
You've not got anything that can generate an error here have you?
hmp.c void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) · line 1837
Quoted 13 lines
hmp.c +13
-0+} + +void hmp_fsdev_get_io_throttle (Monitor *mon,const QDict *qdict) +{ +Error *err =NULL ; +IOThrottleList *fs9p_list, *info; + fs9p_list =qmp_query_fsdev_io_throttle (&err); + +for (info = fs9p_list; info; info = info->next) { +if (info != fs9p_list) { +monitor_printf (mon,"\n" ); + } +print_fsdev_throttle_config (mon, info->value, err);
Since print_fsdev_throttle_config has an if() around it's print, doesn't that mean you can end up with a few extra \n's ?
Quoted 28 lines
hmp.c +7
-0+ qapi_free_IOThrottle(info->value); + } +qapi_free_IOThrottleList (fs9p_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_fsdev_get_io_throttle (Monitor *mon,const QDict *qdict); +#endif void hmp_block_set_io_throttle (Monitor *mon,const QDict *qdict);void hmp_block_stream (Monitor *mon,const QDict *qdict);void hmp_block_job_set_speed (Monitor *mon,const QDict *qdict);Signature · 1 line
1.8.3.1
Dave
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH v6 5/6] fsdev: hmp interface for throttling
Quoted 20 lines · Dr. David Alan Gilbert
Quoted 19 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 | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hmp.h | 4 ++++ 4 files changed, 107 insertions(+)hmp-commands-info.hx +0
-0@@ -84,6 +84,24 @@ STEXI Show block device statistics. ETEXI
Quoted 8 lines
hmp-commands-info.hx STEXI · line 90
Quoted 4 lines
hmp-commands-info.hx +4
-0+#if defined(CONFIG_VIRTFS) + + { + .name = "query-fsdev-iothrottle",This will end up as:
info query-fsdev-iothrottle
OK, I fix it as "fsdev_iothrottle"
Quoted 16 lines
so the query- is unneeded since it's already info.
hmp-commands-info.hx STEXI · line 100
Quoted 10 lines
hmp-commands-info.hx +10
-0+ .args_type = "", + .params = "", + .help = "show fsdev device throttle information", + .cmd = hmp_fsdev_get_io_throttle, + }, + +#endif + +STEXI +@item info fsdev throttleI think that's supposed to match the .name - i.e.
@item info query-fsdev-iothrottle
Quoted 1 line
(or whatever it will become)
OK
Quoted 5 lines
hmp-commands-info.hx STEXI · line 101
Quoted 2 lines
hmp-commands-info.hx +1
-0+@findex fsdevthrottleinfoagain I think that's supposed to match the .name - see the other entries in that file.
OK
Quoted 5 lines
hmp-commands-info.hx STEXI · line 102
Quoted 2 lines
hmp-commands-info.hx +1
-0+Show fsdev device throttleinfo.And we may as well make that text match the .help text.
OK
Quoted 23 lines
Quoted 23 lines
hmp-commands-info.hx +2
-0+ETEXI + { .name = "block-jobs", .args_type = "",hmp-commands.hx +10
-0@@ -1662,6 +1662,25 @@ STEXI Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} ETEXI +#if defined(CONFIG_VIRTFS) + + { + .name = "fsdev-set-io-throttle", + .args_type = "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l,iops_wr:l", + .params = "device bps bps_rd bps_wr iops iops_rd iops_wr", + .help = "change I/O throttle limits for a fs devices", + .cmd = hmp_fsdev_set_io_throttle, + }, +
Quoted 8 lines
hmp-commands.hx STEXI · line 1679
Quoted 5 lines
hmp-commands.hx +5
-0+#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_throttleAgain I think the @item and @findex have to match the .name - so I think make the .name use _'s rather than -'s for HMP.
OK
Quoted 56 lines
Quoted 56 lines
hmp-commands.hx +4
-0+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 +40
-0@@ -1776,6 +1776,72 @@ 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; + +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, +Error *err) +{ +if (fscfg->bps || fscfg->bps_rd || fscfg->bps_wr || + fscfg->iops || fscfg->iops_rd || fscfg->iops_wr) + { +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, + 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,
Quoted 8 lines
hmp.c void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) · line 1824
Quoted 6 lines
hmp.c +6
-0+ fscfg->iops_max, + fscfg->iops_rd_max, + fscfg->iops_wr_max, + fscfg->iops_size); + } +hmp_handle_error (mon, &err);You've not got anything that can generate an error here have you?
No, I think I can avoid the hmp_handle_error() and also passing of err variable to this function.
Quoted 17 lines
Quoted 4 lines
hmp.c +3
-0+} + +void hmp_fsdev_get_io_throttle (Monitor *mon,const QDict *qdict)hmp.c void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) · line 1837
Quoted 10 lines
hmp.c +10
-0+{ +Error *err =NULL ; +IOThrottleList *fs9p_list, *info; + fs9p_list =qmp_query_fsdev_io_throttle (&err); + +for (info = fs9p_list; info; info = info->next) { +if (info != fs9p_list) { +monitor_printf (mon,"\n" ); + } +print_fsdev_throttle_config (mon, info->value, err);Since
print_fsdev_throttle_confighas anif()around it's print, doesn't that mean you can end up with a few extra \n's ?
You are right, I removed \n and added it in print_fsdev_throttle_config.
-Pradeep
Quoted 35 lines
Quoted 27 lines
hmp.c +7
-0+ qapi_free_IOThrottle(info->value); + } +qapi_free_IOThrottleList (fs9p_list); +} + +#endif +void hmp_block_stream (Monitor *mon,const QDict *qdict) {Error *error =NULL ;hmp.h +4
-1@@ -81,6 +81,10 @@ void hmp_set_password(Monitor *mon, const QDict *qdict);void hmp_expire_password (Monitor *mon,const QDict *qdict);void hmp_eject (Monitor *mon,const QDict *qdict);void hmp_change (Monitor *mon,const QDict *qdict); +#ifdef CONFIG_VIRTFS +void hmp_fsdev_set_io_throttle (Monitor *mon,const QDict *qdict); +void hmp_fsdev_get_io_throttle (Monitor *mon,const QDict *qdict); +#endif void hmp_block_set_io_throttle (Monitor *mon,const QDict *qdict);void hmp_block_stream (Monitor *mon,const QDict *qdict);void hmp_block_job_set_speed (Monitor *mon,const QDict *qdict); --Quoted 2 lines
1.8.3.1
Dave
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH v6 6/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 | 10 ++++++ fsdev/qemu-fsdev-throttle.c | 76 +++++++++++++++++++++++++++++++++++++++- fsdev/qemu-fsdev-throttle.h | 13 +++++++ fsdev/qemu-fsdev.c | 37 ++++++++++++++++++++ monitor.c | 5 +++ qapi-schema.json | 3 ++ qapi/fsdev.json | 84 +++++++++++++++++++++++++++++++++++++++++++++ qmp.c | 14 ++++++++ 9 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 qapi/fsdev.json
Makefile +4 -0
@@ -416,6 +416,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 +10 -0
@@ -19,3 +19,13 @@ int qemu_fsdev_add(QemuOpts *opts) {return 0 ; } + +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ +return ; +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +abort (); +}
fsdev/qemu-fsdev-throttle.c +75 -1
88 lines not on this page · raw message
fsdev/qemu-fsdev-throttle.h +13 -0
@@ -20,6 +20,13 @@#include "qemu/coroutine.h" #include "qapi/error.h" #include "qemu/throttle.h" +#include "qemu/throttle-options.h" +#include "qapi/qmp/qerror.h" +#include "qapi/qmp/types.h" +#include "qapi-visit.h" +#include "qapi/qobject-output-visitor.h" +#include "qapi/util.h" +#include "qmp-commands.h" typedef struct FsThrottle { ThrottleState ts;
@@ -36,4 +43,10 @@ void coroutine_fn fsdev_co_throttle_request(FsThrottle *, bool , struct iovec *, int);void fsdev_throttle_cleanup (FsThrottle *); + +void fsdev_set_io_throttle (IOThrottle *,FsThrottle *,Error **errp); + +void fsdev_get_io_throttle (FsThrottle *,IOThrottle **iothp, +char *,Error **errp); +#endif /* _FSDEV_THROTTLE_H */
fsdev/qemu-fsdev.c +37 -0
@@ -16,6 +16,7 @@#include "qemu-common.h" #include "qemu/config-file.h" #include "qemu/error-report.h" +#include "qmp-commands.h" static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries =QTAILQ_HEAD_INITIALIZER (fsdriver_entries);
@@ -98,3 +99,39 @@ FsDriverEntry *get_fsdev_fsentry(char *id) }return NULL ; } + +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ + +FsDriverEntry *fse; + + fse =get_fsdev_fsentry (arg->has_id ? arg->id :NULL ); +if (!fse) { +return ; + } + +fsdev_set_io_throttle (arg, &fse->fst, errp); +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +IOThrottleList *head =NULL , **p_next = &head; +struct FsDriverListEntry *fsle; +Error *local_err =NULL ; + + QTAILQ_FOREACH(fsle, &fsdriver_entries, next) { +IOThrottleList *fscfg =g_malloc0 (sizeof (*fscfg)); +fsdev_get_io_throttle (&fsle->fse.fst, &fscfg->value, + fsle->fse.fsdev_id, &local_err); +if (local_err) { +error_propagate (errp, local_err); +g_free (fscfg); +qapi_free_IOThrottleList (head); +return NULL ; + } + + *p_next = fscfg; + p_next = &fscfg->next; + } +return head; +}
monitor.c +5 -0
@@ -997,6 +997,11 @@ static void qmp_unregister_commands_hack(void) && !defined(TARGET_S390X)qmp_unregister_command (&qmp_commands,"query-cpu-definitions" );#endif +#ifndef CONFIG_VIRTFS +qmp_unregister_command (&qmp_commands,"fsdev-set-io-throttle" ); +qmp_unregister_command (&qmp_commands,"query-fsdev-io-throttle" ); +#endif + }void monitor_init_qmp_commands (void )
qapi-schema.json +3 -0
@@ -81,6 +81,9 @@ # QAPI block definitions { 'include': 'qapi/block.json' } +# QAPI fsdev definitions +{ 'include': 'qapi/fsdev.json' } + # QAPI event definitions { 'include': 'qapi/event.json' }
qapi/fsdev.json new file +84 -0
84 lines not on this page · raw message
qmp.c +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) +{ +abort (); +} + +#endif +#ifndef CONFIG_VNC /* If VNC support is enabled, the "true" query-vnc command is defined in the VNC subsystem */
Signature · 1 line
1.8.3.1