From nobody Wed Dec 17 08:52:28 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 1739356739722545.9452831799379; Wed, 12 Feb 2025 02:38:59 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id BA722BA6; Wed, 12 Feb 2025 05:38:58 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id DA61A19CA; Wed, 12 Feb 2025 05:36:19 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 550631B51; Wed, 12 Feb 2025 05:36:13 -0500 (EST) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 561C61AF6 for ; Wed, 12 Feb 2025 05:35:58 -0500 (EST) Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2fbffe0254fso366590a91.3 for ; Wed, 12 Feb 2025 02:35:58 -0800 (PST) Received: from localhost.localdomain ([117.251.37.46]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2fbf98b3277sm1147688a91.7.2025.02.12.02.35.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 12 Feb 2025 02:35:56 -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=1739356557; x=1739961357; 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=nMTYKtE7DtoFPGJwBR7yB1aJyhHUQ9vHPRE2h3XY1FU=; b=BWs1ASKypVPPz711VzGw/XwblnpkCbMtNfT8RgWJeVdtTD3rlycgPghNWPttek4DWr nrQ0W4pbSefsFqbRsjGOH5OgOt2Ptap5g508QFG8/gJ3F5jWTo+CufVqXnKQ7r0WPtxt 04i7oRoIXI0uYkQYBkppb5W5ORofQnEGLOSdvNfgOKtO6gnTmOFk4B/TIpWmieWfFb0C V4EqUFaLw/37EICPKRpdLGpVnURbRgVxE8QJQ3iVWN2ekN8aFcmp5x7JINi89EyCi15Q tDBvfbgNo4IvkD94WmyitpUioUrrItvEKHei5FQ8PNWW/vU5nlfu0gPPcrbpEjZ0OCaI ZpCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739356557; x=1739961357; 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=nMTYKtE7DtoFPGJwBR7yB1aJyhHUQ9vHPRE2h3XY1FU=; b=gjzNCxuJC43pBhwKKi0FSnZrIxySMHWaMhYRz8F6ijGD6G8G//eJXGntBnMxdQ0HIZ hhaeNFBllJaX6a2ZMKaIXfD5YzBsDMk6shDoSlMjA4moDcZzY2P8RxZLHIlGHG1aqfBj 3vY1bsmMVQo9T2INnMp0ly5ly8/zxRYhlhqB1hbGVr4pt1e5kE/SbtxP72OTacnoxXSx 7IqWV4eApDQo389xQiQ/9qZorVTlmHN28AT9F3XosCwNRpXURp9QbfQXHaRArkgvV52H bmuaMLZKu1fSJIWKjn0XpkSW5GBP19yKmVr/H6hi2bphiFSsYdISWCwc58Mj4H3jxNAB JaYw== X-Gm-Message-State: AOJu0YyAnrAbNYsWz8fluEExwvwVzJCXaGv8dfXqoUgBBJskIZuQ3FCG C0Qig+rkMQ9AnLFIbnLcd4BEfI5Ze6Pi5q8j00K+N4OvzEAYGhpzJObMCA== X-Gm-Gg: ASbGncuzObs1gguafWRur26OmIZjjanBgmYkfui6v/uptbK4RRCd/ur8pfhDb0onWn7 wyGCVSoF0fOxPXQHuaul9T0/+fqZzJSZFGJ7mh5qjHsOfImHPEc1TeTcWF5s9wzouteQfav3m2Z KmEVSkX8D7vluyoaaD+KJlqkpj7dwXOHYYa2vcBdPPEHse3HA49R6OtIOexnHgfK61Zd0ICrzVV hHcPRqgbYDDQbz6A8NQ28FZkE9+6ioZhTQiqexQwuiJiE9fKERoCvZzT42fNrBV3wL95TSvaTMg jX8SciMCTuzFPhOCN17grNiYe3LUIutcQy49HH5ZifIEjg== X-Google-Smtp-Source: AGHT+IFFwexSRKwUZDMiF3puMcGyz+jv10dus1V32gEA2ROKVYDcfsCKwOtdNEcfRjw1TbrnK6hQ3g== X-Received: by 2002:a17:90b:4c04:b0:2f2:a664:df1a with SMTP id 98e67ed59e1d1-2fbf5bc1ab3mr4503469a91.2.1739356556995; Wed, 12 Feb 2025 02:35:56 -0800 (PST) From: Harikumar Rajkumar To: devel@lists.libvirt.org Subject: [PATCH v7 04/18] config: Introduce ThrottleFilter and corresponding XML parsing Date: Wed, 12 Feb 2025 16:05:23 +0530 Message-Id: <20250212103537.26352-5-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: 3Z5UBDVPOM3EFI62CLPYTV27EYJYIUXV X-Message-ID-Hash: 3Z5UBDVPOM3EFI62CLPYTV27EYJYIUXV 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: 1739356743172019100 Content-Type: text/plain; charset="utf-8" Introduce throttle filter along with corresponding operations. * Define new struct 'virDomainThrottleFilterDef' and corresponding destruct= or * Update _virDomainDiskDef to include virDomainThrottleFilterDef * Support throttle filter "Parse" and "Format" for operations between DOM XML and structs. Note, this commit just contains parse/format of group name f= or throttle filter in domain_conf.c, there is other commit to handle throttle filter nodename parse/format between throttlefilter and diskPrivateData f= or statusxml in qemu_domain.c when processing qemuDomainDiskPrivate and qemuDomainDiskPrivate Signed-off-by: Harikumar Rajkumar --- src/conf/domain_conf.c | 99 +++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 20 +++++++++ src/conf/virconftypes.h | 2 + 3 files changed, 121 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fd08e67edc..7d714c333e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3825,6 +3825,16 @@ virDomainThrottleGroupDefArrayFree(virDomainThrottle= GroupDef **def, } =20 =20 +void +virDomainThrottleFilterDefClear(virDomainThrottleFilterDef *def) +{ + if (!def) + return; + g_free(def->group_name); + g_free(def->nodename); +} + + void virDomainResourceDefFree(virDomainResourceDef *resource) { @@ -7976,6 +7986,50 @@ virDomainDefThrottleGroupsParse(virDomainDef *def, } =20 =20 +static virDomainThrottleFilterDef * +virDomainDiskThrottleFilterDefParse(xmlNodePtr node) +{ + g_autoptr(virDomainThrottleFilterDef) filter =3D g_new0(virDomainThro= ttleFilterDef, 1); + + filter->group_name =3D virXMLPropStringRequired(node, "group"); + + return g_steal_pointer(&filter); +} + + +static int +virDomainDiskDefThrottleFiltersParse(virDomainDiskDef *def, + xmlXPathContextPtr ctxt) +{ + size_t i; + int n =3D 0; + g_autofree xmlNodePtr *nodes =3D NULL; + + if ((n =3D virXPathNodeSet("./throttlefilters/throttlefilter", ctxt, &= nodes)) < 0) + return -1; + + if (n) + def->throttlefilters =3D g_new0(virDomainThrottleFilterDef *, n); + + for (i =3D 0; i < n; i++) { + g_autoptr(virDomainThrottleFilterDef) filter =3D NULL; + + if (!(filter =3D virDomainDiskThrottleFilterDefParse(nodes[i]))) { + return -1; + } + + if (virDomainThrottleFilterFind(def, filter->group_name)) { + virReportError(VIR_ERR_XML_ERROR, + _("duplicate filter name '%1$s' found"), + filter->group_name); + return -1; + } + def->throttlefilters[def->nthrottlefilters++] =3D g_steal_pointer(= &filter); + } + return 0; +} + + static int virDomainDiskDefMirrorParse(virDomainDiskDef *def, xmlNodePtr cur, @@ -8466,6 +8520,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, if (virDomainDiskDefIotuneParse(def, ctxt) < 0) return NULL; =20 + if (virDomainDiskDefThrottleFiltersParse(def, ctxt) < 0) + return NULL; + def->domain_name =3D virXPathString("string(./backenddomain/@name)", c= txt); def->serial =3D virXPathString("string(./serial)", ctxt); def->wwn =3D virXPathString("string(./wwn)", ctxt); @@ -22747,6 +22804,31 @@ virDomainThrottleGroupDel(virDomainDef *def, } =20 =20 +/** + * virDomainThrottleFilterFind: + * @def: domain disk definition + * @name: throttle group name + * + * Search domain disk to find throttle filter referencing + * throttle group with name @name. + * + * Return a pointer to throttle filter found + */ +virDomainThrottleFilterDef * +virDomainThrottleFilterFind(const virDomainDiskDef *def, + const char *name) +{ + size_t i; + + for (i =3D 0; i < def->nthrottlefilters; i++) { + if (STREQ(name, def->throttlefilters[i]->group_name)) + return def->throttlefilters[i]; + } + + return NULL; +} + + static int virDomainEventActionDefFormat(virBuffer *buf, int type, @@ -23397,6 +23479,21 @@ virDomainDiskDefFormatIotune(virBuffer *buf, #undef FORMAT_IOTUNE =20 =20 +static void +virDomainDiskDefFormatThrottleFilters(virBuffer *buf, + virDomainDiskDef *disk) +{ + size_t i; + g_auto(virBuffer) throttleChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); + for (i =3D 0; i < disk->nthrottlefilters; i++) { + g_auto(virBuffer) throttleAttrBuf =3D VIR_BUFFER_INITIALIZER; + virBufferEscapeString(&throttleAttrBuf, " group=3D'%s'", disk->thr= ottlefilters[i]->group_name); + virXMLFormatElement(&throttleChildBuf, "throttlefilter", &throttle= AttrBuf, NULL); + } + virXMLFormatElement(buf, "throttlefilters", NULL, &throttleChildBuf); +} + + static void virDomainDiskDefFormatDriver(virBuffer *buf, virDomainDiskDef *disk) @@ -23683,6 +23780,8 @@ virDomainDiskDefFormat(virBuffer *buf, =20 virDomainDiskDefFormatIotune(&childBuf, def); =20 + virDomainDiskDefFormatThrottleFilters(&childBuf, def); + if (def->src->readonly) virBufferAddLit(&childBuf, "\n"); if (def->src->shared) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4977747d9c..9c3eaaedd0 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -520,6 +520,15 @@ void virDomainDiskIothreadDefFree(virDomainDiskIothrea= dDef *def); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainDiskIothreadDef, virDomainDiskIothr= eadDefFree); =20 =20 +/* Stores information related to a ThrottleFilter resource. */ +struct _virDomainThrottleFilterDef { + char *group_name; + char *nodename; /* node name of throttle filter object */ + /* node name is a qemu driver implementation + detail and not a configuration field */ +}; + + /* Stores the virtual disk configuration */ struct _virDomainDiskDef { virStorageSource *src; /* non-NULL. XXX Allow NULL for empty cdrom? */ @@ -552,6 +561,9 @@ struct _virDomainDiskDef { =20 virDomainBlockIoTuneInfo blkdeviotune; =20 + size_t nthrottlefilters; + virDomainThrottleFilterDef **throttlefilters; + char *driverName; =20 char *serial; @@ -4627,3 +4639,11 @@ virDomainThrottleGroupByName(const virDomainDef *def, void virDomainThrottleGroupDefCopy(const virDomainThrottleGroupDef *src, virDomainThrottleGroupDef *dst); + +void +virDomainThrottleFilterDefClear(virDomainThrottleFilterDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainThrottleFilterDef, virDomainThrottl= eFilterDefClear); + +virDomainThrottleFilterDef * +virDomainThrottleFilterFind(const virDomainDiskDef *def, + const char *name); diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h index 1936ef6ab1..c70437bc05 100644 --- a/src/conf/virconftypes.h +++ b/src/conf/virconftypes.h @@ -82,6 +82,8 @@ typedef struct _virDomainBlockIoTuneInfo virDomainBlockIo= TuneInfo; =20 typedef struct _virDomainBlockIoTuneInfo virDomainThrottleGroupDef; =20 +typedef struct _virDomainThrottleFilterDef virDomainThrottleFilterDef; + typedef struct _virDomainCheckpointDef virDomainCheckpointDef; =20 typedef struct _virDomainCheckpointObj virDomainCheckpointObj; --=20 2.39.5 (Apple Git-154)