From patchwork Fri Sep 22 12:03:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pradeep X-Patchwork-Id: 9965905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6F04C600C5 for ; Fri, 22 Sep 2017 12:10:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EFD8298B0 for ; Fri, 22 Sep 2017 12:10:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4405B29893; Fri, 22 Sep 2017 12:10:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8E8CF29893 for ; Fri, 22 Sep 2017 12:10:22 +0000 (UTC) Received: from localhost ([::1]:58503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvMmj-00023O-CV for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 Sep 2017 08:10:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvMh1-0006Nx-68 for qemu-devel@nongnu.org; Fri, 22 Sep 2017 08:04:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvMgv-0004u2-IT for qemu-devel@nongnu.org; Fri, 22 Sep 2017 08:04:27 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:35713) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dvMgv-0004ti-CO for qemu-devel@nongnu.org; Fri, 22 Sep 2017 08:04:21 -0400 Received: by mail-wm0-x242.google.com with SMTP id e64so1097408wmi.2 for ; Fri, 22 Sep 2017 05:04:21 -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=o/kvcto0K7JXFczEainATeD5VGebWAzgYd7vYinFwD8=; b=pcBqOq0b+dWOL76BEtXK2E1QXkb4q1eu7YDEokQEvOj4o12cse6nAt+0DBUqnxtHzo 3D7xtI5DgKrcgJIUEDHBef0ITT90QOPlmFM6YNClzbxEWfVqRl7naHdm/oSnuNTYp+gy JO17BJJDheGCzKQQ0ECyoB2aU6tz5mLpz2b5HIQtMx4AgmCNvEaF4KcV2+JoKg5DVxnr 9Ej2fGlrW6wu3iQX4/HxixsTR/ZXWQKDvs/WWVNYfv6jKdiWUwKg9VgHg2E1e4UMrwbw vlGiPLWaxN5SjwuXXzKhJ3eBBGTeYNKP3jDMD2zQuERs1jBFmpTd2Kt/6o3vXCobhTls 6zsw== 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=o/kvcto0K7JXFczEainATeD5VGebWAzgYd7vYinFwD8=; b=j7IrPL1qKmXVkuFcHGgihw95XIfArZq9B205qw+sjopQBr5o9JgoZDyC+NQ+CQR15p U/PxDYaUM2MQfSV6T+AeCTYnNsXE8EJsV1Cfna6Hx9ppUJB5nb0Ol5TVupvP03++kob3 DL+9OBGWfoSNYaTTKqEnjSCLCjumTzLqt+8jufCP/XBPYt/EBjGlHTnMpUU8Mzf3mL6m xyc8WphsIfRtCBkXZaJoEZMrOeGIzCb9mJj3XXgdzvcci+6F18W7/3SaV1HdhFXrNXPR Fo1rD3k/Zml7UFw6k0BYtFvedZaldmsaxRGlC3KZBm4hQXgUL3PyZY3Q/X7zWX+WRHaK FIRw== X-Gm-Message-State: AHPjjUikwdJDeNN+Aezcpv/iyDFlzHsRDnGF4qeNYvao1/PgFX1UfTnL DJEXxWIat9CmdtH69FlroIs= X-Google-Smtp-Source: AOwi7QCtVvdxVjncGehCDxoBQ8akMcNlL+ec0bZxjdYIM4NqKi6ePd7mnrbVjGTL4rvNBhfnPozryQ== X-Received: by 10.28.66.202 with SMTP id k71mr3694982wmi.19.1506081860270; Fri, 22 Sep 2017 05:04:20 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id v78sm2567133wmv.48.2017.09.22.05.04.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 05:04:19 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Fri, 22 Sep 2017 08:03:42 -0400 Message-Id: <1506081825-14209-4-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1506081825-14209-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1506081825-14209-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:c09::242 Subject: [Qemu-devel] [PATCH v12 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch reuses the code to set throttle limits. Signed-off-by: Pradeep Jagadeesh --- 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;