From nobody Sat Jan 4 23:05:04 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 1733750609502328.8521303238433; Mon, 9 Dec 2024 05:23:29 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 8530B137B; Mon, 9 Dec 2024 08:23:28 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 29CA31257; Mon, 9 Dec 2024 08:19:59 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3650A11CF; Mon, 9 Dec 2024 07:42:30 -0500 (EST) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 610A911BE for ; Mon, 9 Dec 2024 07:42:29 -0500 (EST) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-21669fd5c7cso1049635ad.3 for ; Mon, 09 Dec 2024 04:42:29 -0800 (PST) Received: from localhost.localdomain ([120.60.110.156]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-2164d103993sm18113195ad.193.2024.12.09.04.42.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Dec 2024 04:42:27 -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.6 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=1733748148; x=1734352948; 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=qggqHO98XYjCKDioauFeXVursBKB+9WKmuiapSlyk60=; b=A5O+a0epINJ/j6pslPbhXRVxcKYCBcjG69Lz+wQVyguHL6YB/gw3cokRGZMr8f2VQf vr0PMOVIry+1HzjPszSmKLbXbuSzXxBtg0ibj0XnrqPbyUcCMOX9nVPElospe1ERAu5o KrmMs17lovqCP0Us4wjTz78HQm27M+NRBiSCQNJfh7KIHyqezS0Fy/NJvQahUk2usC51 8Ip4vlNZ3sqkKBSmwu/jo6P365gQK1mC8Sfy69bpNQetSOLczu59CETr5nUwJkWQwVVY GNazL59QoDCV1JPlaJ3J+ceKcwSmJRF7aYHiTEXRVB4aMsXHZRZ/H+4IOOJuoyNux9g6 F0YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733748148; x=1734352948; 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=qggqHO98XYjCKDioauFeXVursBKB+9WKmuiapSlyk60=; b=tsneaO+LhuYLIl7QHc99E5bZDDTTbduNTDE1SaKDIwOf1HKOwrOtvxirePOtCESztk 7BAlcDBV8Gh9HCurT5/X1BNaoPCCGFiELOirNldFGp3sE4mdHtQHzEQJUCb7GSvX0aGn PFopP4lg6dzXIqqja7326e5+IG7D1XQKZkB4LFVbPNi8jr9PbzXtDJ49ZJ8cIeCZ2S+y Ob4wjV7qpMDaxQ2I6gxi+KkxDDXGX2YHRHEZp4JVoo+m6bDt7LE1WN1wLaOiif5/VB2J d2n0zvenjqbdEUh4ZRL39gJW326PzLDLgBzGhZrj++7yjKOa9Q5AeQeBjNaETKCSwvs9 qapw== X-Gm-Message-State: AOJu0YzV0Mt1/yUSxEbaPtToYvMqQ7dYOiPbyGXA8EAyHNAwH8gYjVuq y5zG3iDs73R2KtgDxSKeC4EKGxDKq+ZvddkIomGfTXwo7N5bNjKUfIDBL6Kj X-Gm-Gg: ASbGncuYGGXTz5ku9bqGmYfvy20XPMznyB/O3gIxFbfXe65tNI/YZUd2/yH81JpQfnd XWvO4DRI9/KXeJDm3EkeG846SlI2o3yPVvqfeWrnudYxvf4UY+Jj9bKeTSAd+AH//0QaTvgC6W1 L3TpRp1qjemacnYQoC7VTHDJJwEMlAfeWNoOBUForFbNXvCQu9LiJ2WrUYaDeQs88KUDrptOyXY c+CYz8pOFoni1rhUqDQps4TOxuYvB0JJJ32LV3AMphLSprkIPfjBQLCMC7SrjPBYzsH99RsgK71 x81pYg== X-Google-Smtp-Source: AGHT+IGLw815i9T+vyZY4MgZ9TcaHHEzZPVGWuQcWv0CioIQOSFx6YGvnrAV+HUOXKcCJOmWCzQMng== X-Received: by 2002:a17:902:f709:b0:216:18dc:43b3 with SMTP id d9443c01a7336-21618dc4547mr147086695ad.42.1733748147910; Mon, 09 Dec 2024 04:42:27 -0800 (PST) From: Harikumar R To: devel@lists.libvirt.org Subject: [PATCH v6 04/18] config: Introduce ThrottleFilter and corresponding XML parsing Date: Mon, 9 Dec 2024 18:11:04 +0530 Message-Id: <20241209124118.39471-5-harirajkumar230@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20241209124118.39471-1-harirajkumar230@gmail.com> References: <20241209124118.39471-1-harirajkumar230@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MailFrom: harirajkumar230@gmail.com X-Mailman-Rule-Hits: nonmember-moderation 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 Message-ID-Hash: DX6VVUUTDX64QU6L5BCVKZWTFRTNDDAZ X-Message-ID-Hash: DX6VVUUTDX64QU6L5BCVKZWTFRTNDDAZ X-Mailman-Approved-At: Mon, 09 Dec 2024 13:19:44 -0500 CC: earulana@in.ibm.com, sanjeev.ranjan@ibm.com, harikumar.rajkumar@ibm.com, Chun Feng Wu 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: 1733750610856116600 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 --- src/conf/domain_conf.c | 105 ++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 18 +++++++ src/conf/virconftypes.h | 2 + 3 files changed, 125 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e5a002876f..a4de5c01c3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3816,6 +3816,16 @@ virDomainThrottleGroupDefArrayFree(virDomainThrottle= GroupDef **def, } =20 =20 +void +virDomainThrottleFilterDefFree(virDomainThrottleFilterDef *def) +{ + if (!def) + return; + g_free(def->group_name); + g_free(def->nodename); +} + + void virDomainResourceDefFree(virDomainResourceDef *resource) { @@ -7964,6 +7974,53 @@ virDomainDefThrottleGroupsParse(virDomainDef *def, } =20 =20 +static virDomainThrottleFilterDef * +virDomainDiskThrottleFilterDefParse(xmlNodePtr node) +{ + g_autoptr(virDomainThrottleFilterDef) filter =3D g_new0(virDomainThro= ttleFilterDef, 1); + + filter->group_name =3D virXMLPropString(node, "group"); + + if (!filter->group_name) + return NULL; + + 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, @@ -8454,6 +8511,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); @@ -22672,6 +22732,34 @@ 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; + + if (!def->throttlefilters || def->nthrottlefilters =3D=3D 0) + return NULL; + + 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, @@ -23322,6 +23410,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) @@ -23608,6 +23711,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 2f40d304b4..f1e85ab42f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -520,6 +520,13 @@ 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 */ +}; + + /* Stores the virtual disk configuration */ struct _virDomainDiskDef { virStorageSource *src; /* non-NULL. XXX Allow NULL for empty cdrom? */ @@ -552,6 +559,9 @@ struct _virDomainDiskDef { =20 virDomainBlockIoTuneInfo blkdeviotune; =20 + size_t nthrottlefilters; + virDomainThrottleFilterDef **throttlefilters; + char *driverName; =20 char *serial; @@ -4608,3 +4618,11 @@ virDomainThrottleGroupByName(const virDomainDef *def, void virDomainThrottleGroupDefCopy(const virDomainThrottleGroupDef *src, virDomainThrottleGroupDef *dst); + +void +virDomainThrottleFilterDefFree(virDomainThrottleFilterDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainThrottleFilterDef, virDomainThrottl= eFilterDefFree); + +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)