From nobody Fri Dec 19 20:17:43 2025 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1742319775; cv=none; d=zohomail.com; s=zohoarc; b=MbmmZVhG1MHSPSRIKgBy9L6/riJ6/itIuTt7jkXsVowGbi23eMKpbxfMdEXXeUYqYzDlxQT2kq9dNFjcz7/rCahD8I8j/HH8phzGRCGKShxNtGiUtroQsOGTXS0mTX+OTVwa6NdH07HAtlsP3zkEGm3QZsL3+jck/l3O4SAdw2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742319775; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=Z6AdiiEWA02OHfJ0CK1RsdwoYx5Byu3dj4sLR/4YwhE=; b=b/prpfH6szt4zMO0SnEJJZNboeKnFFBTALEhjXF80xJ3s4NjCv6a1wIj7a9X74TANJrPQgtIw8Bq9cIRCENz5SxWVF8H7PzvwVuFbK8ytfa746d1w4fr8XMxIvfbTjHbADGjSmfq2fZtnpdxPvU10pj/r3nhCcR6V9Ky7rQ3Mn8= ARC-Authentication-Results: i=1; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1742319775250361.9333284276639; Tue, 18 Mar 2025 10:42:55 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4839B1898; Tue, 18 Mar 2025 13:42:54 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5D55D160F; Tue, 18 Mar 2025 13:35:30 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6BC9915E0; Tue, 18 Mar 2025 13:35:21 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 AA3971661 for ; Tue, 18 Mar 2025 13:34:59 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-452-AKxYeHa6OtuGl3faSbQ2rw-1; Tue, 18 Mar 2025 13:34:58 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 00A2E19560BB; Tue, 18 Mar 2025 17:34:57 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.6]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A1F7B3001D0E; Tue, 18 Mar 2025 17:34:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742319299; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zgQQdjpkRNVn0sC9im8EdW3CrwTxdzlclAdMlnWmuZg=; b=EnK24j471/gPg6of2QYReqHY0nucfwOehWJMWZfN2ZR/4pHgSEI+wLcrmDtPZBJRCtvsWF FCBWvPWWTM7cW8Q7FzcW5No2RkQklByQ8PUlwVBrq4H7t/6EK/3dVcSz8kdJq4KY/93ngk frBUOvbQI0X9MFGkgPq5VpvPnOGCJkE= X-MC-Unique: AKxYeHa6OtuGl3faSbQ2rw-1 X-Mimecast-MFC-AGG-ID: AKxYeHa6OtuGl3faSbQ2rw_1742319297 To: devel@lists.libvirt.org Subject: [PATCH v9 12/17] config: validate: Verify iotune, throttle group and filter Date: Tue, 18 Mar 2025 18:34:26 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 5TB3v9AMcBFXB37NoLatgZK1BTihrClA5nywYU-g4rc_1742319297 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MZCXWAE7L45YLJHPA3SPGAXQLIEB4T3H X-Message-ID-Hash: MZCXWAE7L45YLJHPA3SPGAXQLIEB4T3H X-MailFrom: pkrempa@redhat.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 CC: Harikumar Rajkumar , harikumar.rajkumar@ibm.com 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: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1742319776151019100 Content-Type: text/plain; charset="utf-8" From: Chun Feng Wu Refactor iotune verification, and verify some rules * Disk iotune validation can be reused for throttle group validation, refactor it into common method "virDomainDiskIoTuneValidate" * Add "virDomainDefValidateThrottleGroups" to validate throttle groups, which in turn calls "virDomainDiskIoTuneValidate" * Make sure referenced throttle group exists * Use "iotune" and "throttlefilters" exclusively for specific disk * Throttle filters cannot be used together with CDROM Signed-off-by: Chun Feng Wu * Update of code documentation comments. Signed-off-by: Harikumar Rajkumar * Moved validation code from parser to validator * Removed dead checks after validation Reviewed-by: Peter Krempa Signed-off-by: Peter Krempa --- src/conf/domain_validate.c | 124 +++++++++++++++++++++++++++---------- src/qemu/qemu_driver.c | 6 ++ 2 files changed, 96 insertions(+), 34 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 7b901da593..a8f2813b52 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -692,11 +692,55 @@ virDomainDiskDefValidateStartupPolicy(const virDomain= DiskDef *disk) } +static int +virDomainDiskIoTuneValidate(const virDomainBlockIoTuneInfo blkdeviotune) +{ + if ((blkdeviotune.total_bytes_sec && + blkdeviotune.read_bytes_sec) || + (blkdeviotune.total_bytes_sec && + blkdeviotune.write_bytes_sec)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("total and read/write bytes_sec cannot be set at = the same time")); + return -1; + } + + if ((blkdeviotune.total_iops_sec && + blkdeviotune.read_iops_sec) || + (blkdeviotune.total_iops_sec && + blkdeviotune.write_iops_sec)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("total and read/write iops_sec cannot be set at t= he same time")); + return -1; + } + + if ((blkdeviotune.total_bytes_sec_max && + blkdeviotune.read_bytes_sec_max) || + (blkdeviotune.total_bytes_sec_max && + blkdeviotune.write_bytes_sec_max)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("total and read/write bytes_sec_max cannot be set= at the same time")); + return -1; + } + + if ((blkdeviotune.total_iops_sec_max && + blkdeviotune.read_iops_sec_max) || + (blkdeviotune.total_iops_sec_max && + blkdeviotune.write_iops_sec_max)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("total and read/write iops_sec_max cannot be set = at the same time")); + return -1; + } + + return 0; +} + + static int virDomainDiskDefValidate(const virDomainDef *def, const virDomainDiskDef *disk) { virStorageSource *next; + size_t i; /* disk target is used widely in other code so it must be validated fi= rst */ if (!disk->dst) { @@ -746,41 +790,8 @@ virDomainDiskDefValidate(const virDomainDef *def, } /* Validate IotuneParse */ - if ((disk->blkdeviotune.total_bytes_sec && - disk->blkdeviotune.read_bytes_sec) || - (disk->blkdeviotune.total_bytes_sec && - disk->blkdeviotune.write_bytes_sec)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("total and read/write bytes_sec cannot be set at = the same time")); - return -1; - } - - if ((disk->blkdeviotune.total_iops_sec && - disk->blkdeviotune.read_iops_sec) || - (disk->blkdeviotune.total_iops_sec && - disk->blkdeviotune.write_iops_sec)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("total and read/write iops_sec cannot be set at t= he same time")); - return -1; - } - - if ((disk->blkdeviotune.total_bytes_sec_max && - disk->blkdeviotune.read_bytes_sec_max) || - (disk->blkdeviotune.total_bytes_sec_max && - disk->blkdeviotune.write_bytes_sec_max)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("total and read/write bytes_sec_max cannot be set= at the same time")); - return -1; - } - - if ((disk->blkdeviotune.total_iops_sec_max && - disk->blkdeviotune.read_iops_sec_max) || - (disk->blkdeviotune.total_iops_sec_max && - disk->blkdeviotune.write_iops_sec_max)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("total and read/write iops_sec_max cannot be set = at the same time")); + if (virDomainDiskIoTuneValidate(disk->blkdeviotune) < 0) return -1; - } /* Reject disks with a bus type that is not compatible with the * given address type. The function considers only buses that are @@ -981,6 +992,32 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } + if (disk->nthrottlefilters > 0) { + if (disk->blkdeviotune.group_name || + virDomainBlockIoTuneInfoHasAny(&disk->blkdeviotune)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("block 'throttlefilters' can't be used togeth= er with 'iotune' for disk '%1$s'"), + disk->dst); + return -1; + } + + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("cdrom device with throttle filters isn't sup= ported")); + return -1; + } + + for (i =3D 0; i < disk->nthrottlefilters; i++) { + virDomainThrottleFilterDef *filter =3D disk->throttlefilters[i= ]; + if (!virDomainThrottleGroupByName(def, filter->group_name)) { + virReportError(VIR_ERR_XML_ERROR, + _("throttle group '%1$s' not found"), + filter->group_name); + return -1; + } + } + } + return 0; } @@ -1898,6 +1935,22 @@ virDomainDefLaunchSecurityValidate(const virDomainDe= f *def) #undef CHECK_BASE64_LEN +static int +virDomainDefValidateThrottleGroups(const virDomainDef *def) +{ + size_t i; + + for (i =3D 0; i < def->nthrottlegroups; i++) { + virDomainThrottleGroupDef *throttleGroup =3D def->throttlegroups[i= ]; + + if (virDomainDiskIoTuneValidate(*throttleGroup) < 0) + return -1; + } + + return 0; +} + + static int virDomainDefValidateInternal(const virDomainDef *def, virDomainXMLOption *xmlopt) @@ -1956,6 +2009,9 @@ virDomainDefValidateInternal(const virDomainDef *def, if (virDomainDefLaunchSecurityValidate(def) < 0) return -1; + if (virDomainDefValidateThrottleGroups(def) < 0) + return -1; + return 0; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3b6dcd039f..3ca0b8a061 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14849,6 +14849,12 @@ qemuDomainDiskBlockIoTuneIsSupported(virDomainDisk= Def *disk) return false; } + if (disk->throttlefilters) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("block 'iotune' can't be used together with 'thro= ttlefilters' for disk '%1$s'"), disk->dst); + return false; + } + return true; } --=20 2.48.1