From nobody Sun Feb 8 18:30:18 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1712887910254868.4128684864536; Thu, 11 Apr 2024 19:11:50 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 339951A1F; Thu, 11 Apr 2024 22:11:49 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1B9591905; Thu, 11 Apr 2024 22:03:43 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D4EAB1889; Thu, 11 Apr 2024 22:03:36 -0400 (EDT) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3735617C0 for ; Thu, 11 Apr 2024 22:03:06 -0400 (EDT) Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43C1Idv6011196 for ; Fri, 12 Apr 2024 02:03:05 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xeu1682mh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 12 Apr 2024 02:03:05 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 43C0QChm022560 for ; Fri, 12 Apr 2024 02:03:04 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xbhqpf4n5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 12 Apr 2024 02:03:04 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43C231um23528002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 02:03:03 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5357B5806F; Fri, 12 Apr 2024 02:03:01 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5DC905806A; Fri, 12 Apr 2024 02:03:00 +0000 (GMT) Received: from libvirt-dev-u221.fyre.ibm.com (unknown [9.112.252.183]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 02:03:00 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 From: wucf@linux.ibm.com To: devel@lists.libvirt.org Cc: Chun Feng Wu Subject: [PATCH RFC v2 06/12] qemu: command: Support throttle groups and filters during qemuProcessLaunch Date: Thu, 11 Apr 2024 19:01:54 -0700 Message-Id: <20240412020200.2418776-7-wucf@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412020200.2418776-1-wucf@linux.ibm.com> References: <20240412020200.2418776-1-wucf@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: L8IS_LVyD8lVZtLpciFQTJdHXLGNUHLl X-Proofpoint-GUID: L8IS_LVyD8lVZtLpciFQTJdHXLGNUHLl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-11_14,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 clxscore=1015 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120013 Message-ID-Hash: HNES6PSXLOPGDVYGVIRAVEGVAP63QTGS X-Message-ID-Hash: HNES6PSXLOPGDVYGVIRAVEGVAP63QTGS X-MailFrom: wucf@linux.ibm.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1712887911150100001 From: Chun Feng Wu * Add qemuBuildThrottleGroupCommandLine in qemuBuildCommandLine * Add qemuBuildThrottleFiltersCommandLine in qemuBuildDiskCommandLine * Make sure referenced throttle group exists Signed-off-by: Chun Feng Wu --- src/conf/domain_validate.c | 14 ++++++ src/qemu/qemu_command.c | 94 ++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_command.h | 3 ++ 3 files changed, 111 insertions(+) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 395e036e8f..fffe274afc 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -663,6 +663,7 @@ virDomainDiskDefValidate(const virDomainDef *def, const virDomainDiskDef *disk) { virStorageSource *next; + size_t i; =20 /* disk target is used widely in other code so it must be validated fi= rst */ if (!disk->dst) { @@ -942,6 +943,19 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } =20 + /* referenced group should be defined */ + for (i =3D 0; i < disk->nthrottlefilters; i++) { + virDomainThrottleFilterDef *filter =3D disk->throttlefilters[i]; + if (filter) { + if (!virDomainThrottleGroupFind(def, filter->group_name)) { + virReportError(VIR_ERR_XML_ERROR, + _("throttle group '%1$s' not found"), + filter->group_name); + return -1; + } + } + } + return 0; } =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2d8036c3ae..34164c098b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1584,6 +1584,14 @@ qemuDiskConfigThrottleFilterChainEnabled(const virDo= mainDiskDef *disk) } =20 =20 +bool +qemuDiskConfigThrottleFilterEnabled(const virDomainThrottleGroupDef *group) +{ + return !!group->group_name && + virDomainBlockIoTuneInfoHasAny(group); +} + + /** * qemuDiskBusIsSD: * @bus: disk bus @@ -2221,6 +2229,45 @@ qemuBuildBlockStorageSourceAttachDataCommandline(vir= Command *cmd, } =20 =20 +static int +qemuBuildBlockThrottleFilterCommandline(virCommand *cmd, + qemuBlockThrottleFilterAttachData = *data) +{ + char *tmp; + + if (data->filterProps) { + if (!(tmp =3D virJSONValueToString(data->filterProps, false))) + return -1; + + virCommandAddArgList(cmd, "-blockdev", tmp, NULL); + VIR_FREE(tmp); + } + + return 0; +} + + +static int +qemuBuildThrottleFiltersCommandLine(virCommand *cmd, + virDomainDiskDef *disk) +{ + g_autoptr(qemuBlockThrottleFilterChainData) data =3D NULL; + size_t i; + + if (!(data =3D qemuBuildThrottleFilterChainAttachPrepareBlockdev(disk)= )) { + return -1; + } else { + for (i =3D 0; i < data->nfilterdata; i++) { + if (qemuBuildBlockThrottleFilterCommandline(cmd, + data->filterdata[i= ]) < 0) + return -1; + } + } + + return 0; +} + + static int qemuBuildDiskSourceCommandLine(virCommand *cmd, virDomainDiskDef *disk, @@ -2278,6 +2325,9 @@ qemuBuildDiskCommandLine(virCommand *cmd, if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps) < 0) return -1; =20 + if (qemuBuildThrottleFiltersCommandLine(cmd, disk) < 0) + return -1; + /* SD cards are currently instantiated via -drive if=3Dsd, so the -dev= ice * part must be skipped */ if (qemuDiskBusIsSD(disk->bus)) @@ -7451,6 +7501,47 @@ qemuBuildIOThreadCommandLine(virCommand *cmd, } =20 =20 +/** + * qemuBuildThrottleGroupCommandLine: + * @cmd: the command to modify + * @def: domain definition + * @qemuCaps: qemu capabilities object + * + * build throttle group object in json format + * e.g. -object '{"qom-type":"throttle-group","id":"limit0","limits":{"iop= s-total":200}}' + */ +static int +qemuBuildThrottleGroupCommandLine(virCommand *cmd, + const virDomainDef *def, + virQEMUCaps *qemuCaps) +{ + size_t i; + + for (i =3D 0; i < def->nthrottlegroups; i++) { + g_autoptr(virJSONValue) props =3D NULL; + g_autoptr(virJSONValue) limits =3D virJSONValueNewObject(); + virDomainThrottleGroupDef *group =3D def->throttlegroups[i]; + + if (!qemuDiskConfigThrottleFilterEnabled(group)) { + continue; + } + + if (qemuMonitorThrottleGroupLimits(limits, group)<0) + return -1; + + if (qemuMonitorCreateObjectProps(&props, "throttle-group", group->= group_name, + "a:limits", &limits, + NULL) < 0) + return -1; + + if (qemuBuildObjectCommandlineFromJSON(cmd, props, qemuCaps) < 0) + return -1; + } + + return 0; +} + + static int qemuBuildNumaCellCache(virCommand *cmd, const virDomainDef *def, @@ -10485,6 +10576,9 @@ qemuBuildCommandLine(virDomainObj *vm, if (qemuBuildIOThreadCommandLine(cmd, def, qemuCaps) < 0) return NULL; =20 + if (qemuBuildThrottleGroupCommandLine(cmd, def, qemuCaps) < 0) + return NULL; + if (virDomainNumaGetNodeCount(def->numa) && qemuBuildNumaCommandLine(cfg, def, cmd, priv) < 0) return NULL; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index e2dee47906..9b8951d95f 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -122,6 +122,9 @@ qemuBuildThrottleFilterChainAttachPrepareBlockdev(virDo= mainDiskDef *disk); bool qemuDiskConfigThrottleFilterChainEnabled(const virDomainDiskDef *disk); =20 +bool +qemuDiskConfigThrottleFilterEnabled(const virDomainThrottleGroupDef *group= ); + virJSONValue * qemuBuildDiskDeviceProps(const virDomainDef *def, virDomainDiskDef *disk, --=20 2.34.1 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org