[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH v2 2/3] 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.

Signed-off-by: Daniel Henrique Barboza <danielhb413 gmail com>
---

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 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 @@
         <path>/tmp/nvdimm</path>
       </source>
       <target>
-        <size unit='KiB'>550000</size>
+        <size unit='KiB'>524416</size>
         <node>0</node>
         <label>
           <size unit='KiB'>128</size>
-- 
2.26.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]