From nobody Sun Feb 8 05:41:09 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=1600777803; cv=none; d=zohomail.com; s=zohoarc; b=UsA7bplldyDDkwsYTh5stM9jCXK2eCte/UWvVi61SuL8Mzt67Xt7I8vce0cqwfHD3Kexn8dAwrZrt45RkAx/JJ57ptGqa+d3IW3tfh+RMMmLw6ajbUoLwNIrjJl1ckW0zS0jhbnmOLg/77eJb0ZkGmhAVFWbBZWsNDUs11+kZro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600777803; 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=PcsNH7Or7kbwquurvoBVOKP8fx+Sq40A/uW40trcqwE=; b=Db/eS1qPiekDatouPdy5LGVhBO25yVeON0eda6UmSF2bZborYTaMrCaglDjrhskqRt3tqcIfD5334IWVerwbHMJTYvG490ZpeZt7vBamECEgHHacsEgIgUUyDN9gkzlUyXpTWjrgipoaZQL7vQK/dEGpymnvLOeY9OfZpuv2mP4= 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 1600777803386611.1248975775015; Tue, 22 Sep 2020 05:30:03 -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-169-pkpt1UTEM5S65YcnBdnXZw-1; Tue, 22 Sep 2020 08:29:59 -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 DA0F16408B; Tue, 22 Sep 2020 12:29:53 +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 B73D15C1DC; Tue, 22 Sep 2020 12:29: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 83BA818A0C0E; Tue, 22 Sep 2020 12:29: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 08MCTp80017421 for ; Tue, 22 Sep 2020 08:29:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id AAACA114B9D1; Tue, 22 Sep 2020 12:29:51 +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 A38DB114B9D2 for ; Tue, 22 Sep 2020 12:29:49 +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 44ECC101A568 for ; Tue, 22 Sep 2020 12:29:49 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-408-yKx-m_kdMgCkuZQ3jI3WXw-1; Tue, 22 Sep 2020 08:29:46 -0400 Received: by mail-qk1-f196.google.com with SMTP id f142so18727746qke.13 for ; Tue, 22 Sep 2020 05:29:46 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:2c16:ab4f:6f76:8b8e:4be7]) by smtp.gmail.com with ESMTPSA id b199sm10981485qkg.116.2020.09.22.05.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 05:29:42 -0700 (PDT) X-MC-Unique: pkpt1UTEM5S65YcnBdnXZw-1 X-MC-Unique: yKx-m_kdMgCkuZQ3jI3WXw-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=PcsNH7Or7kbwquurvoBVOKP8fx+Sq40A/uW40trcqwE=; b=C4Etvu/giTMdHS3rUsbhvVNmrT1NwkHqja76u7Hw7M1QJJhKlZXOM/3lAWEzFyfw26 56njuak8wSiBKwPeMWTMK+jzdd2KbHH8nJulMkGQr+PkFJbmZDUjKftsP9dn/9abLeXA 768ZJyMe5yH6RZZfwS79MmT74b8OVy80BewPGIDWSQ6mj7hx5x1iH54MHLIHlMWnnCcs hilKuV9RNtjphdM8UAwJrVrWuDKIN+0DrdbmLtQTPLaFt2fcQZk3qXCAU5cv3aXwma7V 95dmggos0NDFDHFuAlHoYM0cOMOGb+YRjS4Z3l6Y+K6BWyq84tYYBcsLnIPtSAwE49PM 1+vw== X-Gm-Message-State: AOAM532aykMpjEQ9eB4HJea97d544L95Y9VstaM20x42a3ZpS9hnWx4n BeEVRxH4lJgYkTU3Sqi9HDLOrHkYlPt3Cg== X-Google-Smtp-Source: ABdhPJxtWdfSL7pJ4atA5myINqS5XN6gmBEmuFjLxlgngDv9HiAv+66s86AXH6CsbfH+3Atw2MUgiQ== X-Received: by 2002:a37:c09:: with SMTP id 9mr4599289qkm.471.1600777786075; Tue, 22 Sep 2020 05:29:46 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 1/3] conf, qemu: move qemuDomainNVDimmAlignSizePseries to domain_conf.c Date: Tue, 22 Sep 2020 09:29:31 -0300 Message-Id: <20200922122933.101879-2-danielhb413@gmail.com> In-Reply-To: <20200922122933.101879-1-danielhb413@gmail.com> References: <20200922122933.101879-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.16 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" 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 9289c147fe..ea6a097161 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16866,6 +16866,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 4724206828..8f1662aae0 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3904,6 +3904,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 bdbe3431b8..6bca87eede 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -543,6 +543,7 @@ virDomainNetTypeToString; virDomainNetUpdate; virDomainNostateReasonTypeFromString; virDomainNostateReasonTypeToString; +virDomainNVDimmAlignSizePseries; virDomainObjAssignDef; virDomainObjBroadcast; virDomainObjCheckActive; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9e0d3a15b2..9fa6fac99a 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