[PATCH v3 2/4] Support live migration between file-backed memory and anonymous memory.

Michael Galaxy via Devel posted 4 patches 1 month ago
[PATCH v3 2/4] Support live migration between file-backed memory and anonymous memory.
Posted by Michael Galaxy via Devel 1 month ago
From: Michael Galaxy <mgalaxy@akamai.com>

In our environment, we need to convert VMs into a live-update-comptabile
configuration "on-the-fly" (via live migration). More specifically: We
need to convert between anonymous memory-backed VMs and file-backed
memory VMs. So, for this very specific case, this needs to work when
host-level PMEM is being enabled. QEMU does not have a problem with this
at all, but we need to relax the rules here a bit so that libvirt allows
it to go through normally.

Signed-off-by: Michael Galaxy <mgalaxy@akamai.com>
---
 src/qemu/qemu_domain.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f87ba6ba51..d574f6ab98 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8748,11 +8748,25 @@ qemuDomainABIStabilityCheck(const virDomainDef *src,
     size_t i;
 
     if (src->mem.source != dst->mem.source) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Target memoryBacking source '%1$s' doesn't match source memoryBacking source'%2$s'"),
-                       virDomainMemorySourceTypeToString(dst->mem.source),
-                       virDomainMemorySourceTypeToString(src->mem.source));
-        return false;
+        /*
+         * The current use case for this is the live migration of live-update
+         * capable CPR guests mounted on PMEM devices at the host
+         * level (not in-guest PMEM). QEMU has no problem doing these kinds of
+         * live migrations between these two memory backends, so let them go through.
+         * This allows us to "upgrade" guests from regular memory to file-backed
+         * memory seemlessly without taking them down.
+         */
+        if (!((src->mem.source == VIR_DOMAIN_MEMORY_SOURCE_NONE
+                && dst->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) ||
+            (src->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE
+                && dst->mem.source == VIR_DOMAIN_MEMORY_SOURCE_NONE))) {
+
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("Target memoryBacking source '%1$s' doesn't match source memoryBacking source'%2$s'"),
+                           virDomainMemorySourceTypeToString(dst->mem.source),
+                           virDomainMemorySourceTypeToString(src->mem.source));
+            return false;
+        }
     }
 
     for (i = 0; i < src->nmems; i++) {
-- 
2.34.1