From nobody Mon Feb 9 01:34:10 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=1621524986; cv=none; d=zohomail.com; s=zohoarc; b=AL0w9vtJ/jQeysevCXE4bMdCVRcZ233Qy/z4jHOVZHSla5UfLP8293e7VcO/wfkALX06IvsZf3bhuMtSn1DuMIZNYiDcNB+8LWIdbhqO5gBpQZibylKgJ98Boz/4MEfTdqphsb19DmMP18gn5gqg7nL6dok20zpho9PrRQ0Cy4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621524986; 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=WQYh90HZ6OcE5HeiVdTYYX/rbtvayBR4i1mguh9EmFE=; b=BHtF12aAA4EL8BHFIdjAwPEcnh6FNUYgJ+nhsArW7KzKV+Se0PewBfslVElfhT84q5WOaWm2xvzcL5F9Ot4bG1gHf8Y5hynhmdLI1TqojKc/56H7nUs1vX9UTmXh1ynWJEre/WREEqODcEeZ6MINLNQrLP+u+Udm41sQpmbPW2s= 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 1621524986142428.93188232006185; Thu, 20 May 2021 08:36:26 -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-408-adRcStbSOTij1tx7-41I0A-1; Thu, 20 May 2021 11:36:23 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEEBF100C61D; Thu, 20 May 2021 15:36:16 +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 9CAA35C23E; Thu, 20 May 2021 15:36:16 +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 578D355355; Thu, 20 May 2021 15:36:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14KFPW3s018235 for ; Thu, 20 May 2021 11:25:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id B259F687F0; Thu, 20 May 2021 15:25:32 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37A94687EC for ; Thu, 20 May 2021 15:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621524985; 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=WQYh90HZ6OcE5HeiVdTYYX/rbtvayBR4i1mguh9EmFE=; b=SeQJUYqcH6IcoU2hhr1dJGzcB0t0S9XXFUVNiVGjmo45e+WYuC6K93Uh2pd2daf3XQ26H1 aQghWB6DcPHDUPFBwM6TUjjSiI9i6jyu/mw3qezwth1ULPNd9rPx2rpsXACFsyepF9ioJT svsdMX9R+12PyDgInzjQlb9VrE7+Bl0= X-MC-Unique: adRcStbSOTij1tx7-41I0A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] numa_conf: Expose virNumaDistance formatter Date: Thu, 20 May 2021 17:24:55 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.16 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" Expose virNumaDistance XML formatter so that it can be re-used by other parts of the code. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/numa_conf.c | 47 +++++++++++++++++++++------------------- src/conf/numa_conf.h | 10 +++++++++ src/libvirt_private.syms | 1 + 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index fa39c1ccc0..8fd5635aca 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -82,8 +82,6 @@ VIR_ENUM_IMPL(virDomainMemoryLatency, "write" ); =20 -typedef struct _virNumaDistance virNumaDistance; - typedef struct _virDomainNumaCache virDomainNumaCache; =20 typedef struct _virDomainNumaInterconnect virDomainNumaInterconnect; @@ -106,10 +104,7 @@ struct _virDomainNuma { virDomainMemoryAccess memAccess; /* shared memory access configura= tion */ virTristateBool discard; /* discard-data for memory-backend-file */ =20 - struct _virNumaDistance { - unsigned int value; /* locality value for node i->j or j->i */ - unsigned int cellid; - } *distances; /* remote node distances */ + virNumaDistance *distances; /* remote node distances */ size_t ndistances; =20 struct _virDomainNumaCache { @@ -1132,22 +1127,9 @@ virDomainNumaDefFormatXML(virBuffer *buf, virBufferAsprintf(&attrBuf, " discard=3D'%s'", virTristateBoolTypeToString(discard)); =20 - if (def->mem_nodes[i].ndistances) { - virNumaDistance *distances =3D def->mem_nodes[i].distances; - - 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(&childBuf, -2); - virBufferAddLit(&childBuf, "\n"); - } + virNumaDistanceFormat(&childBuf, + def->mem_nodes[i].distances, + def->mem_nodes[i].ndistances); =20 for (j =3D 0; j < def->mem_nodes[i].ncaches; j++) { virDomainNumaCache *cache =3D &def->mem_nodes[i].caches[j]; @@ -1836,3 +1818,24 @@ virDomainNumaGetInterconnect(const virDomainNuma *nu= ma, *value =3D l->value; return 0; } + + +void +virNumaDistanceFormat(virBuffer *buf, + const virNumaDistance *distances, + size_t ndistances) +{ + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + size_t i; + + for (i =3D 0; i < ndistances; i++) { + if (distances[i].value =3D=3D 0) + continue; + virBufferAddLit(&childBuf, "\n"); + } + + virXMLFormatElement(buf, "distances", NULL, &childBuf); +} diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h index 8f6597b0b7..6682580ded 100644 --- a/src/conf/numa_conf.h +++ b/src/conf/numa_conf.h @@ -249,3 +249,13 @@ int virDomainNumaGetInterconnect(const virDomainNuma *= numa, unsigned int *cache, virDomainMemoryLatency *accessType, unsigned long *value); + +typedef struct _virNumaDistance virNumaDistance; +struct _virNumaDistance { + unsigned int value; /* locality value for node i->j or j->i */ + unsigned int cellid; +}; + +void virNumaDistanceFormat(virBuffer *buf, + const virNumaDistance *distances, + size_t ndistances); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6fbdee4124..fcf833429b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -913,6 +913,7 @@ virDomainNumatunePlacementTypeFromString; virDomainNumatunePlacementTypeToString; virDomainNumatuneSet; virDomainNumatuneSpecifiedMaxNode; +virNumaDistanceFormat; =20 =20 # conf/nwfilter_conf.h --=20 2.26.3