From patchwork Thu Jun 29 15:10:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pradeep X-Patchwork-Id: 9817237 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 B4E21602B1 for ; Thu, 29 Jun 2017 15:16:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6E86286A9 for ; Thu, 29 Jun 2017 15:16:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BA9D286CA; Thu, 29 Jun 2017 15:16:51 +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 08DD3286A9 for ; Thu, 29 Jun 2017 15:16:50 +0000 (UTC) Received: from localhost ([::1]:39928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQbBa-000468-02 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 29 Jun 2017 11:16:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQb6V-0008Um-Ry for qemu-devel@nongnu.org; Thu, 29 Jun 2017 11:11:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQb6U-00032L-Np for qemu-devel@nongnu.org; Thu, 29 Jun 2017 11:11:35 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:35222) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dQb6U-00031x-Dw for qemu-devel@nongnu.org; Thu, 29 Jun 2017 11:11:34 -0400 Received: by mail-wr0-x243.google.com with SMTP id z45so37152726wrb.2 for ; Thu, 29 Jun 2017 08:11:34 -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=BIoJ0IkM66X+ctpHjC2L7VyYfk5FTxA6cF6lh+EZngM=; b=Ki02MAEG/VOgF6hiuNJ7D7H44KbDBoUSAqaBFf/gSWht8gDGMJcTonMYC77ZSGECnx rYZPNhgntBmdu1tORYZL2Ysfd+YlmEdtH/lgfVKGs6V5PT3Cdj4/941L/YPttkU4NAq2 7RqH5PiCsI7e7A013GjzmiU9BAg+k652pDMr0NTfRofKDUlMnB2jqP2veX0QZZ+n9cRI a2pe7Z10i4KcT0jnBxk92KtywHdB98OAko1A/TNlEE4aUo0PuIFnkuCABhL5MRuFKvMt vzQRybaNGkM2uVqRB7qltA1jPerlR51s6ZGgdg1htGP57xP8IBnYUJvd8cfY14LToVd7 gH2A== 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=BIoJ0IkM66X+ctpHjC2L7VyYfk5FTxA6cF6lh+EZngM=; b=Mnw5jJ9Aia9dTayqqTOWXYvBjwU0wV9hPUoZNb4FsvLLWV6gdCTVDiBp6FGPBUFFt8 0CVrDyW2xsjHYTxEzlw9vCJK/L9MJHgp9dN1vMcEHFCsyvOYJJfVnUhsuJEQiEvo8Hh6 MRMG1WqHMTtYX8CcZlN4Tk9Ff3E8l2htmHvF+ftDxr2thGesyw4JyWfx1q7SEE+N4vVf gqYEf6t8pAV47Vmu/G74KHzA6+ZdJ6alkpW3fovLguG5vu3FHcGaR9+FVeSPmOCOZshl 8rPG7TLB0jsNlVcmuJgYb/OXMeuUIUvvevujKfLgToi72dNkKSZJbx+/KwtEqT6CbMhr ZhyQ== X-Gm-Message-State: AKS2vOwgCdKZWUauZTR3lgiqKDUKacu2b+BB27J81QV3qqbok7AUBKR8 3O0OhfyjfhApcQ== X-Received: by 10.223.135.210 with SMTP id c18mr22783998wrc.109.1498749093458; Thu, 29 Jun 2017 08:11:33 -0700 (PDT) Received: from localhost.localdomain.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id r142sm1679641wmg.24.2017.06.29.08.11.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 08:11:32 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Thu, 29 Jun 2017 11:10:55 -0400 Message-Id: <1498749056-38565-6-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1498749056-38565-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1498749056-38565-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::243 Subject: [Qemu-devel] [PATCH v6 5/6] fsdev: hmp interface for throttling 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 introduces hmp interfaces for the fsdev devices. Signed-off-by: Pradeep Jagadeesh --- hmp-commands-info.hx | 18 ++++++++++++++ hmp-commands.hx | 19 +++++++++++++++ hmp.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hmp.h | 4 ++++ 4 files changed, 107 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index ae16901..f23b627 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -84,6 +84,24 @@ STEXI Show block device statistics. ETEXI +#if defined(CONFIG_VIRTFS) + + { + .name = "query-fsdev-iothrottle", + .args_type = "", + .params = "", + .help = "show fsdev device throttle information", + .cmd = hmp_fsdev_get_io_throttle, + }, + +#endif + +STEXI +@item info fsdev throttle +@findex fsdevthrottleinfo +Show fsdev device throttleinfo. +ETEXI + { .name = "block-jobs", .args_type = "", diff --git a/hmp-commands.hx b/hmp-commands.hx index e763606..c60fd7e 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1662,6 +1662,25 @@ STEXI Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} ETEXI +#if defined(CONFIG_VIRTFS) + + { + .name = "fsdev-set-io-throttle", + .args_type = "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l,iops_wr:l", + .params = "device bps bps_rd bps_wr iops iops_rd iops_wr", + .help = "change I/O throttle limits for a fs devices", + .cmd = hmp_fsdev_set_io_throttle, + }, + +#endif + +STEXI +@item fsdev_set_io_throttle @var{device} @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} +@findex fsdev_set_io_throttle +Change I/O throttle limits for a fs devices to @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} +ETEXI + + { .name = "set_password", .args_type = "protocol:s,password:s,connected:s?", diff --git a/hmp.c b/hmp.c index 220d301..b1c698b 100644 --- a/hmp.c +++ b/hmp.c @@ -1776,6 +1776,72 @@ void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } +#ifdef CONFIG_VIRTFS + +void hmp_fsdev_set_io_throttle(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + IOThrottle throttle; + + hmp_initialize_io_throttle(&throttle, qdict); + qmp_fsdev_set_io_throttle(&throttle, &err); + hmp_handle_error(mon, &err); +} + +static void print_fsdev_throttle_config(Monitor *mon, IOThrottle *fscfg, + Error *err) +{ + if (fscfg->bps || fscfg->bps_rd || fscfg->bps_wr || + fscfg->iops || fscfg->iops_rd || fscfg->iops_wr) + { + monitor_printf(mon, "%s", fscfg->id); + monitor_printf(mon, " I/O throttling:" + " bps=%" PRId64 + " bps_rd=%" PRId64 " bps_wr=%" PRId64 + " bps_max=%" PRId64 + " bps_rd_max=%" PRId64 + " bps_wr_max=%" PRId64 + " iops=%" PRId64 " iops_rd=%" PRId64 + " iops_wr=%" PRId64 + " iops_max=%" PRId64 + " iops_rd_max=%" PRId64 + " iops_wr_max=%" PRId64 + " iops_size=%" PRId64, + fscfg->bps, + fscfg->bps_rd, + fscfg->bps_wr, + fscfg->bps_max, + fscfg->bps_rd_max, + fscfg->bps_wr_max, + fscfg->iops, + fscfg->iops_rd, + fscfg->iops_wr, + fscfg->iops_max, + fscfg->iops_rd_max, + fscfg->iops_wr_max, + fscfg->iops_size); + } + hmp_handle_error(mon, &err); +} + +void hmp_fsdev_get_io_throttle(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + IOThrottleList *fs9p_list, *info; + fs9p_list = qmp_query_fsdev_io_throttle(&err); + + for (info = fs9p_list; info; info = info->next) { + if (info != fs9p_list) { + monitor_printf(mon, "\n"); + } + print_fsdev_throttle_config(mon, info->value, err); + qapi_free_IOThrottle(info->value); + } + qapi_free_IOThrottleList(fs9p_list); +} + +#endif + void hmp_block_stream(Monitor *mon, const QDict *qdict) { Error *error = NULL; diff --git a/hmp.h b/hmp.h index d8b94ce..05e72f2 100644 --- a/hmp.h +++ b/hmp.h @@ -81,6 +81,10 @@ void hmp_set_password(Monitor *mon, const QDict *qdict); void hmp_expire_password(Monitor *mon, const QDict *qdict); void hmp_eject(Monitor *mon, const QDict *qdict); void hmp_change(Monitor *mon, const QDict *qdict); +#ifdef CONFIG_VIRTFS +void hmp_fsdev_set_io_throttle(Monitor *mon, const QDict *qdict); +void hmp_fsdev_get_io_throttle(Monitor *mon, const QDict *qdict); +#endif void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict); void hmp_block_stream(Monitor *mon, const QDict *qdict); void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);