]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
domain_conf.c: auto-align pSeries NVDIMM in virDomainMemoryDefPostParse()
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Tue, 22 Sep 2020 12:12:07 +0000 (09:12 -0300)
committerDaniel Henrique Barboza <danielhb413@gmail.com>
Wed, 23 Sep 2020 16:19:47 +0000 (13:19 -0300)
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 <abologna@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/conf/domain_conf.c
tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml

index ea6a0971614f0466fdd24a98d81091f89602fde0..22c6ba3b0d3ee4166f601bc91b7787adcae8c4b4 100644 (file)
@@ -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;
index ae5a17d3c8d731e394158e61174b778cc52b23a2..ecb1b83b4ac6988ae3131a719755db5e6652825e 100644 (file)
@@ -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>