From nobody Sun Feb 8 10:49:21 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=1621255505; cv=none; d=zohomail.com; s=zohoarc; b=VA03T8VRoe6c//XOhmZQlz5ShzKGvEbhe6cYSUlQFWBzqYG3laN9LLfOhW6N3+7QcuANCPD7YxXG2hQ0NkK9c9gQ6Z0vgzcAh5sbKOQSW9Ztun0v7obSTgUlsMary3Xvq9Fy7EyJu/Jxu/d6y/EBh/gP3bIdY1iPPXlZM59v+qA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621255505; 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=NfIYICIKOdkUD5jZm50spvthc4SQfQ7M/l7FEfdhnQg=; b=KYJCOvqjOIURRUsfaSqhr0WR8NqyfDxVc5KTd/0RfNRNmpf0kw1znc3gdZuh42tup9yaWyHYpA6Cu4KPkIxtOGw9FGr9vUAdcr0lELh1W91eQdP8zSvAYYln3GIe5XefwN/uFt6p0juGmA3Z5BoyCo6Np+7DnCE4P24MwVhbJzo= 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) header.from= 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 1621255505552963.2223451688402; Mon, 17 May 2021 05:45:05 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-594-zsfCjvh8M2SWsAO67pkIBQ-1; Mon, 17 May 2021 08:44:33 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A23B6193579C; Mon, 17 May 2021 12:44:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 106E818A49; Mon, 17 May 2021 12:44:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D01B155347; Mon, 17 May 2021 12:44:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14HCiPJW015613 for ; Mon, 17 May 2021 08:44:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0B77F1899A; Mon, 17 May 2021 12:44:25 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D3D9179B3 for ; Mon, 17 May 2021 12:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621255504; 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=NfIYICIKOdkUD5jZm50spvthc4SQfQ7M/l7FEfdhnQg=; b=Adk4U3wOJDpUnxYABSdCYZFeYLYHxKgEh51GuGjE+GGAgHHSoFJJ72OOgsi0CQOGe7c262 SjjU73tKEtlF8KG9MGsJpujwptmueNojFuJMtPFgXJ/3MMbISNRkZwIu1PZJcpbU80OcZh 9dt2Pw0PWeEPdtkOKgaClh+wzN3+A3A= X-MC-Unique: zsfCjvh8M2SWsAO67pkIBQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] numa_conf: Use virXMLFormatElement() in virDomainNumaDefFormatXML Date: Mon, 17 May 2021 14:44:15 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik --- src/conf/numa_conf.c | 107 +++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 59 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 525bc28962..537e515b5a 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -1105,92 +1105,81 @@ virDomainNumaDefFormatXML(virBuffer *buf, virBufferAdjustIndent(buf, 2); for (i =3D 0; i < ncells; i++) { virBitmap *cpumask =3D virDomainNumaGetNodeCpumask(def, i); - int ndistances; - size_t ncaches; + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + size_t j; =20 memAccess =3D virDomainNumaGetNodeMemoryAccessMode(def, i); discard =3D virDomainNumaGetNodeDiscard(def, i); =20 - virBufferAddLit(buf, "mem_nodes[i].ndistances; - ncaches =3D def->mem_nodes[i].ncaches; - if (ndistances =3D=3D 0 && ncaches =3D=3D 0) { - virBufferAddLit(buf, "/>\n"); - } else { - size_t j; - - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - - if (ndistances) { - virDomainNumaDistance *distances =3D def->mem_nodes[i].dis= tances; - - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - for (j =3D 0; j < ndistances; j++) { - if (distances[j].value) { - virBufferAddLit(buf, "\n"); - } + if (def->mem_nodes[i].ndistances) { + virDomainNumaDistance *distances =3D def->mem_nodes[i].distanc= es; + + virBufferAddLit(&childBuf, "\n"); + virBufferAdjustIndent(&childBuf, 2); + for (j =3D 0; j < def->mem_nodes[i].ndistances; j++) { + if (distances[j].value) { + virBufferAddLit(&childBuf, "\n"); } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); } + virBufferAdjustIndent(&childBuf, -2); + virBufferAddLit(&childBuf, "\n"); + } =20 - for (j =3D 0; j < ncaches; j++) { - virDomainNumaCache *cache =3D &def->mem_nodes[i].caches[j]; - - virBufferAsprintf(buf, "level= ); - if (cache->associativity) { - virBufferAsprintf(buf, " associativity=3D'%s'", - virDomainCacheAssociativityTypeToStr= ing(cache->associativity)); - } + for (j =3D 0; j < def->mem_nodes[i].ncaches; j++) { + virDomainNumaCache *cache =3D &def->mem_nodes[i].caches[j]; =20 - if (cache->policy) { - virBufferAsprintf(buf, " policy=3D'%s'", - virDomainCachePolicyTypeToString(cac= he->policy)); - } - virBufferAddLit(buf, ">\n"); + virBufferAsprintf(&childBuf, "lev= el); + if (cache->associativity) { + virBufferAsprintf(&childBuf, " associativity=3D'%s'", + virDomainCacheAssociativityTypeToString(= cache->associativity)); + } =20 - virBufferAdjustIndent(buf, 2); - virBufferAsprintf(buf, - "\n", - cache->size); + if (cache->policy) { + virBufferAsprintf(&childBuf, " policy=3D'%s'", + virDomainCachePolicyTypeToString(cache->= policy)); + } + virBufferAddLit(&childBuf, ">\n"); =20 - if (cache->line) { - virBufferAsprintf(buf, - "\n", - cache->line); - } + virBufferAdjustIndent(&childBuf, 2); + virBufferAsprintf(&childBuf, + "\n", + cache->size); =20 - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + if (cache->line) { + virBufferAsprintf(&childBuf, + "\n", + cache->line); } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + + virBufferAdjustIndent(&childBuf, -2); + virBufferAddLit(&childBuf, "\n"); } + + virXMLFormatElement(buf, "cell", &attrBuf, &childBuf); } =20 if (def->ninterconnects) { --=20 2.26.3