From nobody Sun Feb 8 11:25:55 2026 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=1607044010; cv=none; d=zohomail.com; s=zohoarc; b=cXxAqxOJsXRa5BvE+6CDcEtJxt6S6t/+q5uE4dXdx3Rb9PUC1qKwq5lX/sBm53JXP/IBoypX4K4MieHQxtJkur3asI+wWeIuAHI/jE+XyNrFT3UGO9+ROQg4+kWrMhJntQqSaoCfpLxZfelpk2/piNNRslrGMAk57PeJ4fTiFW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607044010; 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=ckkhGY/UUjaHvuUPzvOQ2m2HYozzhAbelqxOEyDrq4o=; b=ag+PxsPiXsAvYWiE1fg9NHSQGKFMDnIKo/8zFoW+iSZCy1tCKy7DoLJVs+o4DJZMcDpUgYQEFoFX68AfOMcfzzbNWnM7wU9mzbPcWT0+CYFylbSnNvQir3EkZSIaNFedZhCsxWOitZzEkgwvZvg3IKR/TLhhhNeNs8WnyQ0GMVs= 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 1607044010210359.3468392240052; Thu, 3 Dec 2020 17:06:50 -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-533-iSaVtqUUPQWn5-RlYvzKjg-1; Thu, 03 Dec 2020 20:06:47 -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 D46D0107ACF6; Fri, 4 Dec 2020 01:06:40 +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 ACA011002393; Fri, 4 Dec 2020 01:06:40 +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 73B5F50030; Fri, 4 Dec 2020 01:06:40 +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 0B415s21026413 for ; Thu, 3 Dec 2020 20:05:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 11E1D2026D3E; Fri, 4 Dec 2020 01:05:54 +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 0D24D202717E for ; Fri, 4 Dec 2020 01:05:54 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 E9AE3185A7BC for ; Fri, 4 Dec 2020 01:05:53 +0000 (UTC) Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-443-HZV_Jnw8OuqkWMccdwIfvg-1; Thu, 03 Dec 2020 20:05:49 -0500 Received: by mail-qt1-f172.google.com with SMTP id a6so478033qtw.6; Thu, 03 Dec 2020 17:05:49 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id z133sm3600542qka.20.2020.12.03.17.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 17:05:48 -0800 (PST) X-MC-Unique: iSaVtqUUPQWn5-RlYvzKjg-1 X-MC-Unique: HZV_Jnw8OuqkWMccdwIfvg-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=ckkhGY/UUjaHvuUPzvOQ2m2HYozzhAbelqxOEyDrq4o=; b=qHmBPicSeMQ9yLWOS2O4aXJevwkfrDale7RtuMShlJnZOphEcF/Xdf0fcooPTGfnFw KRE/Cp16nqSdc6Kqy/beXi7o75b8qj6GkZaVhUrccxMN4G57DGgySeyCcQCqFUqMAe9F PG92mv4iN+buen8TTPUpGJXub/tNdscpS0TC2AQqyFm4GDTm3sWVDKuECjyNyEMMr6WY +ousj2vmD/sDip7PauAC7b1D1P8jcZVVoVylh7IWmiLffelbs4XzvWFHEdWJgnosda1m 5y0XjRZkiU+u2Tgr6cuh8as37drp9nMXincSyKrZZI17ahlr6Yi+p0091rdUmJ224RoI bycA== X-Gm-Message-State: AOAM53032DM2apPPWC6yphwnDSMEm3wTq+2Hun3fUVtAiyzeoDKeBy61 PCzAqE/sgcm6M0+hXjjtKeiMA1XqRkmthg== X-Google-Smtp-Source: ABdhPJw48I2QjvbGc0P/+vXCaZ+yywQ9xpixGj032mClZ0gw3AKIOiaPWdVfZoxVmaI0X6ZljmcrWg== X-Received: by 2002:ac8:c2:: with SMTP id d2mr6353343qtg.207.1607043949031; Thu, 03 Dec 2020 17:05:49 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 3/5] domain_conf.c: revert auto-alignment of pSeries NVDIMM in post parse Date: Thu, 3 Dec 2020 22:05:27 -0300 Message-Id: <20201204010529.325244-4-danielhb413@gmail.com> In-Reply-To: <20201204010529.325244-1-danielhb413@gmail.com> References: <20201204010529.325244-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: Michal Privoznik , 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 code to align ppc64 NVDIMMs on post parse was introduced in commit d3f3c2c97f9b. That commit failed to realize that we can't align memory unconditionally. As of commit c7d7ba85a624 ("qemu: command: Align memory sizes only on fresh starts"), all memory alignment should be executed only when we're not migrating or in a snapshot. This revert does not break any guests in the wild, given that ppc64 NVDIMMs are still being aligned in qemuDomainAlignMemorySizes(). Next patch will introduce a mechanism where we can have post parse NVDIMM alignment for pSeries without breaking the intended design, as defined by c7d7ba85a624. Commit d3f3c2c97f9b was predecessed by a move/rename of the former qemuDomainNVDimmAlignSizePseries() function, commit ace5931553c8. Reverting d3f3c2c97f9b will make the function rename obsolete since all callers will now reside in QEMU drivers files, and it will remain that way in the next patches, so let's revert ace5931553c8 as well. This reverts commit d3f3c2c97f9b92c982ff809479495f44614edb88 (domain_conf.c: auto-align pSeries NVDIMM in virDomainMemoryDefPostParse()). This reverts commit ace5931553c87beebb6b3cd994061742b3f88238 (conf, qemu: move qemuDomainNVDimmAlignSizePseries to domain_conf.c). Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 59 +------------------ src/conf/domain_conf.h | 3 - src/libvirt_private.syms | 1 - src/qemu/qemu_domain.c | 42 ++++++++++++- .../memory-hotplug-nvdimm-ppc64.xml | 2 +- 5 files changed, 42 insertions(+), 65 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 425e3c3710..d069a3ecc2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5359,24 +5359,6 @@ virDomainVsockDefPostParse(virDomainVsockDefPtr vsoc= k) } =20 =20 -static int -virDomainMemoryDefPostParse(virDomainMemoryDefPtr mem, - const virDomainDef *def) -{ - /* Although only the QEMU driver implements PPC64 support, this - * code is related to the platform specification (PAPR), i.e. it - * is hypervisor agnostic, and any future PPC64 hypervisor driver - * will have the same restriction. - */ - if (ARCH_IS_PPC64(def->os.arch) && - mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && - virDomainNVDimmAlignSizePseries(mem) < 0) - return -1; - - return 0; -} - - static int virDomainDeviceDefPostParseCommon(virDomainDeviceDefPtr dev, const virDomainDef *def, @@ -5422,10 +5404,6 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDef= Ptr dev, ret =3D 0; break; =20 - case VIR_DOMAIN_DEVICE_MEMORY: - ret =3D virDomainMemoryDefPostParse(dev->data.memory, def); - break; - case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -5440,6 +5418,7 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefP= tr dev, case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: + case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_IOMMU: case VIR_DOMAIN_DEVICE_AUDIO: ret =3D 0; @@ -16836,42 +16815,6 @@ virDomainSEVDefParseXML(xmlNodePtr sevNode, return NULL; } =20 -int -virDomainNVDimmAlignSizePseries(virDomainMemoryDefPtr mem) -{ - /* 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 - * to the user specified size. - * - * The label-size is mandatory for ppc64 as well, meaning that - * the guest visible space will be target_size-label_size. - * - * Finally, target_size must include label_size. - * - * The above can be summed up as follows: - * - * 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; - - /* Align down guest_area. 256MiB is the minimum size. Error - * out if target_size is smaller than 256MiB + label_size, - * since aligning it up will cause QEMU errors. */ - if (mem->size < (ppc64AlignSize + mem->labelsize)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("minimum target size for the NVDIMM " - "must be 256MB plus the label size")); - return -1; - } - - guestArea =3D (guestArea/ppc64AlignSize) * ppc64AlignSize; - mem->size =3D guestArea + mem->labelsize; - - return 0; -} - static virDomainMemoryDefPtr virDomainMemoryDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr memdevNode, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 34cde22965..b1571d423c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3912,9 +3912,6 @@ bool virDomainBlockIoTuneInfoEqual(const virDomainBlockIoTuneInfo *a, const virDomainBlockIoTuneInfo *b); =20 -int -virDomainNVDimmAlignSizePseries(virDomainMemoryDefPtr mem); - bool virHostdevIsSCSIDevice(const virDomainHostdevDef *hostdev) ATTRIBUTE_NONNULL(1); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2f640ef1c4..5cf39bdf6c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -546,7 +546,6 @@ virDomainNetTypeToString; virDomainNetUpdate; virDomainNostateReasonTypeFromString; virDomainNostateReasonTypeToString; -virDomainNVDimmAlignSizePseries; virDomainObjAssignDef; virDomainObjBroadcast; virDomainObjCheckActive; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 663c0af867..af3c0e269a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8044,6 +8044,44 @@ qemuDomainGetMemoryModuleSizeAlignment(const virDoma= inDef *def, } =20 =20 +static int +qemuDomainNVDimmAlignSizePseries(virDomainDefPtr def, + virDomainMemoryDefPtr mem) +{ + /* 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 + * to the user specified size. + * + * The label-size is mandatory for ppc64 as well, meaning that + * the guest visible space will be target_size-label_size. + * + * Finally, target_size must include label_size. + * + * The above can be summed up as follows: + * + * target_size =3D AlignDown(target_size - label_size) + label_size + */ + unsigned long long ppc64AlignSize =3D qemuDomainGetMemorySizeAlignment= (def); + unsigned long long guestArea =3D mem->size - mem->labelsize; + + /* Align down guest_area. 256MiB is the minimum size. Error + * out if target_size is smaller than 256MiB + label_size, + * since aligning it up will cause QEMU errors. */ + if (mem->size < (ppc64AlignSize + mem->labelsize)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("minimum target size for the NVDIMM " + "must be 256MB plus the label size")); + return -1; + } + + guestArea =3D (guestArea/ppc64AlignSize) * ppc64AlignSize; + mem->size =3D guestArea + mem->labelsize; + + return 0; +} + + int qemuDomainAlignMemorySizes(virDomainDefPtr def) { @@ -8092,7 +8130,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 (qemuDomainNVDimmAlignSizePseries(def, def->mems[i]) < 0) return -1; } else { align =3D qemuDomainGetMemoryModuleSizeAlignment(def, def->mem= s[i]); @@ -8129,7 +8167,7 @@ qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def, { if (mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && ARCH_IS_PPC64(def->os.arch)) { - return virDomainNVDimmAlignSizePseries(mem); + return qemuDomainNVDimmAlignSizePseries(def, mem); } else { mem->size =3D VIR_ROUND_UP(mem->size, qemuDomainGetMemorySizeAlignment(def)); diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml b/tes= ts/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml index 0c0b9f96fb..bf7df9a259 100644 --- a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml +++ b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml @@ -34,7 +34,7 @@ /tmp/nvdimm - 524416 + 550000 0