From nobody Tue Dec 16 13:49:38 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=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1739550715906583.6478403419189; Fri, 14 Feb 2025 08:31:55 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 483259BD; Fri, 14 Feb 2025 11:31:55 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7EC8B1BA4; Fri, 14 Feb 2025 11:30:22 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6FE351B24; Fri, 14 Feb 2025 11:30:16 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 73CD919DF for ; Fri, 14 Feb 2025 11:30:00 -0500 (EST) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-231-ElfOwG97N6CxQqCwvi01Zw-1; Fri, 14 Feb 2025 11:29:58 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AC9381801BFE for ; Fri, 14 Feb 2025 16:29:54 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.26]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 06A341955DCE; Fri, 14 Feb 2025 16:29:52 +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, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,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=redhat.com; s=mimecast20190719; t=1739550600; 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=dYBDav/sPsa0JseE/mAOM8J2hu2Z1mQX+zm8V0kiICI=; b=NKi0KfCT0kHUD222wSxwrBKl4d0ZfKX1JBKwzDkBM3Vy04H6BY0dzA4vrCBtcbvNNlWriW rgM1d5wD8Ew66MHBKf81np7r2GFBoaOMINFWAUpaAWoG3S1eE5rWZptWDW9aqPKU1lBMoX sOIgXJFoF+EQWth45O+hl7BRTDgvZJc= X-MC-Unique: ElfOwG97N6CxQqCwvi01Zw-1 X-Mimecast-MFC-AGG-ID: ElfOwG97N6CxQqCwvi01Zw_1739550595 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 02/13] conf: domain: Extract code for parsing and formatting iotrhead mapping definition Date: Fri, 14 Feb 2025 17:29:36 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: onFTT15UwcKE3wm_013IutTo-g4-61LsHTIOofEsmUo_1739550595 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: YWKVL5LM7E65DAXDI2ELYRCNQWD6UZGI X-Message-ID-Hash: YWKVL5LM7E65DAXDI2ELYRCNQWD6UZGI 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: Stefan Hajnoczi 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: 1739550733539019000 Content-Type: text/plain; charset="utf-8" The code will be also needed for 'virtio-scsi' controller definitions. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 143 +++++++++++++++++++++++------------------ 1 file changed, 81 insertions(+), 62 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 22b9dad9ee..1a52cda62d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7939,11 +7939,56 @@ virDomainDiskDefGeometryParse(virDomainDiskDef *def, static int -virDomainDiskDefDriverParseXML(virDomainDiskDef *def, - xmlNodePtr cur) +virDomainIothreadMappingDefParse(xmlNodePtr driverNode, + GSList **iothreads) { xmlNodePtr iothreadsNode; + g_autoslist(virDomainIothreadMappingDef) ioth =3D NULL; + g_autoptr(GPtrArray) iothreadNodes =3D NULL; + size_t i; + + if (!(iothreadsNode =3D virXMLNodeGetSubelement(driverNode, "iothreads= "))) + return 0; + + if (!(iothreadNodes =3D virXMLNodeGetSubelementList(iothreadsNode, "io= thread"))) + return 0; + + for (i =3D 0; i < iothreadNodes->len; i++) { + xmlNodePtr iothNode =3D g_ptr_array_index(iothreadNodes, i); + g_autoptr(virDomainIothreadMappingDef) iothdef =3D g_new0(virDomai= nIothreadMappingDef, 1); + g_autoptr(GPtrArray) queueNodes =3D NULL; + + if (virXMLPropUInt(iothNode, "id", 10, VIR_XML_PROP_REQUIRED, + &iothdef->id) < 0) + return -1; + + if ((queueNodes =3D virXMLNodeGetSubelementList(iothNode, "queue")= )) { + size_t q; + + iothdef->queues =3D g_new0(unsigned int, queueNodes->len); + iothdef->nqueues =3D queueNodes->len; + + for (q =3D 0; q < queueNodes->len; q++) { + xmlNodePtr queueNode =3D g_ptr_array_index(queueNodes, q); + + if (virXMLPropUInt(queueNode, "id", 10, VIR_XML_PROP_REQUI= RED, + &(iothdef->queues[q])) < 0) + return -1; + } + } + ioth =3D g_slist_prepend(ioth, g_steal_pointer(&iothdef)); + } + + *iothreads =3D g_slist_reverse(g_steal_pointer(&ioth)); + return 0; +} + + +static int +virDomainDiskDefDriverParseXML(virDomainDiskDef *def, + xmlNodePtr cur) +{ def->driverName =3D virXMLPropString(cur, "name"); if (virXMLPropEnum(cur, "cache", virDomainDiskCacheTypeFromString, @@ -7990,43 +8035,8 @@ virDomainDiskDefDriverParseXML(virDomainDiskDef *def, if (virXMLPropUInt(cur, "iothread", 10, VIR_XML_PROP_NONZERO, &def->io= thread) < 0) return -1; - if ((iothreadsNode =3D virXMLNodeGetSubelement(cur, "iothreads"))) { - g_autoslist(virDomainIothreadMappingDef) ioth =3D NULL; - g_autoptr(GPtrArray) iothreadNodes =3D NULL; - - if ((iothreadNodes =3D virXMLNodeGetSubelementList(iothreadsNode, = "iothread"))) { - size_t i; - - for (i =3D 0; i < iothreadNodes->len; i++) { - xmlNodePtr iothNode =3D g_ptr_array_index(iothreadNodes, i= ); - g_autoptr(virDomainIothreadMappingDef) iothdef =3D g_new0(= virDomainIothreadMappingDef, 1); - g_autoptr(GPtrArray) queueNodes =3D NULL; - - if (virXMLPropUInt(iothNode, "id", 10, VIR_XML_PROP_REQUIR= ED, - &iothdef->id) < 0) - return -1; - - if ((queueNodes =3D virXMLNodeGetSubelementList(iothNode, = "queue"))) { - size_t q; - - iothdef->queues =3D g_new0(unsigned int, queueNodes->l= en); - iothdef->nqueues =3D queueNodes->len; - - for (q =3D 0; q < queueNodes->len; q++) { - xmlNodePtr queueNode =3D g_ptr_array_index(queueNo= des, q); - - if (virXMLPropUInt(queueNode, "id", 10, VIR_XML_PR= OP_REQUIRED, - &(iothdef->queues[q])) < 0) - return -1; - } - } - - ioth =3D g_slist_prepend(ioth, g_steal_pointer(&iothdef)); - } - - def->iothreads =3D g_slist_reverse(g_steal_pointer(&ioth)); - } - } + if (virDomainIothreadMappingDefParse(cur, &def->iothreads) < 0) + return -1; if (virXMLPropEnum(cur, "detect_zeroes", virDomainDiskDetectZeroesTypeFromString, @@ -23161,6 +23171,37 @@ virDomainDiskDefFormatIotune(virBuffer *buf, #undef FORMAT_IOTUNE +static void +virDomainIothreadMappingDefFormat(virBuffer *buf, + GSList *iothreads) +{ + g_auto(virBuffer) iothreadsChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); + GSList *n; + + if (!iothreads) + return; + + for (n =3D iothreads; n; n =3D n->next) { + virDomainIothreadMappingDef *iothDef =3D n->data; + g_auto(virBuffer) iothreadAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) iothreadChildBuf =3D VIR_BUFFER_INIT_CHILD(&ioth= readsChildBuf); + + virBufferAsprintf(&iothreadAttrBuf, " id=3D'%u'", iothDef->id); + + if (iothDef->queues) { + size_t q; + + for (q =3D 0; q < iothDef->nqueues; q++) + virBufferAsprintf(&iothreadChildBuf, "\n= ", iothDef->queues[q]); + } + + virXMLFormatElement(&iothreadsChildBuf, "iothread", &iothreadAttrB= uf, &iothreadChildBuf); + } + + virXMLFormatElement(buf, "iothreads", NULL, &iothreadsChildBuf); +} + + static void virDomainDiskDefFormatDriver(virBuffer *buf, virDomainDiskDef *disk) @@ -23235,29 +23276,7 @@ virDomainDiskDefFormatDriver(virBuffer *buf, virXMLFormatElement(&childBuf, "metadata_cache", NULL, &metadataCa= cheChildBuf); } - if (disk->iothreads) { - g_auto(virBuffer) iothreadsChildBuf =3D VIR_BUFFER_INIT_CHILD(&chi= ldBuf); - GSList *n; - - for (n =3D disk->iothreads; n; n =3D n->next) { - virDomainIothreadMappingDef *iothDef =3D n->data; - g_auto(virBuffer) iothreadAttrBuf =3D VIR_BUFFER_INITIALIZER; - g_auto(virBuffer) iothreadChildBuf =3D VIR_BUFFER_INIT_CHILD(&= iothreadsChildBuf); - - virBufferAsprintf(&iothreadAttrBuf, " id=3D'%u'", iothDef->id); - - if (iothDef->queues) { - size_t q; - - for (q =3D 0; q < iothDef->nqueues; q++) - virBufferAsprintf(&iothreadChildBuf, "\n", iothDef->queues[q]); - } - - virXMLFormatElement(&iothreadsChildBuf, "iothread", &iothreadA= ttrBuf, &iothreadChildBuf); - } - - virXMLFormatElement(&childBuf, "iothreads", NULL, &iothreadsChildB= uf); - } + virDomainIothreadMappingDefFormat(&childBuf, disk->iothreads); virXMLFormatElement(buf, "driver", &attrBuf, &childBuf); } --=20 2.48.1