From nobody Tue Apr 30 07:51:46 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=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 From nobody Tue Apr 30 07:51:46 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=1600777807; cv=none; d=zohomail.com; s=zohoarc; b=GWFYkpatyS7FI13R14CODbQkRQUztZufKwhlAbtg+s4cmYSsx28AGw/QuimOk3GrNUP1VWNSQYTLznjMujoydVA3SfA6h8nz5QDXHk6NR0RgLJzYKB6qhUmdcreO7g9fZHCtqIiyu6Ab2gG7hql1bIHtpQ7YfjVidFsDM3eUdvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600777807; 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=WBS+TJvskX3jSvBX2SGehr4VNLL4AVvpVkHaXty56cg=; b=hwe/EbliXRLhhrtoBB9GH4cO8IGbrOAVUChxNtgH6XVECuza3dF/dtlTEyQDWfnHbinNGRzCYBpnrClR3MSqBEDX2SikucoyCQvzCMpwkS64eOWqa50FfqFCsvBTMdRJlwzBpQA9I5pm9qhhWPHQRxAOJ5Zjq9WdVvzTqJTNDpU= 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 1600777807790189.1840572199403; Tue, 22 Sep 2020 05:30:07 -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-522-QMUo2QbsPHGdsBpoak_C-g-1; Tue, 22 Sep 2020 08:30:02 -0400 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 8FC9C6408D; Tue, 22 Sep 2020 12:29:56 +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 6697C1972B; Tue, 22 Sep 2020 12:29:56 +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 2CF9918A0C11; Tue, 22 Sep 2020 12:29:56 +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 08MCTpS6017422 for ; Tue, 22 Sep 2020 08:29:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id ABF14114B9D6; 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 A3F01114B9D4 for ; Tue, 22 Sep 2020 12:29:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 A87CC101A56A for ; Tue, 22 Sep 2020 12:29:50 +0000 (UTC) Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-16-Q1fyLNd8MaK196wZTF_m5w-1; Tue, 22 Sep 2020 08:29:48 -0400 Received: by mail-qt1-f178.google.com with SMTP id n10so15341872qtv.3 for ; Tue, 22 Sep 2020 05:29:48 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 05:29:47 -0700 (PDT) X-MC-Unique: QMUo2QbsPHGdsBpoak_C-g-1 X-MC-Unique: Q1fyLNd8MaK196wZTF_m5w-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=WBS+TJvskX3jSvBX2SGehr4VNLL4AVvpVkHaXty56cg=; b=ZtcS8hgxCovQYyOyw+wROSEZp5XRzYZ9wT5jtGHkfSUfcaEKIBASRK0UMsVTEuw26C I9lUFaMN6XKJu2E26L6S6ouJA0LLAX5FKyinx8eUn8yhTWQ4QnCZjZaXUEEgZC8cZe53 IIoEQR40cmwCcq0qQAGYcr8KOFPYM/e6a8DwpAIBMOx/G8hobASjeHi5+sRmFMxmY4qG zggCr/uQMiOuJIGUUsMD2P8DP6cWMNNSvvIFTWIGlVdA10FjzBGRh5Rmas2px8806Kbj 5iptxE8lkjHPWEqaILUD66VHCDSjaAaZBAru+zX/SjFjbCgJn5/2gtw9IR8olvv6YVp3 1AUg== X-Gm-Message-State: AOAM530OXFRSOtRtrJUoUljTqdMqR52e9RnZEBRQSmJeW6ZavKPkavaa aI7y9sOhb65jC/vDh1u1pbXsVnataaZHsQ== X-Google-Smtp-Source: ABdhPJyYCruZ7f4pzqzjE+K7Zpape4JJ/05srM2jP4s/1X3XwNjyUzS6ZgsUDbD2Ny6fWIaPy9QLlA== X-Received: by 2002:ac8:1207:: with SMTP id x7mr4316975qti.109.1600777787675; Tue, 22 Sep 2020 05:29:47 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 2/3] domain_conf.c: auto-align pSeries NVDIMM in virDomainMemoryDefPostParse() Date: Tue, 22 Sep 2020 09:29:32 -0300 Message-Id: <20200922122933.101879-3-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.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" The alignment for the pSeries NVDIMM does not depend on runtime constraints. This means that it can be done in device parse time, instead of runtime, allowing the domain XML to reflect what the auto-alignment would do when the domain starts. This brings consistency between the NVDIMM size reported by the domain XML and what the guest sees, without impacting existing guests that are using an unaligned size - they'll work as usual, but the domain XML will be updated with the actual size of the NVDIMM. Signed-off-by: Daniel Henrique Barboza --- Note: the 'hypervisor agnostic' comment mentioned below is true for all ppc64 DIMMs, not just NVDIMMs. In theory it is possible to move a lot of pSeries memory handling code from QEMU to this new function. Given that the only practical gain is extra nerd points (ppc64 is supported only by QEMU), for now let's settle just for NVDIMMs. src/conf/domain_conf.c | 23 ++++++++++++++++++- .../memory-hotplug-nvdimm-ppc64.xml | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ea6a097161..22c6ba3b0d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5396,6 +5396,24 @@ 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, @@ -5437,6 +5455,10 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDef= Ptr dev, ret =3D virDomainVsockDefPostParse(dev->data.vsock); 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: @@ -5451,7 +5473,6 @@ 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; diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml b/tes= ts/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml index ae5a17d3c8..ecb1b83b4a 100644 --- a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml +++ b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml @@ -38,7 +38,7 @@ /tmp/nvdimm - 550000 + 524416 0