From patchwork Tue Sep 6 10:48:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhi Yong Wu X-Patchwork-Id: 1125962 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p86AooCn006819 for ; Tue, 6 Sep 2011 10:50:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754199Ab1IFKuj (ORCPT ); Tue, 6 Sep 2011 06:50:39 -0400 Received: from e38.co.us.ibm.com ([32.97.110.159]:56430 "EHLO e38.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754232Ab1IFKuf (ORCPT ); Tue, 6 Sep 2011 06:50:35 -0400 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e38.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p86AgaQN014490 for ; Tue, 6 Sep 2011 04:42:36 -0600 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p86AoWj0187604 for ; Tue, 6 Sep 2011 04:50:32 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p864oTOM004445 for ; Mon, 5 Sep 2011 22:50:30 -0600 Received: from us.ibm.com ([9.115.118.38]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id p864oPaF003141; Mon, 5 Sep 2011 22:50:26 -0600 Received: by us.ibm.com (sSMTP sendmail emulation); Tue, 6 Sep 2011 18:49:59 +0800 From: Zhi Yong Wu To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, stefanha@linux.vnet.ibm.com, mtosatti@redhat.com, aliguori@us.ibm.com, ryanh@us.ibm.com, zwu.kernel@gmail.com, kwolf@redhat.com, pair@us.ibm.com, Zhi Yong Wu Subject: [PATCH v7 4/4] qmp/hmp: add block_set_io_throttle Date: Tue, 6 Sep 2011 18:48:21 +0800 Message-Id: <1315306101-3129-5-git-send-email-wuzhy@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1315306101-3129-1-git-send-email-wuzhy@linux.vnet.ibm.com> References: <1315306101-3129-1-git-send-email-wuzhy@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 06 Sep 2011 10:50:51 +0000 (UTC) The patch introduce one new command block_set_io_throttle; For its usage syntax, if you have better idea, pls let me know. Signed-off-by: Zhi Yong Wu --- block.c | 26 ++++++++++++++++++++++++-- hmp-commands.hx | 15 +++++++++++++++ qerror.c | 4 ++++ qerror.h | 3 +++ qmp-commands.hx | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 97 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 1f6f188..dfa5567 100644 --- a/block.c +++ b/block.c @@ -1938,6 +1938,16 @@ static void bdrv_print_dict(QObject *obj, void *opaque) qdict_get_bool(qdict, "ro"), qdict_get_str(qdict, "drv"), qdict_get_bool(qdict, "encrypted")); + + monitor_printf(mon, " bps=%" PRId64 " bps_rd=%" PRId64 + " bps_wr=%" PRId64 " iops=%" PRId64 + " iops_rd=%" PRId64 " iops_wr=%" PRId64, + qdict_get_int(qdict, "bps"), + qdict_get_int(qdict, "bps_rd"), + qdict_get_int(qdict, "bps_wr"), + qdict_get_int(qdict, "iops"), + qdict_get_int(qdict, "iops_rd"), + qdict_get_int(qdict, "iops_wr")); } else { monitor_printf(mon, " [not inserted]"); } @@ -1970,10 +1980,22 @@ void bdrv_info(Monitor *mon, QObject **ret_data) QDict *bs_dict = qobject_to_qdict(bs_obj); obj = qobject_from_jsonf("{ 'file': %s, 'ro': %i, 'drv': %s, " - "'encrypted': %i }", + "'encrypted': %i, " + "'bps': %" PRId64 "," + "'bps_rd': %" PRId64 "," + "'bps_wr': %" PRId64 "," + "'iops': %" PRId64 "," + "'iops_rd': %" PRId64 "," + "'iops_wr': %" PRId64 "}", bs->filename, bs->read_only, bs->drv->format_name, - bdrv_is_encrypted(bs)); + bdrv_is_encrypted(bs), + bs->io_limits.bps[BLOCK_IO_LIMIT_TOTAL], + bs->io_limits.bps[BLOCK_IO_LIMIT_READ], + bs->io_limits.bps[BLOCK_IO_LIMIT_WRITE], + bs->io_limits.iops[BLOCK_IO_LIMIT_TOTAL], + bs->io_limits.iops[BLOCK_IO_LIMIT_READ], + bs->io_limits.iops[BLOCK_IO_LIMIT_WRITE]); if (bs->backing_file[0] != '\0') { QDict *qdict = qobject_to_qdict(obj); qdict_put(qdict, "backing_file", diff --git a/hmp-commands.hx b/hmp-commands.hx index 0ccfb28..147f9cf 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1210,6 +1210,21 @@ ETEXI }, STEXI +@item block_set_io_throttle @var{device} @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} +@findex block_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 = "block_set_io_throttle", + .args_type = "device:B,bps:i?,bps_rd:i?,bps_wr:i?,iops:i?,iops_rd:i?,iops_wr:i?", + .params = "device [bps] [bps_rd] [bps_wr] [iops] [iops_rd] [iops_wr]", + .help = "change I/O throttle limits for a block drive", + .user_print = monitor_user_noop, + .mhandler.cmd_new = do_block_set_io_throttle, + }, + +STEXI @item block_passwd @var{device} @var{password} @findex block_passwd Set the encrypted device @var{device} password to @var{password} diff --git a/qerror.c b/qerror.c index 3d64b80..33f9fdd 100644 --- a/qerror.c +++ b/qerror.c @@ -230,6 +230,10 @@ static const QErrorStringTable qerror_table[] = { .error_fmt = QERR_QGA_COMMAND_FAILED, .desc = "Guest agent command failed, error was '%(message)'", }, + { + .error_fmt = QERR_INVALID_PARAMETER_COMBINATION, + .desc = "Invalid paramter combination", + }, {} }; diff --git a/qerror.h b/qerror.h index 8058456..62c1df2 100644 --- a/qerror.h +++ b/qerror.h @@ -193,4 +193,7 @@ QError *qobject_to_qerror(const QObject *obj); #define QERR_QGA_COMMAND_FAILED \ "{ 'class': 'QgaCommandFailed', 'data': { 'message': %s } }" +#define QERR_INVALID_PARAMETER_COMBINATION \ + "{ 'class': 'InvalidParameterCombination', 'data': {} }" + #endif /* QERROR_H */ diff --git a/qmp-commands.hx b/qmp-commands.hx index 27cc66e..e848969 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -862,6 +862,44 @@ Example: EQMP { + .name = "block_set_io_throttle", + .args_type = "device:B,bps:i?,bps_rd:i?,bps_wr:i?,iops:i?,iops_rd:i?,iops_wr:i?", + .params = "device [bps] [bps_rd] [bps_wr] [iops] [iops_rd] [iops_wr]", + .help = "change I/O throttle limits for a block drive", + .user_print = monitor_user_noop, + .mhandler.cmd_new = do_block_set_io_throttle, + }, + +SQMP +block_set_io_throttle +------------ + +Change I/O throttle limits for a block drive. + +Arguments: + +- "device": device name (json-string) +- "bps": total throughput limit in bytes per second(json-int, optional) +- "bps_rd": read throughput limit in bytes per second(json-int, optional) +- "bps_wr": read throughput limit in bytes per second(json-int, optional) +- "iops": total I/O operations per second(json-int, optional) +- "iops_rd": read I/O operations per second(json-int, optional) +- "iops_wr": write I/O operations per second(json-int, optional) + +Example: + +-> { "execute": "block_set_io_throttle", "arguments": { "device": "virtio0", + "bps": "1000000", + "bps_rd": "0", + "bps_wr": "0", + "iops": "0", + "iops_rd": "0", + "iops_wr": "0" } } +<- { "return": {} } + +EQMP + + { .name = "set_password", .args_type = "protocol:s,password:s,connected:s?", .params = "protocol password action-if-connected", @@ -1143,6 +1181,12 @@ Each json-object contain the following: "tftp", "vdi", "vmdk", "vpc", "vvfat" - "backing_file": backing file name (json-string, optional) - "encrypted": true if encrypted, false otherwise (json-bool) + - "bps": limit total bytes per second (json-int) + - "bps_rd": limit read bytes per second (json-int) + - "bps_wr": limit write bytes per second (json-int) + - "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) Example: @@ -1157,7 +1201,13 @@ Example: "ro":false, "drv":"qcow2", "encrypted":false, - "file":"disks/test.img" + "file":"disks/vm.img", + "bps":1000000, + "bps_rd":0, + "bps_wr":0, + "iops":1000000, + "iops_rd":0, + "iops_wr":0, }, "type":"unknown" },