From patchwork Fri Nov 16 08:00:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xiezhide X-Patchwork-Id: 10685659 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 381CE17F3 for ; Fri, 16 Nov 2018 08:10:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 265082D35B for ; Fri, 16 Nov 2018 08:10:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 168F22D381; Fri, 16 Nov 2018 08:10:45 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 74D532D35B for ; Fri, 16 Nov 2018 08:10:44 +0000 (UTC) Received: from localhost ([::1]:42652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZD9-00063p-Mz for patchwork-qemu-devel@patchwork.kernel.org; Fri, 16 Nov 2018 03:10:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNZ94-0002aI-Iy for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:06:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNZ8v-0007Kb-IS for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:06:26 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:50365 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gNZ8u-0007FF-92 for qemu-devel@nongnu.org; Fri, 16 Nov 2018 03:06:20 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 44CC0F0C0B515; Fri, 16 Nov 2018 16:06:14 +0800 (CST) Received: from huawei.com (10.143.28.95) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 16 Nov 2018 16:06:08 +0800 From: xiezhide To: Date: Fri, 16 Nov 2018 16:00:33 +0800 Message-ID: <05988243066ce14c5f78799952aba7fd33af35d3.1542384802.git.xiezhide@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.143.28.95] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH v5 6/6] fsdev-throttle-qmp: hmp interface for fsdev io 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: berto@igalia.com, armbru@redhat.com, zengcanfu@huawei.com, groug@kaod.org, aneesh.kumar@linux.vnet.ibm.com, jinxuefeng@huawei.com, chenhui.rtos@huawei.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP introduces io throttling hmp interfaces for the fsdev devices Signed-off-by: xiezhide --- hmp-commands-info.hx | 15 ++++++++++ hmp-commands.hx | 15 ++++++++++ hmp.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++------ hmp.h | 4 +++ 4 files changed, 107 insertions(+), 8 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index cbee8b9..eaf0ff5 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -100,6 +100,21 @@ STEXI Show progress of ongoing block device operations. 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 = "registers", .args_type = "cpustate_all:-a", diff --git a/hmp-commands.hx b/hmp-commands.hx index db0c681..40ca7fe 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1716,6 +1716,21 @@ Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @var{bps_ @var{device} can be a block device name, a qdev ID or a QOM path. 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 7828f93..7162d87 100644 --- a/hmp.c +++ b/hmp.c @@ -38,6 +38,7 @@ #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-commands-fsdev.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qapi/string-input-visitor.h" @@ -1886,18 +1887,22 @@ 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 = 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; char *device = (char *) qdict_get_str(qdict, "device"); - BlockIOThrottle throttle = { - .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"), - }; + BlockIOThrottle throttle = {0}; /* qmp_block_set_io_throttle has separate parameters for the * (deprecated) block device name and the qdev ID but the HMP @@ -1910,10 +1915,70 @@ void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) throttle.id = device; } + hmp_initialize_throttle_limits(qapi_BlockIOThrottle_base(&throttle), qdict); qmp_block_set_io_throttle(&throttle, &err); hmp_handle_error(mon, &err); } +#ifdef CONFIG_VIRTFS +void hmp_fsdev_set_io_throttle(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + ThrottleLimits *tlimits; + FsdevIOThrottle throttle = { + .has_id = true, + .id = (char *) qdict_get_str(qdict, "device"), + }; + + tlimits = qapi_FsdevIOThrottle_base(&throttle); + hmp_initialize_throttle_limits(tlimits, qdict); + qmp_fsdev_set_io_throttle(&throttle, &err); + hmp_handle_error(mon, &err); +} + +static void print_fsdev_throttle_config(Monitor *mon, FsdevIOThrottle *fscfg) +{ + 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); +} + +void hmp_info_fsdev_iothrottle(Monitor *mon, const QDict *qdict) +{ + FsdevIOThrottleList *fsdev_list, *info; + fsdev_list = qmp_query_fsdev_io_throttle(NULL); + + for (info = fsdev_list; info; info = info->next) { + print_fsdev_throttle_config(mon, info->value); + } + qapi_free_FsdevIOThrottleList(fsdev_list); +} +#endif + void hmp_block_stream(Monitor *mon, const QDict *qdict) { Error *error = NULL; diff --git a/hmp.h b/hmp.h index 5f1addc..9330e11 100644 --- a/hmp.h +++ b/hmp.h @@ -91,6 +91,10 @@ void hmp_block_job_cancel(Monitor *mon, const QDict *qdict); void hmp_block_job_pause(Monitor *mon, const QDict *qdict); void hmp_block_job_resume(Monitor *mon, const QDict *qdict); void hmp_block_job_complete(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_migrate(Monitor *mon, const QDict *qdict); void hmp_device_add(Monitor *mon, const QDict *qdict); void hmp_device_del(Monitor *mon, const QDict *qdict);