From patchwork Mon Aug 7 12:37:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pradeep X-Patchwork-Id: 9885299 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 4B2C5603B4 for ; Mon, 7 Aug 2017 12:41:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C96B28503 for ; Mon, 7 Aug 2017 12:41:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3179C2868C; Mon, 7 Aug 2017 12:41:10 +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 C56F128684 for ; Mon, 7 Aug 2017 12:41:09 +0000 (UTC) Received: from localhost ([::1]:37109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehLI-0005HB-VL for patchwork-qemu-devel@patchwork.kernel.org; Mon, 07 Aug 2017 08:41:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dehIZ-0003Cu-Dl for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dehIU-0002ws-H2 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:19 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:33456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dehIU-0002vt-9i for qemu-devel@nongnu.org; Mon, 07 Aug 2017 08:38:14 -0400 Received: by mail-wm0-x243.google.com with SMTP id q189so903432wmd.0 for ; Mon, 07 Aug 2017 05:38:14 -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=0A09PHsWtkbl3qVkFa3DyhICvvM1yY42z7IfzxkBSHc=; b=KK9cPYhxjoQdtK9ynLM+7C65tHNQmvzsBQBQTAAcKxRQvIcYgr1MT81m0dVMC4z4Ad 7J7xr6tsyvH+ZnEfwHfmrAaOoHdLpKdKBdGGg+6SPQRM24QAmNXbsDvdZgsYmvn4vHbb vkk3Cqg+1pTBTXLNisWNPq8D90TD4xQLqy4ADALTL8l5sjhR+0YQswpY0Za96fMX8le+ rD+VPesyEdfy3D6ibsvdAn/g9wAhSXImbsGGE6RoZDVPtsArq22oY4D4boSSh5AJmGv2 bFE+H+Djh8c0TGxTQA1GdwxN61tHtMY7ZWDZrIWWFJL56ZmvVqxPpyJ2YhyLYXYTRenO yJTA== 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=0A09PHsWtkbl3qVkFa3DyhICvvM1yY42z7IfzxkBSHc=; b=dfspQK3YbvKHim2aCureHFYLDmCXOflaP3v++7Qk7yjE1OT/NBOpZhge0JQOohwJgF 4Bn4YEECt7e+3qdF5sPEk5eTPXpsGYc5b0u7kE0c7HBuc/bVs8TLXpPzKIlZvH5eC9Q5 DRR6j3Hoy/Wt7jymr6hTd5GY2I/FfNcuIJpY7Qqf7jdYV4YtwhNmNKD31ao/avCNo6pC WbqrC3RbL9G1g58FHJVPo3q2LEUDpldo+gj4Nj25WRqTKAa6J2IPnsLMK3ZFLvw9LAIs SgFNZ8oFIP814ka3VQwaAqTFUoK/2dqMgYZ5jNALrT4R0U78T+Vq5Y6B0UqB+0297pny C28A== X-Gm-Message-State: AHYfb5jIOkDKn3/+odqr2rf/mE7JK09dpwGdKqpmZxxgq7/JkBAY8kZI gOrlTkSH5DCunQ== X-Received: by 10.28.158.148 with SMTP id h142mr578886wme.102.1502109493263; Mon, 07 Aug 2017 05:38:13 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id v23sm7004777wrd.71.2017.08.07.05.38.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 05:38:12 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Mon, 7 Aug 2017 08:37:36 -0400 Message-Id: <1502109458-31251-5-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1502109458-31251-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1502109458-31251-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::243 Subject: [Qemu-devel] [PATCH V8 4/6] hmp: create a throttle initialization function for code reusability 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 , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch creates a throttle initialization function to maximize the code reusability. The same code is also used by fsdev. Acked-by: Dr. David Alan Gilbert Signed-off-by: Pradeep Jagadeesh Reviewed-by: Alberto Garcia --- hmp.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hmp.c b/hmp.c index fd80dce..2dbfb80 100644 --- a/hmp.c +++ b/hmp.c @@ -1758,20 +1758,27 @@ void hmp_change(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } +static void hmp_initialize_io_throttle(IOThrottle *iot, const QDict *qdict) +{ + iot->bps = qdict_get_int(qdict, "bps"); + iot->bps_rd = qdict_get_int(qdict, "bps_rd"); + iot->bps_wr = qdict_get_int(qdict, "bps_wr"); + iot->iops = qdict_get_int(qdict, "iops"); + iot->iops_rd = qdict_get_int(qdict, "iops_rd"); + iot->iops_wr = qdict_get_int(qdict, "iops_wr"); +} + void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) { Error *err = NULL; + IOThrottle *iothrottle; BlockIOThrottle throttle = { .has_device = true, .device = (char *) qdict_get_str(qdict, "device"), - .bps = qdict_get_int(qdict, "bps"), - .bps_rd = qdict_get_int(qdict, "bps_rd"), - .bps_wr = qdict_get_int(qdict, "bps_wr"), - .iops = qdict_get_int(qdict, "iops"), - .iops_rd = qdict_get_int(qdict, "iops_rd"), - .iops_wr = qdict_get_int(qdict, "iops_wr"), }; + iothrottle = qapi_BlockIOThrottle_base(&throttle); + hmp_initialize_io_throttle(iothrottle, qdict); qmp_block_set_io_throttle(&throttle, &err); hmp_handle_error(mon, &err); }