From d3f3c2c97f9b92c982ff809479495f44614edb88 Mon Sep 17 00:00:00 2001 From: Daniel Henrique Barboza Date: Tue, 22 Sep 2020 09:12:07 -0300 Subject: [PATCH] domain_conf.c: auto-align pSeries NVDIMM in virDomainMemoryDefPostParse() 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. Reviewed-by: Andrea Bolognani Signed-off-by: Daniel Henrique Barboza --- 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 vsock) } +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 == 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(virDomainDeviceDefPtr dev, ret = virDomainVsockDefPostParse(dev->data.vsock); break; + case VIR_DOMAIN_DEVICE_MEMORY: + ret = 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(virDomainDeviceDefPtr 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 = 0; diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml b/tests/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