From nobody Sat Feb 7 08:13:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654606392; cv=none; d=zohomail.com; s=zohoarc; b=eWYTjpsJmdMs7KLS92gnLDEUPQVPYdoBLXBLNAjJqn6oQKkR81kAl7bKpT/kE5DTMcPNxuumCKa5EbebKDZshs9pES4nLm17EN6xZw7yo3RXcTsBUeWVddCFTXZtyTeqhdUumkY+vX2MB33HlQI6kLDv7fESBsN8hFcAlI6koOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654606392; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HDVwVgB2+jd7UDiEVhSvsZo8xTyQZr1hLV1gbTsU4bs=; b=QZF/Aa8W1Re0Q7FhAiWZbq8xQPS9VjlcXY2NrHht03nu45TxosOfWCHrA6r1BvfDSFHTq0lNfM95lVjsjWEbPMZ6yuX/Lx6I2l6MYNFVMV+w9zE72sRyTh2xnRGxr6CP+G5YDwgkmSpN6lqi4X6jdCIyiL2+wesoWq/Poeofn18= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654606392003160.2982250260833; Tue, 7 Jun 2022 05:53:12 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-38-uL7kccfyPRW0hg7Hv_50VQ-1; Tue, 07 Jun 2022 08:53:08 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D95D72A59547; Tue, 7 Jun 2022 12:53:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C21E840336A; Tue, 7 Jun 2022 12:53:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7EF9A19451F0; Tue, 7 Jun 2022 12:53:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7065C1947B87 for ; Tue, 7 Jun 2022 12:53:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5513C4050C41; Tue, 7 Jun 2022 12:53:04 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.34.246.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id C16764050C40 for ; Tue, 7 Jun 2022 12:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654606390; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HDVwVgB2+jd7UDiEVhSvsZo8xTyQZr1hLV1gbTsU4bs=; b=EU/gs/sddHjhrq096a/nuR9b0PzDogvjf1EPGQ/6fwQ8fjgLr+OaZHp/qNpAhOwkx/Wsx/ 0l56+bT+i+298f1r/xd06iZMzmsg9X7mkisCNXwcVdKDMeaC64cLV+dMgYI0CkHP/wBEZh 3cEaZZ/xzCB26bBy7YzDhcRgmypBJeQ= X-MC-Unique: uL7kccfyPRW0hg7Hv_50VQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 04/15] conf: Move iothread formatter into a separate function Date: Tue, 7 Jun 2022 14:52:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654606392367100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Formatting iothreads is currently open coded inside of virDomainDefFormatInternalSetRootName(). While this works, it makes the function needlessly long, especially if the formatting code will expand in near future. Therefore, move it into a separate function. At the same time, make virDomainDefIothreadShouldFormat() accept const domain definition so that the new function can also accept const domain definition. Formatters shouldn't need to change definition. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index eec5941089..c60ab4e064 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27569,7 +27569,7 @@ virDomainCpuDefFormat(virBuffer *buf, =20 =20 static bool -virDomainDefIothreadShouldFormat(virDomainDef *def) +virDomainDefIothreadShouldFormat(const virDomainDef *def) { size_t i; =20 @@ -27582,6 +27582,31 @@ virDomainDefIothreadShouldFormat(virDomainDef *def) } =20 =20 +static void +virDomainDefIOThreadsFormat(virBuffer *buf, + const virDomainDef *def) +{ + g_auto(virBuffer) childrenBuf =3D VIR_BUFFER_INIT_CHILD(buf); + size_t i; + + if (def->niothreadids =3D=3D 0) + return; + + virBufferAsprintf(buf, "%zu\n", + def->niothreadids); + + if (!virDomainDefIothreadShouldFormat(def)) + return; + + for (i =3D 0; i < def->niothreadids; i++) { + virBufferAsprintf(&childrenBuf, "\n", + def->iothreadids[i]->iothread_id); + } + + virXMLFormatElement(buf, "iothreadids", NULL, &childrenBuf); +} + + static void virDomainIOMMUDefFormat(virBuffer *buf, const virDomainIOMMUDef *iommu) @@ -28227,20 +28252,7 @@ virDomainDefFormatInternalSetRootName(virDomainDef= *def, if (virDomainCpuDefFormat(buf, def) < 0) return -1; =20 - if (def->niothreadids > 0) { - virBufferAsprintf(buf, "%zu\n", - def->niothreadids); - if (virDomainDefIothreadShouldFormat(def)) { - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - for (i =3D 0; i < def->niothreadids; i++) { - virBufferAsprintf(buf, "\n", - def->iothreadids[i]->iothread_id); - } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } - } + virDomainDefIOThreadsFormat(buf, def); =20 if (virDomainCputuneDefFormat(buf, def, flags) < 0) return -1; --=20 2.35.1