This simplifies the handling of ppc64 alignment in other parts
of the code, with a single function to handle all cases for the
architecture.
No functional changes were made just yet. Function was renamed to
reflect the broader scope.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/conf/domain_conf.c | 15 +++++++++++----
src/conf/domain_conf.h | 2 +-
src/libvirt_private.syms | 2 +-
src/qemu/qemu_domain.c | 4 ++--
4 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a3ca332279..c98e760aa2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5361,7 +5361,7 @@ virDomainMemoryDefPostParse(virDomainMemoryDefPtr mem,
*/
if (ARCH_IS_PPC64(def->os.arch) &&
mem->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
- virDomainNVDimmAlignSizePseries(mem) < 0)
+ virDomainMemoryDeviceAlignSizePseries(mem) < 0)
return -1;
return 0;
@@ -16851,8 +16851,16 @@ virDomainSEVDefParseXML(xmlNodePtr sevNode,
}
int
-virDomainNVDimmAlignSizePseries(virDomainMemoryDefPtr mem)
+virDomainMemoryDeviceAlignSizePseries(virDomainMemoryDefPtr mem)
{
+ unsigned long long ppc64AlignSize = 256 * 1024;
+ unsigned long long guestArea;
+
+ if (mem->model != VIR_DOMAIN_MEMORY_MODEL_NVDIMM) {
+ mem->size = VIR_ROUND_UP(mem->size, ppc64AlignSize);
+ return 0;
+ }
+
/* 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
@@ -16867,8 +16875,7 @@ virDomainNVDimmAlignSizePseries(virDomainMemoryDefPtr mem)
*
* target_size = AlignDown(target_size - label_size) + label_size
*/
- unsigned long long ppc64AlignSize = 256 * 1024;
- unsigned long long guestArea = mem->size - mem->labelsize;
+ guestArea = mem->size - mem->labelsize;
/* Align down guest_area. 256MiB is the minimum size. Error
* out if target_size is smaller than 256MiB + label_size,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 77656c8ae3..fed451c4d5 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3905,7 +3905,7 @@ virDomainBlockIoTuneInfoEqual(const virDomainBlockIoTuneInfo *a,
const virDomainBlockIoTuneInfo *b);
int
-virDomainNVDimmAlignSizePseries(virDomainMemoryDefPtr mem);
+virDomainMemoryDeviceAlignSizePseries(virDomainMemoryDefPtr mem);
bool
virHostdevIsSCSIDevice(const virDomainHostdevDef *hostdev)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 491bd5bd87..a44d37924a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -546,7 +546,6 @@ virDomainNetTypeToString;
virDomainNetUpdate;
virDomainNostateReasonTypeFromString;
virDomainNostateReasonTypeToString;
-virDomainNVDimmAlignSizePseries;
virDomainObjAssignDef;
virDomainObjBroadcast;
virDomainObjCheckActive;
@@ -849,6 +848,7 @@ virDomainCachePolicyTypeFromString;
virDomainCachePolicyTypeToString;
virDomainMemoryAccessTypeFromString;
virDomainMemoryAccessTypeToString;
+virDomainMemoryDeviceAlignSizePseries;
virDomainMemoryLatencyTypeFromString;
virDomainMemoryLatencyTypeToString;
virDomainNumaCheckABIStability;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 70896ad80e..375a9e5075 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8105,7 +8105,7 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def)
for (i = 0; i < def->nmems; i++) {
if (def->mems[i]->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
ARCH_IS_PPC64(def->os.arch)) {
- if (virDomainNVDimmAlignSizePseries(def->mems[i]) < 0)
+ if (virDomainMemoryDeviceAlignSizePseries(def->mems[i]) < 0)
return -1;
} else {
align = qemuDomainGetMemoryModuleSizeAlignment(def, def->mems[i]);
@@ -8142,7 +8142,7 @@ qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
{
if (mem->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
ARCH_IS_PPC64(def->os.arch)) {
- return virDomainNVDimmAlignSizePseries(mem);
+ return virDomainMemoryDeviceAlignSizePseries(mem);
} else {
mem->size = VIR_ROUND_UP(mem->size,
qemuDomainGetMemorySizeAlignment(def));
--
2.26.2