From nobody Fri Dec 19 16:08:30 2025 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=1678274235; cv=none; d=zohomail.com; s=zohoarc; b=JFumD36zhGQsMlD9LRu0Q6vG3X/X5G//1CwxAhrmA9zEwSgqnMn0zZlBQheDggQ5ePQkvWxIrcL+d00e7iT9o5A+mIshPVeEO9vwuUN5yfqB98WQoQnencigz1SM4DXMUlMpiWI8m+wpncHcNnC1Bnqgbg0f33hVkhdGQGPoxIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678274235; 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=WuDdiDQESljgfIFK/C1rvAJfGTcgxu4UvJ5nklhn/7E=; b=On1kcCsTiDfJJi/Vk+YJ9QbVSWIIZKlToNNE3nhQg/RYHGNB4pzCqQOBQwEoIGUYnn6TAwhmPVDeuVRuJbYvZAyPy+P4Nk4UXDelWCZMVzWOsl+6p0f773Tbf15YUw2oSupg+ZZjOT7qSdDvUcmQMTobzO6ysTAXQQnIc/O5EkY= 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 1678274235190391.4835355576614; Wed, 8 Mar 2023 03:17:15 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-643-yq4ow3e7MDCSEFzER0C3Fg-1; Wed, 08 Mar 2023 06:16:35 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1F06F8027FD; Wed, 8 Mar 2023 11:16:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B8C6492C3E; Wed, 8 Mar 2023 11:16:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DDF6519465B2; Wed, 8 Mar 2023 11:16:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BCDE819465B1 for ; Wed, 8 Mar 2023 11:14:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A28F21121314; Wed, 8 Mar 2023 11:14:49 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43CB4112132D for ; Wed, 8 Mar 2023 11:14:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678274234; 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=WuDdiDQESljgfIFK/C1rvAJfGTcgxu4UvJ5nklhn/7E=; b=YA46+UNZWu3M1ZEOqoMuh1x5NnaetQc7p5UuqJWKgyz3nta/cEdmayuAML+/uKqPyJJbph Agy7J3WTZZKzAa+jUnTsVQTwcwOCy6cvRJNE3l6LVAwKgRcxiOPKUP1aZGMJoRY3yV3NS8 UJpywdAeYx8O93oGjVYyRQJWwPTJRZ8= X-MC-Unique: yq4ow3e7MDCSEFzER0C3Fg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 10/14] qemu: Add @nodemaskRet argument to qemuBuildMemoryBackendProps() Date: Wed, 8 Mar 2023 12:14:37 +0100 Message-Id: <3a976221b6e60aeb240daa010573ef52e83edd1b.1678274036.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1678274236769100001 Content-Type: text/plain; charset="utf-8"; x-default="true" While it's true that anybody who's interested in getting .host-nodes attribute value can just use virJSONValueObjectGetArray() (and that's exactly what qemuBuildThreadContextProps() is doing, btw), it somebody is interested in getting the actual virBitmap, they would have to parse the JSON array. Instead, introduce an argument to qemuBuildMemoryBackendProps() which is set to corresponding value used when formatting the attribute. Signed-off-by: Michal Privoznik Reviewed-by: Kristina Hanicova --- src/qemu/qemu_command.c | 40 ++++++++++++++++++++++++---------------- src/qemu/qemu_command.h | 4 +++- src/qemu/qemu_hotplug.c | 2 +- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7adcac418f..1b58171287 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3240,6 +3240,7 @@ qemuBuildMemoryGetPagesize(virQEMUDriverConfig *cfg, * @def: domain definition object * @mem: memory definition object * @force: forcibly use one of the backends + * @nodemaskRet: [out] bitmap used to format .host-nodes attribute * * Creates a configuration object that represents memory backend of given = guest * NUMA node (domain @def and @mem). Use @priv->autoNodeset to fine tune t= he @@ -3264,7 +3265,8 @@ qemuBuildMemoryBackendProps(virJSONValue **backendPro= ps, const virDomainDef *def, const virDomainMemoryDef *mem, bool force, - bool systemMemory) + bool systemMemory, + virBitmap **nodemaskRet) { const char *backendType =3D "memory-backend-file"; virDomainNumatuneMemMode mode; @@ -3437,19 +3439,24 @@ qemuBuildMemoryBackendProps(virJSONValue **backendP= rops, return -1; } =20 - /* Make sure the requested nodeset is sensible */ - if (nodemask && !virNumaNodesetIsAvailable(nodemask)) - return -1; - - /* If mode is "restrictive", we should only use cgroups setting allowe= d memory - * nodes, and skip passing the host-nodes and policy parameters to QEM= U command - * line which means we will use system default memory policy. */ - if (nodemask && mode !=3D VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) { - if (virJSONValueObjectAdd(&props, - "m:host-nodes", nodemask, - "S:policy", qemuNumaPolicyTypeToString(m= ode), - NULL) < 0) + if (nodemask) { + /* Make sure the requested nodeset is sensible */ + if (!virNumaNodesetIsAvailable(nodemask)) return -1; + + /* If mode is "restrictive", we should only use cgroups setting al= lowed memory + * nodes, and skip passing the host-nodes and policy parameters to= QEMU command + * line which means we will use system default memory policy. */ + if (mode !=3D VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) { + if (virJSONValueObjectAdd(&props, + "m:host-nodes", nodemask, + "S:policy", qemuNumaPolicyTypeToStri= ng(mode), + NULL) < 0) + return -1; + + if (nodemaskRet) + *nodemaskRet =3D nodemask; + } } =20 /* If none of the following is requested... */ @@ -3502,7 +3509,8 @@ qemuBuildMemoryCellBackendProps(virDomainDef *def, mem.targetNode =3D cell; mem.info.alias =3D alias; =20 - return qemuBuildMemoryBackendProps(props, alias, cfg, priv, def, &mem,= false, false); + return qemuBuildMemoryBackendProps(props, alias, cfg, priv, + def, &mem, false, false, NULL); } =20 =20 @@ -3526,7 +3534,7 @@ qemuBuildMemoryDimmBackendStr(virCommand *cmd, alias =3D g_strdup_printf("mem%s", mem->info.alias); =20 if (qemuBuildMemoryBackendProps(&props, alias, cfg, - priv, def, mem, true, false) < 0) + priv, def, mem, true, false, NULL) < 0) return -1; =20 if (qemuBuildThreadContextProps(&tcProps, &props, priv) < 0) @@ -7150,7 +7158,7 @@ qemuBuildMemCommandLineMemoryDefaultBackend(virComman= d *cmd, mem.info.alias =3D (char *) defaultRAMid; =20 if (qemuBuildMemoryBackendProps(&props, defaultRAMid, cfg, - priv, def, &mem, false, true) < 0) + priv, def, &mem, false, true, NULL) < = 0) return -1; =20 if (qemuBuildThreadContextProps(&tcProps, &props, priv) < 0) diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index c49096a057..9074822bc5 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -22,6 +22,7 @@ #pragma once =20 #include "domain_conf.h" +#include "virbitmap.h" #include "vircommand.h" #include "virenum.h" #include "qemu_block.h" @@ -140,7 +141,8 @@ int qemuBuildMemoryBackendProps(virJSONValue **backendP= rops, const virDomainDef *def, const virDomainMemoryDef *mem, bool force, - bool systemMemory); + bool systemMemory, + virBitmap **nodemaskRet); =20 virJSONValue * qemuBuildMemoryDeviceProps(virQEMUDriverConfig *cfg, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index da17525824..b9f6a031de 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2280,7 +2280,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver, goto cleanup; =20 if (qemuBuildMemoryBackendProps(&props, objalias, cfg, - priv, vm->def, mem, true, false) < 0) + priv, vm->def, mem, true, false, NULL)= < 0) goto cleanup; =20 if (qemuProcessBuildDestroyMemoryPaths(driver, vm, mem, true) < 0) --=20 2.39.2