From nobody Sat Feb 7 12:11:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1600137811; cv=none; d=zohomail.com; s=zohoarc; b=eqj6XuDYwJ4bJfAUCddhVDF0m+W9IcKpxFVk0UqBgI0kuXkU/nB+1jzRn1Lt3sbVk3etLPutVdtDZLJ1+tpvw0sUlxjpdpoJHaIouMall0LVJWlqGWZEhDh7Twk9CxRBA/yXnTR3IL10vxDTdhlInpWWuAiRL78Ih30yMtSkSyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600137811; 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=bYElcI9krxzzYpc61Ln0n7oGFxVazMXC8IIQcgjmUB4=; b=hXGLcj2oInpyker8ueZHTpSYKiC1aNraRvcw+sU8a36CKCp1aqngiAKzsQuoTuyZE9nedvKfQzEGoNFClSNciRTWPNwbxHx1jkztSI3lw5BKmRXbjwhoUlTxCAfMDT3MVoPXyp7oVkTJ2JFsTx+vzOIcnwGTbPv3uEelzY8pZL4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1600137811048685.0069375220932; Mon, 14 Sep 2020 19:43:31 -0700 (PDT) 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-456-b1tUknhmNNi3oUWkZS_mJA-1; Mon, 14 Sep 2020 22:43:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 270E78014D9; Tue, 15 Sep 2020 02:43:23 +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 B42CB5FC2A; Tue, 15 Sep 2020 02:43:21 +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 91E2944A41; Tue, 15 Sep 2020 02:43:20 +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 08F2hI3k019554 for ; Mon, 14 Sep 2020 22:43:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 680FBB07BF; Tue, 15 Sep 2020 02:43:18 +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 62E348287E for ; Tue, 15 Sep 2020 02:43:15 +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 BCA9A185A78B for ; Tue, 15 Sep 2020 02:43:15 +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-423-9rRj_0z0MceLDT-9dyuPJw-1; Mon, 14 Sep 2020 22:43:13 -0400 Received: by mail-qv1-f65.google.com with SMTP id cr8so1052103qvb.10 for ; Mon, 14 Sep 2020 19:43:13 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7c7:5342:27d9:20da:5ada:61cf]) by smtp.gmail.com with ESMTPSA id v16sm14897324qkg.37.2020.09.14.19.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 19:43:12 -0700 (PDT) X-MC-Unique: b1tUknhmNNi3oUWkZS_mJA-1 X-MC-Unique: 9rRj_0z0MceLDT-9dyuPJw-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=bYElcI9krxzzYpc61Ln0n7oGFxVazMXC8IIQcgjmUB4=; b=nZw+K2Kq6F5bCfrvzYI1cwtJ+2x8spOHj9KiBiMLN8K6FZhpMzLj2D9q8z9koZvmeU FgR+cDotDI1gJ4LFtjFabV5wU/aAXrab7DY0+7BT7AhEeG72FNkpnnrEvtKUGNlctFQT +RxhQggEZZ99V901iQGVbr+Uj4vBltfBktlu0M/kFILMeSukWSLKvI7Ne27FIub+07Q5 fNArIWf35vXYP6NdZzDh8iGeWDu7diSyqGYUYnRRZY1Qntp2DsqF86MbExpw2ZYNej4A zwjxmSnZqz9w5caQZTr4Fca3shLFZa+vxD+BmzochXhNkoemnddKOHemUJoI8lz6aEbP 1SeA== X-Gm-Message-State: AOAM533HAKImuT3F3xz4q8HERVEizEbGtG/H3994TBxHMxGcSWi0BEP7 VLjRYjT2t+mvE54AGmxsxIB21iG56c0= X-Google-Smtp-Source: ABdhPJxvGTZr1teSCtIHAwtJBDhAZYBC1J5sYcBjle/sO1MqGeiIHr7Upq0BgZWPze7kWnUvflXPNw== X-Received: by 2002:a05:6214:5cf:: with SMTP id t15mr16862115qvz.119.1600137792849; Mon, 14 Sep 2020 19:43:12 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v1 2/4] conf, qemu: move qemuDomainNVDimmAlignSizePseries to domain_conf.c Date: Mon, 14 Sep 2020 23:42:57 -0300 Message-Id: <20200915024259.193494-3-danielhb413@gmail.com> In-Reply-To: <20200915024259.193494-1-danielhb413@gmail.com> References: <20200915024259.193494-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.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We'll use the auto-alignment function during parse time, in domain_conf.c. Let's move the function to that file, renaming it to virDomainNVDimmAlignSizePseries(). This will also make it clearer that, although QEMU is the only driver that currently supports it, pSeries NVDIMM restrictions aren't tied to QEMU. Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 36 ++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 3 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_domain.c | 42 ++-------------------------------------- 4 files changed, 42 insertions(+), 40 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 72ac4f4191..63434b9d3e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16876,6 +16876,42 @@ 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 14a376350c..19ee9d6832 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3895,6 +3895,9 @@ 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 5f1aea3694..6bf2ef9744 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -542,6 +542,7 @@ virDomainNetTypeToString; virDomainNetUpdate; virDomainNostateReasonTypeFromString; virDomainNostateReasonTypeToString; +virDomainNVDimmAlignSizePseries; virDomainObjAssignDef; virDomainObjBroadcast; virDomainObjCheckActive; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4f796bef4a..f50a0a4710 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8067,44 +8067,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) { @@ -8153,7 +8115,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 (virDomainNVDimmAlignSizePseries(def->mems[i]) < 0) return -1; } else { align =3D qemuDomainGetMemoryModuleSizeAlignment(def, def->mem= s[i]); @@ -8190,7 +8152,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 virDomainNVDimmAlignSizePseries(mem); } else { mem->size =3D VIR_ROUND_UP(mem->size, qemuDomainGetMemorySizeAlignment(def)); --=20 2.26.2