From patchwork Thu Sep 14 10:40:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pradeep Jagadeesh X-Patchwork-Id: 813773 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="n+MKWcMW"; 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 3xtFYN4P1Lz9sPk for ; Thu, 14 Sep 2017 20:45:28 +1000 (AEST) Received: from localhost ([::1]:46885 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsReA-0002zq-On for incoming@patchwork.ozlabs.org; Thu, 14 Sep 2017 06:45:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRZk-0006rt-CR for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsRZe-0001yk-FH for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:52 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:33548) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dsRZe-0001xd-3v for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:40:46 -0400 Received: by mail-wr0-x244.google.com with SMTP id b9so1474740wra.0 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=ScPvH4Obbnvmv7xQmJQ5gebpCp1S8MORUcIB7ELURNk=; b=n+MKWcMW+luSQf0Nr5S7IzZLCZuENZaMAMYeOPvR0F/8kMOPjbh0XIlU0CpPPkIAbH jrIQVhuvqVYaY635eOS3Kch+1hnCf9q3V+ldgXcY57emziX/M1KdhGphwJVc9wHFoCDO 0dqavPo/BG1wXx/KG5SAwJ6YPmPmpo/yktpTsSaPqyrqAtVprqgnW8JfkMZtvkW+Lz9e OGzJ4S45PdGhcJXUI7nZjSg57keyDsBeyH+uBnZaIBCq5xRvbFmzV7fajsS1HfzV8Z2E PA9VmTP8lMLXE9/OUur6xSGfs7gDEpl71UolMAAsbkWfnY3xHRmRyuOBeZqK8CeLq+U8 tMOA== 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=ScPvH4Obbnvmv7xQmJQ5gebpCp1S8MORUcIB7ELURNk=; b=rGlcv86zXnJztXiEi6KIMHxmnju6eNbygmRg/9RcEV7Yn/chUzyuxDM1pleIYFhvIn 49+hAC7CaOUbjDG6J30iWwYK7DdnwQ3kbtcZ1k7N9aFyUMrZ5pgVlU6vo8tVpYERKHmF BWpp5w5fC9ygxqXYqptESPfMJmz93CpiIQPa6CzBrA7FtvmW5EKSxYlyGTSrsIERlHAQ CPPZdH1qYl56q6yuyYyfWvY+C5YAjFU9pRq3fN7IeJ20paYUXSxjn9htsvnkXkcv7u56 yUOFtRAWN5Hu84IO3j02Ba5FZQP7EwtHxhfSwl+FwV1wilpr6ie6JTL5lfvv+GhPZwXq 43Vg== X-Gm-Message-State: AHPjjUjhBMmjEg9aTB1fC2t6ps1/7UVCv2MV7UkPJOO7D6oW3SKNVE3p 43lTaKJlPFIjnA== X-Google-Smtp-Source: ADKCNb4/NW9EiKAouna483H+g0/SPigqd0t8heOCvuXwVCqgRhyB7l6a6DwrXU9RMXYQvEtKU/ikRA== X-Received: by 10.223.172.228 with SMTP id o91mr17060830wrc.259.1505385645092; Thu, 14 Sep 2017 03:40:45 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 03:40:44 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Thu, 14 Sep 2017 06:40:08 -0400 Message-Id: <1505385610-35529-5-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 4/6] hmp: create a throttle initialization function for code reuse 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. Signed-off-by: Pradeep Jagadeesh Reviewed-by: Alberto Garcia Reviewed-by: Greg Kurz Acked-by: Dr. David Alan Gilbert --- hmp.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/hmp.c b/hmp.c index cd046c6..acaf0e6 100644 --- a/hmp.c +++ b/hmp.c @@ -1752,20 +1752,28 @@ void hmp_change(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } +static void hmp_initialize_throttle_limits(ThrottleLimits *iot, + const QDict *qdict) +{ + iot->bps_total = qdict_get_int(qdict, "bps"); + iot->bps_read = qdict_get_int(qdict, "bps_rd"); + iot->bps_write = qdict_get_int(qdict, "bps_wr"); + iot->iops_total = qdict_get_int(qdict, "iops"); + iot->iops_read = qdict_get_int(qdict, "iops_rd"); + iot->iops_write = qdict_get_int(qdict, "iops_wr"); +} + void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) { Error *err = NULL; + ThrottleLimits *tlimits; 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"), }; + tlimits = qapi_BlockIOThrottle_base(&throttle); + hmp_initialize_throttle_limits(tlimits, qdict); qmp_block_set_io_throttle(&throttle, &err); hmp_handle_error(mon, &err); }