From nobody Sun Feb 8 05:40:58 2026 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=1607043969; cv=none; d=zohomail.com; s=zohoarc; b=Tl3A0CfcxI2dOAVW00K8uXa2iz35ANvGX+asB0vTmQLRrmHiFoEipUY2l2lRGcF3sFCZPE+ARL2g9DBiZYD38pJKId6gv6XSD2eVe/G0hcplW+UeOSgUxllExAKs/3ACcouBDokS0kC6qGxFDBTQmPcZcryXLu+fP8J5X+vfNgY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607043969; 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=znvuEmrkA1wUlaHCOYwxAUo4dNkWPzXNtUkxT1w+xIQ=; b=G4X36RtkRk1GUPLiCsNs/zIWzWbYZGgSv5oUHzvpKktVevFYr6O3R15CYa4ro7POd/OoM8IXkDFaJqeHChg8QaCax1HZmHPymdPnMqRgM5skt/gmA/ajgiyDO5ALoes/wkZ+x5ajDyf2EqrHNx3Jquk6qWTWtPk1XPbCisHOxzA= 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 1607043969072633.3229192675267; Thu, 3 Dec 2020 17:06:09 -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-212-Zk3ygbg1N_GVNeNhccYbuw-1; Thu, 03 Dec 2020 20:06:05 -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 BCFAE858180; Fri, 4 Dec 2020 01:05:59 +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 89DD460854; Fri, 4 Dec 2020 01:05:59 +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 F1AC35002C; Fri, 4 Dec 2020 01:05:58 +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 0B415s6J026412 for ; Thu, 3 Dec 2020 20:05:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0543D2027144; Fri, 4 Dec 2020 01:05:54 +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 001412026D3E for ; Fri, 4 Dec 2020 01:05:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 DBB1E811E78 for ; Fri, 4 Dec 2020 01:05:53 +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-464-EA7RmJNCPVuHbsdYs8KchQ-1; Thu, 03 Dec 2020 20:05:51 -0500 Received: by mail-qk1-f181.google.com with SMTP id 1so4130411qka.0; Thu, 03 Dec 2020 17:05:51 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 17:05:50 -0800 (PST) X-MC-Unique: Zk3ygbg1N_GVNeNhccYbuw-1 X-MC-Unique: EA7RmJNCPVuHbsdYs8KchQ-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=znvuEmrkA1wUlaHCOYwxAUo4dNkWPzXNtUkxT1w+xIQ=; b=nmcANMzpwZwZ4TUl6dCNEOlMQ+CYJxY0HyobzRP8EWd9cTveDuxjYhh7SvM9HXiDlr o3FxMZtaUY6JqeCFhCpTx781gP0smdTNyE7pOPDYwnZHaUgR2MoxWwhGxInxi7PVSpc3 Ox44zyDIhcBsK4qstl0M0yclOVO2dOtmDUndJuwSv8eXJ1wPux2xH+zC+TgW4UcJV7lt TcKKF+YC5HNItHcPvJPvgc69IY3wVEQy+CZ3kuR2d2XyHtVogoFrptfSVfB8LeGxCvte uw37kVosIMGXSEt1QPvqQYAkqn24tj9TecBJ706EMEg3Q/imC9fcxYvkgf3caS82lXtD rYQw== X-Gm-Message-State: AOAM530PElCpx+k2PH39ek7g9hxIoe6oX0SfGpPb+0L8YmXk8p/8A6hZ Kla8ZKMvMWF8ni5agQcRS/d36DRvYj6dQw== X-Google-Smtp-Source: ABdhPJwGJDR9x6jBO2ZLzSdJ7c0BfOyMHbA2cLwXCoL5iSUBYEobhDfSpyTkYBbO9cqdNq0wxEAdpQ== X-Received: by 2002:a37:6f07:: with SMTP id k7mr6068708qkc.476.1607043950905; Thu, 03 Dec 2020 17:05:50 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 4/5] qemu_domain.c: post parse pSeries NVDIMM align with PARSE_ABI_UPDATE Date: Thu, 3 Dec 2020 22:05:28 -0300 Message-Id: <20201204010529.325244-5-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.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" A previous patch removed the pSeries NVDIMM align that wasn't being done properly. This patch reintroduces it in the right fashion, making it reliant on VIR_DOMAIN_DEF_PARSE_ABI_UPDATE. This makes it complying with the intended design defined by commit c7d7ba85a624. Since the PARSE_ABI_UPDATE_FLAG is more restrictive than checking for !migrate && !snapshot, like is being currently done with qemuDomainAlignMemorySizes(), this means that we'll align the pSeries NVDIMMs in two places - in post parse time for new guests, and in qemuDomainAlignMemorySizes() for all guests that aren't migrating or in a snapshot. Another difference is that the logic is now in the QEMU driver instead of domain_conf.c. This was necessary because all considerations made about the PARSE_ABI_UPDATE flag were done under QEMU. Given that no other driver supports ppc64 there is no impact in this change. A new test was added to exercise what we're doing. It consists of a a copy of the existing 'memory-hotplug-nvdimm-ppc64' xml2xml test, called with the PARSE_ABI_UPDATE flag. As intended, we're not changing QEMU command line or any XML without the flag, while the pseries NVDIMM memory is being aligned when the flag is used. qemuDomainNVDimmAlignSizePseries() was moved up to be used by qemuDomainMemoryDefPostParse(). The alignment for pSeries is always 256 * 1024 KiB, making a call to qemuDomainGetMemorySizeAlignment() and the need for the 'def' arg obsolete as well. Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_domain.c | 112 +++++++++++------- ...emory-hotplug-nvdimm-ppc64-abi-update.args | 30 +++++ ...memory-hotplug-nvdimm-ppc64-abi-update.xml | 1 + tests/qemuxml2argvtest.c | 7 ++ ...memory-hotplug-nvdimm-ppc64-abi-update.xml | 46 +++++++ tests/qemuxml2xmltest.c | 7 ++ 6 files changed, 162 insertions(+), 41 deletions(-) create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64-abi-= update.args create mode 120000 tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64-abi-= update.xml create mode 100644 tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64-ab= i-update.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index af3c0e269a..5fff7d312d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5341,6 +5341,70 @@ qemuDomainTPMDefPostParse(virDomainTPMDefPtr tpm, } =20 =20 +static int +qemuDomainNVDimmAlignSizePseries(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_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; +} + + +static int +qemuDomainMemoryDefPostParse(virDomainMemoryDefPtr mem, virArch arch, + unsigned int parseFlags) +{ + /* Memory alignment can't be done for migration or snapshot + * scenarios. This logic was defined by commit c7d7ba85a624. + * + * There is no easy way to replicate at this point the same conditions + * used to call qemuDomainAlignMemorySizes(), which means checking if + * we're not migrating and not in a snapshot. + * + * We can use the PARSE_ABI_UPDATE flag, which is more strict - + * existing guests will not activate the flag to avoid breaking + * boot ABI. This means that any alignment done here will be replicated + * later on by qemuDomainAlignMemorySizes() to contemplate existing + * guests as well. */ + if (parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE) { + if (ARCH_IS_PPC64(arch) && + mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && + qemuDomainNVDimmAlignSizePseries(mem) < 0) + return -1; + } + + return 0; +} + + static int qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, const virDomainDef *def, @@ -5398,6 +5462,11 @@ 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, + parseFlags); + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -5410,7 +5479,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; @@ -8044,44 +8112,6 @@ 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) { @@ -8130,7 +8160,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 (qemuDomainNVDimmAlignSizePseries(def, def->mems[i]) < 0) + if (qemuDomainNVDimmAlignSizePseries(def->mems[i]) < 0) return -1; } else { align =3D qemuDomainGetMemoryModuleSizeAlignment(def, def->mem= s[i]); @@ -8167,7 +8197,7 @@ qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def, { if (mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && ARCH_IS_PPC64(def->os.arch)) { - return qemuDomainNVDimmAlignSizePseries(def, mem); + return qemuDomainNVDimmAlignSizePseries(mem); } else { mem->size =3D VIR_ROUND_UP(mem->size, qemuDomainGetMemorySizeAlignment(def)); diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64-abi-update.= args b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64-abi-update.args new file mode 100644 index 0000000000..f50444e47e --- /dev/null +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64-abi-update.args @@ -0,0 +1,30 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-ppc64 \ +-name QEMUGuest1 \ +-S \ +-machine pseries,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff,nvdimm=3Don \ +-m size=3D1048576k,slots=3D16,maxmem=3D1099511627776k \ +-realtime mlock=3Doff \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-numa node,nodeid=3D0,cpus=3D0-1,mem=3D1024 \ +-object memory-backend-file,id=3Dmemnvdimm0,mem-path=3D/tmp/nvdimm,preallo= c=3Dyes,\ +size=3D537001984 \ +-device nvdimm,node=3D0,label-size=3D131072,\ +uuid=3D49545eb3-75e1-2d0a-acdd-f0294406c99e,memdev=3Dmemnvdimm0,id=3Dnvdim= m0,slot=3D0 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64-abi-update.= xml b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64-abi-update.xml new file mode 120000 index 0000000000..c7d71906f6 --- /dev/null +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64-abi-update.xml @@ -0,0 +1 @@ +memory-hotplug-nvdimm-ppc64.xml \ No newline at end of file diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 8c8426e699..a9bd210ca3 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3014,6 +3014,13 @@ mymain(void) DO_TEST("memory-hotplug-nvdimm-ppc64", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST= _BRIDGE, QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_DEVICE_NVDIMM); + DO_TEST_FULL("memory-hotplug-nvdimm-ppc64-abi-update", + ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, + ARG_QEMU_CAPS, + QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, + QEMU_CAPS_OBJECT_MEMORY_FILE, + QEMU_CAPS_DEVICE_NVDIMM, + QEMU_CAPS_LAST); =20 DO_TEST("machine-aeskeywrap-on-caps", QEMU_CAPS_AES_KEY_WRAP, diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64-abi-updat= e.xml b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64-abi-update.xml new file mode 100644 index 0000000000..3999b1a99f --- /dev/null +++ b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64-abi-update.xml @@ -0,0 +1,46 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1099511627776 + 1572992 + 1267710 + 2 + + hvm + + + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-ppc64 + + + + + + + + + 49545eb3-75e1-2d0a-acdd-f0294406c99e + + /tmp/nvdimm + + + 524416 + 0 + + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 83e5dd0cbe..18faea2b33 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1244,6 +1244,13 @@ mymain(void) DO_TEST("memory-hotplug-nvdimm-ppc64", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST= _BRIDGE, QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_DEVICE_NVDIMM); + DO_TEST_FULL("memory-hotplug-nvdimm-ppc64-abi-update", WHEN_BOTH, + ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, + ARG_QEMU_CAPS, + QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, + QEMU_CAPS_OBJECT_MEMORY_FILE, + QEMU_CAPS_DEVICE_NVDIMM, + QEMU_CAPS_LAST); =20 DO_TEST("net-udp", NONE); =20 --=20 2.26.2