{"id":817458,"url":"http://patchwork.ozlabs.org/api/patches/817458/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1506081825-14209-4-git-send-email-pradeep.jagadeesh@huawei.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1506081825-14209-4-git-send-email-pradeep.jagadeesh@huawei.com>","list_archive_url":null,"date":"2017-09-22T12:03:42","name":"[v12,3/6] qmp: factor out throttle code to reuse code","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"50f77cd172f6c1280ae6e1aa007edb8701bfa6f8","submitter":{"id":69852,"url":"http://patchwork.ozlabs.org/api/people/69852/?format=json","name":"Pradeep Jagadeesh","email":"pradeepkiruvale@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1506081825-14209-4-git-send-email-pradeep.jagadeesh@huawei.com/mbox/","series":[{"id":4607,"url":"http://patchwork.ozlabs.org/api/series/4607/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=4607","date":"2017-09-22T12:03:39","name":"fsdev: qmp interface for io throttling","version":12,"mbox":"http://patchwork.ozlabs.org/series/4607/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/817458/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/817458/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"pcBqOq0b\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xzC313ZkPz9sPm\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 22 Sep 2017 22:09:49 +1000 (AEST)","from localhost ([::1]:58503 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dvMmB-00023O-HA\n\tfor incoming@patchwork.ozlabs.org; Fri, 22 Sep 2017 08:09:47 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:46792)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pradeepkiruvale@gmail.com>) id 1dvMh1-0006Nx-68\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 08:04:31 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pradeepkiruvale@gmail.com>) id 1dvMgv-0004u2-IT\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 08:04:27 -0400","from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:35713)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <pradeepkiruvale@gmail.com>)\n\tid 1dvMgv-0004ti-CO\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 08:04:21 -0400","by mail-wm0-x242.google.com with SMTP id e64so1097408wmi.2\n\tfor <qemu-devel@nongnu.org>; Fri, 22 Sep 2017 05:04:21 -0700 (PDT)","from localhost.localdomain.localdomain ([217.110.131.66])\n\tby smtp.gmail.com with ESMTPSA id\n\tv78sm2567133wmv.48.2017.09.22.05.04.19\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 22 Sep 2017 05:04:19 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=o/kvcto0K7JXFczEainATeD5VGebWAzgYd7vYinFwD8=;\n\tb=pcBqOq0b+dWOL76BEtXK2E1QXkb4q1eu7YDEokQEvOj4o12cse6nAt+0DBUqnxtHzo\n\t3D7xtI5DgKrcgJIUEDHBef0ITT90QOPlmFM6YNClzbxEWfVqRl7naHdm/oSnuNTYp+gy\n\tJO17BJJDheGCzKQQ0ECyoB2aU6tz5mLpz2b5HIQtMx4AgmCNvEaF4KcV2+JoKg5DVxnr\n\t9Ej2fGlrW6wu3iQX4/HxixsTR/ZXWQKDvs/WWVNYfv6jKdiWUwKg9VgHg2E1e4UMrwbw\n\tvlGiPLWaxN5SjwuXXzKhJ3eBBGTeYNKP3jDMD2zQuERs1jBFmpTd2Kt/6o3vXCobhTls\n\t6zsw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=o/kvcto0K7JXFczEainATeD5VGebWAzgYd7vYinFwD8=;\n\tb=j7IrPL1qKmXVkuFcHGgihw95XIfArZq9B205qw+sjopQBr5o9JgoZDyC+NQ+CQR15p\n\tU/PxDYaUM2MQfSV6T+AeCTYnNsXE8EJsV1Cfna6Hx9ppUJB5nb0Ol5TVupvP03++kob3\n\tDL+9OBGWfoSNYaTTKqEnjSCLCjumTzLqt+8jufCP/XBPYt/EBjGlHTnMpUU8Mzf3mL6m\n\txyc8WphsIfRtCBkXZaJoEZMrOeGIzCb9mJj3XXgdzvcci+6F18W7/3SaV1HdhFXrNXPR\n\tFo1rD3k/Zml7UFw6k0BYtFvedZaldmsaxRGlC3KZBm4hQXgUL3PyZY3Q/X7zWX+WRHaK\n\tFIRw==","X-Gm-Message-State":"AHPjjUikwdJDeNN+Aezcpv/iyDFlzHsRDnGF4qeNYvao1/PgFX1UfTnL\n\tDJEXxWIat9CmdtH69FlroIs=","X-Google-Smtp-Source":"AOwi7QCtVvdxVjncGehCDxoBQ8akMcNlL+ec0bZxjdYIM4NqKi6ePd7mnrbVjGTL4rvNBhfnPozryQ==","X-Received":"by 10.28.66.202 with SMTP id k71mr3694982wmi.19.1506081860270;\n\tFri, 22 Sep 2017 05:04:20 -0700 (PDT)","From":"Pradeep Jagadeesh <pradeepkiruvale@gmail.com>","X-Google-Original-From":"Pradeep Jagadeesh <pradeep.jagadeesh@huawei.com>","To":"\"eric blake\" <eblake@redhat.com>,\n\t\"greg kurz\" <groug@kaod.org>","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\n\trecognized.","X-Received-From":"2a00:1450:400c:c09::242","Subject":"[Qemu-devel] [PATCH v12 3/6] qmp: factor out throttle code to reuse\n\tcode","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"qemu-devel@nongnu.org, jani kokkonen <jani.kokkonen@huawei.com>,\n\talberto garcia <berto@igalia.com>,\n\tPradeep Jagadeesh <pradeep.jagadeesh@huawei.com>,\n\tMarkus Armbruster <armbru@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"This patch reuses the code to set throttle limits.\n\nSigned-off-by: Pradeep Jagadeesh <pradeep.jagadeesh@huawei.com>\n---\n blockdev.c | 53 +++--------------------------------------------------\n 1 file changed, 3 insertions(+), 50 deletions(-)","diff":"diff --git a/blockdev.c b/blockdev.c\nindex 9d33c25..2bd8ebd 100644\n--- a/blockdev.c\n+++ b/blockdev.c\n@@ -2569,6 +2569,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)\n     BlockDriverState *bs;\n     BlockBackend *blk;\n     AioContext *aio_context;\n+    ThrottleLimits *tlimit;\n \n     blk = qmp_get_blk(arg->has_device ? arg->device : NULL,\n                       arg->has_id ? arg->id : NULL,\n@@ -2586,56 +2587,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)\n         goto out;\n     }\n \n-    throttle_config_init(&cfg);\n-    cfg.buckets[THROTTLE_BPS_TOTAL].avg = arg->bps;\n-    cfg.buckets[THROTTLE_BPS_READ].avg  = arg->bps_rd;\n-    cfg.buckets[THROTTLE_BPS_WRITE].avg = arg->bps_wr;\n-\n-    cfg.buckets[THROTTLE_OPS_TOTAL].avg = arg->iops;\n-    cfg.buckets[THROTTLE_OPS_READ].avg  = arg->iops_rd;\n-    cfg.buckets[THROTTLE_OPS_WRITE].avg = arg->iops_wr;\n-\n-    if (arg->has_bps_max) {\n-        cfg.buckets[THROTTLE_BPS_TOTAL].max = arg->bps_max;\n-    }\n-    if (arg->has_bps_rd_max) {\n-        cfg.buckets[THROTTLE_BPS_READ].max = arg->bps_rd_max;\n-    }\n-    if (arg->has_bps_wr_max) {\n-        cfg.buckets[THROTTLE_BPS_WRITE].max = arg->bps_wr_max;\n-    }\n-    if (arg->has_iops_max) {\n-        cfg.buckets[THROTTLE_OPS_TOTAL].max = arg->iops_max;\n-    }\n-    if (arg->has_iops_rd_max) {\n-        cfg.buckets[THROTTLE_OPS_READ].max = arg->iops_rd_max;\n-    }\n-    if (arg->has_iops_wr_max) {\n-        cfg.buckets[THROTTLE_OPS_WRITE].max = arg->iops_wr_max;\n-    }\n-\n-    if (arg->has_bps_max_length) {\n-        cfg.buckets[THROTTLE_BPS_TOTAL].burst_length = arg->bps_max_length;\n-    }\n-    if (arg->has_bps_rd_max_length) {\n-        cfg.buckets[THROTTLE_BPS_READ].burst_length = arg->bps_rd_max_length;\n-    }\n-    if (arg->has_bps_wr_max_length) {\n-        cfg.buckets[THROTTLE_BPS_WRITE].burst_length = arg->bps_wr_max_length;\n-    }\n-    if (arg->has_iops_max_length) {\n-        cfg.buckets[THROTTLE_OPS_TOTAL].burst_length = arg->iops_max_length;\n-    }\n-    if (arg->has_iops_rd_max_length) {\n-        cfg.buckets[THROTTLE_OPS_READ].burst_length = arg->iops_rd_max_length;\n-    }\n-    if (arg->has_iops_wr_max_length) {\n-        cfg.buckets[THROTTLE_OPS_WRITE].burst_length = arg->iops_wr_max_length;\n-    }\n-\n-    if (arg->has_iops_size) {\n-        cfg.op_size = arg->iops_size;\n-    }\n+    tlimit = qapi_BlockIOThrottle_base(arg);\n+    throttle_config_to_limits(&cfg, tlimit);\n \n     if (!throttle_is_valid(&cfg, errp)) {\n         goto out;\n","prefixes":["v12","3/6"]}