From patchwork Tue Aug 29 14:23:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pradeep Jagadeesh X-Patchwork-Id: 807106 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="JsVqTBMp"; 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 3xhWB46bt3z9t16 for ; Wed, 30 Aug 2017 00:25:00 +1000 (AEST) Received: from localhost ([::1]:45213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmhRq-0001pO-NX for incoming@patchwork.ozlabs.org; Tue, 29 Aug 2017 10:24:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmhR2-0001jX-Sr for qemu-devel@nongnu.org; Tue, 29 Aug 2017 10:24:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmhQw-0004EE-NP for qemu-devel@nongnu.org; Tue, 29 Aug 2017 10:24:08 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:35524) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dmhQw-0004Ds-Gc for qemu-devel@nongnu.org; Tue, 29 Aug 2017 10:24:02 -0400 Received: by mail-wr0-x242.google.com with SMTP id a47so2408636wra.2 for ; Tue, 29 Aug 2017 07:24:02 -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=JsVqTBMpmv8qgloIEkIoVGScrr5ln1MueQhLRew3dEk/jP+a62yeF/tQJPhAaiiYbA JON2CnkM8Wsv1++w8GnKOkJArWizy75XXizxZF+WgFk01TTQncZKPYc2EfiiFrELjcPM rI1fxXOPpHctZ9zFWnIhZFyYJSXa0KUvsROMP2O8dMLEHF4ZiW0joiSlnOBA3LlTSrfQ 8LOv75LXqskuEaC/PeS9jDN9dG2wZmg7g9HjJgtE2ROMFRT1d0iX8tPHApn3T/LWN2AP 5ribI63krdPHsooKxw5bFeSI1AjP3Z78BmIe8499LhIvIPTG9fufruEXm21792LdinhD +UpA== 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=fCsVCNRabKZIZkGYjyD5Ey76kqeGa0hY9drwKyAivxS5YrnrwbVxul7XJoePIY4pfC 2MLoioCv1bL9pRns+wKaWsd2RZYZh3Rby39YgNFn3Ys5oFCpOxtF8O8L7OaYAi6SQoo6 x/W6ElmqyWA4N8LrAWSpxnkN+9ENWqC3cnFFzPhozQ0yCubAzNMTWq7KRBrdGxKVEmNU jl2TokdJozRCdhVgWvWcToe4tVr4OxWoxnCsqZEpUOJk6WcCNydi1zzxgdgLNV3LNA68 N1DrxGxOP0osHQUNK62gQfLwcUVOkyj3LIS2U4uOTH2HUbDynJLFGBDORSAtT9lj3ty8 vgQg== X-Gm-Message-State: AHYfb5jM+uFLU5+eRPsLhHSN4hSIyVeZmxp2ovXbnJJVTyzyMBJlEedL NCV7Px+v7vcFkRsylS8= X-Received: by 10.223.142.245 with SMTP id q108mr344641wrb.2.1504016641533; Tue, 29 Aug 2017 07:24:01 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id 15sm2540487wmv.45.2017.08.29.07.24.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Aug 2017 07:24:00 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Tue, 29 Aug 2017 10:23:05 -0400 Message-Id: <1504016587-39779-5-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1504016587-39779-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1504016587-39779-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::242 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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); }