From nobody Sat May 4 03:12:25 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494405855239787.9320294554184; Wed, 10 May 2017 01:44:15 -0700 (PDT) Received: from localhost ([::1]:41145 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8NED-0006mP-Jv for importer@patchew.org; Wed, 10 May 2017 04:44:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8NCZ-0005Zc-Rd for qemu-devel@nongnu.org; Wed, 10 May 2017 04:42:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8NCX-0007DL-KJ for qemu-devel@nongnu.org; Wed, 10 May 2017 04:42:31 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:36449) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d8NCX-0007D7-AQ for qemu-devel@nongnu.org; Wed, 10 May 2017 04:42:29 -0400 Received: by mail-wr0-x242.google.com with SMTP id v42so6323050wrc.3 for ; Wed, 10 May 2017 01:42:29 -0700 (PDT) Received: from centos-minion-1.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id y63sm4300148wme.31.2017.05.10.01.42.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 May 2017 01:42:27 -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=6os33wpQubTzHEyKenajUyhpgK2eCW7gReJYbiNEy2Y=; b=c/zK9UF+k5Nv18LiTlhXCOCmc/lRWhJTmPWR9j3mAbc2MV2NMDgSqbTZVfeVSG0MeG GC64jZniMU/McpXlVebI1mRE+DwwDtE9AJYFhy8jcGcqbILa7b5HcT6Z2xgT+nOGlGai GyGAI24/K40fZHLJF6GadraQW18UWHtyr5PWm1JRrILuaKq2p+psvM1qW6UOG4t2eWt0 TXyk5KulOOjXdXDW9Q8JcBr8r0S4BSycJzM83Dtrgu4Q/GAwuvFWow2tcsfOmDGoTJ1P YmH3oiCK1Sx9uaeVs6MdRw7gMM5nk+ndyfcbKFqznYqjTJvMEHudjKLqFpZzrlnbH/QQ 8z0A== 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=6os33wpQubTzHEyKenajUyhpgK2eCW7gReJYbiNEy2Y=; b=LgNvvJf6ujfX2ilshsvJweYymANuOtxxsYhT7nP6ESUOzUA6O9/OEixeklZTevyUw6 /+gCqgoEo56+GbI88Aqq5KF7/uSUbTOIm9qcewBXujfIIhIjWbTHj89GBjXDIZuKBBKi GP+mOkirZxqk1uFk7cdUffuBFyTXIxzMXdv9tCweJWjJeLs6lO8jvc8CR0dyjxkUhq6i JubGdHJaaoBOCg3zRGBZE8Kf9Gz41vCBDlKhbxpA8hJBWBjg82kQsbkDohQ9i8Bf352W YlwTfTODvJ9nIqFSFql4CghfC0HICsFlRHKigmZVj6RTQmHHMDL6qTu3vw3rmJmY4MKM KXPA== X-Gm-Message-State: AODbwcA1t8W1XdDCoxpXf6u+b4/mjKqCfuL6kfmnyTRbcW3wwZN3UiX2 V84LThKMem+JDEsG X-Received: by 10.28.68.195 with SMTP id r186mr2742657wma.22.1494405748173; Wed, 10 May 2017 01:42:28 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Wed, 10 May 2017 04:41:20 -0400 Message-Id: <1494405683-20877-2-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1494405683-20877-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1494405683-20877-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::242 Subject: [Qemu-devel] [PATCH v4 1/4] throttle: factor out duplicate code 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: jani kokkonen , alberto garcia , Pradeep Jagadeesh , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch factor out the duplicate throttle code that was present in block and fsdev devices. Signed-off-by: Pradeep Jagadeesh --- blockdev.c | 44 +---------------------------------- fsdev/qemu-fsdev-throttle.c | 43 +--------------------------------- fsdev/qemu-fsdev-throttle.h | 1 + include/qemu/throttle-options.h | 5 ++++ util/Makefile.objs | 1 + util/throttle-options.c | 51 +++++++++++++++++++++++++++++++++++++= ++++ 6 files changed, 60 insertions(+), 85 deletions(-) create mode 100644 util/throttle-options.c diff --git a/blockdev.c b/blockdev.c index 6428206..a0eb2ed 100644 --- a/blockdev.c +++ b/blockdev.c @@ -386,49 +386,7 @@ static void extract_common_blockdev_options(QemuOpts *= opts, int *bdrv_flags, } =20 if (throttle_cfg) { - throttle_config_init(throttle_cfg); - throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg =3D - qemu_opt_get_number(opts, "throttling.bps-total", 0); - throttle_cfg->buckets[THROTTLE_BPS_READ].avg =3D - qemu_opt_get_number(opts, "throttling.bps-read", 0); - throttle_cfg->buckets[THROTTLE_BPS_WRITE].avg =3D - qemu_opt_get_number(opts, "throttling.bps-write", 0); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL].avg =3D - qemu_opt_get_number(opts, "throttling.iops-total", 0); - throttle_cfg->buckets[THROTTLE_OPS_READ].avg =3D - qemu_opt_get_number(opts, "throttling.iops-read", 0); - throttle_cfg->buckets[THROTTLE_OPS_WRITE].avg =3D - qemu_opt_get_number(opts, "throttling.iops-write", 0); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL].max =3D - qemu_opt_get_number(opts, "throttling.bps-total-max", 0); - throttle_cfg->buckets[THROTTLE_BPS_READ].max =3D - qemu_opt_get_number(opts, "throttling.bps-read-max", 0); - throttle_cfg->buckets[THROTTLE_BPS_WRITE].max =3D - qemu_opt_get_number(opts, "throttling.bps-write-max", 0); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL].max =3D - qemu_opt_get_number(opts, "throttling.iops-total-max", 0); - throttle_cfg->buckets[THROTTLE_OPS_READ].max =3D - qemu_opt_get_number(opts, "throttling.iops-read-max", 0); - throttle_cfg->buckets[THROTTLE_OPS_WRITE].max =3D - qemu_opt_get_number(opts, "throttling.iops-write-max", 0); - - throttle_cfg->buckets[THROTTLE_BPS_TOTAL].burst_length =3D - qemu_opt_get_number(opts, "throttling.bps-total-max-length", 1= ); - throttle_cfg->buckets[THROTTLE_BPS_READ].burst_length =3D - qemu_opt_get_number(opts, "throttling.bps-read-max-length", 1); - throttle_cfg->buckets[THROTTLE_BPS_WRITE].burst_length =3D - qemu_opt_get_number(opts, "throttling.bps-write-max-length", 1= ); - throttle_cfg->buckets[THROTTLE_OPS_TOTAL].burst_length =3D - qemu_opt_get_number(opts, "throttling.iops-total-max-length", = 1); - throttle_cfg->buckets[THROTTLE_OPS_READ].burst_length =3D - qemu_opt_get_number(opts, "throttling.iops-read-max-length", 1= ); - throttle_cfg->buckets[THROTTLE_OPS_WRITE].burst_length =3D - qemu_opt_get_number(opts, "throttling.iops-write-max-length", = 1); - - throttle_cfg->op_size =3D - qemu_opt_get_number(opts, "throttling.iops-size", 0); - + parse_io_throttle_options(throttle_cfg, opts); if (!throttle_is_valid(throttle_cfg, errp)) { return; } diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index 7ae4e86..db386a7 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -31,48 +31,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque) =20 void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **er= rp) { - throttle_config_init(&fst->cfg); - fst->cfg.buckets[THROTTLE_BPS_TOTAL].avg =3D - qemu_opt_get_number(opts, "throttling.bps-total", 0); - fst->cfg.buckets[THROTTLE_BPS_READ].avg =3D - qemu_opt_get_number(opts, "throttling.bps-read", 0); - fst->cfg.buckets[THROTTLE_BPS_WRITE].avg =3D - qemu_opt_get_number(opts, "throttling.bps-write", 0); - fst->cfg.buckets[THROTTLE_OPS_TOTAL].avg =3D - qemu_opt_get_number(opts, "throttling.iops-total", 0); - fst->cfg.buckets[THROTTLE_OPS_READ].avg =3D - qemu_opt_get_number(opts, "throttling.iops-read", 0); - fst->cfg.buckets[THROTTLE_OPS_WRITE].avg =3D - qemu_opt_get_number(opts, "throttling.iops-write", 0); - - fst->cfg.buckets[THROTTLE_BPS_TOTAL].max =3D - qemu_opt_get_number(opts, "throttling.bps-total-max", 0); - fst->cfg.buckets[THROTTLE_BPS_READ].max =3D - qemu_opt_get_number(opts, "throttling.bps-read-max", 0); - fst->cfg.buckets[THROTTLE_BPS_WRITE].max =3D - qemu_opt_get_number(opts, "throttling.bps-write-max", 0); - fst->cfg.buckets[THROTTLE_OPS_TOTAL].max =3D - qemu_opt_get_number(opts, "throttling.iops-total-max", 0); - fst->cfg.buckets[THROTTLE_OPS_READ].max =3D - qemu_opt_get_number(opts, "throttling.iops-read-max", 0); - fst->cfg.buckets[THROTTLE_OPS_WRITE].max =3D - qemu_opt_get_number(opts, "throttling.iops-write-max", 0); - - fst->cfg.buckets[THROTTLE_BPS_TOTAL].burst_length =3D - qemu_opt_get_number(opts, "throttling.bps-total-max-length", 1); - fst->cfg.buckets[THROTTLE_BPS_READ].burst_length =3D - qemu_opt_get_number(opts, "throttling.bps-read-max-length", 1); - fst->cfg.buckets[THROTTLE_BPS_WRITE].burst_length =3D - qemu_opt_get_number(opts, "throttling.bps-write-max-length", 1); - fst->cfg.buckets[THROTTLE_OPS_TOTAL].burst_length =3D - qemu_opt_get_number(opts, "throttling.iops-total-max-length", 1); - fst->cfg.buckets[THROTTLE_OPS_READ].burst_length =3D - qemu_opt_get_number(opts, "throttling.iops-read-max-length", 1); - fst->cfg.buckets[THROTTLE_OPS_WRITE].burst_length =3D - qemu_opt_get_number(opts, "throttling.iops-write-max-length", 1); - fst->cfg.op_size =3D - qemu_opt_get_number(opts, "throttling.iops-size", 0); - + parse_io_throttle_options(&fst->cfg, opts); throttle_is_valid(&fst->cfg, errp); } =20 diff --git a/fsdev/qemu-fsdev-throttle.h b/fsdev/qemu-fsdev-throttle.h index e418643..c493e83 100644 --- a/fsdev/qemu-fsdev-throttle.h +++ b/fsdev/qemu-fsdev-throttle.h @@ -20,6 +20,7 @@ #include "qemu/coroutine.h" #include "qapi/error.h" #include "qemu/throttle.h" +#include "qemu/throttle-options.h" =20 typedef struct FsThrottle { ThrottleState ts; diff --git a/include/qemu/throttle-options.h b/include/qemu/throttle-option= s.h index 3133d1c..9b68eb8 100644 --- a/include/qemu/throttle-options.h +++ b/include/qemu/throttle-options.h @@ -10,6 +10,9 @@ #ifndef THROTTLE_OPTIONS_H #define THROTTLE_OPTIONS_H =20 +#include "qemu/throttle.h" +#include "qmp-commands.h" + #define THROTTLE_OPTS \ { \ .name =3D "throttling.iops-total",\ @@ -89,4 +92,6 @@ .help =3D "when limiting by iops max size of an I/O in bytes",\ } =20 +void parse_io_throttle_options(ThrottleConfig *, QemuOpts *); + #endif diff --git a/util/Makefile.objs b/util/Makefile.objs index c6205eb..7119ce0 100644 --- a/util/Makefile.objs +++ b/util/Makefile.objs @@ -43,3 +43,4 @@ util-obj-y +=3D qdist.o util-obj-y +=3D qht.o util-obj-y +=3D range.o util-obj-y +=3D systemd.o +util-obj-y +=3D throttle-options.o diff --git a/util/throttle-options.c b/util/throttle-options.c new file mode 100644 index 0000000..02b26b8 --- /dev/null +++ b/util/throttle-options.c @@ -0,0 +1,51 @@ +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qemu/throttle-options.h" +#include "qemu/iov.h" + +void parse_io_throttle_options(ThrottleConfig *throttle_cfg, QemuOpts *opt= s) +{ + throttle_config_init(throttle_cfg); + throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg =3D + qemu_opt_get_number(opts, "throttling.bps-total", 0); + throttle_cfg->buckets[THROTTLE_BPS_READ].avg =3D + qemu_opt_get_number(opts, "throttling.bps-read", 0); + throttle_cfg->buckets[THROTTLE_BPS_WRITE].avg =3D + qemu_opt_get_number(opts, "throttling.bps-write", 0); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL].avg =3D + qemu_opt_get_number(opts, "throttling.iops-total", 0); + throttle_cfg->buckets[THROTTLE_OPS_READ].avg =3D + qemu_opt_get_number(opts, "throttling.iops-read", 0); + throttle_cfg->buckets[THROTTLE_OPS_WRITE].avg =3D + qemu_opt_get_number(opts, "throttling.iops-write", 0); + + throttle_cfg->buckets[THROTTLE_BPS_TOTAL].max =3D + qemu_opt_get_number(opts, "throttling.bps-total-max", 0); + throttle_cfg->buckets[THROTTLE_BPS_READ].max =3D + qemu_opt_get_number(opts, "throttling.bps-read-max", 0); + throttle_cfg->buckets[THROTTLE_BPS_WRITE].max =3D + qemu_opt_get_number(opts, "throttling.bps-write-max", 0); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL].max =3D + qemu_opt_get_number(opts, "throttling.iops-total-max", 0); + throttle_cfg->buckets[THROTTLE_OPS_READ].max =3D + qemu_opt_get_number(opts, "throttling.iops-read-max", 0); + throttle_cfg->buckets[THROTTLE_OPS_WRITE].max =3D + qemu_opt_get_number(opts, "throttling.iops-write-max", 0); + + throttle_cfg->buckets[THROTTLE_BPS_TOTAL].burst_length =3D + qemu_opt_get_number(opts, "throttling.bps-total-max-length", 1); + throttle_cfg->buckets[THROTTLE_BPS_READ].burst_length =3D + qemu_opt_get_number(opts, "throttling.bps-read-max-length", 1); + throttle_cfg->buckets[THROTTLE_BPS_WRITE].burst_length =3D + qemu_opt_get_number(opts, "throttling.bps-write-max-length", 1); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL].burst_length =3D + qemu_opt_get_number(opts, "throttling.iops-total-max-length", 1); + throttle_cfg->buckets[THROTTLE_OPS_READ].burst_length =3D + qemu_opt_get_number(opts, "throttling.iops-read-max-length", 1); + throttle_cfg->buckets[THROTTLE_OPS_WRITE].burst_length =3D + qemu_opt_get_number(opts, "throttling.iops-write-max-length", 1); + + throttle_cfg->op_size =3D + qemu_opt_get_number(opts, "throttling.iops-size", 0); + +} --=20 1.8.3.1 From nobody Sat May 4 03:12:25 2024 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@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494405970029359.6243794325395; Wed, 10 May 2017 01:46:10 -0700 (PDT) Received: from localhost ([::1]:41160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8NG4-000053-Mm for importer@patchew.org; Wed, 10 May 2017 04:46:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8NCZ-0005Zn-Sd for qemu-devel@nongnu.org; Wed, 10 May 2017 04:42:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8NCY-0007DW-Ev for qemu-devel@nongnu.org; Wed, 10 May 2017 04:42:31 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:36459) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d8NCY-0007DG-59 for qemu-devel@nongnu.org; Wed, 10 May 2017 04:42:30 -0400 Received: by mail-wr0-x241.google.com with SMTP id v42so6323259wrc.3 for ; Wed, 10 May 2017 01:42:30 -0700 (PDT) Received: from centos-minion-1.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id y63sm4300148wme.31.2017.05.10.01.42.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 May 2017 01:42:28 -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=RjStfD+hmelHWNosBEklKfl46zz1AykuluL/cUVTY0o=; b=NbXqafCtPowW0KLwkxZWwE0rI+XsK6BLJlwP08fr4SasopeZKA7x8TJJqWBCaWHtr9 65j+reKoVWhzW3c17Mn2r2AgiQAbDcbcovtgEiXz2LCWS/+dioHeVtPrO4+uXELAlwSq g2jbBJFVwMvq4UHj4nrkGRQ+h2ViHI0l6aaaE+Sgkj/7sKFGSSjM1BiuhhzNjft/+C9Z iItqRsi1Ol7W2AmhHJ1z1RCmC4xa1pjJdIjay0GlsfiHAsv86yOu+kwGxNQphNo1IUZN /GcE7XypV+XbcOI975DGxbHcFnNu/HmIEvWJnRlsYsdXGzavycXqfZRu0+XAyQnJwCI2 WEZw== 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=RjStfD+hmelHWNosBEklKfl46zz1AykuluL/cUVTY0o=; b=TGIZ+BpGV1Qi6xWFr7EJJ+3CV2FW5INnaNP8qS16+/I9Kf8yEv/Un1hq4D7ZhKPQ65 MdJ8XMrJRTp86Jn0UaJQ3B8+xC5ZpVcCwLR23/8pctE7zEFC0XNL5C/pusebOQDlZp34 6/1hAPJlvctFSHOIGVE4sjqxlGK5tQU+lV8O8ShJWX5PYGdyAsuUmIKBUN8BimJvqMU9 ifLIh3mS5QRU5cpfYL22MZgEcxBvChV1Zgr6kyaWAdfGxzgTKKzjlkh3KWktWAEb4TbX ho6zUUOqCwq0M99IETRgvQuuA91V40EQGTPISsXuDdpQdlOXEs3bPnKkHA9DW2V4Q3aO cPQQ== X-Gm-Message-State: AODbwcDw+A2nNYpGVXwtoedyzEtkvO9FwKpUu+M9vY23d5VBq5Emgr3u CcoyofNyjyRKGw== X-Received: by 10.28.30.145 with SMTP id e139mr215995wme.129.1494405749024; Wed, 10 May 2017 01:42:29 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Wed, 10 May 2017 04:41:21 -0400 Message-Id: <1494405683-20877-3-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1494405683-20877-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1494405683-20877-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 v4 2/4] qmp: Create IOThrottle structure 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: jani kokkonen , alberto garcia , Pradeep Jagadeesh , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.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 enables qmp interfaces for the fsdev devices. This provides two interfaces one=20 for querying info of all the fsdev devices. The second one to set the IO limits for the required fsdev device. Signed-off-by: Pradeep Jagadeesh Reviewed-by: Greg Kurz Reviewed-by: Eric Blake --- qapi/block-core.json | 76 ++------------------------------------------- qapi/iothrottle.json | 88 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 91 insertions(+), 73 deletions(-) create mode 100644 qapi/iothrottle.json diff --git a/qapi/block-core.json b/qapi/block-core.json index 87fb747..93d346b 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -6,6 +6,7 @@ =20 # QAPI common definitions { 'include': 'common.json' } +{ 'include': 'iothrottle.json' } =20 ## # @SnapshotInfo: @@ -1760,84 +1761,13 @@ # # @device: Block device name (deprecated, use @id instead) # -# @id: The name or QOM path of the guest device (since: 2.8) -# -# @bps: total throughput limit in bytes per second -# -# @bps_rd: read throughput limit in bytes per second -# -# @bps_wr: write throughput limit in bytes per second -# -# @iops: total I/O operations per second -# -# @iops_rd: read I/O operations per second -# -# @iops_wr: write I/O operations per second -# -# @bps_max: total throughput limit during bursts, -# in bytes (Since 1.7) -# -# @bps_rd_max: read throughput limit during bursts, -# in bytes (Since 1.7) -# -# @bps_wr_max: write throughput limit during bursts, -# in bytes (Since 1.7) -# -# @iops_max: total I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @iops_rd_max: read I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @iops_wr_max: write I/O operations per second during bursts, -# in bytes (Since 1.7) -# -# @bps_max_length: maximum length of the @bps_max burst -# period, in seconds. It must only -# be set if @bps_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @bps_rd_max_length: maximum length of the @bps_rd_max -# burst period, in seconds. It must only -# be set if @bps_rd_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @bps_wr_max_length: maximum length of the @bps_wr_max -# burst period, in seconds. It must only -# be set if @bps_wr_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_max_length: maximum length of the @iops burst -# period, in seconds. It must only -# be set if @iops_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_rd_max_length: maximum length of the @iops_rd_max -# burst period, in seconds. It must only -# be set if @iops_rd_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_wr_max_length: maximum length of the @iops_wr_max -# burst period, in seconds. It must only -# be set if @iops_wr_max is set as well. -# Defaults to 1. (Since 2.6) -# -# @iops_size: an I/O size in bytes (Since 1.7) -# # @group: throttle group name (Since 2.4) # # Since: 1.1 ## { 'struct': 'BlockIOThrottle', - 'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int', - 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': '= int', - '*bps_max': 'int', '*bps_rd_max': 'int', - '*bps_wr_max': 'int', '*iops_max': 'int', - '*iops_rd_max': 'int', '*iops_wr_max': 'int', - '*bps_max_length': 'int', '*bps_rd_max_length': 'int', - '*bps_wr_max_length': 'int', '*iops_max_length': 'int', - '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int', - '*iops_size': 'int', '*group': 'str' } } + 'base': 'IOThrottle', + 'data': { '*device': 'str', '*group': 'str' } } =20 ## # @block-stream: diff --git a/qapi/iothrottle.json b/qapi/iothrottle.json new file mode 100644 index 0000000..0f067c3 --- /dev/null +++ b/qapi/iothrottle.json @@ -0,0 +1,88 @@ +# -*- Mode: Python -*- + +## +# =3D=3D QAPI IOThrottle definitions +## + +## +# @IOThrottle: +# +# A set of parameters describing IO throttling +# +# @id: The name or QOM path of the guest device (since: 2.8) +# +# @bps: total throughput limit in bytes per second +# +# @bps_rd: read throughput limit in bytes per second +# +# @bps_wr: write throughput limit in bytes per second +# +# @iops: total I/O operations per second +# +# @iops_rd: read I/O operations per second +# +# @iops_wr: write I/O operations per second +# +# @bps_max: total throughput limit during bursts, +# in bytes (Since 1.7) +# +# @bps_rd_max: read throughput limit during bursts, +# in bytes (Since 1.7) +# +# @bps_wr_max: write throughput limit during bursts, +# in bytes (Since 1.7) +# +# @iops_max: total I/O operations per second during bursts, +# in bytes (Since 1.7) +# +# @iops_rd_max: read I/O operations per second during bursts, +# in bytes (Since 1.7) +# +# @iops_wr_max: write I/O operations per second during bursts, +# in bytes (Since 1.7) +# +# @bps_max_length: maximum length of the @bps_max burst +# period, in seconds. It must only +# be set if @bps_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @bps_rd_max_length: maximum length of the @bps_rd_max +# burst period, in seconds. It must only +# be set if @bps_rd_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @bps_wr_max_length: maximum length of the @bps_wr_max +# burst period, in seconds. It must only +# be set if @bps_wr_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @iops_max_length: maximum length of the @iops burst +# period, in seconds. It must only +# be set if @iops_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @iops_rd_max_length: maximum length of the @iops_rd_max +# burst period, in seconds. It must only +# be set if @iops_rd_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @iops_wr_max_length: maximum length of the @iops_wr_max +# burst period, in seconds. It must only +# be set if @iops_wr_max is set as well. +# Defaults to 1. (Since 2.6) +# +# @iops_size: an I/O size in bytes (Since 1.7) +# +# +# Since: 2.10 +## +{ 'struct': 'IOThrottle', + 'data': { '*id': 'str', 'bps': 'int', 'bps_rd': 'int', + 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': '= int', + '*bps_max': 'int', '*bps_rd_max': 'int', + '*bps_wr_max': 'int', '*iops_max': 'int', + '*iops_rd_max': 'int', '*iops_wr_max': 'int', + '*bps_max_length': 'int', '*bps_rd_max_length': 'int', + '*bps_wr_max_length': 'int', '*iops_max_length': 'int', + '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int', + '*iops_size': 'int' } } --=20 1.8.3.1 From nobody Sat May 4 03:12:25 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494405856635525.626925894213; Wed, 10 May 2017 01:44:16 -0700 (PDT) Received: from localhost ([::1]:41146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8NEF-0006o7-59 for importer@patchew.org; Wed, 10 May 2017 04:44:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8NCa-0005c4-JB for qemu-devel@nongnu.org; Wed, 10 May 2017 04:42:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8NCZ-0007Dh-78 for qemu-devel@nongnu.org; Wed, 10 May 2017 04:42:32 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:36465) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d8NCY-0007DS-Tr for qemu-devel@nongnu.org; Wed, 10 May 2017 04:42:31 -0400 Received: by mail-wr0-x242.google.com with SMTP id v42so6323461wrc.3 for ; Wed, 10 May 2017 01:42:30 -0700 (PDT) Received: from centos-minion-1.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id y63sm4300148wme.31.2017.05.10.01.42.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 May 2017 01:42:29 -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=+00665U+zG4JyAYtaIBEC+w1kOkoaX6Iyxn+NABcG2Q=; b=AxKFchlL3jVXG6SVFuwKz9DIGA2Tq55Mn9MqT6yc4qef0rWVSsNXfi5cklA2SHw+xt ZTGSFuhLyW23/SH3s3M5JcHrOeRTJiJa/YBxlG/01REaLsDnQgtP19feWklB8zPTnnuM mp4Ygd5BmGMLKyyZhKJtuRFzBkCy0aiVxcNWcth73fTbGLMOZ6cLWs3qU09+xpKB1G0q 7HjelUQoJSXALuEs+ocXYGnHzF5GsNxT119JZwCs5rCd3FGCSLOovdhqVNppARqSD9Wj 2Vhzjk6baCQQCUJ73eNJB8d8TCdmOz7zhv7nl2PN/ABfIuCDBWN5LpjVX8L/BpopSjiC rcZQ== 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=+00665U+zG4JyAYtaIBEC+w1kOkoaX6Iyxn+NABcG2Q=; b=ors/2b1jl0Kv2iPYmcYW6rL9HX/GvoNVfDF3qUfPhWDwI+lH/W0wYZsEYp37IDEkvG xeiA62Y1YeNmfacrOnuGCX8f0tqg7U6JEnU+uoKsOgliezcte9lQeSiMOmqno7Pt2R0m FhguAqQfvLK+rLqxNKZdJisKk5qYjF36gR8ifd8roOfAKpNpE6xJdLiEs7jE19bIQfc4 18GjqRrkkni2rI+LBpL41Rdwy6imDa7dXFrA7WfuQpr1/esnJuGNffX1tNuCsMSdYY1F SgroQiTbokfoQIER/0pxWDUm5WmyGaB3K0m9NLOgM8/oku78CM/WKuYh8oABnRm5qtB4 b8Bw== X-Gm-Message-State: AODbwcDJceJuLuPjOFTPU/aY/TVU0i3VcD8ZGHAXkXqjSTygSGVg94aM r1Di+/5svzh9OA== X-Received: by 10.28.207.207 with SMTP id f198mr221310wmg.85.1494405749920; Wed, 10 May 2017 01:42:29 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Wed, 10 May 2017 04:41:22 -0400 Message-Id: <1494405683-20877-4-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1494405683-20877-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1494405683-20877-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::242 Subject: [Qemu-devel] [PATCH v4 3/4] qmp: refactor duplicate code 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: jani kokkonen , alberto garcia , Pradeep Jagadeesh , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch factor out the duplicate qmp throttle interface code that was present in both block and fsdev device files. Signed-off-by: Pradeep Jagadeesh --- blockdev.c | 53 +++----------------------------------= --- hmp.c | 21 +++++++++++----- include/qemu/throttle-options.h | 2 ++ util/throttle-options.c | 54 +++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 74 insertions(+), 56 deletions(-) diff --git a/blockdev.c b/blockdev.c index a0eb2ed..a55f6be 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2593,6 +2593,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, = Error **errp) BlockDriverState *bs; BlockBackend *blk; AioContext *aio_context; + IOThrottle *iothrottle; =20 blk =3D qmp_get_blk(arg->has_device ? arg->device : NULL, arg->has_id ? arg->id : NULL, @@ -2610,56 +2611,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg,= Error **errp) goto out; } =20 - throttle_config_init(&cfg); - cfg.buckets[THROTTLE_BPS_TOTAL].avg =3D arg->bps; - cfg.buckets[THROTTLE_BPS_READ].avg =3D arg->bps_rd; - cfg.buckets[THROTTLE_BPS_WRITE].avg =3D arg->bps_wr; - - cfg.buckets[THROTTLE_OPS_TOTAL].avg =3D arg->iops; - cfg.buckets[THROTTLE_OPS_READ].avg =3D arg->iops_rd; - cfg.buckets[THROTTLE_OPS_WRITE].avg =3D arg->iops_wr; - - if (arg->has_bps_max) { - cfg.buckets[THROTTLE_BPS_TOTAL].max =3D arg->bps_max; - } - if (arg->has_bps_rd_max) { - cfg.buckets[THROTTLE_BPS_READ].max =3D arg->bps_rd_max; - } - if (arg->has_bps_wr_max) { - cfg.buckets[THROTTLE_BPS_WRITE].max =3D arg->bps_wr_max; - } - if (arg->has_iops_max) { - cfg.buckets[THROTTLE_OPS_TOTAL].max =3D arg->iops_max; - } - if (arg->has_iops_rd_max) { - cfg.buckets[THROTTLE_OPS_READ].max =3D arg->iops_rd_max; - } - if (arg->has_iops_wr_max) { - cfg.buckets[THROTTLE_OPS_WRITE].max =3D arg->iops_wr_max; - } - - if (arg->has_bps_max_length) { - cfg.buckets[THROTTLE_BPS_TOTAL].burst_length =3D arg->bps_max_leng= th; - } - if (arg->has_bps_rd_max_length) { - cfg.buckets[THROTTLE_BPS_READ].burst_length =3D arg->bps_rd_max_le= ngth; - } - if (arg->has_bps_wr_max_length) { - cfg.buckets[THROTTLE_BPS_WRITE].burst_length =3D arg->bps_wr_max_l= ength; - } - if (arg->has_iops_max_length) { - cfg.buckets[THROTTLE_OPS_TOTAL].burst_length =3D arg->iops_max_len= gth; - } - if (arg->has_iops_rd_max_length) { - cfg.buckets[THROTTLE_OPS_READ].burst_length =3D arg->iops_rd_max_l= ength; - } - if (arg->has_iops_wr_max_length) { - cfg.buckets[THROTTLE_OPS_WRITE].burst_length =3D arg->iops_wr_max_= length; - } - - if (arg->has_iops_size) { - cfg.op_size =3D arg->iops_size; - } + iothrottle =3D qapi_BlockIOThrottle_base(arg); + qmp_set_io_throttle(&cfg, iothrottle); =20 if (!throttle_is_valid(&cfg, errp)) { goto out; diff --git a/hmp.c b/hmp.c index ab407d6..9660373 100644 --- a/hmp.c +++ b/hmp.c @@ -1552,20 +1552,29 @@ void hmp_change(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } =20 +static void hmp_initialize_io_throttle(IOThrottle *iot, const QDict *qdict) +{ + iot->has_id =3D true; + iot->id =3D (char *) qdict_get_str(qdict, "id"); + iot->bps =3D qdict_get_int(qdict, "bps"); + iot->bps_rd =3D qdict_get_int(qdict, "bps_rd"); + iot->bps_wr =3D qdict_get_int(qdict, "bps_wr"); + iot->iops =3D qdict_get_int(qdict, "iops"); + iot->iops_rd =3D qdict_get_int(qdict, "iops_rd"); + iot->iops_wr =3D qdict_get_int(qdict, "iops_wr"); +} + void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; + IOThrottle *iothrottle; 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 + iothrottle =3D qapi_BlockIOThrottle_base(&throttle); + hmp_initialize_io_throttle(iothrottle, qdict); qmp_block_set_io_throttle(&throttle, &err); hmp_handle_error(mon, &err); } diff --git a/include/qemu/throttle-options.h b/include/qemu/throttle-option= s.h index 9b68eb8..ccf10cc 100644 --- a/include/qemu/throttle-options.h +++ b/include/qemu/throttle-options.h @@ -94,4 +94,6 @@ =20 void parse_io_throttle_options(ThrottleConfig *, QemuOpts *); =20 +void qmp_set_io_throttle(ThrottleConfig *, IOThrottle *); + #endif diff --git a/util/throttle-options.c b/util/throttle-options.c index 02b26b8..ded57bc 100644 --- a/util/throttle-options.c +++ b/util/throttle-options.c @@ -49,3 +49,57 @@ void parse_io_throttle_options(ThrottleConfig *throttle_= cfg, QemuOpts *opts) qemu_opt_get_number(opts, "throttling.iops-size", 0); =20 } + +void qmp_set_io_throttle(ThrottleConfig *cfg, IOThrottle *arg) +{ + throttle_config_init(cfg); + cfg->buckets[THROTTLE_BPS_TOTAL].avg =3D arg->bps; + cfg->buckets[THROTTLE_BPS_READ].avg =3D arg->bps_rd; + cfg->buckets[THROTTLE_BPS_WRITE].avg =3D arg->bps_wr; + + cfg->buckets[THROTTLE_OPS_TOTAL].avg =3D arg->iops; + cfg->buckets[THROTTLE_OPS_READ].avg =3D arg->iops_rd; + cfg->buckets[THROTTLE_OPS_WRITE].avg =3D arg->iops_wr; + + if (arg->has_bps_max) { + cfg->buckets[THROTTLE_BPS_TOTAL].max =3D arg->bps_max; + } + if (arg->has_bps_rd_max) { + cfg->buckets[THROTTLE_BPS_READ].max =3D arg->bps_rd_max; + } + if (arg->has_bps_wr_max) { + cfg->buckets[THROTTLE_BPS_WRITE].max =3D arg->bps_wr_max; + } + if (arg->has_iops_max) { + cfg->buckets[THROTTLE_OPS_TOTAL].max =3D arg->iops_max; + } + if (arg->has_iops_rd_max) { + cfg->buckets[THROTTLE_OPS_READ].max =3D arg->iops_rd_max; + } + if (arg->has_iops_wr_max) { + cfg->buckets[THROTTLE_OPS_WRITE].max =3D arg->iops_wr_max; + } + + if (arg->has_bps_max_length) { + cfg->buckets[THROTTLE_BPS_TOTAL].burst_length =3D arg->bps_max_len= gth; + } + if (arg->has_bps_rd_max_length) { + cfg->buckets[THROTTLE_BPS_READ].burst_length =3D arg->bps_rd_max_l= ength; + } + if (arg->has_bps_wr_max_length) { + cfg->buckets[THROTTLE_BPS_WRITE].burst_length =3D arg->bps_wr_max_= length; + } + if (arg->has_iops_max_length) { + cfg->buckets[THROTTLE_OPS_TOTAL].burst_length =3D arg->iops_max_le= ngth; + } + if (arg->has_iops_rd_max_length) { + cfg->buckets[THROTTLE_OPS_READ].burst_length =3D arg->iops_rd_max_= length; + } + if (arg->has_iops_wr_max_length) { + cfg->buckets[THROTTLE_OPS_WRITE].burst_length =3D arg->iops_wr_max= _length; + } + + if (arg->has_iops_size) { + cfg->op_size =3D arg->iops_size; + } +} --=20 1.8.3.1 From nobody Sat May 4 03:12:25 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494405861567692.403190004915; Wed, 10 May 2017 01:44:21 -0700 (PDT) Received: from localhost ([::1]:41147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8NEK-0006rI-50 for importer@patchew.org; Wed, 10 May 2017 04:44:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8NCc-0005fE-7V for qemu-devel@nongnu.org; Wed, 10 May 2017 04:42:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8NCa-0007EE-Ak for qemu-devel@nongnu.org; Wed, 10 May 2017 04:42:34 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:35295) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d8NCa-0007Dl-1G for qemu-devel@nongnu.org; Wed, 10 May 2017 04:42:32 -0400 Received: by mail-wr0-x243.google.com with SMTP id g12so6336159wrg.2 for ; Wed, 10 May 2017 01:42:31 -0700 (PDT) Received: from centos-minion-1.localdomain ([217.110.131.66]) by smtp.gmail.com with ESMTPSA id y63sm4300148wme.31.2017.05.10.01.42.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 May 2017 01:42:30 -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=8qKwWB02woZDORBoMKr4Xe3goxvR5oWZ839AVeya7O8=; b=rIxEp5RE418l+WGpbq4OYYtS0Bc6vX8lFd701dmlxb/oC7kCy/0tUE7FPWBSviyV7e hSqU3xL1E+P2//ynoLG/8CbM9pxqXIqM7zvZwihtZzuLUDkQzYR8Gg2OpROXHXOOvttc PYoZ6guaShWbdFO4OLhz2vRfNlH6jes+ZyvyG7gjDUErwvPvFryJ3Rx4JC2YcahJSLzB cTYUQS088eITOjN+SnK1OyxOkDLHbbfA3k3JaAha5T01XgOxb0Yc5TQMjRM/ArY1o+Fh guoc+7MHdDB8FVtuKwNmS/jSRRw3dOmreB+1xgBzlFhHzL0q4ZSuKXevXTSY83tmSFVJ iw5Q== 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=8qKwWB02woZDORBoMKr4Xe3goxvR5oWZ839AVeya7O8=; b=HF6eqAK6o6NlpZT8fzgLLyPbfJ05NpXpxjMm6u30DxOvYUjQjnVnMMyi9CBSLypgoV Q9mArIt3IAGXBZTjdF3IPpg0hitWHVhmu7DsD31CR9/MbhXXaW34yoADSLouMAxoP9hO zH3awVUsKyPoHfCf9+DbucsZ1D/2DcQD1zCRZQPY5lIMV3SYuHKOPVG3KovIYkA3cd8e bikZVy9Nsznw/uAk/Cjxxdo+nIiLWU4ZhPBx0dfLlcoLqB/BNA7YyALHm0S2gec226WN 1NAh0RRxhrGhrkTol0Yvja8gMH1ZC5k8hsaow9jjzN0QKBvmaiizqEdlSat3qjT8Hbk3 RTZg== X-Gm-Message-State: AODbwcD/minLTa6DajRJ9bNWufZJb5HY2q85T4t2OQbWqge8o5cteyig ubNl5Cb7bWoQng== X-Received: by 10.223.164.153 with SMTP id g25mr2754294wrb.103.1494405750826; Wed, 10 May 2017 01:42:30 -0700 (PDT) From: Pradeep Jagadeesh X-Google-Original-From: Pradeep Jagadeesh To: "eric blake" , "greg kurz" Date: Wed, 10 May 2017 04:41:23 -0400 Message-Id: <1494405683-20877-5-git-send-email-pradeep.jagadeesh@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1494405683-20877-1-git-send-email-pradeep.jagadeesh@huawei.com> References: <1494405683-20877-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 v4 4/4] fsdev: QMP 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: jani kokkonen , alberto garcia , Pradeep Jagadeesh , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch enables qmp interfaces for the fsdev devices. This provides two interfaces one=20 for querying info of all the fsdev devices. The second one to set the IO limits for the required fsdev device. Signed-off-by: Pradeep Jagadeesh --- Makefile | 3 ++ fsdev/qemu-fsdev-dummy.c | 10 ++++++ fsdev/qemu-fsdev-throttle.c | 75 ++++++++++++++++++++++++++++++++++++++++ fsdev/qemu-fsdev-throttle.h | 12 +++++++ fsdev/qemu-fsdev.c | 37 ++++++++++++++++++++ hmp-commands-info.hx | 19 ++++++++++ hmp-commands.hx | 19 ++++++++++ hmp.c | 67 ++++++++++++++++++++++++++++++++++++ hmp.h | 4 +++ qapi-schema.json | 3 ++ qapi/fsdev.json | 84 +++++++++++++++++++++++++++++++++++++++++= ++++ qmp.c | 15 ++++++++ 12 files changed, 348 insertions(+) create mode 100644 qapi/fsdev.json diff --git a/Makefile b/Makefile index 31d41a7..7b928d9 100644 --- a/Makefile +++ b/Makefile @@ -414,6 +414,9 @@ qapi-modules =3D $(SRC_PATH)/qapi-schema.json $(SRC_PAT= H)/qapi/common.json \ $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.jso= n \ $(SRC_PATH)/qapi/crypto.json $(SRC_PATH)/qapi/rocker.json \ $(SRC_PATH)/qapi/trace.json +ifdef CONFIG_VIRTFS +qapi-modules +=3D $(SRC_PATH)/qapi/fsdev.json +endif =20 qapi-types.c qapi-types.h :\ $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) diff --git a/fsdev/qemu-fsdev-dummy.c b/fsdev/qemu-fsdev-dummy.c index 6dc0fbc..f33305d 100644 --- a/fsdev/qemu-fsdev-dummy.c +++ b/fsdev/qemu-fsdev-dummy.c @@ -19,3 +19,13 @@ int qemu_fsdev_add(QemuOpts *opts) { return 0; } + +void qmp_fsdev_set_io_throttle(IOThrottle *arg, Error **errp) +{ + return; +} + +IOThrottleList *qmp_query_fsdev_io_throttle(Error **errp) +{ + abort(); +} diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index db386a7..ccbdfbd 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -29,6 +29,81 @@ static void fsdev_throttle_write_timer_cb(void *opaque) qemu_co_enter_next(&fst->throttled_reqs[true]); } =20 +void fsdev_set_io_throttle(IOThrottle *arg, FsThrottle *fst, Error **errp) +{ + ThrottleConfig cfg; + + qmp_set_io_throttle(&cfg, arg); + + if (throttle_is_valid(&cfg, errp)) { + fst->cfg =3D cfg; + fsdev_throttle_init(fst); + } +} + +void fsdev_get_io_throttle(FsThrottle *fst, IOThrottle **fs9pcfg, + char *fsdevice, Error **errp) +{ + + ThrottleConfig cfg =3D fst->cfg; + IOThrottle *fscfg =3D g_malloc0(sizeof(*fscfg)); + + fscfg->has_id =3D true; + fscfg->id =3D g_strdup(fsdevice); + fscfg->bps =3D cfg.buckets[THROTTLE_BPS_TOTAL].avg; + fscfg->bps_rd =3D cfg.buckets[THROTTLE_BPS_READ].avg; + fscfg->bps_wr =3D cfg.buckets[THROTTLE_BPS_WRITE].avg; + + fscfg->iops =3D cfg.buckets[THROTTLE_OPS_TOTAL].avg; + fscfg->iops_rd =3D cfg.buckets[THROTTLE_OPS_READ].avg; + fscfg->iops_wr =3D cfg.buckets[THROTTLE_OPS_WRITE].avg; + + fscfg->has_bps_max =3D cfg.buckets[THROTTLE_BPS_TOTAL].max; + fscfg->bps_max =3D cfg.buckets[THROTTLE_BPS_TOTAL].max; + fscfg->has_bps_rd_max =3D cfg.buckets[THROTTLE_BPS_READ].max; + fscfg->bps_rd_max =3D cfg.buckets[THROTTLE_BPS_READ].max; + fscfg->has_bps_wr_max =3D cfg.buckets[THROTTLE_BPS_WRITE].max; + fscfg->bps_wr_max =3D cfg.buckets[THROTTLE_BPS_WRITE].max; + + fscfg->has_iops_max =3D cfg.buckets[THROTTLE_OPS_TOTAL].max; + fscfg->iops_max =3D cfg.buckets[THROTTLE_OPS_TOTAL].max; + fscfg->has_iops_rd_max =3D cfg.buckets[THROTTLE_OPS_READ].max; + fscfg->iops_rd_max =3D cfg.buckets[THROTTLE_OPS_READ].max; + fscfg->has_iops_wr_max =3D cfg.buckets[THROTTLE_OPS_WRITE].max; + fscfg->iops_wr_max =3D cfg.buckets[THROTTLE_OPS_WRITE].max; + + fscfg->has_bps_max_length =3D fscfg->has_bps_max; + fscfg->bps_max_length =3D + cfg.buckets[THROTTLE_BPS_TOTAL].burst_length; + fscfg->has_bps_rd_max_length =3D fscfg->has_bps_rd_max; + fscfg->bps_rd_max_length =3D + cfg.buckets[THROTTLE_BPS_READ].burst_length; + fscfg->has_bps_wr_max_length =3D fscfg->has_bps_wr_max; + fscfg->bps_wr_max_length =3D + cfg.buckets[THROTTLE_BPS_WRITE].burst_length; + + fscfg->has_iops_max_length =3D fscfg->has_iops_max; + fscfg->iops_max_length =3D + cfg.buckets[THROTTLE_OPS_TOTAL].burst_length; + fscfg->has_iops_rd_max_length =3D fscfg->has_iops_rd_max; + fscfg->iops_rd_max_length =3D + cfg.buckets[THROTTLE_OPS_READ].burst_length; + fscfg->has_iops_wr_max_length =3D fscfg->has_iops_wr_max; + fscfg->iops_wr_max_length =3D + cfg.buckets[THROTTLE_OPS_WRITE].burst_length; + + fscfg->bps_max_length =3D cfg.buckets[THROTTLE_BPS_TOTAL].burst_length; + fscfg->bps_rd_max_length =3D cfg.buckets[THROTTLE_BPS_READ].burst_leng= th; + fscfg->bps_wr_max_length =3D cfg.buckets[THROTTLE_BPS_WRITE].burst_len= gth; + fscfg->iops_max_length =3D cfg.buckets[THROTTLE_OPS_TOTAL].burst_lengt= h; + fscfg->iops_rd_max_length =3D cfg.buckets[THROTTLE_OPS_READ].burst_len= gth; + fscfg->iops_wr_max_length =3D cfg.buckets[THROTTLE_OPS_WRITE].burst_le= ngth; + + fscfg->iops_size =3D cfg.op_size; + + *fs9pcfg =3D fscfg; +} + void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **er= rp) { parse_io_throttle_options(&fst->cfg, opts); diff --git a/fsdev/qemu-fsdev-throttle.h b/fsdev/qemu-fsdev-throttle.h index c493e83..a49b2e5 100644 --- a/fsdev/qemu-fsdev-throttle.h +++ b/fsdev/qemu-fsdev-throttle.h @@ -21,6 +21,12 @@ #include "qapi/error.h" #include "qemu/throttle.h" #include "qemu/throttle-options.h" +#include "qapi/qmp/qerror.h" +#include "qapi/qmp/types.h" +#include "qapi-visit.h" +#include "qapi/qobject-output-visitor.h" +#include "qapi/util.h" +#include "qmp-commands.h" =20 typedef struct FsThrottle { ThrottleState ts; @@ -37,4 +43,10 @@ void coroutine_fn fsdev_co_throttle_request(FsThrottle *= , bool , struct iovec *, int); =20 void fsdev_throttle_cleanup(FsThrottle *); + +void fsdev_set_io_throttle(IOThrottle *, FsThrottle *, Error **errp); + +void fsdev_get_io_throttle(FsThrottle *, IOThrottle **iothp, + char *, Error **errp); + #endif /* _FSDEV_THROTTLE_H */ diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index 266e442..a99e299 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -16,6 +16,7 @@ #include "qemu-common.h" #include "qemu/config-file.h" #include "qemu/error-report.h" +#include "qmp-commands.h" =20 static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries= =3D QTAILQ_HEAD_INITIALIZER(fsdriver_entries); @@ -98,3 +99,39 @@ FsDriverEntry *get_fsdev_fsentry(char *id) } return NULL; } + +void qmp_fsdev_set_io_throttle(IOThrottle *arg, Error **errp) +{ + + FsDriverEntry *fse; + + fse =3D get_fsdev_fsentry(arg->has_id ? arg->id : NULL); + if (!fse) { + return; + } + + fsdev_set_io_throttle(arg, &fse->fst, errp); +} + +IOThrottleList *qmp_query_fsdev_io_throttle(Error **errp) +{ + IOThrottleList *head =3D NULL, **p_next =3D &head; + struct FsDriverListEntry *fsle; + Error *local_err =3D NULL; + + QTAILQ_FOREACH(fsle, &fsdriver_entries, next) { + IOThrottleList *fscfg =3D g_malloc0(sizeof(*fscfg)); + fsdev_get_io_throttle(&fsle->fse.fst, &fscfg->value, + fsle->fse.fsdev_id, &local_err); + if (local_err) { + error_propagate(errp, local_err); + g_free(fscfg); + qapi_free_IOThrottleList(head); + return NULL; + } + + *p_next =3D fscfg; + p_next =3D &fscfg->next; + } + return head; +} diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index a53f105..8c1c33e 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -84,6 +84,25 @@ STEXI Show block device statistics. ETEXI =20 +#if defined(CONFIG_VIRTFS) + + { + .name =3D "query-fsdev-iothrottle", + .args_type =3D "", + .params =3D "", + .help =3D "show fsdev device throttle information", + .cmd =3D hmp_fsdev_get_io_throttle, + }, + +#endif + +STEXI +@item info fsdev throttle +@findex fsdevthrottleinfo +Show fsdev device throttleinfo. + +ETEXI + { .name =3D "block-jobs", .args_type =3D "", diff --git a/hmp-commands.hx b/hmp-commands.hx index 0aca984..7699475 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1660,6 +1660,25 @@ STEXI Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @va= r{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} ETEXI =20 +#if defined(CONFIG_VIRTFS) + + { + .name =3D "fsdev-set-io-throttle", + .args_type =3D "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l= ,iops_wr:l", + .params =3D "device bps bps_rd bps_wr iops iops_rd iops_wr", + .help =3D "change I/O throttle limits for a block drive", + .cmd =3D hmp_fsdev_set_io_throttle, + }, + +#endif + +STEXI +@item fsdev_set_io_throttle @var{device} @var{bps} @var{bps_rd} @var{bps_w= r} @var{iops} @var{iops_rd} @var{iops_wr} +@findex fsdev_set_io_throttle +Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @va= r{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} + +ETEXI + { .name =3D "set_password", .args_type =3D "protocol:s,password:s,connected:s?", diff --git a/hmp.c b/hmp.c index 9660373..19a4ad0 100644 --- a/hmp.c +++ b/hmp.c @@ -38,6 +38,7 @@ #include "qemu/cutils.h" #include "qemu/error-report.h" #include "hw/intc/intc.h" +#include "fsdev/qemu-fsdev-throttle.h" =20 #ifdef CONFIG_SPICE #include @@ -1579,6 +1580,72 @@ void hmp_block_set_io_throttle(Monitor *mon, const Q= Dict *qdict) hmp_handle_error(mon, &err); } =20 +#ifdef CONFIG_VIRTFS + +void hmp_fsdev_set_io_throttle(Monitor *mon, const QDict *qdict) +{ + Error *err =3D 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=3D%" PRId64 + " bps_rd=3D%" PRId64 " bps_wr=3D%" PRId64 + " bps_max=3D%" PRId64 + " bps_rd_max=3D%" PRId64 + " bps_wr_max=3D%" PRId64 + " iops=3D%" PRId64 " iops_rd=3D%" PRId64 + " iops_wr=3D%" PRId64 + " iops_max=3D%" PRId64 + " iops_rd_max=3D%" PRId64 + " iops_wr_max=3D%" PRId64 + " iops_size=3D%" 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 =3D NULL; + IOThrottleList *fs9p_list, *info; + fs9p_list =3D qmp_query_fsdev_io_throttle(&err); + + for (info =3D fs9p_list; info; info =3D info->next) { + if (info !=3D 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 =3D NULL; diff --git a/hmp.h b/hmp.h index 799fd37..f1adb9d 100644 --- a/hmp.h +++ b/hmp.h @@ -77,6 +77,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); diff --git a/qapi-schema.json b/qapi-schema.json index 01b087f..6aa1446 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -81,6 +81,9 @@ # QAPI block definitions { 'include': 'qapi/block.json' } =20 +# QAPI fsdev definitions +{ 'include': 'qapi/fsdev.json' } + # QAPI event definitions { 'include': 'qapi/event.json' } =20 diff --git a/qapi/fsdev.json b/qapi/fsdev.json new file mode 100644 index 0000000..eff1efe --- /dev/null +++ b/qapi/fsdev.json @@ -0,0 +1,84 @@ +# -*- Mode: Python -*- + +## +# =3D=3D QAPI fsdev definitions +## + +# QAPI common definitions +{ 'include': 'iothrottle.json' } + +## +# @fsdev-set-io-throttle: +# +# Change I/O limits for a 9p/fsdev device. +# +# I/O limits can be enabled by setting throttle value to non-zero number. +# +# I/O limits can be disabled by setting all throttle values to 0. +# +# Returns: Nothing on success +# If @device is not a valid fsdev device, DeviceNotFound +# +# Since: 2.10 +# +# Example: +# +# -> { "execute": "fsdev-set-io-throttle", +# "arguments": { "id": "id0-1-0", +# "bps": 1000000, +# "bps_rd": 0, +# "bps_wr": 0, +# "iops": 0, +# "iops_rd": 0, +# "iops_wr": 0, +# "bps_max": 8000000, +# "bps_rd_max": 0, +# "bps_wr_max": 0, +# "iops_max": 0, +# "iops_rd_max": 0, +# "iops_wr_max": 0, +# "bps_max_length": 60, +# "iops_size": 0 } } +# <- { "returns": {} } +## +{ 'command': 'fsdev-set-io-throttle', 'boxed': true, + 'data': 'IOThrottle' } +## +# @query-fsdev-io-throttle: +# +# Returns: a list of @IOThrottle describing io throttle values of each fsd= ev device +# +# Since: 2.10 +# +# Example: +# +# -> { "Execute": "query-fsdev-io-throttle" } +# <- { "returns" : [ +# { +# "id": "id0-hd0", +# "bps":1000000, +# "bps_rd":0, +# "bps_wr":0, +# "iops":1000000, +# "iops_rd":0, +# "iops_wr":0, +# "bps_max": 8000000, +# "bps_rd_max": 0, +# "bps_wr_max": 0, +# "iops_max": 0, +# "iops_rd_max": 0, +# "iops_wr_max": 0, +# "bps_max_length": 0, +# "bps_rd_max_length": 0, +# "bps_wr_max_length": 0, +# "iops_max_length": 0, +# "iops_rd_max_length": 0, +# "iops_wr_max_length": 0, +# "iops_size": 0 +# } +# ] +# } +# +## +{ 'command': 'query-fsdev-io-throttle', 'returns': [ 'IOThrottle' ] } + diff --git a/qmp.c b/qmp.c index ab74cd7..c76a973 100644 --- a/qmp.c +++ b/qmp.c @@ -130,6 +130,21 @@ void qmp_cpu_add(int64_t id, Error **errp) } } =20 +#ifdef _WIN64 + +void qmp_fsdev_set_io_throttle(IOThrottle *arg, Error **errp) +{ + return; +} + +IOThrottleList *qmp_query_fsdev_io_throttle(Error **errp) +{ + abort(); +} + +#endif + + #ifndef CONFIG_VNC /* If VNC support is enabled, the "true" query-vnc command is defined in the VNC subsystem */ --=20 1.8.3.1