We only need to turn QEMU_MIGRATION_CAP_BACKGROUND_SNAPSHOT migration capabiliti for this. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx> --- src/qemu/qemu_driver.c | 4 ++-- src/qemu/qemu_migration.c | 20 +++++++++++++++----- src/qemu/qemu_migration.h | 1 + src/qemu/qemu_migration_params.c | 1 + src/qemu/qemu_migration_params.h | 1 + src/qemu/qemu_saveimage.c | 3 ++- src/qemu/qemu_saveimage.h | 1 + src/qemu/qemu_snapshot.c | 5 +++-- 8 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6a77d9f513..8edc38d343 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2855,7 +2855,7 @@ qemuDomainSaveInternal(virQEMUDriver *driver, xml = NULL; ret = qemuSaveImageCreate(driver, vm, path, data, compressor, - flags, QEMU_ASYNC_JOB_SAVE); + flags, false, QEMU_ASYNC_JOB_SAVE); if (ret < 0) goto endjob; @@ -3238,7 +3238,7 @@ doCoreDump(virQEMUDriver *driver, if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0)) goto cleanup; - rc = qemuMigrationSrcToFile(driver, vm, fd, compressor, + rc = qemuMigrationSrcToFile(driver, vm, fd, compressor, false, QEMU_ASYNC_JOB_DUMP); } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 9729041846..18a01df3d0 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5898,6 +5898,7 @@ int qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, int fd, virCommand *compressor, + bool instant, qemuDomainAsyncJob asyncJob) { qemuDomainObjPrivate *priv = vm->privateData; @@ -5924,6 +5925,11 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, QEMU_DOMAIN_MIG_BANDWIDTH_MAX * 1024 * 1024) < 0) return -1; + if (instant) + qemuMigrationParamsSetCapability(migParams, + QEMU_MIGRATION_CAP_BACKGROUND_SNAPSHOT, + true); + if (qemuMigrationParamsApply(driver, vm, asyncJob, migParams) < 0) return -1; @@ -6018,11 +6024,15 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, /* Restore max migration bandwidth */ if (virDomainObjIsActive(vm)) { if (bwParam) { - if (qemuMigrationParamsSetULL(migParams, - QEMU_MIGRATION_PARAM_MAX_BANDWIDTH, - saveMigBandwidth * 1024 * 1024) == 0) - ignore_value(qemuMigrationParamsApply(driver, vm, asyncJob, - migParams)); + qemuMigrationParamsSetULL(migParams, + QEMU_MIGRATION_PARAM_MAX_BANDWIDTH, + saveMigBandwidth * 1024 * 1024); + if (instant) + qemuMigrationParamsSetCapability(migParams, + QEMU_MIGRATION_CAP_BACKGROUND_SNAPSHOT, + false); + ignore_value(qemuMigrationParamsApply(driver, vm, asyncJob, + migParams)); } else { if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { qemuMonitorSetMigrationSpeed(priv->mon, saveMigBandwidth); diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index dd74f8bc88..9d91fbc882 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -209,6 +209,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, int fd, virCommand *compressor, + bool instant, qemuDomainAsyncJob asyncJob) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c index 11081dc11c..148aa2d12d 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -90,6 +90,7 @@ VIR_ENUM_IMPL(qemuMigrationCapability, "late-block-activate", "multifd", "dirty-bitmaps", + "background-snapshot", ); diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h index 5ca171226f..844ebf92eb 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -40,6 +40,7 @@ typedef enum { QEMU_MIGRATION_CAP_LATE_BLOCK_ACTIVATE, QEMU_MIGRATION_CAP_MULTIFD, QEMU_MIGRATION_CAP_BLOCK_DIRTY_BITMAPS, + QEMU_MIGRATION_CAP_BACKGROUND_SNAPSHOT, QEMU_MIGRATION_CAP_LAST } qemuMigrationCapability; diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index e03b79c303..b2b48610e6 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -258,6 +258,7 @@ qemuSaveImageCreate(virQEMUDriver *driver, virQEMUSaveData *data, virCommand *compressor, unsigned int flags, + bool instant, qemuDomainAsyncJob asyncJob) { g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); @@ -295,7 +296,7 @@ qemuSaveImageCreate(virQEMUDriver *driver, goto cleanup; /* Perform the migration */ - if (qemuMigrationSrcToFile(driver, vm, fd, compressor, asyncJob) < 0) + if (qemuMigrationSrcToFile(driver, vm, fd, compressor, instant, asyncJob) < 0) goto cleanup; /* Touch up file header to mark image complete. */ diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index 0710426742..2e87d6485a 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -96,6 +96,7 @@ qemuSaveImageCreate(virQEMUDriver *driver, virQEMUSaveData *data, virCommand *compressor, unsigned int flags, + bool instant, qemuDomainAsyncJob asyncJob); int diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 7e4dadb876..b521634f2a 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1344,6 +1344,7 @@ qemuSnapshotSaveMemory(virQEMUDriver *driver, virDomainObj *vm, virDomainSnapshotDef *snapdef, bool running, + bool instant, virQEMUDriverConfig *cfg) { qemuDomainObjPrivate *priv = vm->privateData; @@ -1377,7 +1378,7 @@ qemuSnapshotSaveMemory(virQEMUDriver *driver, xml = NULL; if (qemuSaveImageCreate(driver, vm, snapdef->memorysnapshotfile, - data, compressor, 0, + data, compressor, 0, instant, QEMU_ASYNC_JOB_SNAPSHOT) < 0) return -1; @@ -1471,7 +1472,7 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *driver, if (memory) { memory_existing = virFileExists(snapdef->memorysnapshotfile); - if (qemuSnapshotSaveMemory(driver, vm, snapdef, resume, cfg) < 0) + if (qemuSnapshotSaveMemory(driver, vm, snapdef, resume, false, cfg) < 0) goto cleanup; /* the memory image was created, remove it on errors */ -- 2.27.0