On Tue, May 10, 2022 at 17:20:58 +0200, Jiri Denemark wrote:
By separating it into a dedicated qemuMigrationSrcComplete function
which can be later called in other places.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_migration.c | 70 ++++++++++++++++++++++++---------------
src/qemu/qemu_migration.h | 5 +++
2 files changed, 48 insertions(+), 27 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index b62f7256c4..903c1dbf6b 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3518,6 +3518,48 @@ qemuMigrationAnyPrepareDef(virQEMUDriver *driver,
}
+void
+qemuMigrationSrcComplete(virQEMUDriver *driver,
+ virDomainObj *vm,
+ virDomainAsyncJob asyncJob)
+{
+ qemuDomainObjPrivate *priv = vm->privateData;
+ virDomainJobData *jobData = priv->job.completed;
+ virObjectEvent *event;
+ int reason;
+
+ if (jobData) {
+ /* We need to refresh migration statistics after a completed post-copy
+ * migration since jobData contains obsolete data from the time we
+ * switched to post-copy mode.
+ */
+ if (virDomainObjGetState(vm, &reason) == VIR_DOMAIN_PAUSED &&
+ reason == VIR_DOMAIN_PAUSED_POSTCOPY) {
+ VIR_DEBUG("Refreshing migration statistics");
+ if (qemuMigrationAnyFetchStats(driver, vm, VIR_ASYNC_JOB_MIGRATION_OUT,
+ jobData, NULL) < 0)
+ VIR_WARN("Could not refresh migration statistics");
+ }
+
+ qemuDomainJobDataUpdateTime(jobData);
+ }
+
+ /* If guest uses SPICE and supports seamless migration we have to hold
+ * up domain shutdown until SPICE server transfers its data */
+ qemuMigrationSrcWaitForSpice(vm);
+
+ qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_MIGRATED, asyncJob,
+ VIR_QEMU_PROCESS_STOP_MIGRATED);
+ virDomainAuditStop(vm, "migrated");
+
+ event = virDomainEventLifecycleNewFromObj(vm,
+ VIR_DOMAIN_EVENT_STOPPED,
+ VIR_DOMAIN_EVENT_STOPPED_MIGRATED);
Fix the alignment here.
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>