From nobody Mon Feb 9 09:34:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@gnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@gnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150695497311178.9088841619731; Mon, 2 Oct 2017 07:36:13 -0700 (PDT) Received: from localhost ([::1]:52616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz1pM-0006tk-B3 for importer@patchew.org; Mon, 02 Oct 2017 10:36:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz1nS-0005co-1K for qemu-devel@nongnu.org; Mon, 02 Oct 2017 10:34:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dz1nM-0007uh-3K for qemu-devel@nongnu.org; Mon, 02 Oct 2017 10:34:14 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:37885) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dz1nL-0007uL-T2 for qemu-devel@nongnu.org; Mon, 02 Oct 2017 10:34:08 -0400 Received: by mail-wr0-x241.google.com with SMTP id v38so946608wrc.4 for ; Mon, 02 Oct 2017 07:34:07 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id b89sm28440668wrd.42.2017.10.02.07.34.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 07:34:05 -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=KPljf64mzBI3rA7EhRwQ5L/FPvDUv+hIHgYdBfdiRBQ=; b=LE70LLxccx5BnUxkmuhh4A4qS5i5vw0j5NhJDT/XuZHXKPfUEqIznZ2GRDl+PdDo7Q 8CXjsNQMExYi8hHQFJuGEJseZbILUZyBvC5Q7OO2RBWcU6KplHV5hy76QaQJsSxuEzno EKeSd1FiYD+ys9T0voQLVZ5fPv9AD0eDkSMUYAEKzm6/uQz+JD8nnyCoqqDfC0CKRDA5 p3lTJisK7WmRP3QcLxSEIjPJzV+xfu59hXQvwVZq5zl8XWJvnQJTe++CrZ53FD9k05CT mftI2O/L3D4DeiaaFWdHZ4Lb0OFcyjxR/YPoAs1GqTvZcltbB/lCb3Zm0pWf5M0joVbL ZnzA== 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=KPljf64mzBI3rA7EhRwQ5L/FPvDUv+hIHgYdBfdiRBQ=; b=tffVDISuUFfv5DJUKz22F5oY326+93Wxl4Qoe1wSZXzc4pIi/jPHtK9y0Bm4byi5N3 p113oQQTpUosjYooWkU1zcdX/6mJhibB7HSSbIiWJIdSwN/wqCUYi2AAgejF30o7frVQ KtDYK/YODYyzgNueprXSmQDEEHmqd8/iEt0/0xkmQu5KoCg1WmYNxrsBjcRIVp+KG4kq LnLWOVtms4uQUiS7KEcyFSs9d0ds6nZ5JTr0xFcqB6ta5gqbMDsaYGXMPIPOTcTnib1t UfBkWtoMptLREKi3HkoHPHzewd1kw2SYfU89OqGo2uN3LMQgsVVqjyQGq8lG5XzXl0Cl W/Ew== X-Gm-Message-State: AMCzsaWrYnN4R1h49WTRRFXA5mmtngGhZpgfBMivQNnNU24KL36Www/7 zHJx97F3/11UIVJ1Vx2zN6g= X-Google-Smtp-Source: AOwi7QCzAqNqBPW4a+Npju6hCfbBYIfkGYmgyY0cCpsk4sxXaOm+Fr5kK/J/KHEYTbZHY+HWLUI01w== X-Received: by 10.223.136.246 with SMTP id g51mr2119716wrg.226.1506954846692; Mon, 02 Oct 2017 07:34:06 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Mon, 2 Oct 2017 10:33:30 -0400 Message-Id: <1506954812-6552-5-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1506954812-6552-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1506954812-6552-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::241 Subject: [Qemu-devel] [PATCH v13 4/6] hmp: create a throttle initialization function for code reuse X-BeenThere: qemu-devel@gnu.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+importer=patchew.org@gnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 ace729d..904fc4a 100644 --- a/hmp.c +++ b/hmp.c @@ -1766,20 +1766,28 @@ void hmp_change(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } =20 +static void hmp_initialize_throttle_limits(ThrottleLimits *iot, + const QDict *qdict) +{ + iot->bps_total =3D qdict_get_int(qdict, "bps"); + iot->bps_read =3D qdict_get_int(qdict, "bps_rd"); + iot->bps_write =3D qdict_get_int(qdict, "bps_wr"); + iot->iops_total =3D qdict_get_int(qdict, "iops"); + iot->iops_read =3D qdict_get_int(qdict, "iops_rd"); + iot->iops_write =3D qdict_get_int(qdict, "iops_wr"); +} + void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; + ThrottleLimits *tlimits; BlockIOThrottle throttle =3D { .has_device =3D true, .device =3D (char *) qdict_get_str(qdict, "device"), - .bps =3D qdict_get_int(qdict, "bps"), - .bps_rd =3D qdict_get_int(qdict, "bps_rd"), - .bps_wr =3D qdict_get_int(qdict, "bps_wr"), - .iops =3D qdict_get_int(qdict, "iops"), - .iops_rd =3D qdict_get_int(qdict, "iops_rd"), - .iops_wr =3D qdict_get_int(qdict, "iops_wr"), }; =20 + tlimits =3D qapi_BlockIOThrottle_base(&throttle); + hmp_initialize_throttle_limits(tlimits, qdict); qmp_block_set_io_throttle(&throttle, &err); hmp_handle_error(mon, &err); } --=20 1.8.3.1