qemu: Allow migration with disk cache on

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>
Acked-By: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Jiri Denemark 2019-08-13 15:17:53 +02:00
parent 598ec0db68
commit 4514abbd41

View File

@ -1214,6 +1214,7 @@ qemuMigrationSrcIsAllowed(virQEMUDriverPtr driver,
static bool static bool
qemuMigrationSrcIsSafe(virDomainDefPtr def, qemuMigrationSrcIsSafe(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps,
size_t nmigrate_disks, size_t nmigrate_disks,
const char **migrate_disks, const char **migrate_disks,
unsigned int flags) unsigned int flags)
@ -1264,6 +1265,11 @@ qemuMigrationSrcIsSafe(virDomainDefPtr def,
disk->cachemode == VIR_DOMAIN_DISK_CACHE_DIRECTSYNC) disk->cachemode == VIR_DOMAIN_DISK_CACHE_DIRECTSYNC)
continue; 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", virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s",
_("Migration may lead to data corruption if disks" _("Migration may lead to data corruption if disks"
" use cache other than none or directsync")); " use cache other than none or directsync"));
@ -1971,7 +1977,8 @@ qemuMigrationSrcBeginPhase(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
if (!(flags & (VIR_MIGRATE_UNSAFE | VIR_MIGRATE_OFFLINE)) && 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; goto cleanup;
if (flags & VIR_MIGRATE_POSTCOPY && if (flags & VIR_MIGRATE_POSTCOPY &&
@ -4583,7 +4590,8 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver,
goto endjob; goto endjob;
if (!(flags & (VIR_MIGRATE_UNSAFE | VIR_MIGRATE_OFFLINE)) && 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; goto endjob;
qemuMigrationSrcStoreDomainState(vm); qemuMigrationSrcStoreDomainState(vm);