From patchwork Tue Aug 29 14:23:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pradeep X-Patchwork-Id: 9927491 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 D4FD360383 for ; Tue, 29 Aug 2017 14:26:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAC312893B for ; Tue, 29 Aug 2017 14:26:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCCC628950; Tue, 29 Aug 2017 14:26:16 +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 1209128953 for ; Tue, 29 Aug 2017 14:26:15 +0000 (UTC) Received: from localhost ([::1]:45211 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmhSK-0001lE-Vs for patchwork-qemu-devel@patchwork.kernel.org; Tue, 29 Aug 2017 10:25:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmhQy-0001go-VV for qemu-devel@nongnu.org; Tue, 29 Aug 2017 10:24:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmhQx-0004Ek-Sg for qemu-devel@nongnu.org; Tue, 29 Aug 2017 10:24:04 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:36720) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dmhQx-0004EN-Jj for qemu-devel@nongnu.org; Tue, 29 Aug 2017 10:24:03 -0400 Received: by mail-wr0-x243.google.com with SMTP id 40so2194055wrv.3 for ; Tue, 29 Aug 2017 07:24:03 -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=eKrlh9zg8th8mFz103ypbzRThDmre+y56U3DVu642Qs=; b=fPjS0j8E7O0fPydphs+7qPwwAbB8UfZKso4vpQoc1knGgr5SWbG3r3mkfBX+S07W4+ kf0ExxdkuOrOuVyPFzEedMOYnwcgRMUbg2bE3oUwe7CS8915An/GvrjCT7c7iaQqi2Kx mw8c762X2D2c3JDURYENbdvJJ6iZfZi3OruamxlZUkZnywmzLMyO5JHdcXP80JYtmA2k MLjeYYPbw8VCOab0K637O49NMKR219IEtZSH0QQmm8OXtvgSMBEW8cvzI2Ew+WSjGEXL ylhJFNyR+MMn3JaBkgoUy8ZVJ/uDupKdzm4sxNEt8FBTd8jwEOxcElSwBJkHtWge0QZ3 dawQ== 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=eKrlh9zg8th8mFz103ypbzRThDmre+y56U3DVu642Qs=; b=e9Fz66joy0LoQRkQPTfT67WvTUevGeOBHwhpoaRSsWmwICMObwmQrHKYmg2fSmVDDE Oru0G5BwOSj7dGkGHLJiVh5IPjJf2ysXpkS8O1053uFS9S3NXoPLmmoXaQPe43q/L8lF 6Xrv5VhRdhIKqOqwiddjePAaxPOlTWUw1QaD81pR7SZ1gR7O0SdU0YEydhJixfsaWP8z J546AT0ox76ZP34NOVk0ixQOjhfFLjq4HFVGMjUmDgKSIeOg2KIMBR9HwAfeXfsgl6gQ X2FA0dEVFigJAuOSCSxEDEeGn9/Q7Vnhw0GEXB5RsyWBBBRRC2crAwKbAgxvu2jk5LNv QHdA== X-Gm-Message-State: AHYfb5hmidmDZEuVjYFUkJPR3mHM+X4ykV4FD8hFAiaW2K2fAOedxE5Z zSfjWpgZM7c10CAqXfE= X-Received: by 10.223.128.163 with SMTP id 32mr328555wrl.179.1504016642521; Tue, 29 Aug 2017 07:24:02 -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.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Aug 2017 07:24:01 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Tue, 29 Aug 2017 10:23:06 -0400 Message-Id: <1504016587-39779-6-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::243 Subject: [Qemu-devel] [PATCH v8 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 | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hmp.h | 4 ++++ 4 files changed, 103 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index d9df238..07ed338 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 = "fsdev_iothrottle", + .args_type = "", + .params = "", + .help = "show fsdev iothrottle information", + .cmd = hmp_info_fsdev_iothrottle, + }, + +#endif + +STEXI +@item info fsdev_iothrottle +@findex fsdev_iothrottle +Show fsdev device throttle info. +ETEXI + { .name = "block-jobs", .args_type = "", diff --git a/hmp-commands.hx b/hmp-commands.hx index 1941e19..aef9f79 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1680,6 +1680,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 2dbfb80..712c6a3 100644 --- a/hmp.c +++ b/hmp.c @@ -1783,6 +1783,68 @@ 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 = { + .has_id = true, + .id = (char *) qdict_get_str(qdict, "device"), + }; + + 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) +{ + 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 + "\n", + 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_info_fsdev_iothrottle(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + IOThrottleList *fsdev_list, *info; + fsdev_list = qmp_query_fsdev_io_throttle(&err); + + for (info = fsdev_list; info; info = info->next) { + print_fsdev_throttle_config(mon, info->value, err); + } + qapi_free_IOThrottleList(fsdev_list); +} + +#endif + void hmp_block_stream(Monitor *mon, const QDict *qdict) { Error *error = NULL; diff --git a/hmp.h b/hmp.h index 1ff4552..d700d7d 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_info_fsdev_iothrottle(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);