From patchwork Thu Sep 14 10:40:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pradeep Jagadeesh X-Patchwork-Id: 813769 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mmancngt"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xtFSq2CzFz9sDB for ; Thu, 14 Sep 2017 20:41:31 +1000 (AEST) Received: from localhost ([::1]:46867 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRaL-0006u8-Bz for incoming@patchwork.ozlabs.org; Thu, 14 Sep 2017 06:41:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRZi-0006pz-15 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsRZd-0001xp-OK for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:50 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:37356) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dsRZd-0001wd-DV for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:45 -0400 Received: by mail-wr0-x244.google.com with SMTP id u48so1465652wrf.4 for ; Thu, 14 Sep 2017 03:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=D8G1QRbFFpH0lZ2paMxJ5yLCN5Sk1RphI2r5zE6ycjY=; b=mmancngt8wxn4gzZn6jEqdkYdAD/4fjB9GXztfBRyQISXAgDGjhkEVdM3ADgPrilYK aO7cr1vfCWQCFUT3zE++D8r0+iQuFABstpBOWpjSNZTBByw105QWfeGInhA6giSN1zfr 4vbTuy83NJGU/zchIseNQfXF9MOMVWQzdLeWy8AnIok5PwWiNEjbmOi6Z5qISQrRnoH+ nn3OSqdMnBRtOxsPdnaUA1CDpX2imRz9tNwY4nbIEi7jE6foFES0aTNlE6yFwgwoIkI2 EofK5ZEzdy2UtT6YqZdsRkuut2HqMEq1l6ZBFEZvog4qy9Vj6C+FUPjDJRE2hitOHbt8 3sDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=D8G1QRbFFpH0lZ2paMxJ5yLCN5Sk1RphI2r5zE6ycjY=; b=rxfhp+7c1MeRLZU240UHIs1X89TWuZo27i4LsxOxfJoz39eTc/2Ndy1am8CA4lkZCx 6WKNpKwg6qCDxrR+E+tGUOnxxFjwHhgXfr1i2scVdSWO0870QbJR+PU4u6py+5vgQiR5 gKGEyyYoXhetj9NxSpg75NZhlVidYxBiLOkoTSwUTjqcebGQ5bQoOkb8V3Ck8PxOmQZ/ +vPaizamkB88bl4ZzPIlLEs4WonX5G+cDeQiL0vcGkgYrJvx0HEV6UOCUWFpi4rbMDub 6aj+gkPrpiTzCVAoD9oIbkn74qd1SplcTfb6ZaPb2qzLL/XVABDbIzewBUKyXcsTeAmx 9Bjw== X-Gm-Message-State: AHPjjUhoQNkY2fBXc+GTiJKyxKxj9hyz/QOlFE7VU5mJp9kp9xa0ejK8 0shR4XihZQ9+Gg== X-Google-Smtp-Source: ADKCNb4dG2ZoDsZqq7Gw1NQqkbbUheuVAaNBHQd1UmJh+JxObulCFGV2AunBX9yJGThMEgTWQqxWxA== X-Received: by 10.223.136.170 with SMTP id f39mr17693803wrf.164.1505385644286; Thu, 14 Sep 2017 03:40:44 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id w14sm742801wmf.13.2017.09.14.03.40.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 03:40:43 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Thu, 14 Sep 2017 06:40:07 -0400 Message-Id: <1505385610-35529-4-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1505385610-35529-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1505385610-35529-1-git-send-email-pradeep.jagadeesh@huawei.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PATCH v11 3/6] qmp: factor out throttle code to reuse code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, jani kokkonen , alberto garcia , Pradeep Jagadeesh , Markus Armbruster Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch reuses the code to set throttle limits. Signed-off-by: Pradeep Jagadeesh Reviewed-by: Alberto Garcia Reviewed-by: Greg Kurz --- blockdev.c | 53 +++-------------------------------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/blockdev.c b/blockdev.c index 9d33c25..2bd8ebd 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2569,6 +2569,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp) BlockDriverState *bs; BlockBackend *blk; AioContext *aio_context; + ThrottleLimits *tlimit; blk = qmp_get_blk(arg->has_device ? arg->device : NULL, arg->has_id ? arg->id : NULL, @@ -2586,56 +2587,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; - } + tlimit = qapi_BlockIOThrottle_base(arg); + throttle_config_to_limits(&cfg, tlimit); if (!throttle_is_valid(&cfg, errp)) { goto out;