From nobody Sun Feb 8 21:32:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1489075800383648.9956177077697; Thu, 9 Mar 2017 08:10:00 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v29G6qIf051467; Thu, 9 Mar 2017 11:06:52 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v29G6Xc0032386 for ; Thu, 9 Mar 2017 11:06:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8D03C2D655; Thu, 9 Mar 2017 16:06:33 +0000 (UTC) Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1405B2D653 for ; Thu, 9 Mar 2017 16:06:32 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 9 Mar 2017 17:06:12 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 03/17] qemuBuildMemoryBackendStr: Pass virDomainMemoryDefPtr 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik --- src/qemu/qemu_command.c | 49 ++++++++++++++++++++++-----------------------= ---- src/qemu/qemu_command.h | 5 +---- src/qemu/qemu_hotplug.c | 6 ++---- 3 files changed, 25 insertions(+), 35 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 62d3a0a4e..cbe3e3492 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3078,11 +3078,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd, =20 /** * qemuBuildMemoryBackendStr: - * @size: size of the memory device in kibibytes - * @pagesize: size of the requested memory page in KiB, 0 for default - * @guestNode: NUMA node in the guest that the memory object will be attac= hed - * to, or -1 if NUMA is not used in the guest - * @hostNodes: map of host nodes to alloc the memory in, NULL for default + * @mem: memory definition object * @autoNodeset: fallback nodeset in case of automatic numa placement * @def: domain definition object * @qemuCaps: qemu capabilities object @@ -3100,10 +3096,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd, * -1 in case of an error. */ int -qemuBuildMemoryBackendStr(unsigned long long size, - unsigned long long pagesize, - int guestNode, - virBitmapPtr userNodeset, +qemuBuildMemoryBackendStr(virDomainMemoryDefPtr mem, virBitmapPtr autoNodeset, virDomainDefPtr def, virQEMUCapsPtr qemuCaps, @@ -3122,26 +3115,27 @@ qemuBuildMemoryBackendStr(unsigned long long size, virBitmapPtr nodemask =3D NULL; int ret =3D -1; virJSONValuePtr props =3D NULL; - bool nodeSpecified =3D virDomainNumatuneNodeSpecified(def->numa, guest= Node); + bool nodeSpecified =3D virDomainNumatuneNodeSpecified(def->numa, mem->= targetNode); + unsigned long long pagesize =3D mem->pagesize; bool needHugepage =3D !!pagesize; =20 *backendProps =3D NULL; *backendType =3D NULL; =20 - if (guestNode >=3D 0) { + if (mem->targetNode >=3D 0) { /* memory devices could provide a invalid guest node */ - if (guestNode >=3D virDomainNumaGetNodeCount(def->numa)) { + if (mem->targetNode >=3D virDomainNumaGetNodeCount(def->numa)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("can't add memory backend for guest node '%d'= as " "the guest has only '%zu' NUMA nodes configur= ed"), - guestNode, virDomainNumaGetNodeCount(def->numa)= ); + mem->targetNode, virDomainNumaGetNodeCount(def-= >numa)); return -1; } =20 - memAccess =3D virDomainNumaGetNodeMemoryAccessMode(def->numa, gues= tNode); + memAccess =3D virDomainNumaGetNodeMemoryAccessMode(def->numa, mem-= >targetNode); } =20 - if (virDomainNumatuneGetMode(def->numa, guestNode, &mode) < 0 && + if (virDomainNumatuneGetMode(def->numa, mem->targetNode, &mode) < 0 && virDomainNumatuneGetMode(def->numa, -1, &mode) < 0) mode =3D VIR_DOMAIN_NUMATUNE_MEM_STRICT; =20 @@ -3158,10 +3152,10 @@ qemuBuildMemoryBackendStr(unsigned long long size, } =20 /* just find the master hugepage in case we don't use NUMA */ - if (guestNode < 0) + if (mem->targetNode < 0) continue; =20 - if (virBitmapGetBit(hugepage->nodemask, guestNode, + if (virBitmapGetBit(hugepage->nodemask, mem->targetNode, &thisHugepage) < 0) { /* Ignore this error. It's not an error after all. Well, * the nodemask for this can contain lower NUMA @@ -3250,14 +3244,14 @@ qemuBuildMemoryBackendStr(unsigned long long size, *backendType =3D "memory-backend-ram"; } =20 - if (virJSONValueObjectAdd(props, "U:size", size * 1024, NULL) < 0) + if (virJSONValueObjectAdd(props, "U:size", mem->size * 1024, NULL) < 0) goto cleanup; =20 - if (userNodeset) { - nodemask =3D userNodeset; + if (mem->sourceNodes) { + nodemask =3D mem->sourceNodes; } else { if (virDomainNumatuneMaybeGetNodeset(def->numa, autoNodeset, - &nodemask, guestNode) < 0) + &nodemask, mem->targetNode) <= 0) goto cleanup; } =20 @@ -3272,7 +3266,7 @@ qemuBuildMemoryBackendStr(unsigned long long size, } =20 /* If none of the following is requested... */ - if (!needHugepage && !userNodeset && !nodeSpecified && + if (!needHugepage && !mem->sourceNodes && !nodeSpecified && memAccess =3D=3D VIR_DOMAIN_MEMORY_ACCESS_DEFAULT && def->mem.source !=3D VIR_DOMAIN_MEMORY_SOURCE_FILE && !force) { /* report back that using the new backend is not necessary @@ -3321,17 +3315,19 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def, const char *backendType; int ret =3D -1; int rc; + virDomainMemoryDef mem =3D { 0 }; unsigned long long memsize =3D virDomainNumaGetNodeMemorySize(def->num= a, cell); =20 *backendStr =3D NULL; + mem.size =3D memsize; + mem.targetNode =3D cell; =20 if (virAsprintf(&alias, "ram-node%zu", cell) < 0) goto cleanup; =20 - if ((rc =3D qemuBuildMemoryBackendStr(memsize, 0, cell, NULL, auto_nod= eset, - def, qemuCaps, cfg, &backendType, - &props, false)) < 0) + if ((rc =3D qemuBuildMemoryBackendStr(&mem, auto_nodeset, def, qemuCap= s, + cfg, &backendType, &props, false))= < 0) goto cleanup; =20 if (!(*backendStr =3D virQEMUBuildObjectCommandlineFromJSON(backendTyp= e, @@ -3370,8 +3366,7 @@ qemuBuildMemoryDimmBackendStr(virDomainMemoryDefPtr m= em, if (virAsprintf(&alias, "mem%s", mem->info.alias) < 0) goto cleanup; =20 - if (qemuBuildMemoryBackendStr(mem->size, mem->pagesize, - mem->targetNode, mem->sourceNodes, auto_= nodeset, + if (qemuBuildMemoryBackendStr(mem, auto_nodeset, def, qemuCaps, cfg, &backendType, &props, true) < 0) goto cleanup; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 69fe84613..9b2b81f55 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -124,10 +124,7 @@ char *qemuBuildControllerDevStr(const virDomainDef *do= mainDef, virQEMUCapsPtr qemuCaps, int *nusbcontroller); =20 -int qemuBuildMemoryBackendStr(unsigned long long size, - unsigned long long pagesize, - int guestNode, - virBitmapPtr userNodeset, +int qemuBuildMemoryBackendStr(virDomainMemoryDefPtr mem, virBitmapPtr autoNodeset, virDomainDefPtr def, virQEMUCapsPtr qemuCaps, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 0e4af830f..39710db19 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2240,10 +2240,8 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, if (!(devstr =3D qemuBuildMemoryDeviceStr(mem))) goto cleanup; =20 - if (qemuBuildMemoryBackendStr(mem->size, mem->pagesize, - mem->targetNode, mem->sourceNodes, NULL, - vm->def, priv->qemuCaps, cfg, - &backendType, &props, true) < 0) + if (qemuBuildMemoryBackendStr(mem, NULL, vm->def, priv->qemuCaps, + cfg, &backendType, &props, true) < 0) goto cleanup; =20 if (virDomainMemoryInsert(vm->def, mem) < 0) { --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list