From patchwork Thu Feb 9 03:32:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 140305 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 724C9B6EE7 for ; Thu, 9 Feb 2012 14:29:02 +1100 (EST) Received: from localhost ([::1]:45233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvKgr-0003xd-Dl for incoming@patchwork.ozlabs.org; Wed, 08 Feb 2012 22:28:57 -0500 Received: from eggs.gnu.org ([140.186.70.92]:39875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvKgk-0003xM-V6 for qemu-devel@nongnu.org; Wed, 08 Feb 2012 22:28:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvKgj-0002jw-BC for qemu-devel@nongnu.org; Wed, 08 Feb 2012 22:28:50 -0500 Received: from [222.73.24.84] (port=63503 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvKgi-0002cf-8A for qemu-devel@nongnu.org; Wed, 08 Feb 2012 22:28:49 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 61E5917012B; Thu, 9 Feb 2012 11:28:47 +0800 (CST) Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id q193Sici000747; Thu, 9 Feb 2012 11:28:45 +0800 Received: from [10.167.225.226] ([10.167.225.226]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2012020911271587-577008 ; Thu, 9 Feb 2012 11:27:15 +0800 Message-ID: <4F333E36.1050602@cn.fujitsu.com> Date: Thu, 09 Feb 2012 11:32:06 +0800 From: Wen Congyang User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100413 Fedora/3.0.4-2.fc13 Thunderbird/3.0.4 MIME-Version: 1.0 To: qemu-devel , Jan Kiszka , Dave Anderson , HATAYAMA Daisuke , Luiz Capitulino , Eric Blake References: <4F333AAA.1070601@cn.fujitsu.com> In-Reply-To: <4F333AAA.1070601@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2012-02-09 11:27:15, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2012-02-09 11:27:18, Serialize complete at 2012-02-09 11:27:18 X-detected-operating-system: by eggs.gnu.org: FreeBSD 6.x (1) X-Received-From: 222.73.24.84 Subject: [Qemu-devel] [RFC][PATCH 13/16 v6] support to set dumping speed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add API to allow the user to control dumping speed Signed-off-by: Wen Congyang --- dump.c | 12 ++++++++++++ hmp-commands.hx | 15 +++++++++++++++ hmp.c | 6 ++++++ hmp.h | 1 + qapi-schema.json | 15 +++++++++++++++ qmp-commands.hx | 22 ++++++++++++++++++++++ 6 files changed, 71 insertions(+), 0 deletions(-) diff --git a/dump.c b/dump.c index cea4c8c..9f0aceb 100644 --- a/dump.c +++ b/dump.c @@ -86,6 +86,7 @@ typedef struct DumpState { } DumpState; #define DEFAULT_THROTTLE (32 << 20) /* Default dump speed throttling */ +#define MIN_THROTTLE (1 << 10) /* Miniumum dump speed */ static DumpState *dump_get_current(void) { @@ -722,3 +723,14 @@ void qmp_dump_cancel(Error **errp) dump_cleanup(s); return; } + +void qmp_dump_set_speed(int64_t value, Error **errp) +{ + DumpState *s = dump_get_current(); + + if (value < MIN_THROTTLE) { + value = MIN_THROTTLE; + } + s->bandwidth = value; + return; +} diff --git a/hmp-commands.hx b/hmp-commands.hx index d0f3485..407bd06 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -897,6 +897,21 @@ Cancel the current VM dumping. ETEXI { + .name = "dump_set_speed", + .args_type = "value:o", + .params = "value", + .help = "set maximum speed (in bytes) for dumping. " + "Defaults to MB if no size suffix is specified, ie. B/K/M/G/T", + .mhandler.cmd = hmp_dump_set_speed, + }, + +STEXI +@item dump_set_speed @var{value} +@findex dump_set_speed +Set maximum speed to @var{value} (in bytes) for dumping. +ETEXI + + { .name = "snapshot_blkdev", .args_type = "device:B,snapshot-file:s?,format:s?", .params = "device [new-image-file] [format]", diff --git a/hmp.c b/hmp.c index 3865032..de70690 100644 --- a/hmp.c +++ b/hmp.c @@ -866,3 +866,9 @@ void hmp_dump_cancel(Monitor *mon, const QDict *qdict) { qmp_dump_cancel(NULL); } + +void hmp_dump_set_speed(Monitor *mon, const QDict *qdict) +{ + int64_t value = qdict_get_int(qdict, "value"); + qmp_dump_set_speed(value, NULL); +} diff --git a/hmp.h b/hmp.h index c712f63..8de4aff 100644 --- a/hmp.h +++ b/hmp.h @@ -60,5 +60,6 @@ void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict); void hmp_block_job_cancel(Monitor *mon, const QDict *qdict); void hmp_dump(Monitor *mon, const QDict *qdict); void hmp_dump_cancel(Monitor *mon, const QDict *qdict); +void hmp_dump_set_speed(Monitor *mon, const QDict *qdict); #endif diff --git a/qapi-schema.json b/qapi-schema.json index e5fd056..472eac0 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1609,3 +1609,18 @@ # Since: 1.1 ## { 'command': 'dump_cancel' } + +## +# @dump_set_speed +# +# Set maximum speed for dumping. +# +# @value: maximum speed in bytes. +# +# Returns: nothing on success +# +# Notes: A value lesser than 1024 will be automatically round up to 1024. +# +# Since: 1.1 +## +{ 'command': 'dump_set_speed', 'data': { 'value': 'int' } } diff --git a/qmp-commands.hx b/qmp-commands.hx index c09ca86..73cef06 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -614,6 +614,28 @@ Example: EQMP { + .name = "dump_set_speed", + .args_type = "value:o", + .mhandler.cmd_new = qmp_marshal_input_dump_set_speed, + }, + +SQMP +dump_set_speed + +Set maximum speed for dumping. + +Arguments: + +- "value": maximum speed, in bytes per second (json-int) + +Example: + +-> { "execute": "dump_set_speed", "arguments": { "value": 1024 } } +<- { "return": {} } + +EQMP + + { .name = "netdev_add", .args_type = "netdev:O", .params = "[user|tap|socket],id=str[,prop=value][,...]",