From nobody Tue May 7 05:56:57 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1605132472; cv=none; d=zohomail.com; s=zohoarc; b=U6cpi+7HhABRi7b+avc2E8ol5A3yrU+BD6MJ1T2kknMEuC54qLXnZUWLuVUHSkzDuFVomkvy4cfPXTk7aBmT+TAZa5yl0Cp2houa4F/9ezGzIRyOAAmXNYYIz53itE/492U6q/IYE2EFdgjAbMQB6W3fHH4a1K6epU6poIm9ewU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605132472; h=Content-Type:Content-Transfer-Encoding:Cc: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=9zAtBFOfc9OzWhjtZtqXIA+0SFmVBaELZluL78y4Z+M=; b=G3ZA49yBIiNs+bZ4GdoDqheRITgWZRmqD8Ql26fRtBMffN00/sKM6KgG9ouCTP/ri+trPzHPt11YVGCY9VREh535mU8fNXrYIaLJfJheXBVgyuxyk3ad/NAaoAH19TfkOzV52GRumPnYxJspTBBTvReV4vX9zM6nG2OemjTKyf4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 1605132472559824.1065179221584; Wed, 11 Nov 2020 14:07:52 -0800 (PST) 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-185-Oupg7MpsOP-6iYmdtOD_eQ-1; Wed, 11 Nov 2020 17:07:48 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8EB5464098; Wed, 11 Nov 2020 22:07:42 +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 6ED5C5B4D0; Wed, 11 Nov 2020 22:07:42 +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 1259744A7E; Wed, 11 Nov 2020 22:07:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ABM7dLZ006066 for ; Wed, 11 Nov 2020 17:07:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 96E18F00EE; Wed, 11 Nov 2020 22:07:39 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 916FFF00EF for ; Wed, 11 Nov 2020 22:07:37 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4AA8585829F for ; Wed, 11 Nov 2020 22:07:37 +0000 (UTC) Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-9-5PEHlsMpayOaI0B4rU1g-1; Wed, 11 Nov 2020 17:07:35 -0500 Received: by mail-qk1-f178.google.com with SMTP id l2so3429315qkf.0 for ; Wed, 11 Nov 2020 14:07:34 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:b9cd:904e:d02:53c4:1c05]) by smtp.gmail.com with ESMTPSA id a200sm3427842qkb.66.2020.11.11.14.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 14:07:33 -0800 (PST) X-MC-Unique: Oupg7MpsOP-6iYmdtOD_eQ-1 X-MC-Unique: 9-5PEHlsMpayOaI0B4rU1g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9zAtBFOfc9OzWhjtZtqXIA+0SFmVBaELZluL78y4Z+M=; b=PGYtZhGzH4cYHZs0r3Azhh2PimdEAeSIDW3++QK1/IJd+1AYTovZ67a+pG/P5TvJTF HWvzzZR/omvL38t3aidSusVNqvM3QYi9276jo8aDM4fm/MafRiO9RwFUOn65TFcs1etv 1BGyHV1A+rKGDqvA68JVWQjlhc8UJj/o8c/e1UnK+xWZqMVeWBH7MMf+EgtA8hisE5IG iQoQdwn/3NYEEmTaaswj3pprDqwSqTh2hPO14Q6emnX0p519+pAlxuqI6UuRmmcWVKh3 lRvTAe8j/PFZo7uDkKRBFQHkrynQocu0rj2sZMGIgU91Vqd+NYT5UtIGjcdkT2fk4Trd 3U2Q== X-Gm-Message-State: AOAM532GcVX/c010vNq8uLs0OW5bnbFdBvlXiFABx4TjVhNpHX1Q0XtF vW7fz73YvaIM9TcYlXvf7Xpl74aT5Nc= X-Google-Smtp-Source: ABdhPJx7SVWhErD8c414gRdXjQYY3XtYMLGAR/zqXYA3lKLN+I8ltygAbetNmILvtrM0mu7XHsNz9A== X-Received: by 2002:a37:9ecc:: with SMTP id h195mr27110747qke.103.1605132454295; Wed, 11 Nov 2020 14:07:34 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v1 01/10] domain_conf.c: handle all ppc64 dimms in virDomainNVDimmAlignSizePseries Date: Wed, 11 Nov 2020 19:07:16 -0300 Message-Id: <20201111220725.356297-2-danielhb413@gmail.com> In-Reply-To: <20201111220725.356297-1-danielhb413@gmail.com> References: <20201111220725.356297-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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.11 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 Content-Type: text/plain; charset="utf-8" This simplifies the handling of ppc64 alignment in other parts of the code, with a single function to handle all cases for the architecture. No functional changes were made just yet. Function was renamed to reflect the broader scope. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 15 +++++++++++---- src/conf/domain_conf.h | 2 +- src/libvirt_private.syms | 2 +- src/qemu/qemu_domain.c | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a3ca332279..c98e760aa2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5361,7 +5361,7 @@ virDomainMemoryDefPostParse(virDomainMemoryDefPtr mem, */ if (ARCH_IS_PPC64(def->os.arch) && mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && - virDomainNVDimmAlignSizePseries(mem) < 0) + virDomainMemoryDeviceAlignSizePseries(mem) < 0) return -1; =20 return 0; @@ -16851,8 +16851,16 @@ virDomainSEVDefParseXML(xmlNodePtr sevNode, } =20 int -virDomainNVDimmAlignSizePseries(virDomainMemoryDefPtr mem) +virDomainMemoryDeviceAlignSizePseries(virDomainMemoryDefPtr mem) { + unsigned long long ppc64AlignSize =3D 256 * 1024; + unsigned long long guestArea; + + if (mem->model !=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM) { + mem->size =3D VIR_ROUND_UP(mem->size, ppc64AlignSize); + return 0; + } + /* For NVDIMMs in ppc64 in we want to align down the guest * visible space, instead of align up, to avoid writing * beyond the end of file by adding a potential 256MiB @@ -16867,8 +16875,7 @@ virDomainNVDimmAlignSizePseries(virDomainMemoryDefP= tr mem) * * target_size =3D AlignDown(target_size - label_size) + label_size */ - unsigned long long ppc64AlignSize =3D 256 * 1024; - unsigned long long guestArea =3D mem->size - mem->labelsize; + guestArea =3D mem->size - mem->labelsize; =20 /* Align down guest_area. 256MiB is the minimum size. Error * out if target_size is smaller than 256MiB + label_size, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 77656c8ae3..fed451c4d5 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3905,7 +3905,7 @@ virDomainBlockIoTuneInfoEqual(const virDomainBlockIoT= uneInfo *a, const virDomainBlockIoTuneInfo *b); =20 int -virDomainNVDimmAlignSizePseries(virDomainMemoryDefPtr mem); +virDomainMemoryDeviceAlignSizePseries(virDomainMemoryDefPtr mem); =20 bool virHostdevIsSCSIDevice(const virDomainHostdevDef *hostdev) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 491bd5bd87..a44d37924a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -546,7 +546,6 @@ virDomainNetTypeToString; virDomainNetUpdate; virDomainNostateReasonTypeFromString; virDomainNostateReasonTypeToString; -virDomainNVDimmAlignSizePseries; virDomainObjAssignDef; virDomainObjBroadcast; virDomainObjCheckActive; @@ -849,6 +848,7 @@ virDomainCachePolicyTypeFromString; virDomainCachePolicyTypeToString; virDomainMemoryAccessTypeFromString; virDomainMemoryAccessTypeToString; +virDomainMemoryDeviceAlignSizePseries; virDomainMemoryLatencyTypeFromString; virDomainMemoryLatencyTypeToString; virDomainNumaCheckABIStability; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 70896ad80e..375a9e5075 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8105,7 +8105,7 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def) for (i =3D 0; i < def->nmems; i++) { if (def->mems[i]->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && ARCH_IS_PPC64(def->os.arch)) { - if (virDomainNVDimmAlignSizePseries(def->mems[i]) < 0) + if (virDomainMemoryDeviceAlignSizePseries(def->mems[i]) < 0) return -1; } else { align =3D qemuDomainGetMemoryModuleSizeAlignment(def, def->mem= s[i]); @@ -8142,7 +8142,7 @@ qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def, { if (mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && ARCH_IS_PPC64(def->os.arch)) { - return virDomainNVDimmAlignSizePseries(mem); + return virDomainMemoryDeviceAlignSizePseries(mem); } else { mem->size =3D VIR_ROUND_UP(mem->size, qemuDomainGetMemorySizeAlignment(def)); --=20 2.26.2 From nobody Tue May 7 05:56:57 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1605132471; cv=none; d=zohomail.com; s=zohoarc; b=cS0v++M1Fumg/glawpTB4aYDqpie6dwoEQts3UIKjSvj8V5e5fzw0X0WPxzheXrkwrpjsrPvfcsb2yyDs/z3/MS7mfY2NKMPxKQqKZTOINasNMoPsjEL3B24Ddml+Rrviej8imgKbr3yoiMiHWkbsqVKCtWO0SU+hcpb7mYmp60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605132471; h=Content-Type:Content-Transfer-Encoding:Cc: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=GbXtOMRAPX3SkRziKrJBZfiX+o/lH+cpgzPDFdyyXcU=; b=ZvtGv9XJFgt6szjI4TEZn1isHRjTyyTDZyZ36XxA9rgLgkljv/2PnDYqraEoVzIpYQALYFEXrUnj1nodOHEHuIZSfFmqW2twSJUUoASQ4Y6DumFFFh26cGvo8B/uxq+HDfuKIJ2KZ5BMvr6/SSY5QBD02E5lPh/n6IiFBZssV9g= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 1605132471759578.4463706477945; Wed, 11 Nov 2020 14:07:51 -0800 (PST) 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-79-Fv1j3ox8OJq1DRulgOHmTQ-1; Wed, 11 Nov 2020 17:07:48 -0500 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 C2DDA6409A; Wed, 11 Nov 2020 22:07:42 +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 A2BC77366A; Wed, 11 Nov 2020 22:07:42 +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 6E99B18199CD; Wed, 11 Nov 2020 22:07:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ABM7dC9006061 for ; Wed, 11 Nov 2020 17:07:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 27FF2115D346; Wed, 11 Nov 2020 22:07:39 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 24157115D342 for ; Wed, 11 Nov 2020 22:07:39 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0C8F0811E76 for ; Wed, 11 Nov 2020 22:07:39 +0000 (UTC) Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-568-3mz6To1uPhmdpeeq3GAqgw-1; Wed, 11 Nov 2020 17:07:36 -0500 Received: by mail-qv1-f43.google.com with SMTP id ed14so1773384qvb.4 for ; Wed, 11 Nov 2020 14:07:36 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:b9cd:904e:d02:53c4:1c05]) by smtp.gmail.com with ESMTPSA id a200sm3427842qkb.66.2020.11.11.14.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 14:07:35 -0800 (PST) X-MC-Unique: Fv1j3ox8OJq1DRulgOHmTQ-1 X-MC-Unique: 3mz6To1uPhmdpeeq3GAqgw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GbXtOMRAPX3SkRziKrJBZfiX+o/lH+cpgzPDFdyyXcU=; b=KhacFiEeKvB7f40HEgB9JEXs75KtfuTPrMm1qXqKMryIP6Z8X9heVqynEGQvV0D8nE 5WfSiECCGszKDFb3tYdOaNErepM8lm7Pr/wy5EpzEhoLkctQPR14DJ3ioyln+cnvFL4w 3gLg3Mw4pWq4gX5+NrTJDkbX10bAiKYbehBvs9YTX+FI1K6bMy/6WeIhQL245Bp5Blo5 MC0wuwUt6akNEylwgp16+4IQ8jMb1XYZPaa3ZnP/LD/tgx4U1FK53nuV+2iJyizS8BjY VTjH8AA7KWBFyNLWQ/9Pn403Nagryb3sYJ807ZJVxbEHf4fN3fZ2b+SNt1abM/d6EeRU y3oA== X-Gm-Message-State: AOAM533zeXneroc6oLzgduhNf4osuMYskJOeOwFgZRn6E9EHxolIDBIp 3te0W7d0epuaMxgIemKBCzoxMP7gxt8= X-Google-Smtp-Source: ABdhPJzVuNPJ/Sa4/278mJSkAZ9x4v64967uAV+5hEf3l1cT2yFCSlNRw1cIVLDXmyKXggxaOcIolA== X-Received: by 2002:ad4:50a2:: with SMTP id d2mr26889151qvq.21.1605132455940; Wed, 11 Nov 2020 14:07:35 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v1 02/10] qemu_domain.c: align memory modules before calculating 'initialmem' Date: Wed, 11 Nov 2020 19:07:17 -0300 Message-Id: <20201111220725.356297-3-danielhb413@gmail.com> In-Reply-To: <20201111220725.356297-1-danielhb413@gmail.com> References: <20201111220725.356297-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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 Content-Type: text/plain; charset="utf-8" qemuDomainAlignMemorySizes() has an operation order problem. We are calculating 'initialmem' without aligning the memory modules first. Since we're aligning the dimms afterwards this can create inconsistencies in the end result. x86 has alignment of 1-2MiB and it's not severely impacted by it, but pSeries works with 256MiB alignment and the difference is noticeable. This is the case of the existing 'memory-hotplug-ppc64-nonuma' test. The test consists of a 2GiB (aligned value) guest with 2 ~520MiB dimms, both unaligned. 'initialmem' is calculated by taking total_mem and subtracting the dimms size (via virDomainDefGetMemoryInitial()), which wil give us 2GiB - 520MiB - 520MiB, ending up with a little more than an 1GiB of 'initialmem'. Note that this value is now unaligned, and will be aligned up via VIR_ROUND_UP(), and we'll end up with 'initialmem' of 1GiB + 256MiB. Given that the dimms are aligned later on, the end result for QEMU is that the guest will have a 'mem' size of 1310720k, plus the two 512 MiB dimms, exceeding in 256MiB the desired 2GiB memory and currentMemory specified in the XML. This behavior was found when trying to push ppc64 memory alignment to postparse, as done in the next patch. In that case, the memory modules are aligned before entering qemuDomainAlignMemorySizes() and the 'memory-hotplug-ppc64-nonuma' test started to fail. Fortunately the fix is simple: align the memory modules before calculating 'initialmem' in qemuDomainAlignMemorySizes(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/qemu/qemu_domain.c | 42 ++++++++++--------- .../memory-hotplug-ppc64-nonuma.args | 2 +- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 375a9e5075..5a17887fa1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8083,25 +8083,9 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def) virDomainNumaSetNodeMemorySize(def->numa, i, mem); } =20 - /* align initial memory size, if NUMA is present calculate it as total= of - * individual aligned NUMA node sizes */ - if (initialmem =3D=3D 0) - initialmem =3D VIR_ROUND_UP(virDomainDefGetMemoryInitial(def), ali= gn); - - if (initialmem > maxmemcapped) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("initial memory size overflowed after alignment")= ); - return -1; - } - - def->mem.max_memory =3D VIR_ROUND_UP(def->mem.max_memory, align); - if (def->mem.max_memory > maxmemkb) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("maximum memory size overflowed after alignment")= ); - return -1; - } - - /* Align memory module sizes */ + /* Align memory module sizes. This needs to occur before 'initialmem' + * calculation because virDomainDefGetMemoryInitial() uses the size + * of the modules in the math. */ for (i =3D 0; i < def->nmems; i++) { if (def->mems[i]->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && ARCH_IS_PPC64(def->os.arch)) { @@ -8122,6 +8106,26 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def) } } =20 + /* Align initial memory size, if NUMA is present calculate it as total= of + * individual aligned NUMA node sizes. */ + if (initialmem =3D=3D 0) { + align =3D qemuDomainGetMemorySizeAlignment(def); + initialmem =3D VIR_ROUND_UP(virDomainDefGetMemoryInitial(def), ali= gn); + } + + if (initialmem > maxmemcapped) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("initial memory size overflowed after alignment")= ); + return -1; + } + + def->mem.max_memory =3D VIR_ROUND_UP(def->mem.max_memory, align); + if (def->mem.max_memory > maxmemkb) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("maximum memory size overflowed after alignment")= ); + return -1; + } + virDomainDefSetMemoryTotal(def, initialmem + hotplugmem); =20 return 0; diff --git a/tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma.args b/test= s/qemuxml2argvdata/memory-hotplug-ppc64-nonuma.args index 91cea9d8bf..78406f7f04 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma.args +++ b/tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma.args @@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=3Dnone \ -name QEMUGuest1 \ -S \ -machine pseries,accel=3Dkvm,usb=3Doff,dump-guest-core=3Doff \ --m size=3D1310720k,slots=3D16,maxmem=3D4194304k \ +-m size=3D1048576k,slots=3D16,maxmem=3D4194304k \ -realtime mlock=3Doff \ -smp 1,sockets=3D1,cores=3D1,threads=3D1 \ -object memory-backend-ram,id=3Dmemdimm0,size=3D536870912 \ --=20 2.26.2 From nobody Tue May 7 05:56:57 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1605132476; cv=none; d=zohomail.com; s=zohoarc; b=fU5Io58UAXyardiq7qyLKsrzxVKxJypZaVznEDL2aBcPrhHTFKlEZp6mS3VawmDwPGxHLaWC8eGGVohoYyXalCEiNPGIafCoDWfblba819/WQxvkX9+1F9Y0Tem6OFF+cW0xEyuauL3mls4nrKRSFXMmYCKWjhl1sVpQtNYvoQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605132476; h=Content-Type:Content-Transfer-Encoding:Cc: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=De0ggMmH2GfugTouea1c6aehegjWRhxF0kwO2BojkAY=; b=KshHPaBHZImkEr7sYwsQwaVaaYpJMn/Fnyx7v8EQk2njHgL/U7UxgnTvsuZrgOJpTdZtZHEpAoWC5pN8k4H6kUM3gsHHOmHSRMMP7aMDcJEhz5T2KNJIpbUTseTVNPtr0m/pAFNGY3j5T+Yb6ZzI19AjBM2FBQOIqDTnDiCneXw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 1605132476948413.27016113025707; Wed, 11 Nov 2020 14:07:56 -0800 (PST) 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-47-vbfoZcKkOOas_X7tA2g63Q-1; Wed, 11 Nov 2020 17:07:52 -0500 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 9DE4B879532; Wed, 11 Nov 2020 22:07:45 +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 7563019C66; Wed, 11 Nov 2020 22:07:45 +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 3FC9B996F; Wed, 11 Nov 2020 22:07:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ABM7eLQ006076 for ; Wed, 11 Nov 2020 17:07:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 637A2115D346; Wed, 11 Nov 2020 22:07:40 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5F549115D342 for ; Wed, 11 Nov 2020 22:07:40 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 48610102F1E2 for ; Wed, 11 Nov 2020 22:07:40 +0000 (UTC) Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-377-wBKkLprPPxug4l5rumWqjA-1; Wed, 11 Nov 2020 17:07:38 -0500 Received: by mail-qt1-f194.google.com with SMTP id g17so2553302qts.5 for ; Wed, 11 Nov 2020 14:07:38 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:b9cd:904e:d02:53c4:1c05]) by smtp.gmail.com with ESMTPSA id a200sm3427842qkb.66.2020.11.11.14.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 14:07:37 -0800 (PST) X-MC-Unique: vbfoZcKkOOas_X7tA2g63Q-1 X-MC-Unique: wBKkLprPPxug4l5rumWqjA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=De0ggMmH2GfugTouea1c6aehegjWRhxF0kwO2BojkAY=; b=dAPxZM0Ed8C8PdTCj6uKAnlMiAetWbAtYFYX7xWrzSZeWv3Lkns/MPkrs4BDF9WYap GXU9nrCxzgJU53m/as+K5vtIqDYGKqbK9DG78IEXOAItHqlhLKJL5kPSauiMMKQyGrRR M/TIetemfVK+Lh0GGyc1dqdM2Nb1CM5tSStsyJXu4oMu0OSPZzNkkXblDV/Wy6U8iyyc Dyk5QEzy317GwflxH2ViailYbXIV4WmCYZJHguspUJLGOVSjyFvkJBP+mL6AJISILIl0 3VWBo/dxthuWLEuzK2LG13tieZnwjFRH6AuoeCY4y/Oa6d5nVTJV6qsZRL5enboRvD+b IB8g== X-Gm-Message-State: AOAM532+MVyMdLJuTBJiyHOIf8/SDEqyD1K2Bp9Als1oHGXsM/CfW5uW ECDKCyisntjPLy7FGehtTRuRYkhld4aCxQ== X-Google-Smtp-Source: ABdhPJzEwRHOZNU663h73W0j1ANC9neJ4SG3BAh8IVN1W1wwlBXrnAgdtFSgkr3NMju605iStw/BSA== X-Received: by 2002:aed:38e4:: with SMTP id k91mr25263135qte.138.1605132457575; Wed, 11 Nov 2020 14:07:37 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v1 03/10] domain_conf.c: align pSeries mem modules in virDomainMemoryDefPostParse() Date: Wed, 11 Nov 2020 19:07:18 -0300 Message-Id: <20201111220725.356297-4-danielhb413@gmail.com> In-Reply-To: <20201111220725.356297-1-danielhb413@gmail.com> References: <20201111220725.356297-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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 Content-Type: text/plain; charset="utf-8" Until now, we were aligning just ppc64 NVDIMM modules in post parse time. Let's extend the treatment to all ppc64 memory models. This is possible because the alignment restrictions for the architecture are imposed by the platform specification, being hypervisor-agnostic. This will remove the need for mem module alignment for pSeries in the QEMU driver, simplifying the code a bit. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 1 - src/qemu/qemu_domain.c | 13 +++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c98e760aa2..e4aecc9a4d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5360,7 +5360,6 @@ virDomainMemoryDefPostParse(virDomainMemoryDefPtr mem, * will have the same restriction. */ if (ARCH_IS_PPC64(def->os.arch) && - mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && virDomainMemoryDeviceAlignSizePseries(mem) < 0) return -1; =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5a17887fa1..33a5765c57 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8087,11 +8087,8 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def) * calculation because virDomainDefGetMemoryInitial() uses the size * of the modules in the math. */ for (i =3D 0; i < def->nmems; i++) { - if (def->mems[i]->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && - ARCH_IS_PPC64(def->os.arch)) { - if (virDomainMemoryDeviceAlignSizePseries(def->mems[i]) < 0) - return -1; - } else { + /* ppc64 memory modules are aligned by virDomainMemoryDefPostParse= (). */ + if (!ARCH_IS_PPC64(def->os.arch)) { align =3D qemuDomainGetMemoryModuleSizeAlignment(def, def->mem= s[i]); def->mems[i]->size =3D VIR_ROUND_UP(def->mems[i]->size, align); } @@ -8144,13 +8141,9 @@ int qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def, virDomainMemoryDefPtr mem) { - if (mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && - ARCH_IS_PPC64(def->os.arch)) { - return virDomainMemoryDeviceAlignSizePseries(mem); - } else { + if (!ARCH_IS_PPC64(def->os.arch)) mem->size =3D VIR_ROUND_UP(mem->size, qemuDomainGetMemorySizeAlignment(def)); - } =20 return 0; } --=20 2.26.2 From nobody Tue May 7 05:56:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1605132602; cv=none; d=zohomail.com; s=zohoarc; b=gBbcOmkUJJO3jeVteUYZv3/aJPXOyDs4A6q6niMaS+GYTEoFPjOBnKw6DemgZ2FJg0JqMI790j0nJI8DGnThzn2R1RQaXByx2GhYt/wrAWtA8d9lLEAzXlnuarLFs05mY9c0HUI8hiJvcbiFwRU/2aMm7YqD6gMQRLAE+8IPT/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605132602; h=Content-Type:Content-Transfer-Encoding:Cc: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=YRp+9ZFE7j+W80UZgxx3EAp/wCQ3WaRve3Zuy1w+glI=; b=Pa6aU/bTaMDzl6ExkXYLHoaPTok8Do85IEr68eG9wUyte598HMfnYzOCOoWZXGe/i5DYcvBUUI7ylzdeiEvJxRsWsB2Nl01/o47/aNFO3Xq6/XbD/MBvraE3uzEXhUGaW7TNPutCyRWpCJfh+xssck1i/KruozcdYOTrWsqiIB8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1605132602020792.5125171898709; Wed, 11 Nov 2020 14:10:02 -0800 (PST) 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-572-52z3KdlrM7mmUZBkYmoIaw-1; Wed, 11 Nov 2020 17:09:58 -0500 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 A8BE8188C131; Wed, 11 Nov 2020 22:09:53 +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 860DF1002C0E; Wed, 11 Nov 2020 22:09:53 +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 5249B58103; Wed, 11 Nov 2020 22:09:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ABM7ioX006102 for ; Wed, 11 Nov 2020 17:07:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 27F11115D348; Wed, 11 Nov 2020 22:07:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 237B1115D342 for ; Wed, 11 Nov 2020 22:07:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0CE06185A7A2 for ; Wed, 11 Nov 2020 22:07:44 +0000 (UTC) Received: from mail-qv1-f65.google.com (mail-qv1-f65.google.com [209.85.219.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-572-Ourp9EyGOZWLikmil9SXIA-1; Wed, 11 Nov 2020 17:07:39 -0500 Received: by mail-qv1-f65.google.com with SMTP id z17so1742559qvy.11 for ; Wed, 11 Nov 2020 14:07:39 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:b9cd:904e:d02:53c4:1c05]) by smtp.gmail.com with ESMTPSA id a200sm3427842qkb.66.2020.11.11.14.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 14:07:38 -0800 (PST) X-MC-Unique: 52z3KdlrM7mmUZBkYmoIaw-1 X-MC-Unique: Ourp9EyGOZWLikmil9SXIA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YRp+9ZFE7j+W80UZgxx3EAp/wCQ3WaRve3Zuy1w+glI=; b=oabIMz4g+gyMGM3UCNPhJYVm5LR/Re/ZJO7Hc2e2RZAKL7bFws1CTCrl+NS62aCp4I d5SrEjf6eknPtrI1ky2QrZ6ytktFBAxGkFFKuqMX13dmY/WJAj52M7ZQFwXPeSuB7Xf6 9TrqpOvCnEvUQjMPwPeZrLoEjCHUP+QPOfEKJ2DaYBPaP14jGlzP4fOKEHzZH0t5kDrz ladhHsrm+9v16m7+NxM3JSl56uipTRilxTLe7VK0hUBjoY0a8epd8asKaQ91RWUk2fV0 WnEKZKfhhHE2VjLMO6uH0TJlNjEKERwvrvORKZtFejXtdRO2w8Z+LZbhwBB8fahU288W 03BA== X-Gm-Message-State: AOAM533Sc5K+jMQg8JvrcPK20IQFcH5hXWm/LXYmxD9P1Kz8ZyNz4Mdz nEoF6CXpyII6trA7EIx5SsvEr5Flqhwy0A== X-Google-Smtp-Source: ABdhPJzCLA5yjHcg69xpBTSjUD71PC80lTReOXX2ZXe7rFoCo9loLSa0sYjBKhcT2GzfEVzDVaXifA== X-Received: by 2002:ad4:56b2:: with SMTP id bd18mr17973584qvb.22.1605132459109; Wed, 11 Nov 2020 14:07:39 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v1 04/10] qemu_domain.c: simplify qemuDomainGetMemoryModuleSizeAlignment() Date: Wed, 11 Nov 2020 19:07:19 -0300 Message-Id: <20201111220725.356297-5-danielhb413@gmail.com> In-Reply-To: <20201111220725.356297-1-danielhb413@gmail.com> References: <20201111220725.356297-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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 Content-Type: text/plain; charset="utf-8" The function is no longer used for ppc64 alignment. This allow us to exclude the 'def' argument and simplify its usage. Let's also make it clearer in the comment that the function is now returning x86 specific values. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/qemu/qemu_domain.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 33a5765c57..e40c122311 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8043,16 +8043,10 @@ qemuDomainGetMemorySizeAlignment(const virDomainDef= *def) =20 =20 static unsigned long long -qemuDomainGetMemoryModuleSizeAlignment(const virDomainDef *def, - const virDomainMemoryDef *mem G_GNU= C_UNUSED) +qemuDomainGetMemoryModuleSizeAlignment(void) { - /* PPC requires the memory sizes to be rounded to 256MiB increments, so - * round them to the size always. */ - if (ARCH_IS_PPC64(def->os.arch)) - return 256 * 1024; - - /* dimm memory modules require 2MiB alignment rather than the 1MiB we = are - * using elsewhere. */ + /* For x86, dimm memory modules require 2MiB alignment rather than + * the 1MiB we are using elsewhere. */ return 2048; } =20 @@ -8089,7 +8083,7 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def) for (i =3D 0; i < def->nmems; i++) { /* ppc64 memory modules are aligned by virDomainMemoryDefPostParse= (). */ if (!ARCH_IS_PPC64(def->os.arch)) { - align =3D qemuDomainGetMemoryModuleSizeAlignment(def, def->mem= s[i]); + align =3D qemuDomainGetMemoryModuleSizeAlignment(); def->mems[i]->size =3D VIR_ROUND_UP(def->mems[i]->size, align); } =20 --=20 2.26.2 From nobody Tue May 7 05:56:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1605132578; cv=none; d=zohomail.com; s=zohoarc; b=jbpx1oyJx7YQgtc75rFgqrr4D/xL4jRUd71OSwI49inCh7mgpr8sAxoXrTs8VU4t13Mb/+oc/5E4gQ2mlBBa20Ysm/OdlCLvNiq5B/HUJo/gdO9BySQeq2alR+5SmKTp7UV6sbYIMq8+urQ2KLPZc6WrWzSEd8aN8Z7KJQkybDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605132578; h=Content-Type:Content-Transfer-Encoding:Cc: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=ukzmyI4mrZjsEjDywtJh9ODro2d5lzhg7Ee67pGLtxA=; b=Lxe0pSgj+ZLT0L90s3zkSs1LC2+9uLMWl4+rv2bCHT+v132wvsL+RVvNPefHaeHkiyLDxa4jpRyi4cO0rIJbk1Qdpa6Xc45bNsypR9vtJeYgtWJdJi0hlcpoWHdlGPffonB4gFyMtsDfUgeUCUZYDvGywiD4zy5anBpCw11CGEo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1605132578049923.0980641770186; Wed, 11 Nov 2020 14:09:38 -0800 (PST) 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-6-46M3t9vBPCex4qHBELEp6w-1; Wed, 11 Nov 2020 17:09:34 -0500 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 C10F38DFB42; Wed, 11 Nov 2020 22:09: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 9D5AE73672; Wed, 11 Nov 2020 22:09: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 640AA5810C; Wed, 11 Nov 2020 22:09:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ABM7kZP006110 for ; Wed, 11 Nov 2020 17:07:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 167FE202278F; Wed, 11 Nov 2020 22:07:46 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F20D2022794 for ; Wed, 11 Nov 2020 22:07:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B159C85829F for ; Wed, 11 Nov 2020 22:07:43 +0000 (UTC) Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-257-0dwGKn_4NSWz2MqU1PW9AA-1; Wed, 11 Nov 2020 17:07:41 -0500 Received: by mail-qk1-f181.google.com with SMTP id r7so3424417qkf.3 for ; Wed, 11 Nov 2020 14:07:41 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:b9cd:904e:d02:53c4:1c05]) by smtp.gmail.com with ESMTPSA id a200sm3427842qkb.66.2020.11.11.14.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 14:07:40 -0800 (PST) X-MC-Unique: 46M3t9vBPCex4qHBELEp6w-1 X-MC-Unique: 0dwGKn_4NSWz2MqU1PW9AA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ukzmyI4mrZjsEjDywtJh9ODro2d5lzhg7Ee67pGLtxA=; b=SYiAKP4mM548pCU1xWV7yzNQJuo+Etp3Luk+62reQR6q/IEUWhYnn72x7cg86e+B6m vYwm9iwSf92dMyfyw21QEAtwvTuj7MNVH90JS+WxySP0UQpUIESIhfLsKjxuT6/Sm0wl FGLBF2Djd9phlC4xUW051yMHSUlfOwnyfGFj1YDuFQUDBcv5KA7PF5vLTaKs2A0le2J/ lm4eUbCF1LR7Wi7IIhkdPHHFJRBSCAqtGOSxmTi/vQMFeuEHYA5OTjue6z7+Bn9yw+xP LEz9xDotWp8bU0bDT46TsSFdeOcHGoPmVFU76NtSIbJOQDGPFsxjavvICEQQnDvhWO9w 5VOg== X-Gm-Message-State: AOAM530/Oa4R1MbZ6cbFwgnFskHHHLhpRvastSUmak8DmudDM1ejPKP2 zybtDxw2vxVlrmAyHYJmStwEpr+dV20zhg== X-Google-Smtp-Source: ABdhPJyjNG1YvQVe44UkcVylJgSCPvYEbtRicwEt7rNhf+X9kQ9xWhmZl51ydk0338I8FpeAu3qovg== X-Received: by 2002:ae9:dcc1:: with SMTP id q184mr28415429qkf.436.1605132460742; Wed, 11 Nov 2020 14:07:40 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v1 05/10] qemu_domain.c: align x86 memory module in post parse time Date: Wed, 11 Nov 2020 19:07:20 -0300 Message-Id: <20201111220725.356297-6-danielhb413@gmail.com> In-Reply-To: <20201111220725.356297-1-danielhb413@gmail.com> References: <20201111220725.356297-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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 Content-Type: text/plain; charset="utf-8" This is already being done for pSeries guests, so let's extend the treatment for x86. The difference here is that the existing x86 alignment in the QEMU driver might be restricted only to QEMU, meaning that we can't put it in virDomainMemoryDefPostParse() without infering that all hypervisors would handle it the same way. Instead, let's create a qemuDomainMemoryDefPostParse() that will be called in qemuDomainDeviceDefPostParse() to do that. After this change, def->nmems will always be aligned after parsing time. qemuDomainAlignMemorySizes() doesn't need to align each memory module before calculating 'hotplugmem'. We'll also generated aligned values in the resulting XML as well. Some xml2xml tests were changed to reflect this new behavior. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/qemu/qemu_domain.c | 45 +++++++++++-------- tests/qemuxml2argvdata/hugepages-nvdimm.xml | 2 +- .../memory-hotplug-nvdimm-access.xml | 2 +- .../memory-hotplug-nvdimm-align.xml | 2 +- .../memory-hotplug-nvdimm-label.xml | 2 +- .../memory-hotplug-nvdimm-pmem.xml | 2 +- .../memory-hotplug-nvdimm-readonly.xml | 2 +- .../memory-hotplug-nvdimm.xml | 2 +- tests/qemuxml2argvdata/pages-dimm-discard.xml | 2 +- .../memory-hotplug-dimm.xml | 4 +- 10 files changed, 36 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e40c122311..c06c33f8d0 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5343,6 +5343,23 @@ qemuDomainTPMDefPostParse(virDomainTPMDefPtr tpm, } =20 =20 +static int +qemuDomainMemoryDefPostParse(virDomainMemoryDefPtr mem, + virArch arch) +{ + /* For x86, dimm memory modules require 2MiB alignment rather than + * the 1MiB we are using elsewhere. */ + unsigned int x86MemoryModuleSizeAlignment =3D 2048; + + /* ppc64 memory module alignment is done in + * virDomainMemoryDefPostParse(). */ + if (!ARCH_IS_PPC64(arch)) + mem->size =3D VIR_ROUND_UP(mem->size, x86MemoryModuleSizeAlignment= ); + + return 0; +} + + static int qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, const virDomainDef *def, @@ -5400,6 +5417,10 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr d= ev, ret =3D qemuDomainTPMDefPostParse(dev->data.tpm, def->os.arch); break; =20 + case VIR_DOMAIN_DEVICE_MEMORY: + ret =3D qemuDomainMemoryDefPostParse(dev->data.memory, def->os.arc= h); + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -5412,7 +5433,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr de= v, case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_RNG: - case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_IOMMU: case VIR_DOMAIN_DEVICE_AUDIO: ret =3D 0; @@ -8042,15 +8062,6 @@ qemuDomainGetMemorySizeAlignment(const virDomainDef = *def) } =20 =20 -static unsigned long long -qemuDomainGetMemoryModuleSizeAlignment(void) -{ - /* For x86, dimm memory modules require 2MiB alignment rather than - * the 1MiB we are using elsewhere. */ - return 2048; -} - - int qemuDomainAlignMemorySizes(virDomainDefPtr def) { @@ -8077,16 +8088,12 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def) virDomainNumaSetNodeMemorySize(def->numa, i, mem); } =20 - /* Align memory module sizes. This needs to occur before 'initialmem' - * calculation because virDomainDefGetMemoryInitial() uses the size - * of the modules in the math. */ + /* Calculate hotplugmem. The memory modules are already aligned at this + * point: + * + * - ppc64 mem modules are being aligned by virDomainMemoryDefPostPars= e(); + * - x86 mem modules are being aligned by qemuDomainMemoryDefPostParse= (). */ for (i =3D 0; i < def->nmems; i++) { - /* ppc64 memory modules are aligned by virDomainMemoryDefPostParse= (). */ - if (!ARCH_IS_PPC64(def->os.arch)) { - align =3D qemuDomainGetMemoryModuleSizeAlignment(); - def->mems[i]->size =3D VIR_ROUND_UP(def->mems[i]->size, align); - } - hotplugmem +=3D def->mems[i]->size; =20 if (def->mems[i]->size > maxmemkb) { diff --git a/tests/qemuxml2argvdata/hugepages-nvdimm.xml b/tests/qemuxml2ar= gvdata/hugepages-nvdimm.xml index 144d02b56e..d356ad12a8 100644 --- a/tests/qemuxml2argvdata/hugepages-nvdimm.xml +++ b/tests/qemuxml2argvdata/hugepages-nvdimm.xml @@ -39,7 +39,7 @@ /tmp/nvdimm - 523264 + 524288 0
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-access.xml b/test= s/qemuxml2argvdata/memory-hotplug-nvdimm-access.xml index a1cc1264eb..4ac5589076 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-access.xml +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-access.xml @@ -48,7 +48,7 @@ /tmp/nvdimm - 523264 + 524288 0
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml b/tests= /qemuxml2argvdata/memory-hotplug-nvdimm-align.xml index 018a693aaf..2436b1a1af 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml @@ -49,7 +49,7 @@ 2048 - 523264 + 524288 0
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-label.xml b/tests= /qemuxml2argvdata/memory-hotplug-nvdimm-label.xml index c9d54a6088..6e8902a25e 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-label.xml +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-label.xml @@ -48,7 +48,7 @@ /tmp/nvdimm - 523264 + 524288 0