fsdev: QMP interface for throttling
PATCH 1/2 fsdev: QMP interface for throttling
This patchset enables qmp interfaces for the 9pfs devices (fsdev). This provides two interfaces one for querying all the 9pfs devices info. The second one to set the IO limits for the required 9pfs device.
--- Makefile | 5 ++- fsdev/qemu-fsdev-throttle.c | 96 +++++++++++++++++++++++++++++++++++++++++++++ fsdev/qemu-fsdev-throttle.h | 11 ++++++ fsdev/qemu-fsdev.c | 38 +++++++++++++++++- fsdev/qemu-fsdev.h | 2 +- hmp-commands-info.hx | 18 +++++++++ hmp-commands.hx | 18 +++++++++ hmp.c | 74 ++++++++++++++++++++++++++++++++++ hmp.h | 5 +++ qapi-schema.json | 6 +++ qapi/fsdev.json | 87 ++++++++++++++++++++++++++++++++++++++++ qapi/iothrottle.json | 93 +++++++++++++++++++++++++++++++++++++++++++ qmp.c | 14 +++++++ 13 files changed, 464 insertions(+), 3 deletions(-) create mode 100644 qapi/fsdev.json create mode 100644 qapi/iothrottle.json
v0 -> v1:
Addressed the comments by Erik Blake, Greg Kurz and Daniel P.Berrange Mainly renaming the functions and removing the redundant code
Makefile +4 -1
@@ -413,7 +413,10 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \ $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.json \ $(SRC_PATH)/qapi/crypto.json $(SRC_PATH)/qapi/rocker.json \ - $(SRC_PATH)/qapi/trace.json + $(SRC_PATH)/qapi/trace.json $(SRC_PATH)/qapi/iothrottle.json +ifdef CONFIG_VIRTFS +qapi-modules += $(SRC_PATH)/qapi/fsdev.json +endif qapi-types.c qapi-types.h :\ $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
fsdev/qemu-fsdev-throttle.c +96 -0
102 lines not on this page · raw message
fsdev/qemu-fsdev-throttle.h +11 -0
@@ -20,6 +20,12 @@#include "qemu/coroutine.h" #include "qapi/error.h" #include "qemu/throttle.h" +#include "qapi/qmp/types.h" +#include "qapi-visit.h" +#include "qapi/qmp/qerror.h" +#include "qapi/qobject-output-visitor.h" +#include "qapi/util.h" +#include "qmp-commands.h" typedef struct FsThrottle { ThrottleState ts;
@@ -36,4 +42,9 @@ 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 **); + +void fsdev_get_io_throttle (FsThrottle *,IOThrottle **,char *,Error **); +#endif /* _FSDEV_THROTTLE_H */
fsdev/qemu-fsdev.c +37 -1
@@ -17,7 +17,7 @@#include "qemu/config-file.h" #include "qemu/error-report.h" -static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries = +QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries =QTAILQ_HEAD_INITIALIZER (fsdriver_entries);static FsDriverTable FsDrivers[] = {
@@ -98,3 +98,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_device ? arg->device :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; +}
fsdev/qemu-fsdev.h +1 -1
@@ -39,8 +39,8 @@ typedef struct FsDriverListEntry {QTAILQ_ENTRY (FsDriverListEntry) next; } FsDriverListEntry; +FsDriverEntry *get_fsdev_fsentry (char *);int qemu_fsdev_add (QemuOpts *opts); -FsDriverEntry *get_fsdev_fsentry (char *id);extern FileOperations local_ops;extern FileOperations handle_ops;extern FileOperations synth_ops;
hmp-commands-info.hx +18 -0
@@ -84,6 +84,24 @@ STEXI Show block device statistics. ETEXI +#if defined(CONFIG_VIRTFS) + + { + .name = "fsdevthrottle", + .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 +18 -0
@@ -1628,6 +1628,24 @@ 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 block drive", + .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 block drive 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 +74 -0
86 lines not on this page · raw message
hmp.h +5 -0
@@ -56,6 +56,7 @@ void hmp_system_wakeup(Monitor *mon, const QDict *qdict);void hmp_nmi (Monitor *mon,const QDict *qdict);void hmp_set_link (Monitor *mon,const QDict *qdict);void hmp_block_passwd (Monitor *mon,const QDict *qdict); +void hmp_9p_passwd (Monitor *mon,const QDict *qdict);void hmp_balloon (Monitor *mon,const QDict *qdict);void hmp_block_resize (Monitor *mon,const QDict *qdict);void hmp_snapshot_blkdev (Monitor *mon,const QDict *qdict);
@@ -77,6 +78,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);
qapi-schema.json +6 -0
@@ -78,9 +78,15 @@ # QAPI crypto definitions { 'include': 'qapi/crypto.json' } +# QAPI IOThrottle definitions +{ 'include': 'qapi/iothrottle.json' } + # 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 +87 -0
87 lines not on this page · raw message
qapi/iothrottle.json new file +93 -0
93 lines not on this page · raw message
qmp.c +14 -0
@@ -162,6 +162,20 @@ SpiceInfo *qmp_query_spice(Error **errp) };#endif +#ifndef CONFIG_VIRTFS + +void qmp_fsdev_set_io_throttle (IOThrottle *arg,Error **errp) +{ + +} + +IOThrottleList *qmp_query_fsdev_io_throttle (Error **errp) +{ +abort (); +} + +#endif +void qmp_cont (Error **errp) {Error *local_err =NULL ;
Signature · 1 line
1.8.3.1
PATCH 2/2 throttle: factor out the redundant code
This patchset removes the throttle redundant code that was present in block and fsdev files.
--- blockdev.c | 106 ++++----------------------------------- fsdev/Makefile.objs | 1 + fsdev/qemu-fsdev-throttle.c | 94 +--------------------------------- fsdev/qemu-fsdev-throttle.h | 3 +- hmp.c | 39 +++++++-------- include/qemu/throttle-options.h | 5 ++ qapi/block-core.json | 76 +--------------------------- qapi/iothrottle.json | 4 +- util/Makefile.objs | 1 + util/throttle-options.c | 108 ++++++++++++++++++++++++++++++++++++++++ 10 files changed, 151 insertions(+), 286 deletions(-) create mode 100644 util/throttle-options.c
blockdev.c +9 -97
@@ -386,49 +386,7 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, }if (throttle_cfg) { -throttle_config_init (throttle_cfg); - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].avg = -qemu_opt_get_number (opts,"throttling.bps-total" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].avg = -qemu_opt_get_number (opts,"throttling.bps-read" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].avg = -qemu_opt_get_number (opts,"throttling.bps-write" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].avg = -qemu_opt_get_number (opts,"throttling.iops-total" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].avg = -qemu_opt_get_number (opts,"throttling.iops-read" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].avg = -qemu_opt_get_number (opts,"throttling.iops-write" ,0 ); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].max = -qemu_opt_get_number (opts,"throttling.bps-total-max" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].max = -qemu_opt_get_number (opts,"throttling.bps-read-max" ,0 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].max = -qemu_opt_get_number (opts,"throttling.bps-write-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].max = -qemu_opt_get_number (opts,"throttling.iops-total-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].max = -qemu_opt_get_number (opts,"throttling.iops-read-max" ,0 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].max = -qemu_opt_get_number (opts,"throttling.iops-write-max" ,0 ); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-total-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_BPS_READ ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-read-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_BPS_WRITE ].burst_length = -qemu_opt_get_number (opts,"throttling.bps-write-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-total-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_READ ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-read-max-length" ,1 ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE ].burst_length = -qemu_opt_get_number (opts,"throttling.iops-write-max-length" ,1 ); - - throttle_cfg->op_size = -qemu_opt_get_number (opts,"throttling.iops-size" ,0 ); - +parse_io_throttle_options (throttle_cfg, opts);if (!throttle_is_valid (throttle_cfg, errp)) {return ; }
@@ -2635,9 +2593,12 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)BlockDriverState *bs;BlockBackend *blk;AioContext *aio_context; +IOThrottle *iothrottle; + + iothrottle = arg->iothrottle; - blk =qmp_get_blk (arg->has_device ? arg->device :NULL , - arg->has_id ? arg->id :NULL , + blk =qmp_get_blk (iothrottle->has_device ? iothrottle->device :NULL , + iothrottle->has_id ? iothrottle->id :NULL , errp);if (!blk) {return ;
@@ -2652,56 +2613,7 @@ 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; - } +qmp_set_io_throttle (&cfg, iothrottle);if (!throttle_is_valid (&cfg, errp)) { goto out;
@@ -2713,8 +2625,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)if (!blk_get_public (blk)->throttle_state) {blk_io_limits_enable (blk, arg->has_group ? arg->group : - arg->has_device ? arg->device : - arg->id); + iothrottle->has_device ? iothrottle->device : + iothrottle->id); }else if (arg->has_group) {blk_io_limits_update_group (blk, arg->group); }
fsdev/Makefile.objs +1 -0
@@ -5,6 +5,7 @@ common-obj-y = qemu-fsdev.o 9p-marshal.o 9p-iov-marshal.o else common-obj-y = qemu-fsdev-dummy.o endif +#common-obj-y += qemu-fsdev-opts.o prin.o qemu-fsdev-throttle.o qmp-throttle.o common-obj-y += qemu-fsdev-opts.o qemu-fsdev-throttle.o # Toplevel always builds this; targets without virtio will put it in
fsdev/qemu-fsdev-throttle.c +2 -92
106 lines not on this page · raw message
fsdev/qemu-fsdev-throttle.h +2 -1
@@ -19,13 +19,14 @@#include "qemu/main-loop.h" #include "qemu/coroutine.h" #include "qapi/error.h" +#include "qapi/qmp/qerror.h" #include "qemu/throttle.h" #include "qapi/qmp/types.h" #include "qapi-visit.h" -#include "qapi/qmp/qerror.h" #include "qapi/qobject-output-visitor.h" #include "qapi/util.h" #include "qmp-commands.h" +#include "qemu/throttle-options.h" typedef struct FsThrottle { ThrottleState ts;
hmp.c +18 -21
@@ -1554,20 +1554,25 @@ 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_device = true; + iot->device = (char *)qdict_get_str (qdict,"device" ); + 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 ; -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" ), - }; - +BlockIOThrottle throttle; +IOThrottle iothrottle; +hmp_initialize_io_throttle (&iothrottle, qdict); + throttle.iothrottle = &iothrottle;qmp_block_set_io_throttle (&throttle, &err);hmp_handle_error (mon, &err); }
@@ -1577,16 +1582,8 @@ void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)void hmp_fsdev_set_io_throttle (Monitor *mon,const QDict *qdict) {Error *err =NULL ; -IOThrottle throttle = { - .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 throttle; +hmp_initialize_io_throttle (&throttle, qdict);qmp_fsdev_set_io_throttle (&throttle, &err);hmp_handle_error (mon, &err); }
include/qemu/throttle-options.h +5 -0
@@ -10,6 +10,9 @@#ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H +#include "qemu/throttle.h" +#include "qmp-commands.h" +#define THROTTLE_OPTS \ { \ .name = "throttling.iops-total",\
@@ -89,4 +92,6 @@ .help = "when limiting by iops max size of an I/O in bytes",\ } +void qmp_set_io_throttle (ThrottleConfig *,IOThrottle *); +void parse_io_throttle_options (ThrottleConfig *,QemuOpts *);#endif
qapi/block-core.json +2 -74
88 lines not on this page · raw message
qapi/iothrottle.json +3 -1
@@ -14,6 +14,8 @@ # # @device: Block device name # +# @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
@@ -80,7 +82,7 @@ # Since: 2.10 ## { 'struct': 'IOThrottle', - 'data': { '*device': 'str', 'bps': 'int', 'bps_rd': 'int', + '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',
util/Makefile.objs +1 -0
@@ -42,3 +42,4 @@ util-obj-y += log.o util-obj-y += qdist.o util-obj-y += qht.o util-obj-y += range.o +util-obj-y += throttle-options.o
util/throttle-options.c new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 2/2 v1] throttle: factor out the redundant code
Quoted 5 lines · Pradeep Jagadeesh
This patchset removes the throttle redundant code that was present in block and fsdev files.
Signed-off-by Pradeep Jagadeesh <[email protected]>---
I think you want portions of this patch to come first; you want to refactor out the IOThrottle portion of existing types, and then extend IOThrottle to be used in more places.
Quoted 16 lines
blockdev.c | 106 ++++----------------------------------- fsdev/Makefile.objs | 1 + fsdev/qemu-fsdev-throttle.c | 94 +--------------------------------- fsdev/qemu-fsdev-throttle.h | 3 +- hmp.c | 39 +++++++-------- include/qemu/throttle-options.h | 5 ++ qapi/block-core.json | 76 +--------------------------- qapi/iothrottle.json | 4 +- util/Makefile.objs | 1 + util/throttle-options.c | 108 ++++++++++++++++++++++++++++++++++++++++ 10 files changed, 151 insertions(+), 286 deletions(-) create mode 100644 util/throttle-options.c+++
b/fsdev/qemu-fsdev-throttle.c
fsdev/qemu-fsdev-throttle.c void fsdev_set_io_throttle(IOThrottle *arg, FsThrottle *fst, Error **errp) · line 40
Quoted 8 lines
fsdev/qemu-fsdev-throttle.c +0
-5@@ -33,56 +33,7 @@ void fsdev_set_io_throttle(IOThrottle *arg, FsThrottle *fst, Error **errp) {ThrottleConfig cfg; -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; -
This code was added in the last patch - which makes for a lot of unnecessary churn. Again, the best series does refactoring of existing code first, then adds the new code that takes advantage of the refactored entry points, so that the new code isn't churning.
hmp.c void hmp_change(Monitor *mon, const QDict *qdict) · line 1560
Quoted 9 lines
hmp.c +5
-0+++ b/hmp.c@@ -1554,20 +1554,25 @@ 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_device = true; + iot->device = (char *)qdict_get_str (qdict,"device" );
Is casting away const going to result in a double free of memory later on? Or put another way, should this be a g_strdup'd copy (which you then have to make sure is not leaked)?
Quoted 4 lines
hmp.c +4
-0+ 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" );
hmp.c void hmp_change(Monitor *mon, const QDict *qdict) · line 1562
Quoted 10 lines
hmp.c +4
-3+ 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 ; -BlockIOThrottle throttle = { - .has_device = true, - .device = (char *)qdict_get_str (qdict,"device" ),
At any rate, I see it is just code motion. You are refactoring too much in one patch here; I'd consider splitting it along the lines of one patch that adds hmp_initialize_io_throttle; and another patch that adds parse_io_throttle_options(), so that it's easier to see just one piece of code motion at a time, rather than trying to track multiple motions in the same large patch.
qapi/block-core.json line 1762
Quoted 8 lines
qapi/block-core.json +2
-1+++ b/qapi/block-core.json@@ -1758,86 +1758,14 @@ # # A set of parameters describing block throttling. # -# @iops_size: an I/O size in bytes (Since 1.7) +# @iothrottle: throttle configuration (Since 1.7)
NACK. This is an incompatible change; you are breaking the QMP wire structure (that is, where I used to pass "arguments":{"device":"foo", "bps_rd":1, "group":"bar" }, your change would now require me to pass "arguments":{"iothrottle":{"device":"foo", "bps_rd":1}, "group":"bar"}; the extra nesting is what breaks things).
Quoted 6 lines
qapi/block-core.json +0
-0# # @group: throttle group name (Since 2.4) # # Since: 1.1 ## { 'struct': 'BlockIOThrottle',
qapi/block-core.json line 1768
Quoted 10 lines
qapi/block-core.json +1
-9- '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' } } + 'data': { '*iothrottle': 'IOThrottle', '*group': 'str' } }
What you REALLY want is a compatible change, namely:
{ 'struct': 'BlockIOThrottle', 'base': 'IOThrottle',
'data': { '*group': 'str' } }
which says that all fields of IOThrottle are inherited at the same level as the additional field 'group'.
For that matter, are you sure that 'group' is the only field that should not be directly in IOThrottle, or should 'device' also be specific to BlockIOThrottle (I'm not sure whether you were actually using 'device' in the fsdev case, or if 'id' was sufficient).
qapi/iothrottle.json line 18
Quoted 13 lines
qapi/block-core.json +0
-0## # @block-stream:qapi/iothrottle.json +2
-0@@ -14,6 +14,8 @@ # # @device: Block device name # +# @id: The name or QOM path of the guest device (since: 2.8) +#
You've missed 2.8 by a long shot. Oh - this is an argument that it is 'id' (and not 'device') that does not belong here, but should be placed alongside 'group' in the BlockIOThrottle subtype.
Quoted 12 lines
qapi/iothrottle.json +1
-1# @bps: total throughput limit in bytes per second # # @bps_rd: read throughput limit in bytes per second@@ -80,7 +82,7 @@ # Since: 2.10 ## { 'struct': 'IOThrottle', - 'data': { '*device': 'str', 'bps': 'int', 'bps_rd': 'int', + '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',
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 2/2 v1] throttle: factor out the redundant code
Quoted 10 lines · Eric Blake
Quoted 5 lines · Pradeep Jagadeesh
This patchset removes the throttle redundant code that was present in block and fsdev files.
Signed-off-by Pradeep Jagadeesh <[email protected]>---
I think you want portions of this patch to come first; you want to refactor out the IOThrottle portion of existing types, and then extend IOThrottle to be used in more places.
For the record, here's a nice example of how to factor out common fields into a new base class:
https://lists.gnu.org/archive/html/qemu-devel/2017-03/msg04649.html
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 2/2 v1] throttle: factor out the redundant code
Quoted 8 lines · Eric Blake
Quoted 7 lines · Eric Blake
Quoted 5 lines · Pradeep Jagadeesh
This patchset removes the throttle redundant code that was present in block and fsdev files.
Signed-off-by Pradeep Jagadeesh <[email protected]>---
Quoted 8 lines
Quoted 3 lines
I think you want portions of this patch to come first; you want to refactor out the IOThrottle portion of existing types, and then extend IOThrottle to be used in more places.
For the record, here's a nice example of how to factor out common fields into a new base class:
https://lists.gnu.org/archive/html/qemu-devel/2017-03/msg04649.html
Nice one, but If I do this way, I can not remove some duplicate code from initialization code. For example below code.
void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
- 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"),- };
Quoted 1 line
Also
void hmp_fsdev_set_io_throttle(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
- IOThrottle throttle = {
- .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"),- };
-
Regards,
Pradeep
Re: [Qemu-devel] [PATCH 2/2 v1] throttle: factor out the redundant code
In reply to Eric BlakeQuoted 10 lines · Eric Blake
Quoted 5 lines · Pradeep Jagadeesh
This patchset removes the throttle redundant code that was present in block and fsdev files.
Signed-off-by Pradeep Jagadeesh <[email protected]>---
I think you want portions of this patch to come first; you want to refactor out the IOThrottle portion of existing types, and then extend IOThrottle to be used in more places.
OK, I will do that.
Quoted 20 lines
Quoted 20 lines
blockdev.c | 106 ++++----------------------------------- fsdev/Makefile.objs | 1 + fsdev/qemu-fsdev-throttle.c | 94 +--------------------------------- fsdev/qemu-fsdev-throttle.h | 3 +- hmp.c | 39 +++++++-------- include/qemu/throttle-options.h | 5 ++ qapi/block-core.json | 76 +--------------------------- qapi/iothrottle.json | 4 +- util/Makefile.objs | 1 + util/throttle-options.c | 108 ++++++++++++++++++++++++++++++++++++++++ 10 files changed, 151 insertions(+), 286 deletions(-) create mode 100644 util/throttle-options.c+++
b/fsdev/qemu-fsdev-throttle.cfsdev/qemu-fsdev-throttle.c +0
-0@@ -33,56 +33,7 @@ void fsdev_set_io_throttle(IOThrottle *arg, FsThrottle *fst, Error **errp) {ThrottleConfig cfg;
Quoted 11 lines
blockdev.c void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp) · line 2659
Quoted 5 lines
blockdev.c +0
-5-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; -This code was added in the last patch - which makes for a lot of unnecessary churn. Again, the best series does refactoring of existing code first, then adds the new code that takes advantage of the refactored entry points, so that the new code isn't churning.
OK
Quoted 6 lines
Quoted 6 lines
hmp.c +1
-0+++ b/hmp.c@@ -1554,20 +1554,25 @@ void hmp_change(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); }
Quoted 8 lines
hmp.c void hmp_change(Monitor *mon, const QDict *qdict) · line 1560
Quoted 4 lines
hmp.c +4
-0+static void hmp_initialize_io_throttle (IOThrottle *iot,const QDict *qdict) +{ + iot->has_device = true; + iot->device = (char *)qdict_get_str (qdict,"device" );Is casting away const going to result in a double free of memory later on? Or put another way, should this be a g_strdup'd copy (which you then have to make sure is not leaked)?
This code was there in block_set_io_throttle(). I have just moved to new function. But I will think about it.
Quoted 14 lines
Quoted 14 lines
hmp.c +8
-2+ 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 ; -BlockIOThrottle throttle = { - .has_device = true,
Quoted 8 lines
Review void hmp_change(Monitor *mon, const QDict *qdict) · line 1562
Quoted 1 line
(quoted diff) +0
-1- .device = (char *) qdict_get_str(qdict, "device"),At any rate, I see it is just code motion. You are refactoring too much in one patch here; I'd consider splitting it along the lines of one patch that adds
hmp_initialize_io_throttle; and another patch that addsparse_io_throttle_options(), so that it's easier to see just one piece of code motion at a time, rather than trying to track multiple motions in the same large patch.
I will split the code into different patches.
Quoted 38 lines
qapi/block-core.json line 1762
Quoted 9 lines
qapi/block-core.json +2
-1+++ b/qapi/block-core.json@@ -1758,86 +1758,14 @@ # # A set of parameters describing block throttling. # -# @iops_size: an I/O size in bytes (Since 1.7) +# @iothrottle: throttle configuration (Since 1.7)NACK. This is an incompatible change; you are breaking the QMP wire structure (that is, where I used to pass "arguments":{"device":"foo", "bps_rd":1, "group":"bar" }, your change would now require me to pass "arguments":{"iothrottle":{"device":"foo", "bps_rd":1}, "group":"bar"}; the extra nesting is what breaks things).
Quoted 6 lines
qapi/block-core.json +0
-0# # @group: throttle group name (Since 2.4) # # Since: 1.1 ## { 'struct': 'BlockIOThrottle',qapi/block-core.json line 1768
Quoted 10 lines
qapi/block-core.json +1
-9- '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' } } + 'data': { '*iothrottle': 'IOThrottle', '*group': 'str' } }What you REALLY want is a compatible change, namely:
{ 'struct': 'BlockIOThrottle', 'base': 'IOThrottle',
'data': { '*group': 'str' } }
Quoted 7 lines
which says that all fields of IOThrottle are inherited at the same level as the additional field 'group'.
For that matter, are you sure that 'group' is the only field that should not be directly in IOThrottle, or should 'device' also be specific to BlockIOThrottle (I'm not sure whether you were actually using 'device' in the fsdev case, or if 'id' was sufficient).
Yes, I just need id in case of fsdev. I will fix that. But if I do this way, some of the code refactoring is not possible.Because they will have different structures for fsdev and block.
Quoted 18 lines
Quoted 9 lines
qapi/block-core.json +0
-0## # @block-stream:qapi/iothrottle.json +0
-0qapi/iothrottle.json line 18
Quoted 5 lines
qapi/iothrottle.json +2
-0@@ -14,6 +14,8 @@ # # @device: Block device name # +# @id: The name or QOM path of the guest device (since: 2.8) +#You've missed 2.8 by a long shot. Oh - this is an argument that it is 'id' (and not 'device') that does not belong here, but should be placed alongside 'group' in the BlockIOThrottle subtype.
id is required for the fsdev/block both. This was part of the BlockIOThrottle. So I just took it and kept the description as it is. What should I changed to? 2.10?
Quoted 15 lines
Quoted 13 lines
qapi/iothrottle.json +1
-1# @bps: total throughput limit in bytes per second # # @bps_rd: read throughput limit in bytes per second@@ -80,7 +82,7 @@ # Since: 2.10 ## { 'struct': 'IOThrottle', - 'data': { '*device': 'str', 'bps': 'int', 'bps_rd': 'int', + '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',
Quoted 2 lines · Pradeep Jagadeesh
This patchset enables qmp interfaces for the 9pfs devices (fsdev). This provides two interfaces one
s/interfaces/interfaces,/
Also, I just noticed you are using trailing spaces in your commit message (not fatal, but unusual).
Quoted 2 lines
for querying all the 9pfs devices info. The second one to set the IO limits for the required 9pfs device.
When sending a multi-patch series, please remember to include the 0/2 cover letter ('git config format.coverletter auto' can help here).
Quoted 17 lines
Signed-off-by Pradeep Jagadeesh <[email protected]>--- Makefile | 5 ++- fsdev/qemu-fsdev-throttle.c | 96 +++++++++++++++++++++++++++++++++++++++++++++ fsdev/qemu-fsdev-throttle.h | 11 ++++++ fsdev/qemu-fsdev.c | 38 +++++++++++++++++- fsdev/qemu-fsdev.h | 2 +- hmp-commands-info.hx | 18 +++++++++ hmp-commands.hx | 18 +++++++++ hmp.c | 74 ++++++++++++++++++++++++++++++++++ hmp.h | 5 +++ qapi-schema.json | 6 +++ qapi/fsdev.json | 87 ++++++++++++++++++++++++++++++++++++++++ qapi/iothrottle.json | 93 +++++++++++++++++++++++++++++++++++++++++++ qmp.c | 14 +++++++ 13 files changed, 464 insertions(+), 3 deletions(-)
That's a big patch to review in one go. Does it make sense to break it down into smaller chunks?
Quoted 6 lines
create mode 100644 qapi/fsdev.json create mode 100644 qapi/iothrottle.jsonv0 -> v1:
Addressed the comments by Erik Blake, Greg Kurz and Daniel P.Berrange
It's Eric, but you're not the first (and probably not the last) to get it wrong.
Makefile qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ · line 416
Quoted 12 lines
Mainly renaming the functions and removing the redundant code
Makefile +1
-1@@ -413,7 +413,10 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \ $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.json \ $(SRC_PATH)/qapi/crypto.json $(SRC_PATH)/qapi/rocker.json \ - $(SRC_PATH)/qapi/trace.json + $(SRC_PATH)/qapi/trace.json $(SRC_PATH)/qapi/iothrottle.json
Why two spaces?
Quoted 4 lines
Makefile +1
-0+++ b/qapi-schema.json@@ -78,9 +78,15 @@ # QAPI crypto definitions { 'include': 'qapi/crypto.json' }
Makefile line 89
Quoted 10 lines
Makefile +6
-0+# QAPI IOThrottle definitions +{ 'include': 'qapi/iothrottle.json' } + # QAPI block definitions { 'include': 'qapi/block.json' } +# QAPI fsdev definitions +{ 'include': 'qapi/fsdev.json' } +
Adding two new files definitely feels like something that could be split. Also, is it possible that existing code could take advantage of qapi/iothrottle.json, rather than it just being additional code?
Quoted 9 lines
Makefile +0
-0# QAPI event definitions { 'include': 'qapi/event.json' }qapi/fsdev.json new file +0
-0
qapi/fsdev.json line 9
Quoted 9 lines
qapi/fsdev.json new file +9
-0@@ -0,0 +1,87 @@ +# -*- Mode: Python -*- + +## +# == QAPI fsdev definitions +## + +# QAPI common definitions +{ 'include': 'common.json' } +{ 'include': 'iothrottle.json' }
Is this really necessary? Given that the top level already included these, I think it serves more as a documentation purpose than something you actually need.
qapi/fsdev.json line 16
Quoted 7 lines
qapi/fsdev.json new file +7
-0+ +## +# @fsdev_set_io_throttle: +# +# Change I/O limits for a 9p/fsdev device. +# +# I/O limits can be enabled by setting throttle vaue to non-zero numbers.
s/vaue/value/
qapi/fsdev.json line 27
Quoted 11 lines
qapi/fsdev.json new file +11
-0+# +# I/O limits can be disabled by setting all of them to 0. +# +# Returns: Nothing on success +# If @device is not a valid fsdev device, DeviceNotFound +# +# Since: 2.10 +# +# Example: +# +# -> { "execute": "fsdev_set_io_throttle",
Please name this fsdev-set-io-throttle. New commands should favor the use of '-' rather than '_'.
qapi/fsdev.json line 52
Quoted 6 lines
qapi/fsdev.json new file +6
-0+## +# @query-fsdev-io-throttle: +# +# Return a list of information about fsdev device +# +# Returns: @FsdevIOIOThrottle
Typo in the type name, should be merely IOThrottle
Quoted 17 lines
qapi/fsdev.json new file +10
-0+# +# Since: 2.10 +# +# Example: +# +# -> { "Execute": "query-fsdev-io-throttle" } +# +## +{ 'command': 'query-fsdev-io-throttle', 'returns': [ 'IOThrottle' ] } +qapi/iothrottle.json new file +0
-0
qapi/iothrottle.json line 8
Quoted 8 lines
qapi/iothrottle.json new file +8
-0@@ -0,0 +1,93 @@ +# -*- Mode: Python -*- + +## +# == QAPI IOThrottle definitions +## + +# QAPI common definitions +{ 'include': 'common.json' }
Again, is this necessary?
qapi/iothrottle.json line 80
Quoted 4 lines
qapi/iothrottle.json new file +4
-0+# @iops_size: an I/O size in bytes (Since 1.7) +# +# +# Since: 2.10
It's weird to state that this struct is since 2.10, but its members are since 1.7. Either you should list a 'since' for when the members of the struct were first useful (0.14.0), or eliminate all the (since ...) tags on the members and keep the overall struct at 2.10. I'd lean towards the former, at least if BlockDeviceInfo is properly refactored to inherit from this type.
qapi/iothrottle.json line 91
Quoted 11 lines
qapi/iothrottle.json new file +11
-0+## +{ 'struct': 'IOThrottle', + 'data': { '*device': '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' } }
So yeah, you definitely need to split this patch. Your FIRST patch should be the creation of IOThrottle, and fixing BlockDeviceInfo to inherit from it; then a later patch would be the introduction of the fsdev throttle commands that are additional clients of the new IOThrottle type.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 9 lines · Eric Blake
Quoted 2 lines · Pradeep Jagadeesh
This patchset enables qmp interfaces for the 9pfs devices (fsdev). This provides two interfaces one
s/interfaces/interfaces,/
Also, I just noticed you are using trailing spaces in your commit message (not fatal, but unusual).
Will fix.
Quoted 5 lines
Quoted 2 lines
for querying all the 9pfs devices info. The second one to set the IO limits for the required 9pfs device.
When sending a multi-patch series, please remember to include the 0/2 cover letter ('git config format.coverletter auto' can help here).
OK, I will have a look.
Quoted 25 lines
Quoted 18 lines
Signed-off-by Pradeep Jagadeesh <[email protected]>--- Makefile | 5 ++- fsdev/qemu-fsdev-throttle.c | 96 +++++++++++++++++++++++++++++++++++++++++++++ fsdev/qemu-fsdev-throttle.h | 11 ++++++ fsdev/qemu-fsdev.c | 38 +++++++++++++++++- fsdev/qemu-fsdev.h | 2 +- hmp-commands-info.hx | 18 +++++++++ hmp-commands.hx | 18 +++++++++ hmp.c | 74 ++++++++++++++++++++++++++++++++++ hmp.h | 5 +++ qapi-schema.json | 6 +++ qapi/fsdev.json | 87 ++++++++++++++++++++++++++++++++++++++++ qapi/iothrottle.json | 93 +++++++++++++++++++++++++++++++++++++++++++ qmp.c | 14 +++++++ 13 files changed, 464 insertions(+), 3 deletions(-)That's a big patch to review in one go. Does it make sense to break it down into smaller chunks?
Quoted 3 lines
create mode 100644 qapi/fsdev.json create mode 100644 qapi/iothrottle.json
Quoted 6 lines
Quoted 3 lines
v0 -> v1:
Addressed the comments by Erik Blake, Greg Kurz and Daniel P.Berrange
It's Eric, but you're not the first (and probably not the last) to get it wrong.
:) will remember.
Quoted 16 lines
Makefile qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ · line 416
Quoted 13 lines
Mainly renaming the functions and removing the redundant code
Makefile +1
-1@@ -413,7 +413,10 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \ $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.json \ $(SRC_PATH)/qapi/crypto.json $(SRC_PATH)/qapi/rocker.json \ - $(SRC_PATH)/qapi/trace.json + $(SRC_PATH)/qapi/trace.json $(SRC_PATH)/qapi/iothrottle.jsonWhy two spaces?
Will fix it.
Quoted 12 lines
Quoted 12 lines
Makefile +4
-0+++ b/qapi-schema.json@@ -78,9 +78,15 @@ # QAPI crypto definitions { 'include': 'qapi/crypto.json' } +# QAPI IOThrottle definitions +{ 'include': 'qapi/iothrottle.json' } + # QAPI block definitions { 'include': 'qapi/block.json' }
Quoted 7 lines
Makefile line 89
Quoted 3 lines
Makefile +3
-0+# QAPI fsdev definitions +{ 'include': 'qapi/fsdev.json' } +Adding two new files definitely feels like something that could be split. Also, is it possible that existing code could take advantage of
qapi/iothrottle.json, rather than it just being additional code?
I will check and remove unnecessary includes.
Quoted 15 lines
Quoted 15 lines
Makefile +0
-0# QAPI event definitions { 'include': 'qapi/event.json' }qapi/fsdev.json new file +5
-0@@ -0,0 +1,87 @@ +# -*- Mode: Python -*- + +## +# == QAPI fsdev definitions +##
Quoted 8 lines
qapi/fsdev.json line 9
Quoted 4 lines
qapi/fsdev.json new file +4
-0+ +# QAPI common definitions +{ 'include': 'common.json' } +{ 'include': 'iothrottle.json' }Is this really necessary? Given that the top level already included these, I think it serves more as a documentation purpose than something you actually need.
Not really, will fix this.
Quoted 10 lines
qapi/fsdev.json line 16
Quoted 8 lines
qapi/fsdev.json new file +7
-0+ +## +# @fsdev_set_io_throttle: +# +# Change I/O limits for a 9p/fsdev device. +# +# I/O limits can be enabled by setting throttle vaue to non-zero numbers.s/vaue/value/
ok
Quoted 17 lines
qapi/fsdev.json line 27
Quoted 12 lines
qapi/fsdev.json new file +11
-0+# +# I/O limits can be disabled by setting all of them to 0. +# +# Returns: Nothing on success +# If @device is not a valid fsdev device, DeviceNotFound +# +# Since: 2.10 +# +# Example: +# +# -> { "execute": "fsdev_set_io_throttle",Please name this fsdev-set-io-throttle. New commands should favor the use of '-' rather than '_'.
ok
Quoted 8 lines
qapi/fsdev.json line 52
Quoted 6 lines
qapi/fsdev.json new file +6
-0+## +# @query-fsdev-io-throttle: +# +# Return a list of information about fsdev device +# +# Returns: @FsdevIOIOThrottleTypo in the type name, should be merely IOThrottle
ok
Quoted 20 lines
Quoted 20 lines
qapi/fsdev.json new file +10
-0+# +# Since: 2.10 +# +# Example: +# +# -> { "Execute": "query-fsdev-io-throttle" } +# +## +{ 'command': 'query-fsdev-io-throttle', 'returns': [ 'IOThrottle' ] } +qapi/iothrottle.json new file +2
-0@@ -0,0 +1,93 @@ +# -*- Mode: Python -*- +
Quoted 8 lines
qapi/iothrottle.json line 8
Quoted 6 lines
qapi/iothrottle.json new file +6
-0+## +# == QAPI IOThrottle definitions +## + +# QAPI common definitions +{ 'include': 'common.json' }Again, is this necessary?
Removed.
Quoted 13 lines
qapi/iothrottle.json line 80
Quoted 6 lines
qapi/iothrottle.json new file +4
-0+# @iops_size: an I/O size in bytes (Since 1.7) +# +# +# Since: 2.10It's weird to state that this struct is since 2.10, but its members are since 1.7. Either you should list a 'since' for when the members of the struct were first useful (0.14.0), or eliminate all the (since ...) tags on the members and keep the overall struct at 2.10. I'd lean towards the former, at least if BlockDeviceInfo is properly refactored to inherit from this type.
Some members of this structure have Since, not all of them. So, shall I remove since tag from all?
As of now I used as it is from BlockIOThrottle. Not changed any since tags.
OK, I will try to refactor the BlockDeviceInfo using this structure.
Quoted 10 lines
Quoted 10 lines
qapi/iothrottle.json new file +9
-0+## +{ 'struct': 'IOThrottle', + 'data': { '*device': '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',
Quoted 8 lines
qapi/iothrottle.json line 91
Quoted 2 lines
qapi/iothrottle.json new file +2
-0+ '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int', + '*iops_size': 'int' } }So yeah, you definitely need to split this patch. Your FIRST patch should be the creation of IOThrottle, and fixing BlockDeviceInfo to inherit from it; then a later patch would be the introduction of the fsdev throttle commands that are additional clients of the new IOThrottle type.
OK