From nobody Wed Dec 17 08:52:29 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=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1739357072421391.42714664737457; Wed, 12 Feb 2025 02:44:32 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6FB5D1BD7; Wed, 12 Feb 2025 05:44:31 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A404EA56; Wed, 12 Feb 2025 05:36:55 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 18B0F1B03; Wed, 12 Feb 2025 05:36:50 -0500 (EST) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 8EB7B1170 for ; Wed, 12 Feb 2025 05:36:22 -0500 (EST) Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-2fa5af6d743so5722046a91.3 for ; Wed, 12 Feb 2025 02:36:22 -0800 (PST) Received: from localhost.localdomain ([117.251.37.46]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2fbf98b3277sm1147688a91.7.2025.02.12.02.36.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 12 Feb 2025 02:36:19 -0800 (PST) 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_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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=gmail.com; s=20230601; t=1739356580; x=1739961380; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OdcuakuEEmxqPbAvRlwhNh1VGT/lE2pQZj4Ay+vFTh8=; b=hRd4fQQ0+3EiFnqCOG2Moq01IOUdarfLZ1xPwXvUVxm5XGux1ZNy8p7UYKRBP0Qtyn qPJjEuHTt5L3VccIL4MolGqT/joQRMEwF5+8LSAi5/qFpAIJQa5NU3jYj1BmmfDAVUSK 4PhujhQWO4sYPEdUFCuBiWfQTVxhUdR9nY0R+ELBbY5kpDAujmwpKwxeIYMSHfF3BCve FLcz9/6hTVODyxx6+DwKJNo7fSemsMwtYqlVTGTnsZ19aJatRN3XwGlyteL73LQ4L0/9 9hWeN2yo/GYMV28C+S6wobmWqvbUOGerb3HK2s6u7mbR3H00DqLCw8S1kuFzRlSpImyA z/Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739356580; x=1739961380; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OdcuakuEEmxqPbAvRlwhNh1VGT/lE2pQZj4Ay+vFTh8=; b=JQGVRUAAs7+fYdOYYyuWLa2up7hBLCVkUSgrmalwHMUluBQXM7zn2oMYXLC5AYPvap Gh/2+JQL1m+2AD1CWciw9Ub91khVU6guDa/KDK+GQJS8IPVH+f1b5BqaEe2bpjwlU5F9 d3nCDmsZ930/h6bHGhvBGCIGoQ5Sb+NdgQg/3y6KCph0fWCHCuD9bOttpLsD9lplBJhx v2fQzbon7QWVpN4WPSQV6qt9TASbtoB2vc57N2lNCVpL+jLJovgITjF5KCWMQPEKmw8i oIoIOk7W2KOhbQtTNuy2PMunVvxPRDsyu//l6yugNle6rZ7xdmsxDqFRvDsoXsSlUE22 eXiA== X-Gm-Message-State: AOJu0YwEFSgpN06uuH9ysJptSjHaO1zL1lhFagXExX7kUiPJgLCc0b11 abezaQ9Dfy4Fygp9HLlF7tYzXvXzUt/RDYoEniiEVhW22e85u8ChHTwcAA== X-Gm-Gg: ASbGncuqkkGo1l39prWrA91rLO1jt+NHkjaBDkfLGzxjm54vXeWEPl+o8NA13BrG8x+ TCOLG6KY5IJ8jULA2fuOH5q3k3RZgz9w8Vd3s2Y4NLfxeAUC2GL1K1Zv1azXLu6md/5XNFf776N aJRCHHtJ/Ys69xFAgXZStvDKkFCs6wewXiEWkUYyikUPs+jCETw2bKbqr96KKsokIeOiDji5oMY 2U9axcdmmcF6YOV3aLmJHx81D5yRfdeZW9vJi6Cxj+U5ti2FDJ3pkkc2EPvRZD2BoL8hgZ01Xmx q4HyodOjDQBY5W00KgDC2GE04DISgMEYA9sFfftArmw2eQ== X-Google-Smtp-Source: AGHT+IHI/9AvTS9cLEOA7s6sqStnaXTmsH1OKM32P7ELogS3/3HFyaC7p7+5T39jqJUQ2kjWTKSMpg== X-Received: by 2002:a17:90b:5252:b0:2fa:1e3e:9be5 with SMTP id 98e67ed59e1d1-2fbf5ad2824mr4796083a91.0.1739356580208; Wed, 12 Feb 2025 02:36:20 -0800 (PST) From: Harikumar Rajkumar To: devel@lists.libvirt.org Subject: [PATCH v7 12/18] config: validate: Verify iotune, throttle group and filter Date: Wed, 12 Feb 2025 16:05:31 +0530 Message-Id: <20250212103537.26352-13-harirajkumar230@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250212103537.26352-1-harirajkumar230@gmail.com> References: <20250212103537.26352-1-harirajkumar230@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: CBGWQL26ZBUHBNKMGU26ZKBEGZE4C32D X-Message-ID-Hash: CBGWQL26ZBUHBNKMGU26ZKBEGZE4C32D X-MailFrom: harirajkumar230@gmail.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@ibm.com, sanjeev.ranjan@ibm.com, earulana@in.ibm.com, Harikumar Rajkumar 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: 1739357075688019100 Content-Type: text/plain; charset="utf-8" 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: Harikumar Rajkumar --- src/conf/domain_conf.c | 8 +++ src/conf/domain_validate.c | 118 ++++++++++++++++++++++++++----------- src/qemu/qemu_driver.c | 13 ++++ src/qemu/qemu_hotplug.c | 8 +++ 4 files changed, 113 insertions(+), 34 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7d714c333e..d8745ffa3b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8008,6 +8008,14 @@ virDomainDiskDefThrottleFiltersParse(virDomainDiskDe= f *def, if ((n =3D virXPathNodeSet("./throttlefilters/throttlefilter", ctxt, &= nodes)) < 0) return -1; =20 + if (def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) { + if (n > 0) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("cdrom device with throttle filters isn't sup= ported")); + return -1; + } + } + if (n) def->throttlefilters =3D g_new0(virDomainThrottleFilterDef *, n); =20 diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index eb5e764c02..8f6175a139 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -685,11 +685,55 @@ virDomainDiskDefValidateStartupPolicy(const virDomain= DiskDef *disk) } =20 =20 +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; =20 /* disk target is used widely in other code so it must be validated fi= rst */ if (!disk->dst) { @@ -739,41 +783,8 @@ virDomainDiskDefValidate(const virDomainDef *def, } =20 /* 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")); + if (virDomainDiskIoTuneValidate(disk->blkdeviotune) < 0) 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")); - return -1; - } =20 /* Reject disks with a bus type that is not compatible with the * given address type. The function considers only buses that are @@ -974,6 +985,26 @@ 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 (!virDomainThrottleGroupByName(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_OPERATION_UNSUPPORTED, + _("block 'throttlefilters' can't be used together w= ith 'iotune' for disk '%1$s'"), + disk->dst); + return -1; + } + return 0; } =20 @@ -1874,6 +1905,22 @@ virDomainDefLaunchSecurityValidate(const virDomainDe= f *def) =20 #undef CHECK_BASE64_LEN =20 +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) @@ -1932,6 +1979,9 @@ virDomainDefValidateInternal(const virDomainDef *def, if (virDomainDefLaunchSecurityValidate(def) < 0) return -1; =20 + if (virDomainDefValidateThrottleGroups(def) < 0) + return -1; + return 0; } =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7786e757a0..fb46bc28eb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6724,6 +6724,13 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef, _("target %1$s already exists"), disk->dst); return -1; } + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) { + if (disk->nthrottlefilters > 0) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("cdrom device with throttle filters isn't= supported")); + return -1; + } + } if (virDomainDiskTranslateSourcePool(disk) < 0) return -1; if (qemuCheckDiskConfigAgainstDomain(vmdef, disk) < 0) @@ -14883,6 +14890,12 @@ qemuDomainDiskBlockIoTuneIsSupported(virDomainDisk= Def *disk) return false; } =20 + 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 diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index b4f5208e3e..a0b4454be7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -985,6 +985,14 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *= driver, bool releaseSeclabel =3D false; int ret =3D -1; =20 + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) { + if (disk->nthrottlefilters > 0) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("cdrom device with throttle filters isn't suppor= ted")); + return -1; + } + } + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("floppy device hotplug isn't supported")); --=20 2.39.5 (Apple Git-154)