From nobody Sun Dec 7 13:20:57 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 1739984686565767.2055512560853; Wed, 19 Feb 2025 09:04:46 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6A48B1C9B; Wed, 19 Feb 2025 12:04:45 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 866DA1D85; Wed, 19 Feb 2025 12:02:08 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 8D3AD1C6E; Wed, 19 Feb 2025 12:02:01 -0500 (EST) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 BB8711D57 for ; Wed, 19 Feb 2025 12:01:46 -0500 (EST) Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2fa48404207so22779a91.1 for ; Wed, 19 Feb 2025 09:01:46 -0800 (PST) Received: from localhost.localdomain ([2001:4490:4ea9:8374:8512:e327:fdaf:a56e]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-220d558fe3asm106651545ad.234.2025.02.19.09.01.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 19 Feb 2025 09:01:44 -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=1739984505; x=1740589305; 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=3kwfKY1+8TMjsKjJeiUs4jtbdnjGZ/6KuM6hJnbMkm4=; b=fNBzw+J3nHq4fOj4G44uOtAVAfOwrTAPBNhlURlBVfvDiIv+lv6n3NfsiA7PbCdzut YehC/sGGXBMUGGuFbnIgVzEIhkOYfRExhHVXe8RvCq3F2boeYylQfwr2WftbTMXG3mVt xbI9qRXAxrjvUty3vK4tk/E5yABYzgmYyN9phEY3yaU6N+zrr2pihRyBHYrnMMMr5R1w QT6Mvv1i+UVpSgBYj2S8hWVK4NGHTvSp5GCcUvsFj5yD/bQmk7RfKqpmxc2vht11goL8 aBQi+8nyMNMo5N5iLZBC4kI/f4Dvr7lWhRWwsf03C6OmUH2fFUe4xMwlNkgB6GJUS0em vA9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739984505; x=1740589305; 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=3kwfKY1+8TMjsKjJeiUs4jtbdnjGZ/6KuM6hJnbMkm4=; b=vXQnTKfGh2mms7DMwCCmkxX6yPZDTDB5j5BwQneJbJeMj5DebGZRucN3eAEhT8Brj5 opA61HkTJjYR71FKoijOu9Sja0LWVYRhqArcy1RPQtEcr5896BWoxYrMcJ3mwyKivdFK RMdNOgakGiHTkR831D/HDkRJMmx7HyJ0xDuqFX5Wc0fjHkv+xkMgKZ/YJOLfbb++oasp xdP5CKulCfVat4vrfs7eRieFI5wmilgHVLlBBgl+PBZxDHc4yPGFEaajrWhEI14SpH5q nfGPS+b4etv7drrI/m2sSKmakiY7Igey1hZ7ChJ9xzVq1oFpaCNHxlIS173X8dnDmxXe X++Q== X-Gm-Message-State: AOJu0YwbQYgHtnKMsej68Dj7NOMsss74omVV15+rbW5TMFvMrNFLGNbT pbxWfXxAbNVXjXZ+qE8OgwNY2U/r/WUHJwRVjhyINwVIjRzCizAs8o22PdgQ X-Gm-Gg: ASbGncsgaWpySjrXt+Nppyu9h2T+brHGM/5OFcrBK57b1uvYAIKU0xf7HI+iNXibD4/ lDuV7t02UDsRDZfYR9yreuVgfGUyfUlVkKmrGsNY329esjCSSwV5378QaT+ajmrw64mHOmEfk5L Z0gpk/wqxblsNoTNdICKRh6vHyJcUyYa5IwRA0Q4vl6AIagvuYKic/gc54V4XTK2QzQyThgvok2 8l9x6Ah5gu/0sObqTWBw3lR4umwmlcXmwb54Hv3wEMfsWMN/azav9GfProk43XIgHMNKjkssffu rCWyh+N+ey69ODNHobJbn9CDm5tMJaaR0xwouTu428tH5i8mz7pUeetDRQ== X-Google-Smtp-Source: AGHT+IHji82LxQ17t5EGOJ7Tg0BWqnPmVu5hNyNpBBsjs3pzsFv94cwnkTb2Y34Hf9K7iqX8zEz6cQ== X-Received: by 2002:a17:90b:685:b0:2fc:a3b7:10a3 with SMTP id 98e67ed59e1d1-2fca3b71273mr11222280a91.24.1739984505080; Wed, 19 Feb 2025 09:01:45 -0800 (PST) From: Harikumar Rajkumar To: devel@lists.libvirt.org Subject: [PATCH v8 04/18] config: Introduce ThrottleFilter and corresponding XML parsing Date: Wed, 19 Feb 2025 22:27:08 +0530 Message-Id: <20250219165722.26348-5-harirajkumar230@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250219165722.26348-1-harirajkumar230@gmail.com> References: <20250219165722.26348-1-harirajkumar230@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: TAN7EECPUYPQFN7CPWJB57NSDHEDXFNG X-Message-ID-Hash: TAN7EECPUYPQFN7CPWJB57NSDHEDXFNG 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: sanjeev.ranjan@ibm.com, harikumar.rajkumar@ibm.com, earulana@in.ibm.com, Chun Feng Wu , 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: 1739984694124019100 Content-Type: text/plain; charset="utf-8" From: Chun Feng Wu 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 X= ML 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: Chun Feng Wu * Error handling for null throttle group. * Update of code documentation comments. * Apply suggested coding style changes. Signed-off-by: Harikumar Rajkumar Reviewed-by: Peter Krempa --- 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 40f4bf6f49..303aa7d1ae 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); @@ -22746,6 +22803,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, @@ -23396,6 +23478,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) @@ -23682,6 +23779,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 211054274f..2a9912bae8 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)