From nobody Mon Feb 9 00:56:22 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=1629383529; cv=none; d=zohomail.com; s=zohoarc; b=kI/nVbRIukFI78orzJlGp4VkR2YqvB9tyBJexpW7+EwcVMh1W+/uHB1ijBIzenbWXdcUJMsH/4HCIqLr/zvH4bWXSEqB8IQI9rLulXjPAthgNDvqhKu/DR7Mq9RzylkShDPJUXtkGi6KM+YLi05vTSV4sC1tRuSNWSXb6BTHHeA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629383529; 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=TsJhxNXq/wH+/9r7htC0NKHTgubimUAZPvbdP8OtRkk=; b=QTPN5euoiSN+ykfYW3PJALLV9Bq/WdG5G4fAyuiXOnh1VpHJ+CMNahd+CIb35jzSGTIUpATeW5EZCy7ZjByYRxdY57bnI8RvvaQwktmsETGcHv1vnLGK2UF0y9xKTckrWdM/oLnnO/vmTKPEr7ydD4KlGEwxXRtnz8J6WLctoYg= 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 1629383529891188.2058497933558; Thu, 19 Aug 2021 07:32:09 -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-288-4rh4b7eaM0KL21QoUjKI0Q-1; Thu, 19 Aug 2021 10:32:07 -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 EE056EC1A4; Thu, 19 Aug 2021 14:32:01 +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 C12CD6A8FD; Thu, 19 Aug 2021 14:32:01 +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 75708181A2A7; Thu, 19 Aug 2021 14:32:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17JERDr0016910 for ; Thu, 19 Aug 2021 10:27:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6C1455C1D1; Thu, 19 Aug 2021 14:27:13 +0000 (UTC) Received: from bart.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA8795C1BB for ; Thu, 19 Aug 2021 14:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629383528; 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=TsJhxNXq/wH+/9r7htC0NKHTgubimUAZPvbdP8OtRkk=; b=hjqC8H41tG2kAlrNsa97lr0U+v8FOsjExYSdCJwSXfRL6VMJg7nnfdZEqoTYIJK8bGyV68 MNOpyPMSo4AH2zgAg++803AwJUalGuqfBFdkIJZ0zM9cbGDfM6KBs+TC74EAmP9gvd2V4y XtShleGtQXhsAwxaKKbPafd/AvflPV4= X-MC-Unique: 4rh4b7eaM0KL21QoUjKI0Q-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/5] virhostmem: Let caller pass max NUMA node to virHostMemAllocPages Date: Thu, 19 Aug 2021 16:27:03 +0200 Message-Id: <1b4e3d4d261167e4bc1a8ff1ef85a5137d69241f.1629383171.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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) X-ZM-MESSAGEID: 1629383532351100001 Content-Type: text/plain; charset="utf-8" In all three cases (LXC, QEMU and VBox drivers) the caller has access to host capabilities and thus know the maximum NUMA node. This means, that virHostMemAllocPages() doesn't have to query it. Querying may fail if libvirt was compiled without numactl support. Signed-off-by: Michal Privoznik --- src/lxc/lxc_driver.c | 11 ++++++++++- src/qemu/qemu_driver.c | 11 ++++++++++- src/util/virhostmem.c | 6 ++---- src/util/virhostmem.h | 1 + src/vbox/vbox_common.c | 8 +++++++- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index f720cf968d..e2720a6f89 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -5041,6 +5041,9 @@ lxcNodeAllocPages(virConnectPtr conn, unsigned int cellCount, unsigned int flags) { + virLXCDriver *driver =3D conn->privateData; + g_autoptr(virCaps) caps =3D NULL; + int lastCell; bool add =3D !(flags & VIR_NODE_ALLOC_PAGES_SET); =20 virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1); @@ -5048,8 +5051,14 @@ lxcNodeAllocPages(virConnectPtr conn, if (virNodeAllocPagesEnsureACL(conn) < 0) return -1; =20 + if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) + return -1; + + lastCell =3D virCapabilitiesHostNUMAGetMaxNode(caps->host.numa); + return virHostMemAllocPages(npages, pageSizes, pageCounts, - startCell, cellCount, add); + startCell, cellCount, + lastCell, add); } =20 =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6a065a9c06..444e9e5cbc 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18802,6 +18802,9 @@ qemuNodeAllocPages(virConnectPtr conn, unsigned int cellCount, unsigned int flags) { + virQEMUDriver *driver =3D conn->privateData; + g_autoptr(virCaps) caps =3D NULL; + int lastCell; bool add =3D !(flags & VIR_NODE_ALLOC_PAGES_SET); =20 virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1); @@ -18809,8 +18812,14 @@ qemuNodeAllocPages(virConnectPtr conn, if (virNodeAllocPagesEnsureACL(conn) < 0) return -1; =20 + if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) + return -1; + + lastCell =3D virCapabilitiesHostNUMAGetMaxNode(caps->host.numa); + return virHostMemAllocPages(npages, pageSizes, pageCounts, - startCell, cellCount, add); + startCell, cellCount, + lastCell, add); } =20 static int diff --git a/src/util/virhostmem.c b/src/util/virhostmem.c index 43dd775fd3..8734dafb72 100644 --- a/src/util/virhostmem.c +++ b/src/util/virhostmem.c @@ -885,14 +885,12 @@ virHostMemAllocPages(unsigned int npages, unsigned long long *pageCounts, int startCell, unsigned int cellCount, + int lastCell, bool add) { - int cell, lastCell; + int cell; size_t i, ncounts =3D 0; =20 - if ((lastCell =3D virNumaGetMaxNode()) < 0) - return 0; - if (startCell > lastCell) { virReportError(VIR_ERR_INTERNAL_ERROR, _("start cell %d out of range (0-%d)"), diff --git a/src/util/virhostmem.h b/src/util/virhostmem.h index ecfdd71618..3265215d84 100644 --- a/src/util/virhostmem.h +++ b/src/util/virhostmem.h @@ -53,4 +53,5 @@ int virHostMemAllocPages(unsigned int npages, unsigned long long *pageCounts, int startCell, unsigned int cellCount, + int lastCell, bool add); diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 89f74b86d6..7334254a36 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -7628,12 +7628,18 @@ vboxNodeAllocPages(virConnectPtr conn G_GNUC_UNUSED, unsigned int cellCount, unsigned int flags) { + struct _vboxDriver *driver =3D conn->privateData; + int lastCell; bool add =3D !(flags & VIR_NODE_ALLOC_PAGES_SET); =20 virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1); =20 + virObjectLock(driver); + lastCell =3D virCapabilitiesHostNUMAGetMaxNode(driver->caps->host.numa= ); + virObjectUnlock(driver); + return virHostMemAllocPages(npages, pageSizes, pageCounts, - startCell, cellCount, add); + startCell, cellCount, lastCell, add); } =20 static int --=20 2.31.1