From nobody Fri May 17 15:06:10 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=1620201766; cv=none; d=zohomail.com; s=zohoarc; b=cQ4o2ODE9KExyOPbe0WiqYxYkYlRsdsfev7Hp5hgaKVXs6v1Tnb5pwbTrsB/p5AT80cS9uqj4dpZyJl5SI7Oke0zgZFJtH7gmmERPYhpfRt2G3K0L5xVyWhWGboanRpT9a313p3zsQ/7t1G7MkAh5nielZIRGRBbMrwRUebZF/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201766; 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=F2BsXG4eRny27Ex6ymq8m/9wj+yrK8bE9Rzf8+jD/7o=; b=AR7FcVJTDCyS9qpMMEu4aT6HsndeWJ6AEVzT4BF236Z+yQpS/vSa2jX+3N0fH5NsQVb0BszWADnGkO71KNEhBLTiQDHA5w6SA3Dp+6BOZxdcE6m9iBeaU5OjLu8iE3Ha3AL1eZh2i7slgUrLNuRCzz2e0vKQWugLmdNYd7c14Ws= 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 1620201766103850.1113422732748; Wed, 5 May 2021 01:02: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-165-aA8WVJceN2ePIscIreKCBw-1; Wed, 05 May 2021 04:02:42 -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 AE3EB1006C81; Wed, 5 May 2021 08:02:36 +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 681121043293; Wed, 5 May 2021 08:02: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 ED34C180B464; Wed, 5 May 2021 08:02:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14582WWR007784 for ; Wed, 5 May 2021 04:02:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id E09605D9E3; Wed, 5 May 2021 08:02:32 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.235]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60C3C5D9E2 for ; Wed, 5 May 2021 08:02:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620201765; 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=F2BsXG4eRny27Ex6ymq8m/9wj+yrK8bE9Rzf8+jD/7o=; b=dTWXVR1QXJDK8+LJCcvJ3WK2oBHIV6duxR7XwWFHQYQf9vjRFCeykPbOdc4DRSqIYB3g5n KWTYCc1NR3hYQmUBJeqiFyNEnM8l5erwjjop04g6NcmlQwnKF5nYhJxQ2MD+zS7jWDVNv/ uit3/rVHfjljPnPk801fq32SONwTlbA= X-MC-Unique: aA8WVJceN2ePIscIreKCBw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/5] virCapabilitiesHostNUMAFormat: Swap order of arguments Date: Wed, 5 May 2021 10:02:20 +0200 Message-Id: <7181152854cb4292a9c982f120817ce2d723d23c.1620201674.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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" The rest of virCapabilities format functions take virBuffer as the first argument and struct to format as the second. Also, they accept NULL (as the second argument). Fix virCapabilitiesHostNUMAFormat() so that it follows this logic. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/capabilities.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 9bd59b3cbf..084e09286d 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -794,13 +794,16 @@ virCapabilitiesAddStoragePool(virCaps *caps, =20 =20 static int -virCapabilitiesHostNUMAFormat(virCapsHostNUMA *caps, - virBuffer *buf) +virCapabilitiesHostNUMAFormat(virBuffer *buf, + virCapsHostNUMA *caps) { size_t i; size_t j; char *siblings; =20 + if (!caps) + return 0; + virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); virBufferAsprintf(buf, "\n", caps->cells->len); @@ -1125,8 +1128,7 @@ virCapabilitiesFormatHostXML(virCapsHost *host, virBufferAsprintf(buf, "%s\n", host->netprefix); =20 - if (host->numa && - virCapabilitiesHostNUMAFormat(host->numa, buf) < 0) + if (virCapabilitiesHostNUMAFormat(buf, host->numa) < 0) return -1; =20 if (virCapabilitiesFormatCaches(buf, &host->cache) < 0) --=20 2.26.3 From nobody Fri May 17 15:06:10 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=1620201766; cv=none; d=zohomail.com; s=zohoarc; b=Hhp1npbHhv82hANNFYOykaqlNlzOHDlqwBZy+kthy4JO+6ZH/UTmLOpIwIGZLYZ5wuxnpk+K6GKoDBFYhCeBrPs4hdo1hWkOzyKyZFRJGyZEEqXnKw7peeIH6OC560tQrH/feG22SF9Rr/MNNGuOdwHHaGoMQE+8oWHTW7ECzuY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201766; 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=5rGvRFoIGVo+aoiHhznUt31HZSm3KeDO7tF/jiekyLY=; b=DUbRVxN2HJAopLuRURaBKeRuNfyWBSUmV4iEsBiAe2zc7a+S8JLMx+TEiTmKoRuR3FVOy6agAUhIKBWS8aGDyUKWHlysQpUfvqKZrpSnFnnKNsyJLYetPQv8U7sjjOxpupQsA48SG6kryFvrQFFhUSyROyGfhPhrEzE4NoZQYns= 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 1620201766277390.37879496003256; Wed, 5 May 2021 01:02: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-235-d_3QKiBmMnKkisThX62B8A-1; Wed, 05 May 2021 04:02: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 26CCF805EFF; Wed, 5 May 2021 08:02:37 +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 E5CDB131E3; Wed, 5 May 2021 08:02: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 D02B4180B463; Wed, 5 May 2021 08:02:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14582Xfp007794 for ; Wed, 5 May 2021 04:02:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id BEB5B5D9E3; Wed, 5 May 2021 08:02:33 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.235]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E6BC5D9E2 for ; Wed, 5 May 2021 08:02:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620201765; 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=5rGvRFoIGVo+aoiHhznUt31HZSm3KeDO7tF/jiekyLY=; b=S+RALks0dv6czduxQenbtr7aXAS26OvVRd+wMTjce/+1mTZD3Sv8LegcBEjaYQw2mgbhJD tnwwZzEUQJfbyAc14oKABF9Xwb48pPVwcZn7VK6jjqfKWTX0J1d7iI25Pwdyy8580LTPPS MK2C9w+VKPhMu8z9gCVyEXViEeUZiXE= X-MC-Unique: d_3QKiBmMnKkisThX62B8A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/5] virCapabilitiesHostNUMAInitReal: Free @cpus properly Date: Wed, 5 May 2021 10:02:21 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 @cpus variable is an array of structs in which each item contains a virBitmap member. As such it is not enough to just VIR_FREE() the array - each bitmap has to be freed too. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/capabilities.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 084e09286d..4d509a6d28 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1648,6 +1648,7 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *caps) =20 cleanup: virBitmapFree(cpumap); + virCapabilitiesClearHostNUMACellCPUTopology(cpus, ncpus); VIR_FREE(cpus); VIR_FREE(siblings); VIR_FREE(pageinfo); --=20 2.26.3 From nobody Fri May 17 15:06:10 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=1620201773; cv=none; d=zohomail.com; s=zohoarc; b=itBO2Am/TsNWGZrvhc6Qs97FWEBrvzxbWYxQpr9oMr3K0dJsjSEoGrN/BdHdXXSheyjQhJnOxojgnq3qMdHl2PYkbdqyLUhniwqUP38AURztKe82hjpU8qZsjbdQv0TPYcuOQ1QY7AI5706chAP1kFp+EbewqpTHN4/iSPTzxlo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201773; 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=cC7Q//Pd+jY/1IwWWOzq3GuhcDsnbThH31v4MOvSd6Q=; b=nkTJGHPq2Wr+NYA8yquIfChzOBHKFqf79yFrivUA2d8++dF0iqBOXlWcFBS7ODqreEHm7W0KNsyQV3UqGfbaMLsFHAXIbEU3R5FAKoFYeFHatSHR/El+YEGuTrRNGozPAJeJHwhr7e7+jmnJQ8Uq6tHzqWB6jrOET4y+DxKQ1bI= 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 1620201773705955.6235318988436; Wed, 5 May 2021 01:02:53 -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-168-DczhOeOfO1q_6HHBi9VeSg-1; Wed, 05 May 2021 04:02:48 -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 3979E81842E; Wed, 5 May 2021 08:02:44 +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 0DBE1131EF; Wed, 5 May 2021 08:02:44 +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 C6F9455350; Wed, 5 May 2021 08:02:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14582YNV007802 for ; Wed, 5 May 2021 04:02:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D07B5D9E3; Wed, 5 May 2021 08:02:34 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.235]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DBDA5D9E2 for ; Wed, 5 May 2021 08:02:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620201772; 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=cC7Q//Pd+jY/1IwWWOzq3GuhcDsnbThH31v4MOvSd6Q=; b=QkBLg9y+/7GFk2UKEX7gvCGfDlJNMAidjKdldOwzz/svyAl1FJa/+K4AqnTHcbB9tx6xta rcAo7zz1KOVynQBJiGndi6MCBIWd7D7k2PphViD0/LYI2/j7ilJEFRPDMWZM6FANxNd+/t MH5hrsNDgn5lssxoav6cq2dZZArBaGk= X-MC-Unique: DczhOeOfO1q_6HHBi9VeSg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/5] virCapabilitiesHostNUMAAddCell: Take double pointer Date: Wed, 5 May 2021 10:02:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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" What this function really does it takes ownership of all pointers passed (well, except for the first one - caps - to which it registers new NUMA node). But since all info is passed as a single pointer it's hard to tell (and use g_auto*). Let's use double pointers to make the ownership transfer obvious. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/capabilities.c | 45 +++++++++++++++++++--------------- src/conf/capabilities.h | 6 ++--- src/libxl/libxl_capabilities.c | 4 +-- src/test/test_driver.c | 5 ++-- tests/testutils.c | 6 ++--- 5 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 4d509a6d28..ea07afc920 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -330,36 +330,45 @@ virCapabilitiesSetNetPrefix(virCaps *caps, * @num: ID number of NUMA cell * @mem: Total size of memory in the NUMA node (in KiB) * @ncpus: number of CPUs in cell - * @cpus: array of CPU definition structures, the pointer is stolen + * @cpus: array of CPU definition structures * @nsiblings: number of sibling NUMA nodes * @siblings: info on sibling NUMA nodes * @npageinfo: number of pages at node @num * @pageinfo: info on each single memory page * - * Registers a new NUMA cell for a host, passing in a - * array of CPU IDs belonging to the cell + * Registers a new NUMA cell for a host, passing in a array of + * CPU IDs belonging to the cell, distances to other NUMA nodes + * and info on hugepages on the node. + * + * All pointers are stolen. */ void virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps, int num, unsigned long long mem, int ncpus, - virCapsHostNUMACellCPU *cpus, + virCapsHostNUMACellCPU **cpus, int nsiblings, - virCapsHostNUMACellSiblingInfo *siblings, + virCapsHostNUMACellSiblingInfo **siblings, int npageinfo, - virCapsHostNUMACellPageInfo *pageinfo) + virCapsHostNUMACellPageInfo **pageinfo) { virCapsHostNUMACell *cell =3D g_new0(virCapsHostNUMACell, 1); =20 cell->num =3D num; cell->mem =3D mem; - cell->ncpus =3D ncpus; - cell->cpus =3D cpus; - cell->nsiblings =3D nsiblings; - cell->siblings =3D siblings; - cell->npageinfo =3D npageinfo; - cell->pageinfo =3D pageinfo; + if (cpus) { + cell->ncpus =3D ncpus; + cell->cpus =3D g_steal_pointer(cpus); + } + if (siblings) { + cell->nsiblings =3D nsiblings; + cell->siblings =3D g_steal_pointer(siblings); + } + if (pageinfo) { + cell->npageinfo =3D npageinfo; + cell->pageinfo =3D g_steal_pointer(pageinfo); + } =20 g_ptr_array_add(caps->cells, cell); } @@ -1568,7 +1577,7 @@ virCapabilitiesHostNUMAInitFake(virCapsHostNUMA *caps) =20 virCapabilitiesHostNUMAAddCell(caps, 0, nodeinfo.memory, - cid, cpus, + cid, &cpus, 0, NULL, 0, NULL); } @@ -1633,13 +1642,9 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *cap= s) memory >>=3D 10; =20 virCapabilitiesHostNUMAAddCell(caps, n, memory, - ncpus, cpus, - nsiblings, siblings, - npageinfo, pageinfo); - - cpus =3D NULL; - siblings =3D NULL; - pageinfo =3D NULL; + ncpus, &cpus, + nsiblings, &siblings, + npageinfo, &pageinfo); virBitmapFree(cpumap); cpumap =3D NULL; } diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 66cae4b902..ba863447c0 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -254,11 +254,11 @@ virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps, int num, unsigned long long mem, int ncpus, - virCapsHostNUMACellCPU *cpus, + virCapsHostNUMACellCPU **cpus, int nsiblings, - virCapsHostNUMACellSiblingInfo *siblings, + virCapsHostNUMACellSiblingInfo **siblings, int npageinfo, - virCapsHostNUMACellPageInfo *pageinfo); + virCapsHostNUMACellPageInfo **pageinfo); =20 virCapsGuestMachine ** virCapabilitiesAllocMachines(const char *const *names, diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index 6c1199552d..ea4f370a6d 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -330,8 +330,8 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCaps *caps) =20 virCapabilitiesHostNUMAAddCell(caps->host.numa, i, numa_info[i].size / 1024, - nr_cpus_node[i], cpus[i], - nr_siblings, siblings, + nr_cpus_node[i], &cpus[i], + nr_siblings, &siblings, 0, NULL); =20 /* This is safe, as the CPU list is now stored in the NUMA cell */ diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 15e9018803..ea5a5005e7 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -329,8 +329,9 @@ testBuildCapabilities(virConnectPtr conn) =20 virCapabilitiesHostNUMAAddCell(caps->host.numa, i, privconn->cells[i].mem, - privconn->cells[i].numCpus, - cpu_cells, 0, NULL, nPages, pages); + privconn->cells[i].numCpus, &cpu_ce= lls, + 0, NULL, + nPages, &pages); } =20 for (i =3D 0; i < G_N_ELEMENTS(guest_types); i++) { diff --git a/tests/testutils.c b/tests/testutils.c index c39797e51d..d6b7c2a580 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -935,9 +935,9 @@ virTestCapsBuildNUMATopology(int seq) =20 virCapabilitiesHostNUMAAddCell(caps, cell_id + seq, MAX_MEM_IN_CELL, - MAX_CPUS_IN_CELL, cell_cpus, - VIR_ARCH_NONE, NULL, - VIR_ARCH_NONE, NULL); + MAX_CPUS_IN_CELL, &cell_cpus, + 0, NULL, + 0, NULL); =20 cell_cpus =3D NULL; } --=20 2.26.3 From nobody Fri May 17 15:06:10 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=1620201774; cv=none; d=zohomail.com; s=zohoarc; b=h4lGI30KYApItuqHt1ufYXzgH4kWYVqr3+CGchHm3JXMFhYaV4jTgBXHCN59wfXKo0dUDtkEkBg4IdC6IYHEbtX4RcG2w8tHtiuLglZssPvEfrkq3iDBUZ+KV/+2i1UhpubEC56DOzGgWENh1V5HHLd6ytYNTlYT5/b2bdeX4hw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201774; 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=6PfcCFXYN8MQiyKHy3CrjxhGha99fTtJkCWGaDX1xzk=; b=ZQ7bL8lp8+wVuokKp5t8pBd/WkE0fqGIYmqppWwpJ1ITWKe6xqw4e91hZ35wo5cjZ6PvzbkoofgbgjxzYCG3S359wuJmdXbIYduTKErhOTEKHhf91TE9kD57v/AQ3W0zSXuYgqF7jWSytKtLBNoO+3bo42iWM6976LUQ7D24Jug= 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 1620201774319861.8057194564769; Wed, 5 May 2021 01:02:54 -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-283-OJ2TlHSJN0KlYiGE7beWjg-1; Wed, 05 May 2021 04:02:50 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 26BC4A40D7; Wed, 5 May 2021 08:02:44 +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 07C9E60D08; Wed, 5 May 2021 08:02:44 +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 C5705180B465; Wed, 5 May 2021 08:02:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14582ZWf007815 for ; Wed, 5 May 2021 04:02:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7E9C65D9D5; Wed, 5 May 2021 08:02:35 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.235]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF66F5D9E2 for ; Wed, 5 May 2021 08:02:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620201773; 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=6PfcCFXYN8MQiyKHy3CrjxhGha99fTtJkCWGaDX1xzk=; b=b8fdDaUFMjAP741ohH5kggNHILSZUCJDk7FW95InUlv6YeisXwr9gdN1n4uXMkLDCMWDZa 9vdI7rFqqEyk6aor+hA01UYZnX+wXQ1zkFFFlLHzFc3f+s/+LwVaD5nipYxV2ednsn3rCi hWILMJWka+A/DgUqUUP+d9QxVrCdP8M= X-MC-Unique: OJ2TlHSJN0KlYiGE7beWjg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/5] virCapabilitiesHostNUMAInitReal: Use g_auto* where possible Date: Wed, 5 May 2021 10:02:23 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.13 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, 3 insertions(+), 6 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index ea07afc920..c487229ae8 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1598,10 +1598,10 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *ca= ps) int n; unsigned long long memory; virCapsHostNUMACellCPU *cpus =3D NULL; - virBitmap *cpumap =3D NULL; - virCapsHostNUMACellSiblingInfo *siblings =3D NULL; + g_autoptr(virBitmap) cpumap =3D NULL; + g_autofree virCapsHostNUMACellSiblingInfo *siblings =3D NULL; int nsiblings =3D 0; - virCapsHostNUMACellPageInfo *pageinfo =3D NULL; + g_autofree virCapsHostNUMACellPageInfo *pageinfo =3D NULL; int npageinfo; int ret =3D -1; int ncpus =3D 0; @@ -1652,11 +1652,8 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *cap= s) ret =3D 0; =20 cleanup: - virBitmapFree(cpumap); virCapabilitiesClearHostNUMACellCPUTopology(cpus, ncpus); VIR_FREE(cpus); - VIR_FREE(siblings); - VIR_FREE(pageinfo); return ret; } =20 --=20 2.26.3 From nobody Fri May 17 15:06:10 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=1620201778; cv=none; d=zohomail.com; s=zohoarc; b=EIQS8+5nEQ842qEZr/CQJLtUkYQlTxZf2fZUbEhVBOoImkjzHTaKFp1e7mlu/lSYF2zskr/paYgKsEGjMf4mjJ5m29/IsL5JyXExa3PhiyPZOke9dxcGgQjeIgx89oNzhvodRrKAphTpyXiBtH8GrzgHj5R7oI6Gwbeof5OW4Rc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201778; 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=JsktfPDVPAC5U17PB2+gzq6oyRsOmf6STqP/TuG+SSs=; b=NWcnfg0BB8Yh9rj26A5kbKqxb9JZi3LYFH74h/ac5ywppCbs7uGRW0AsFmqXRAqdgguuIqDZgM69XGyE+83KwH9lyj8i3DEg5fkpgg83OnzxZ2q4O1GBoWmIcP2YxKK1rbUqpzRQnASZHj5o3PDnexo2mBJ30Uff6418nW30T2w= 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 1620201778856401.9470573533562; Wed, 5 May 2021 01:02:58 -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-249-xPngLNMsMdWVGL9Sp0ulpw-1; Wed, 05 May 2021 04:02:55 -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 9AEB8BBEE5; Wed, 5 May 2021 08:02:49 +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 429D3131D5; Wed, 5 May 2021 08:02:49 +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 0B3CC55350; Wed, 5 May 2021 08:02:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14582aeO007825 for ; Wed, 5 May 2021 04:02:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5D8075D9E2; Wed, 5 May 2021 08:02:36 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.235]) by smtp.corp.redhat.com (Postfix) with ESMTP id D148A5D9D5 for ; Wed, 5 May 2021 08:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620201777; 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=JsktfPDVPAC5U17PB2+gzq6oyRsOmf6STqP/TuG+SSs=; b=gCeduHyGRTUqthVSRiEAWdMzgCe9jp3tjIt2YRXl3HwC5guNSaC0ifrbyfosbSO1sN/GfV yzYNdeo7ANNO6N7nldJcphY+XG+QwxLRLBLqfF30maUA38BVCMy7vH0yXYBhFzt4Lz51pj NnmqOxb7GKwy44UkB9ZR+1E1BC6zBDA= X-MC-Unique: xPngLNMsMdWVGL9Sp0ulpw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/5] virCapabilitiesHostNUMAInitReal: Bring variables into loop Date: Wed, 5 May 2021 10:02:24 +0200 Message-Id: <66015045325126f2cf9ab7b67c7951e9ab44823a.1620201674.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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" Some variables are needed only inside for() loop. They were declared at the beginning of the function because of VIR_FREE() calls, but since they are auto-freed they can be declared inside the loop. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/capabilities.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index c487229ae8..1dae6d38cc 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1596,22 +1596,22 @@ static int virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *caps) { int n; - unsigned long long memory; virCapsHostNUMACellCPU *cpus =3D NULL; - g_autoptr(virBitmap) cpumap =3D NULL; - g_autofree virCapsHostNUMACellSiblingInfo *siblings =3D NULL; - int nsiblings =3D 0; - g_autofree virCapsHostNUMACellPageInfo *pageinfo =3D NULL; - int npageinfo; int ret =3D -1; int ncpus =3D 0; - int cpu; int max_node; =20 if ((max_node =3D virNumaGetMaxNode()) < 0) goto cleanup; =20 for (n =3D 0; n <=3D max_node; n++) { + g_autoptr(virBitmap) cpumap =3D NULL; + g_autofree virCapsHostNUMACellSiblingInfo *siblings =3D NULL; + int nsiblings =3D 0; + g_autofree virCapsHostNUMACellPageInfo *pageinfo =3D NULL; + int npageinfo; + unsigned long long memory; + int cpu; size_t i; =20 if ((ncpus =3D virNumaGetNodeCPUs(n, &cpumap)) < 0) { @@ -1645,8 +1645,6 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *caps) ncpus, &cpus, nsiblings, &siblings, npageinfo, &pageinfo); - virBitmapFree(cpumap); - cpumap =3D NULL; } =20 ret =3D 0; --=20 2.26.3