Received: from eggs.gnu.org ([2001:4830:134:3::10]:52349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGKE5-00057A-Bt for qemu-devel@nongnu.org; Sun, 01 Sep 2013 22:50:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VGKE0-0002os-9W for qemu-devel@nongnu.org; Sun, 01 Sep 2013 22:50:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGKDz-0002om-Uz for qemu-devel@nongnu.org; Sun, 01 Sep 2013 22:50:44 -0400 Date: Mon, 2 Sep 2013 10:50:32 +0800 From: Fam Zheng Message-ID: <20130902025032.GA9089@T430s.nay.redhat.com> References: <1378053587-12121-1-git-send-email-benoit@irqsave.net> <1378053587-12121-5-git-send-email-benoit@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1378053587-12121-5-git-send-email-benoit@irqsave.net> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH V11 4/5] block: Add support for throttling burst max in QMP and the command line. Reply-To: famz@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Beno=EEt?= Canet Cc: kwolf@redhat.com, stefanha@gmail.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com On Sun, 09/01 18:39, Beno=EEt Canet wrote: > The max parameter of the leaky bucket throttling algorithm can be used = to > allow the guest to do bursts. > The max value is a pool of I/O that the guest can use without being thr= ottled > at all. Throttling is triggered once this pool is empty. It would be good to putting this description in comment and/or document s= trings (e.g. help text) to make it easier for both users and developers to under= stand how is this "max" used, because it's hard to fully understand from "total= max in bytes" or "total max in bytes". >=20 > Signed-off-by: Benoit Canet > Reviewed-by: Eric Blake > --- > block/qapi.c | 26 ++++++++++++ > blockdev.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++= -------- > hmp.c | 32 +++++++++++++-- > qapi-schema.json | 34 +++++++++++++++- > qemu-options.hx | 4 +- > qmp-commands.hx | 28 ++++++++++++- > 6 files changed, 218 insertions(+), 24 deletions(-) >=20 > diff --git a/block/qapi.c b/block/qapi.c > index cac3919..b1edc66 100644 > --- a/block/qapi.c > +++ b/block/qapi.c > @@ -232,6 +232,32 @@ void bdrv_query_info(BlockDriverState *bs, > info->inserted->iops =3D cfg.buckets[THROTTLE_OPS_TOTAL= ].avg; > info->inserted->iops_rd =3D cfg.buckets[THROTTLE_OPS_READ]= .avg; > info->inserted->iops_wr =3D cfg.buckets[THROTTLE_OPS_WRITE= ].avg; > + > + info->inserted->has_bps_max =3D > + cfg.buckets[THROTTLE_BPS_TOTAL].max; > + info->inserted->bps_max =3D > + cfg.buckets[THROTTLE_BPS_TOTAL].max; > + info->inserted->has_bps_rd_max =3D > + cfg.buckets[THROTTLE_BPS_READ].max; > + info->inserted->bps_rd_max =3D > + cfg.buckets[THROTTLE_BPS_READ].max; > + info->inserted->has_bps_wr_max =3D > + cfg.buckets[THROTTLE_BPS_WRITE].max; > + info->inserted->bps_wr_max =3D > + cfg.buckets[THROTTLE_BPS_WRITE].max; > + > + info->inserted->has_iops_max =3D > + cfg.buckets[THROTTLE_OPS_TOTAL].max; > + info->inserted->iops_max =3D > + cfg.buckets[THROTTLE_OPS_TOTAL].max; > + info->inserted->has_iops_rd_max =3D > + cfg.buckets[THROTTLE_OPS_READ].max; > + info->inserted->iops_rd_max =3D > + cfg.buckets[THROTTLE_OPS_READ].max; > + info->inserted->has_iops_wr_max =3D > + cfg.buckets[THROTTLE_OPS_WRITE].max; > + info->inserted->iops_wr_max =3D > + cfg.buckets[THROTTLE_OPS_WRITE].max; > } > =20 > bs0 =3D bs; > diff --git a/blockdev.c b/blockdev.c > index 66fce9f..dc0637d 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -495,13 +495,18 @@ static DriveInfo *blockdev_init(QemuOpts *all_opt= s, > cfg.buckets[THROTTLE_OPS_WRITE].avg =3D > qemu_opt_get_number(opts, "throttling.iops-write", 0); > =20 > - cfg.buckets[THROTTLE_BPS_TOTAL].max =3D 0; > - cfg.buckets[THROTTLE_BPS_READ].max =3D 0; > - cfg.buckets[THROTTLE_BPS_WRITE].max =3D 0; > - > - cfg.buckets[THROTTLE_OPS_TOTAL].max =3D 0; > - cfg.buckets[THROTTLE_OPS_READ].max =3D 0; > - cfg.buckets[THROTTLE_OPS_WRITE].max =3D 0; > + cfg.buckets[THROTTLE_BPS_TOTAL].max =3D > + qemu_opt_get_number(opts, "throttling.bps-total-max", 0); > + cfg.buckets[THROTTLE_BPS_READ].max =3D > + qemu_opt_get_number(opts, "throttling.bps-read-max", 0); > + cfg.buckets[THROTTLE_BPS_WRITE].max =3D > + qemu_opt_get_number(opts, "throttling.bps-write-max", 0); > + cfg.buckets[THROTTLE_OPS_TOTAL].max =3D > + qemu_opt_get_number(opts, "throttling.iops-total-max", 0); > + cfg.buckets[THROTTLE_OPS_READ].max =3D > + qemu_opt_get_number(opts, "throttling.iops-read-max", 0); > + cfg.buckets[THROTTLE_OPS_WRITE].max =3D > + qemu_opt_get_number(opts, "throttling.iops-write-max", 0); > =20 > cfg.op_size =3D 0; > =20 > @@ -782,6 +787,14 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInt= erfaceType block_default_type) > qemu_opt_rename(all_opts, "bps_rd", "throttling.bps-read"); > qemu_opt_rename(all_opts, "bps_wr", "throttling.bps-write"); > =20 > + qemu_opt_rename(all_opts, "iops_max", "throttling.iops-total-max")= ; > + qemu_opt_rename(all_opts, "iops_rd_max", "throttling.iops-read-max= "); > + qemu_opt_rename(all_opts, "iops_wr_max", "throttling.iops-write-ma= x"); > + > + qemu_opt_rename(all_opts, "bps_max", "throttling.bps-total-max"); > + qemu_opt_rename(all_opts, "bps_rd_max", "throttling.bps-read-max")= ; > + qemu_opt_rename(all_opts, "bps_wr_max", "throttling.bps-write-max"= ); > + > qemu_opt_rename(all_opts, "readonly", "read-only"); > =20 > value =3D qemu_opt_get(all_opts, "cache"); > @@ -1266,8 +1279,22 @@ void qmp_change_blockdev(const char *device, con= st char *filename, > =20 > /* throttling disk I/O limits */ > void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_= t bps_rd, > - int64_t bps_wr, int64_t iops, int64_t i= ops_rd, > - int64_t iops_wr, Error **errp) > + int64_t bps_wr, > + int64_t iops, > + int64_t iops_rd, > + int64_t iops_wr, > + bool has_bps_max, > + int64_t bps_max, > + bool has_bps_rd_max, > + int64_t bps_rd_max, > + bool has_bps_wr_max, > + int64_t bps_wr_max, > + bool has_iops_max, > + int64_t iops_max, > + bool has_iops_rd_max, > + int64_t iops_rd_max, > + bool has_iops_wr_max, > + int64_t iops_wr_max, Error **errp) > { > ThrottleConfig cfg; > BlockDriverState *bs; > @@ -1287,13 +1314,24 @@ void qmp_block_set_io_throttle(const char *devi= ce, int64_t bps, int64_t bps_rd, > cfg.buckets[THROTTLE_OPS_READ].avg =3D iops_rd; > cfg.buckets[THROTTLE_OPS_WRITE].avg =3D iops_wr; > =20 > - cfg.buckets[THROTTLE_BPS_TOTAL].max =3D 0; > - cfg.buckets[THROTTLE_BPS_READ].max =3D 0; > - cfg.buckets[THROTTLE_BPS_WRITE].max =3D 0; > - > - cfg.buckets[THROTTLE_OPS_TOTAL].max =3D 0; > - cfg.buckets[THROTTLE_OPS_READ].max =3D 0; > - cfg.buckets[THROTTLE_OPS_WRITE].max =3D 0; > + if (has_bps_max) { > + cfg.buckets[THROTTLE_BPS_TOTAL].max =3D bps_max; > + } > + if (has_bps_rd_max) { > + cfg.buckets[THROTTLE_BPS_READ].max =3D bps_rd_max; > + } > + if (has_bps_wr_max) { > + cfg.buckets[THROTTLE_BPS_WRITE].max =3D bps_wr_max; > + } > + if (has_iops_max) { > + cfg.buckets[THROTTLE_OPS_TOTAL].max =3D iops_max; > + } > + if (has_iops_rd_max) { > + cfg.buckets[THROTTLE_OPS_READ].max =3D iops_rd_max; > + } > + if (has_iops_wr_max) { > + cfg.buckets[THROTTLE_OPS_WRITE].max =3D iops_wr_max; > + } > =20 > cfg.op_size =3D 0; > =20 > @@ -1997,6 +2035,30 @@ QemuOptsList qemu_common_drive_opts =3D { > .type =3D QEMU_OPT_NUMBER, > .help =3D "limit write bytes per second", > },{ > + .name =3D "throttling.iops-total-max", > + .type =3D QEMU_OPT_NUMBER, > + .help =3D "I/O operations burst", > + },{ > + .name =3D "throttling.iops-read-max", > + .type =3D QEMU_OPT_NUMBER, > + .help =3D "I/O operations read burst", > + },{ > + .name =3D "throttling.iops-write-max", > + .type =3D QEMU_OPT_NUMBER, > + .help =3D "I/O operations write burst", > + },{ > + .name =3D "throttling.bps-total-max", > + .type =3D QEMU_OPT_NUMBER, > + .help =3D "total bytes burst", > + },{ > + .name =3D "throttling.bps-read-max", > + .type =3D QEMU_OPT_NUMBER, > + .help =3D "total bytes read burst", > + },{ > + .name =3D "throttling.bps-write-max", > + .type =3D QEMU_OPT_NUMBER, > + .help =3D "total bytes write burst", > + },{ > .name =3D "copy-on-read", > .type =3D QEMU_OPT_BOOL, > .help =3D "copy read data from backing file into image fil= e", > @@ -2119,6 +2181,30 @@ QemuOptsList qemu_old_drive_opts =3D { > .type =3D QEMU_OPT_NUMBER, > .help =3D "limit write bytes per second", > },{ > + .name =3D "iops_max", > + .type =3D QEMU_OPT_NUMBER, > + .help =3D "I/O operations burst", > + },{ > + .name =3D "iops_rd_max", > + .type =3D QEMU_OPT_NUMBER, > + .help =3D "I/O operations read burst", > + },{ > + .name =3D "iops_wr_max", > + .type =3D QEMU_OPT_NUMBER, > + .help =3D "I/O operations write burst", > + },{ > + .name =3D "bps_max", > + .type =3D QEMU_OPT_NUMBER, > + .help =3D "total bytes burst", > + },{ > + .name =3D "bps_rd_max", > + .type =3D QEMU_OPT_NUMBER, > + .help =3D "total bytes read burst", > + },{ > + .name =3D "bps_wr_max", > + .type =3D QEMU_OPT_NUMBER, > + .help =3D "total bytes write burst", > + },{ > .name =3D "copy-on-read", > .type =3D QEMU_OPT_BOOL, > .help =3D "copy read data from backing file into image fil= e", > diff --git a/hmp.c b/hmp.c > index fcca6ae..85a6c16 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -344,14 +344,28 @@ void hmp_info_block(Monitor *mon, const QDict *qd= ict) > { > monitor_printf(mon, " I/O throttling: bps=3D%" PRId64 > " bps_rd=3D%" PRId64 " bps_wr=3D%" PRId64 > + " bps_max=3D%" PRId64 > + " bps_rd_max=3D%" PRId64 > + " bps_wr_max=3D%" PRId64 > " iops=3D%" PRId64 " iops_rd=3D%" PRId64 > - " iops_wr=3D%" PRId64 "\n", > + " iops_wr=3D%" PRId64 > + " iops_max=3D%" PRId64 > + " iops_rd_max=3D%" PRId64 > + " iops_wr_max=3D%" PRId64 "\n", > info->value->inserted->bps, > info->value->inserted->bps_rd, > info->value->inserted->bps_wr, > + info->value->inserted->bps_max, > + info->value->inserted->bps_rd_max, > + info->value->inserted->bps_wr_max, > info->value->inserted->iops, > info->value->inserted->iops_rd, > - info->value->inserted->iops_wr); > + info->value->inserted->iops_wr, > + info->value->inserted->iops_max, > + info->value->inserted->iops_rd_max, > + info->value->inserted->iops_wr_max); > + } else { > + monitor_printf(mon, " [not inserted]"); > } > =20 > if (verbose) { > @@ -1098,7 +1112,19 @@ void hmp_block_set_io_throttle(Monitor *mon, con= st QDict *qdict) > qdict_get_int(qdict, "bps_wr"), > qdict_get_int(qdict, "iops"), > qdict_get_int(qdict, "iops_rd"), > - qdict_get_int(qdict, "iops_wr"), &err); > + qdict_get_int(qdict, "iops_wr"), > + false, /* no burst max via HMP */ > + 0, > + false, > + 0, > + false, > + 0, > + false, > + 0, > + false, > + 0, > + false, > + 0, &err); > hmp_handle_error(mon, &err); > } > =20 > diff --git a/qapi-schema.json b/qapi-schema.json > index a51f7d2..5e5461e 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -785,6 +785,18 @@ > # > # @image: the info of image used (since: 1.6) > # > +# @bps_max: #optional total max in bytes (Since 1.7) > +# > +# @bps_rd_max: #optional read max in bytes (Since 1.7) > +# > +# @bps_wr_max: #optional write max in bytes (Since 1.7) > +# > +# @iops_max: #optional total I/O operations max (Since 1.7) > +# > +# @iops_rd_max: #optional read I/O operations max (Since 1.7) > +# > +# @iops_wr_max: #optional write I/O operations max (Since 1.7) > +# > # Since: 0.14.0 > # > # Notes: This interface is only found in @BlockInfo. > @@ -795,7 +807,10 @@ > 'encrypted': 'bool', 'encryption_key_missing': 'bool', > 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int', > 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', > - 'image': 'ImageInfo' } } > + 'image': 'ImageInfo', > + '*bps_max': 'int', '*bps_rd_max': 'int', > + '*bps_wr_max': 'int', '*iops_max': 'int', > + '*iops_rd_max': 'int', '*iops_wr_max': 'int' }} Please be consistent with brace spaceing: s/}}/} }/ > =20 > ## > # @BlockDeviceIoStatus: > @@ -2174,6 +2189,18 @@ > # > # @iops_wr: write I/O operations per second > # > +# @bps_max: #optional total max in bytes (Since 1.7) > +# > +# @bps_rd_max: #optional read max in bytes (Since 1.7) > +# > +# @bps_wr_max: #optional write max in bytes (Since 1.7) > +# > +# @iops_max: #optional total I/O operations max (Since 1.7) > +# > +# @iops_rd_max: #optional read I/O operations max (Since 1.7) > +# > +# @iops_wr_max: #optional write I/O operations max (Since 1.7) > +# > # Returns: Nothing on success > # If @device is not a valid block device, DeviceNotFound > # > @@ -2181,7 +2208,10 @@ > ## > { 'command': 'block_set_io_throttle', > 'data': { 'device': 'str', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': = 'int', > - 'iops': 'int', 'iops_rd': 'int', 'iops_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' }} Please be consistent with brace spaceing: s/}}/} }/ > =20 > ## > # @block-stream: > diff --git a/qemu-options.hx b/qemu-options.hx > index d15338e..8df7f1f 100644 > --- a/qemu-options.hx > +++ b/qemu-options.hx > @@ -409,7 +409,9 @@ DEF("drive", HAS_ARG, QEMU_OPTION_drive, > " [,cache=3Dwritethrough|writeback|none|directsync|unsafe][,= format=3Df]\n" > " [,serial=3Ds][,addr=3DA][,id=3Dname][,aio=3Dthreads|native= ]\n" > " [,readonly=3Don|off][,copy-on-read=3Don|off]\n" > - " [[,bps=3Db]|[[,bps_rd=3Dr][,bps_wr=3Dw]]][[,iops=3Di]|[[,i= ops_rd=3Dr][,iops_wr=3Dw]]\n" > + " [[,bps=3Db]|[[,bps_rd=3Dr][,bps_wr=3Dw]]][[,iops=3Di]|[[,i= ops_rd=3Dr]\n" > + " [,iops_wr=3Dw][,bps_max=3Dbm]|[[,bps_rd_max=3Drm][,bps_wr= _max=3Dwm]]]\n" > + " [[,iops_max=3Dim]|[[,iops_rd_max=3Dirm][,iops_wr_max=3Diwm= ]]\n" The brackets don't match here, let's expand and indent it to see what's here: [ [,bps=3Db] | [ [,bps_rd=3Dr] [,bps_wr=3Dw] ] ] [ [,iops=3Di] | [ [,iops_rd=3Dr] [,iops_wr=3Dw] [,bps_max=3Dbm] | [ [,bps_rd_max=3Drm] [,bps_wr_max=3Dwm] ] ] [ [,iops_max=3Dim] | [ [,iops_rd_max=3Dirm] [,iops_wr_max=3Diwm] ]\n" Mismatch here, right? And I think you wanted to move bps_max* group to ou= tmost. > " use 'file' as a drive image\n", QEMU_ARCH_ALL) > STEXI > @item -drive @var{option}[,@var{option}[,@var{option}[,...]]] > diff --git a/qmp-commands.hx b/qmp-commands.hx > index cf93d9b..a10d82b 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -1389,7 +1389,7 @@ EQMP > =20 > { > .name =3D "block_set_io_throttle", > - .args_type =3D "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_= rd:l,iops_wr:l", > + .args_type =3D "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_= rd:l,iops_wr:l,bps_max:l?,bps_rd_max:l?,bps_wr_max:l?,iops_max:l?,iops_rd= _max:l?,iops_wr_max:l?", Too long, wrap this line? > .mhandler.cmd_new =3D qmp_marshal_input_block_set_io_throttle, > }, > =20 > @@ -1408,6 +1408,12 @@ Arguments: > - "iops": total I/O operations per second (json-int) > - "iops_rd": read I/O operations per second (json-int) > - "iops_wr": write I/O operations per second (json-int) > +- "bps_max": total max in bytes (json-int) > +- "bps_rd_max": read max in bytes (json-int) > +- "bps_wr_max": write max in bytes (json-int) > +- "iops_max": total I/O operations max (json-int) > +- "iops_rd_max": read I/O operations max (json-int) > +- "iops_wr_max": write I/O operations max (json-int) > =20 > Example: > =20 > @@ -1417,7 +1423,13 @@ Example: > "bps_wr": 0, > "iops": 0, > "iops_rd": 0, > - "iops_wr": 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 }=A0} OK, good brace spacing. > <- { "return": {} } > =20 > EQMP > @@ -1758,6 +1770,12 @@ Each json-object contain the following: > - "iops": limit total I/O operations per second (json-int) > - "iops_rd": limit read operations per second (json-int) > - "iops_wr": limit write operations per second (json-int) > + - "bps_max": total max in bytes (json-int) > + - "bps_rd_max": read max in bytes (json-int) > + - "bps_wr_max": write max in bytes (json-int) > + - "iops_max": total I/O operations max (json-int) > + - "iops_rd_max": read I/O operations max (json-int) > + - "iops_wr_max": write I/O operations max (json-int) > - "image": the detail of the image, it is a json-object conta= ining > the following: > - "filename": image file name (json-string) > @@ -1827,6 +1845,12 @@ Example: > "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, > "image":{ > "filename":"disks/test.qcow2", > "format":"qcow2", > --=20 > 1.7.10.4 >=20 >=20