From nobody Thu Sep 19 01:06:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) 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 1718187061339469.1569732552772; Wed, 12 Jun 2024 03:11:01 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 41EB6A76; Wed, 12 Jun 2024 06:11:00 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9A32C1183; Wed, 12 Jun 2024 06:04:12 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3E0BEDF0; Wed, 12 Jun 2024 06:04:05 -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 9D049D7F for ; Wed, 12 Jun 2024 06:03:43 -0400 (EDT) Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45C9ZkmQ000869 for ; Wed, 12 Jun 2024 10:03:43 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yq86vg799-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Jun 2024 10:03:42 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45C9KOhr027209 for ; Wed, 12 Jun 2024 10:03:42 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yn210vn94-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Jun 2024 10:03:42 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45CA3dDr19923684 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Jun 2024 10:03:41 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 27A9F58055; Wed, 12 Jun 2024 10:03:39 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3A43F58043; Wed, 12 Jun 2024 10:03:38 +0000 (GMT) Received: from libvirt-dev-u221.fyre.ibm.com (unknown [9.112.252.183]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 12 Jun 2024 10:03:37 +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.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=Q+qKv0ahqwB0W Sl2LQ+GWv3BS6QQniytgJO2Qk19C+I=; b=KGuPiQLeWf61Pvm6ny1bvfE9tdvmj z8/MeJPpvCGvzb7o5gIlB9DxZz9xgTH4Uw0Y0uluNbi69G6LFfWexcia5+c4VdC1 KjT/4gFle3d9PnRp14wDzCxeJ+ih1Mpy4BqeWlEV0r2uITgg+Anb9hBDvqUluwn4 PzI7s+uTdJYFaHohJYj7t+MJbZLcOc3hgOE0ftQdZxEfIVyuVFRqOOW+q2MMDAT5 HqqOfFhjM9KP+7J9k2xZQP3E3GNnc4RUSyL088De6/9wiwD6IwJNJm8kgDjU6xXR 1Z+5fVRwr4Byblhey7d+KgUNcIHX/pgu8Cp9KhxM1RwrDGkW31DjfQgKA== From: wucf@linux.ibm.com To: devel@lists.libvirt.org Cc: Chun Feng Wu Subject: [PATCH RFC v3 12/16] qemu: command: Support throttle filters during qemuProcessLaunch Date: Wed, 12 Jun 2024 03:02:20 -0700 Message-Id: <20240612100224.2024439-13-wucf@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240612100224.2024439-1-wucf@linux.ibm.com> References: <20240612100224.2024439-1-wucf@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 2_hJHHUKxVsiOio1I7xDdW1EZZ_SS8dx X-Proofpoint-GUID: 2_hJHHUKxVsiOio1I7xDdW1EZZ_SS8dx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-12_06,2024-06-11_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 impostorscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 priorityscore=1501 bulkscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406120071 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ICJ32NDDLMFU6GC72VQM2PDKEBMBCFWO X-Message-ID-Hash: ICJ32NDDLMFU6GC72VQM2PDKEBMBCFWO 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1718187062809100001 Content-Type: text/plain; charset="utf-8" From: Chun Feng Wu * Add qemuBuildDiskThrottleFiltersCommandLine in qemuBuildDiskCommandLine t= o add "blockdev" * Make sure referenced throttle group exists Signed-off-by: Chun Feng Wu --- src/conf/domain_validate.c | 12 ++++++++++++ src/qemu/qemu_command.c | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 27d7a9968b..bedc28d481 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -706,6 +706,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) { @@ -952,6 +953,17 @@ 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 (!virDomainThrottleGroupFind(def, filter->group_name)) { + virReportError(VIR_ERR_XML_ERROR, + _("throttle group '%1$s' not found"), + filter->group_name); + return -1; + } + } + if (disk->throttlefilters && (disk->blkdeviotune.group_name || virDomainBlockIoTuneInfoHasAny(&disk->blkdeviotune))) { virReportError(VIR_ERR_XML_ERROR, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 863544938f..2194b15fd3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2229,6 +2229,43 @@ qemuBuildBlockStorageSourceAttachDataCommandline(vir= Command *cmd, } =20 =20 +static int +qemuBuildBlockThrottleFilterCommandline(virCommand *cmd, + qemuBlockThrottleFilterAttachData = *data) +{ + if (data->filterProps) { + g_autofree char *tmp =3D NULL; + if (!(tmp =3D virJSONValueToString(data->filterProps, false))) + return -1; + + virCommandAddArgList(cmd, "-blockdev", tmp, NULL); + } + + return 0; +} + + +static int +qemuBuildDiskThrottleFiltersCommandLine(virCommand *cmd, + virDomainDiskDef *disk) +{ + g_autoptr(qemuBlockThrottleFiltersData) data =3D NULL; + size_t i; + + data =3D qemuBuildThrottleFiltersAttachPrepareBlockdev(disk); + if (!data) + return -1; + + 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, @@ -2286,6 +2323,9 @@ qemuBuildDiskCommandLine(virCommand *cmd, if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps) < 0) return -1; =20 + if (qemuBuildDiskThrottleFiltersCommandLine(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)) --=20 2.34.1