From nobody Thu Nov 6 18:57:30 2025 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; 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 1488237681530484.06368127635767; Mon, 27 Feb 2017 15:21:21 -0800 (PST) Received: from localhost ([::1]:57529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciUbY-0000fr-4e for importer@patchew.org; Mon, 27 Feb 2017 18:21:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciUHj-0000WB-FW for qemu-devel@nongnu.org; Mon, 27 Feb 2017 18:00:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciUHh-0003ul-2A for qemu-devel@nongnu.org; Mon, 27 Feb 2017 18:00:51 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50591) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciUHg-0003n8-Lh for qemu-devel@nongnu.org; Mon, 27 Feb 2017 18:00:48 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1RMreEo107971 for ; Mon, 27 Feb 2017 18:00:41 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 28vm1w2u50-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 27 Feb 2017 18:00:40 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 27 Feb 2017 23:00:38 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 27 Feb 2017 23:00:36 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id BEED82190019; Mon, 27 Feb 2017 22:59:36 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1RN0Z0X19857862; Mon, 27 Feb 2017 23:00:35 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D8194A404D; Mon, 27 Feb 2017 23:00:31 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B608AA4040; Mon, 27 Feb 2017 23:00:31 +0000 (GMT) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 27 Feb 2017 23:00:31 +0000 (GMT) Received: from bahia.lan (icon-9-164-183-34.megacenter.de.ibm.com [9.164.183.34]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 7905C220225; Tue, 28 Feb 2017 00:00:34 +0100 (CET) From: Greg Kurz To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 23:59:53 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488236421-30983-1-git-send-email-groug@kaod.org> References: <1488236421-30983-1-git-send-email-groug@kaod.org> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17022723-0028-0000-0000-000002B2F5FB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17022723-0029-0000-0000-00002285FFF0 Message-Id: <1488236421-30983-4-git-send-email-groug@kaod.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-27_17:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=4 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702270213 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 03/31] 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: Pradeep Jagadeesh , Peter Maydell , "Aneesh Kumar K.V" , Pradeep , Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pradeep This patch removes the redundant throttle code that was present in block and fsdev device files. Now the common code is moved to a single file. Signed-off-by: Pradeep Jagadeesh Reviewed-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia (fix indent nit, Greg Kurz) Signed-off-by: Greg Kurz --- blockdev.c | 83 +++---------------------------------- fsdev/qemu-fsdev-opts.c | 80 ++--------------------------------- include/qemu/throttle-options.h | 92 +++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 102 insertions(+), 153 deletions(-) create mode 100644 include/qemu/throttle-options.h diff --git a/blockdev.c b/blockdev.c index 2b2f6ceef036..8682bd81d889 100644 --- a/blockdev.c +++ b/blockdev.c @@ -52,6 +52,7 @@ #include "sysemu/arch_init.h" #include "qemu/cutils.h" #include "qemu/help_option.h" +#include "qemu/throttle-options.h" =20 static QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =3D QTAILQ_HEAD_INITIALIZER(monitor_bdrv_states); @@ -4007,83 +4008,11 @@ QemuOptsList qemu_common_drive_opts =3D { .name =3D BDRV_OPT_READ_ONLY, .type =3D QEMU_OPT_BOOL, .help =3D "open drive file as read-only", - },{ - .name =3D "throttling.iops-total", - .type =3D QEMU_OPT_NUMBER, - .help =3D "limit total I/O operations per second", - },{ - .name =3D "throttling.iops-read", - .type =3D QEMU_OPT_NUMBER, - .help =3D "limit read operations per second", - },{ - .name =3D "throttling.iops-write", - .type =3D QEMU_OPT_NUMBER, - .help =3D "limit write operations per second", - },{ - .name =3D "throttling.bps-total", - .type =3D QEMU_OPT_NUMBER, - .help =3D "limit total bytes per second", - },{ - .name =3D "throttling.bps-read", - .type =3D QEMU_OPT_NUMBER, - .help =3D "limit read bytes per second", - },{ - .name =3D "throttling.bps-write", - .type =3D QEMU_OPT_NUMBER, - .help =3D "limit write bytes per second", - },{ - .name =3D "throttling.iops-total-max", - .type =3D QEMU_OPT_NUMBER, - .help =3D "I/O operations burst", - },{ - .name =3D "throttling.iops-read-max", - .type =3D QEMU_OPT_NUMBER, - .help =3D "I/O operations read burst", - },{ - .name =3D "throttling.iops-write-max", - .type =3D QEMU_OPT_NUMBER, - .help =3D "I/O operations write burst", - },{ - .name =3D "throttling.bps-total-max", - .type =3D QEMU_OPT_NUMBER, - .help =3D "total bytes burst", - },{ - .name =3D "throttling.bps-read-max", - .type =3D QEMU_OPT_NUMBER, - .help =3D "total bytes read burst", - },{ - .name =3D "throttling.bps-write-max", - .type =3D QEMU_OPT_NUMBER, - .help =3D "total bytes write burst", - },{ - .name =3D "throttling.iops-total-max-length", - .type =3D QEMU_OPT_NUMBER, - .help =3D "length of the iops-total-max burst period, in secon= ds", - },{ - .name =3D "throttling.iops-read-max-length", - .type =3D QEMU_OPT_NUMBER, - .help =3D "length of the iops-read-max burst period, in second= s", - },{ - .name =3D "throttling.iops-write-max-length", - .type =3D QEMU_OPT_NUMBER, - .help =3D "length of the iops-write-max burst period, in secon= ds", - },{ - .name =3D "throttling.bps-total-max-length", - .type =3D QEMU_OPT_NUMBER, - .help =3D "length of the bps-total-max burst period, in second= s", - },{ - .name =3D "throttling.bps-read-max-length", - .type =3D QEMU_OPT_NUMBER, - .help =3D "length of the bps-read-max burst period, in seconds= ", - },{ - .name =3D "throttling.bps-write-max-length", - .type =3D QEMU_OPT_NUMBER, - .help =3D "length of the bps-write-max burst period, in second= s", - },{ - .name =3D "throttling.iops-size", - .type =3D QEMU_OPT_NUMBER, - .help =3D "when limiting by iops max size of an I/O in bytes", - },{ + }, + + THROTTLE_OPTS, + + { .name =3D "throttling.group", .type =3D QEMU_OPT_STRING, .help =3D "name of the block throttling group", diff --git a/fsdev/qemu-fsdev-opts.c b/fsdev/qemu-fsdev-opts.c index 385423f02db6..bf5713008a1b 100644 --- a/fsdev/qemu-fsdev-opts.c +++ b/fsdev/qemu-fsdev-opts.c @@ -9,6 +9,7 @@ #include "qemu/config-file.h" #include "qemu/option.h" #include "qemu/module.h" +#include "qemu/throttle-options.h" =20 static QemuOptsList qemu_fsdev_opts =3D { .name =3D "fsdev", @@ -37,83 +38,10 @@ static QemuOptsList qemu_fsdev_opts =3D { }, { .name =3D "sock_fd", .type =3D QEMU_OPT_NUMBER, - }, { - .name =3D "throttling.iops-total", - .type =3D QEMU_OPT_NUMBER, - .help =3D "limit total I/O operations per second", - }, { - .name =3D "throttling.iops-read", - .type =3D QEMU_OPT_NUMBER, - .help =3D "limit read operations per second", - }, { - .name =3D "throttling.iops-write", - .type =3D QEMU_OPT_NUMBER, - .help =3D "limit write operations per second", - }, { - .name =3D "throttling.bps-total", - .type =3D QEMU_OPT_NUMBER, - .help =3D "limit total bytes per second", - }, { - .name =3D "throttling.bps-read", - .type =3D QEMU_OPT_NUMBER, - .help =3D "limit read bytes per second", - }, { - .name =3D "throttling.bps-write", - .type =3D QEMU_OPT_NUMBER, - .help =3D "limit write bytes per second", - }, { - .name =3D "throttling.iops-total-max", - .type =3D QEMU_OPT_NUMBER, - .help =3D "I/O operations burst", - }, { - .name =3D "throttling.iops-read-max", - .type =3D QEMU_OPT_NUMBER, - .help =3D "I/O operations read burst", - }, { - .name =3D "throttling.iops-write-max", - .type =3D QEMU_OPT_NUMBER, - .help =3D "I/O operations write burst", - }, { - .name =3D "throttling.bps-total-max", - .type =3D QEMU_OPT_NUMBER, - .help =3D "total bytes burst", - }, { - .name =3D "throttling.bps-read-max", - .type =3D QEMU_OPT_NUMBER, - .help =3D "total bytes read burst", - }, { - .name =3D "throttling.bps-write-max", - .type =3D QEMU_OPT_NUMBER, - .help =3D "total bytes write burst", - }, { - .name =3D "throttling.iops-total-max-length", - .type =3D QEMU_OPT_NUMBER, - .help =3D "length of the iops-total-max burst period, in secon= ds", - }, { - .name =3D "throttling.iops-read-max-length", - .type =3D QEMU_OPT_NUMBER, - .help =3D "length of the iops-read-max burst period, in second= s", - }, { - .name =3D "throttling.iops-write-max-length", - .type =3D QEMU_OPT_NUMBER, - .help =3D "length of the iops-write-max burst period, in secon= ds", - }, { - .name =3D "throttling.bps-total-max-length", - .type =3D QEMU_OPT_NUMBER, - .help =3D "length of the bps-total-max burst period, in second= s", - }, { - .name =3D "throttling.bps-read-max-length", - .type =3D QEMU_OPT_NUMBER, - .help =3D "length of the bps-read-max burst period, in seconds= ", - }, { - .name =3D "throttling.bps-write-max-length", - .type =3D QEMU_OPT_NUMBER, - .help =3D "length of the bps-write-max burst period, in second= s", - }, { - .name =3D "throttling.iops-size", - .type =3D QEMU_OPT_NUMBER, - .help =3D "when limiting by iops max size of an I/O in bytes", }, + + THROTTLE_OPTS, + { /*End of list */ } }, }; diff --git a/include/qemu/throttle-options.h b/include/qemu/throttle-option= s.h new file mode 100644 index 000000000000..3133d1ca4022 --- /dev/null +++ b/include/qemu/throttle-options.h @@ -0,0 +1,92 @@ +/* + * QEMU throttling command line options + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * (at your option) any later version. + * + * See the COPYING file in the top-level directory for details. + * + */ +#ifndef THROTTLE_OPTIONS_H +#define THROTTLE_OPTIONS_H + +#define THROTTLE_OPTS \ + { \ + .name =3D "throttling.iops-total",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "limit total I/O operations per second",\ + },{ \ + .name =3D "throttling.iops-read",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "limit read operations per second",\ + },{ \ + .name =3D "throttling.iops-write",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "limit write operations per second",\ + },{ \ + .name =3D "throttling.bps-total",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "limit total bytes per second",\ + },{ \ + .name =3D "throttling.bps-read",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "limit read bytes per second",\ + },{ \ + .name =3D "throttling.bps-write",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "limit write bytes per second",\ + },{ \ + .name =3D "throttling.iops-total-max",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "I/O operations burst",\ + },{ \ + .name =3D "throttling.iops-read-max",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "I/O operations read burst",\ + },{ \ + .name =3D "throttling.iops-write-max",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "I/O operations write burst",\ + },{ \ + .name =3D "throttling.bps-total-max",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "total bytes burst",\ + },{ \ + .name =3D "throttling.bps-read-max",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "total bytes read burst",\ + },{ \ + .name =3D "throttling.bps-write-max",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "total bytes write burst",\ + },{ \ + .name =3D "throttling.iops-total-max-length",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "length of the iops-total-max burst period, in secon= ds",\ + },{ \ + .name =3D "throttling.iops-read-max-length",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "length of the iops-read-max burst period, in second= s",\ + },{ \ + .name =3D "throttling.iops-write-max-length",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "length of the iops-write-max burst period, in secon= ds",\ + },{ \ + .name =3D "throttling.bps-total-max-length",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "length of the bps-total-max burst period, in second= s",\ + },{ \ + .name =3D "throttling.bps-read-max-length",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "length of the bps-read-max burst period, in seconds= ",\ + },{ \ + .name =3D "throttling.bps-write-max-length",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "length of the bps-write-max burst period, in second= s",\ + },{ \ + .name =3D "throttling.iops-size",\ + .type =3D QEMU_OPT_NUMBER,\ + .help =3D "when limiting by iops max size of an I/O in bytes",\ + } + +#endif --=20 2.7.4