From nobody Tue May 14 07:50:12 2024 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 Reviewed-by: J=C3=A1n Tomko --- 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 From nobody Tue May 14 07:50:12 2024 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=1621255476; cv=none; d=zohomail.com; s=zohoarc; b=OourtCD8TJaKKHiqF2f7rROT7VfV/79+v3wOp4qVBgRwBwIwtTmmogu4t1vbJTwl5inqKRDlgHomseS69LSXjD+/Zir+KA2KPmy6kdPIyyPkDiOzAK58D86Vx8ko0R+J/2Y6uPgsgpbq/ulAx7EM+to7jBhI1+5VOxOQS0Wmej0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621255476; 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=5oWhIS8D1oEf+H5HZ8jXvKdO5djw9hPm+u2UPQrQJgM=; b=cC2y/jlODZp9qYjxyXPaAZNfJK8HtKFJft4pr7Sms30Jk74FmDFD4Zr15VGdfOveJNtdYPsv3vbkPoJm4QsRKcnkrS41Yc7s+Ojo0mYX/hrWF89fOiISSBUUx3LDofBCmG3BhhRRjTHXykS+BOOA34HBim8Bkwk4G1W+UYL7jr8= 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 1621255476448588.0895301139868; Mon, 17 May 2021 05:44:36 -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-J7Y-BngtMkGSQryPpjbk_w-1; Mon, 17 May 2021 08:44:33 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6AB3E107ACF2; Mon, 17 May 2021 12:44:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13A71100F49F; 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 7CC4C180B465; 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 14HCiPuK015623 for ; Mon, 17 May 2021 08:44:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id D5F2B1899A; 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 5AECA179B3 for ; Mon, 17 May 2021 12:44:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621255475; 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=5oWhIS8D1oEf+H5HZ8jXvKdO5djw9hPm+u2UPQrQJgM=; b=XYQC1YvZgtAE/YqFgQm4FckiG3WoF6aKG0N5M4Q52sEuyANdWBBBC9HaSespRYye1agLYO GjrnxhcttCebCleUKxRFqOUmw5wOnIKuWbEJw3CSiVFpwRqIaQ/RJaX1UZPfN5tZ0ivIcB toNlkaIApSo2S49KJkIT2aJFaYADUGM= X-MC-Unique: J7Y-BngtMkGSQryPpjbk_w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] virnuma: Export virNumaGetMaxCPUs properly Date: Mon, 17 May 2021 14:44:16 +0200 Message-Id: <87636b9845cceba09ff3ab8e15ab047683b0a229.1621255232.git.mprivozn@redhat.com> 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.84 on 10.5.11.22 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" This function will be used in virnumamock, shortly. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/util/virnuma.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1df4b8cfe8..b7bbe46dc7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2872,6 +2872,7 @@ virNodeSuspendGetTargetMask; virNumaGetAutoPlacementAdvice; virNumaGetDistances; virNumaGetHostMemoryNodeset; +virNumaGetMaxCPUs; virNumaGetMaxNode; virNumaGetNodeCPUs; virNumaGetNodeMemory; diff --git a/src/util/virnuma.h b/src/util/virnuma.h index 45342ecf11..bc79bff891 100644 --- a/src/util/virnuma.h +++ b/src/util/virnuma.h @@ -43,7 +43,7 @@ int virNumaGetNodeMemory(int node, unsigned long long *memsize, unsigned long long *memfree) G_GNUC_NO_INLINE; =20 -unsigned int virNumaGetMaxCPUs(void); +unsigned int virNumaGetMaxCPUs(void) G_GNUC_NO_INLINE; =20 int virNumaGetNodeCPUs(int node, virBitmap **cpus) G_GNUC_NO_INLINE; int virNumaNodesetToCPUset(virBitmap *nodeset, --=20 2.26.3 From nobody Tue May 14 07:50:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1621255486; cv=none; d=zohomail.com; s=zohoarc; b=LwJjGQeehnCpcn4RBHpmsrdH8MSzwOldJIz/kfXo1JFaAGH6+fVkfmp4G0V+Qh/IafkL19hlF9mb1xTXHEH6Jb9L3118o/xN8LPQqYtK42N2rVv1Yad2ait49zpOUXT6DI1tgFSjJc0GxAs2XwV45iJA9gh7Nc58IJ/eeO/N7fI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621255486; 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=JxyPsMvBqisOlGiMAsYCZMntBNpU+UrPBIj409tYMN0=; b=JdxFDkNptAz9QT55oUq2iEcgtaA2vuozMxjhbKn8ZXA2Aa5auUeMOsOJq7qxioOjYI5/+BrvkAK/6sKixR4/miG17sA0aFmuO+ApG59dieHUxtgrJe1bVsjVWHBBSfUa83glfdFR/gIRGNfi8iVcqtzgEbB9ByXkTST2QejIP8c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1621255486334254.0821690034311; Mon, 17 May 2021 05:44:46 -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-105-JuyO_00jNCiusTA2xrd6pA-1; Mon, 17 May 2021 08:44:43 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8A66B107ACE6; Mon, 17 May 2021 12:44:36 +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 6289219704; Mon, 17 May 2021 12:44:36 +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 0A7895535C; Mon, 17 May 2021 12:44:36 +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 14HCiQQ6015628 for ; Mon, 17 May 2021 08:44:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id B03391899A; Mon, 17 May 2021 12:44:26 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 319B6179B3 for ; Mon, 17 May 2021 12:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621255485; 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=JxyPsMvBqisOlGiMAsYCZMntBNpU+UrPBIj409tYMN0=; b=TeEShXVkjlpKQ1R+zwCP79jAVXWTvlWWmYwPd7RpSsBgSxyiAFjKMtDoR214ZvTxJMXaQd LpOBR/RLfQykAo0OUDTixSuAERfByOZZjwh2Kch+cCavbV8a2FV8unpgUqXKauRmKakex/ rUkI+igUiScieKQNGXHSxJmWgM/5CQw= X-MC-Unique: JuyO_00jNCiusTA2xrd6pA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] virnumamock: Allow CPU-less NUMA nodes Date: Mon, 17 May 2021 14:44:17 +0200 Message-Id: <47598e6441bd2d973ddc60fe1053ffe08efa3883.1621255232.git.mprivozn@redhat.com> 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.84 on 10.5.11.23 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" The original virNumaGetNodeCPUs() returns an empty virBitmap if given NUMA node has no CPUs. But that's not how our mock behaves - it looks under $fakesysfs/node/node$N/cpulist only to find an empty file which is then passed to virBitmapParseUnlimited() which threats such input as error. Fortunately, we don't have any fake sysfs data where this path is hit, but we might soon. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- tests/virnumamock.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/virnumamock.c b/tests/virnumamock.c index 3a203ded77..ff9c6e951d 100644 --- a/tests/virnumamock.c +++ b/tests/virnumamock.c @@ -172,7 +172,12 @@ virNumaGetNodeCPUs(int node, virBitmap **cpus) SYSFS_SYSTEM_PATH, node) < 0) return -1; =20 - *cpus =3D virBitmapParseUnlimited(cpulist); + if (STREQ(cpulist, "")) { + unsigned int max_n_cpus =3D virNumaGetMaxCPUs(); + *cpus =3D virBitmapNew(max_n_cpus); + } else { + *cpus =3D virBitmapParseUnlimited(cpulist); + } if (!*cpus) goto cleanup; =20 --=20 2.26.3 From nobody Tue May 14 07:50:12 2024 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=1621255487; cv=none; d=zohomail.com; s=zohoarc; b=WwH4hu1PIWvAPtbMBwqA/n2EU+tGAZCk560270xFDPEH64E7Yd+h5o64mjW/hfoNVwKlzHGGebfMBvekjHsUqJE9EdTjeEDiHcSoqC3dR3b+qgjZjsCNLrUp0GoWNiY3CruRgKjK2csbNuy4xjnVeavjIOoMX4O7z5OjjSJGF6A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621255487; 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=x84FijrNImbpXbxdLzUUkcHczUGedDYsV2XW/xRtYkY=; b=S3WWehZEkjGmVOCmyM0QyDqwxHlzceDujMfAbeSZEfpiIzIjTvJOvA6xGbJ1xhjvCxUX4OUDEZ/OBJ5xjusM5NZlbAvLtPqFIhPXSmV09U8QDMi7qJvq7JAALiWhbd2qIhhAQX7Vd96MNCa4tBbAbWTFLeTKWbmWBnw6Fp4Lvzs= 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 1621255487652990.972453075721; Mon, 17 May 2021 05:44:47 -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-596-dCKg5-4WMv24DoE_B5_m2g-1; Mon, 17 May 2021 08:44:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DDC0801AEB; Mon, 17 May 2021 12:44:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 10EE65B68E; Mon, 17 May 2021 12:44:39 +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 D4552180B463; Mon, 17 May 2021 12:44:38 +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 14HCiRxP015641 for ; Mon, 17 May 2021 08:44:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 84A381899A; Mon, 17 May 2021 12:44:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 096FA179B3 for ; Mon, 17 May 2021 12:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621255486; 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=x84FijrNImbpXbxdLzUUkcHczUGedDYsV2XW/xRtYkY=; b=e7xaL1QYSSvzthRyo+8zAPokxm1lVuVhaIFNRV1ZxMdGiwwPaZENgB87nH5v25j1zyDmVg m6NPdDL1yoSkAKgE9p3EE+aZ2+vCJtTZAKnR2FdzNgRYwDTJBYk3mSW/xHTSX4Psf68/WZ FP1yfmNZe9J/aMCUd3p/vcm8l3H6+Sc= X-MC-Unique: dCKg5-4WMv24DoE_B5_m2g-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] virCapabilitiesHostNUMAFormat: Bring variables into loops Date: Mon, 17 May 2021 14:44:18 +0200 Message-Id: <8ececc4ce0665891ec9ff7fc20feb9b8c4924373.1621255232.git.mprivozn@redhat.com> 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.15 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 Reviewed-by: J=C3=A1n Tomko --- src/conf/capabilities.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 1dae6d38cc..915cd3149e 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -807,8 +807,6 @@ virCapabilitiesHostNUMAFormat(virBuffer *buf, virCapsHostNUMA *caps) { size_t i; - size_t j; - char *siblings; =20 if (!caps) return 0; @@ -819,6 +817,8 @@ virCapabilitiesHostNUMAFormat(virBuffer *buf, virBufferAdjustIndent(buf, 2); for (i =3D 0; i < caps->cells->len; i++) { virCapsHostNUMACell *cell =3D g_ptr_array_index(caps->cells, i); + size_t j; + virBufferAsprintf(buf, "\n", cell->num); virBufferAdjustIndent(buf, 2); =20 @@ -847,10 +847,12 @@ virCapabilitiesHostNUMAFormat(virBuffer *buf, =20 virBufferAsprintf(buf, "\n", cell->ncpus); virBufferAdjustIndent(buf, 2); - for (j =3D 0; j < cell->ncpus; j++) { + for (j =3D 0; j < cell->ncpus; ++j) { virBufferAsprintf(buf, "cpus[j].id); =20 if (cell->cpus[j].siblings) { + g_autofree char * siblings =3D NULL; + if (!(siblings =3D virBitmapFormat(cell->cpus[j].siblings)= )) return -1; =20 @@ -860,7 +862,6 @@ virCapabilitiesHostNUMAFormat(virBuffer *buf, cell->cpus[j].die_id, cell->cpus[j].core_id, siblings); - VIR_FREE(siblings); } virBufferAddLit(buf, "/>\n"); } --=20 2.26.3