]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Create completed jobData in qemuMigrationSrcComplete
authorJiri Denemark <jdenemar@redhat.com>
Tue, 10 May 2022 13:20:25 +0000 (15:20 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 7 Jun 2022 15:40:20 +0000 (17:40 +0200)
Normally the structure is created once the source reports completed
migration, but with post-copy migration we can get here even after
libvirt daemon was restarted. It doesn't make sense to preserve the
structure in our status XML as we're going to rewrite almost all of it
while refreshing the stats anyway. So we just create the structure here
if it doesn't exist to make sure we can properly report statistics of a
completed migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_migration.c

index 0adad73103ae457f47e894974385e98ac2dacfcc..8c969344ce9fa094ae8ce4e77ed5eccda0c0939a 100644 (file)
@@ -3917,22 +3917,26 @@ qemuMigrationSrcComplete(virQEMUDriver *driver,
     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");
-        }
+    if (!jobData) {
+        priv->job.completed = virDomainJobDataCopy(priv->job.current);
+        jobData = priv->job.completed;
+        jobData->status = VIR_DOMAIN_JOB_STATUS_COMPLETED;
+    }
 
-        qemuDomainJobDataUpdateTime(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);