[libvirt] [PATCH 3/3] qemu: Allow migration with disk cache on

Jiri Denemark posted 3 patches 5 weeks ago

[libvirt] [PATCH 3/3] qemu: Allow migration with disk cache on

Posted by Jiri Denemark 5 weeks ago
When QEMU supports flushing caches at the end of migration, we can
safely allow migration even if disk/driver/@cache is not none nor
directsync.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_migration.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 2bd1a464bf..bd40a8e70d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1214,6 +1214,7 @@ qemuMigrationSrcIsAllowed(virQEMUDriverPtr driver,
 
 static bool
 qemuMigrationSrcIsSafe(virDomainDefPtr def,
+                       virQEMUCapsPtr qemuCaps,
                        size_t nmigrate_disks,
                        const char **migrate_disks,
                        unsigned int flags)
@@ -1264,6 +1265,11 @@ qemuMigrationSrcIsSafe(virDomainDefPtr def,
             disk->cachemode == VIR_DOMAIN_DISK_CACHE_DIRECTSYNC)
             continue;
 
+        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATION_FILE_DROP_CACHE)) {
+            VIR_DEBUG("QEMU supports flushing caches; migration is safe");
+            continue;
+        }
+
         virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s",
                        _("Migration may lead to data corruption if disks"
                          " use cache other than none or directsync"));
@@ -1971,7 +1977,8 @@ qemuMigrationSrcBeginPhase(virQEMUDriverPtr driver,
         goto cleanup;
 
     if (!(flags & (VIR_MIGRATE_UNSAFE | VIR_MIGRATE_OFFLINE)) &&
-        !qemuMigrationSrcIsSafe(vm->def, nmigrate_disks, migrate_disks, flags))
+        !qemuMigrationSrcIsSafe(vm->def, priv->qemuCaps,
+                                nmigrate_disks, migrate_disks, flags))
         goto cleanup;
 
     if (flags & VIR_MIGRATE_POSTCOPY &&
@@ -4583,7 +4590,8 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver,
         goto endjob;
 
     if (!(flags & (VIR_MIGRATE_UNSAFE | VIR_MIGRATE_OFFLINE)) &&
-        !qemuMigrationSrcIsSafe(vm->def, nmigrate_disks, migrate_disks, flags))
+        !qemuMigrationSrcIsSafe(vm->def, priv->qemuCaps,
+                                nmigrate_disks, migrate_disks, flags))
         goto endjob;
 
     qemuMigrationSrcStoreDomainState(vm);
-- 
2.22.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list