[libvirt PATCH 59/80] qemu: Implement VIR_MIGRATE_POSTCOPY_RESUME for Confirm phase

Jiri Denemark posted 80 patches 3 years, 9 months ago
There is a newer version of this series
[libvirt PATCH 59/80] qemu: Implement VIR_MIGRATE_POSTCOPY_RESUME for Confirm phase
Posted by Jiri Denemark 3 years, 9 months ago
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_migration.c | 49 +++++++++++++++++++++++++--------------
 1 file changed, 32 insertions(+), 17 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 29be797d78..8ed1c2c2b6 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3812,15 +3812,19 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver,
 
     virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
 
-    /* Keep the original migration phase in case post-copy failed as the job
-     * will stay active even though migration API finishes with an error.
-     */
-    if (virDomainObjIsFailedPostcopy(vm))
+    if (flags & VIR_MIGRATE_POSTCOPY_RESUME) {
+        phase = QEMU_MIGRATION_PHASE_CONFIRM_RESUME;
+    } else if (virDomainObjIsFailedPostcopy(vm)) {
+        /* Keep the original migration phase in case post-copy failed as the
+         * job will stay active even though migration API finishes with an
+         * error.
+         */
         phase = priv->job.phase;
-    else if (retcode == 0)
+    } else if (retcode == 0) {
         phase = QEMU_MIGRATION_PHASE_CONFIRM3;
-    else
+    } else {
         phase = QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED;
+    }
 
     if (qemuMigrationJobStartPhase(vm, phase) < 0)
         return -1;
@@ -3895,24 +3899,35 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver,
     qemuDomainObjPrivate *priv = vm->privateData;
     int ret = -1;
 
-    if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_OUT))
-        goto cleanup;
+    VIR_DEBUG("vm=%p, flags=0x%x, cancelled=%d", vm, flags, cancelled);
 
-    /* Keep the original migration phase in case post-copy failed as the job
-     * will stay active even though migration API finishes with an error.
-     */
-    if (virDomainObjIsFailedPostcopy(vm))
-        phase = priv->job.phase;
-    else if (cancelled)
-        phase = QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED;
-    else
-        phase = QEMU_MIGRATION_PHASE_CONFIRM3;
+    if (flags & VIR_MIGRATE_POSTCOPY_RESUME) {
+        if (!qemuMigrationAnyCanResume(vm, VIR_ASYNC_JOB_MIGRATION_OUT, flags,
+                                       QEMU_MIGRATION_PHASE_PERFORM_RESUME))
+            goto cleanup;
+        phase = QEMU_MIGRATION_PHASE_CONFIRM_RESUME;
+    } else {
+        if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_OUT))
+            goto cleanup;
+
+        /* Keep the original migration phase in case post-copy failed as the
+         * job will stay active even though migration API finishes with an
+         * error.
+         */
+        if (virDomainObjIsFailedPostcopy(vm))
+            phase = priv->job.phase;
+        else if (cancelled)
+            phase = QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED;
+        else
+            phase = QEMU_MIGRATION_PHASE_CONFIRM3;
+    }
 
     if (qemuMigrationJobStartPhase(vm, phase) < 0)
         goto cleanup;
 
     virCloseCallbacksUnset(driver->closeCallbacks, vm,
                            qemuMigrationSrcCleanup);
+    qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob);
 
     ret = qemuMigrationSrcConfirmPhase(driver, vm,
                                        cookiein, cookieinlen,
-- 
2.35.1
Re: [libvirt PATCH 59/80] qemu: Implement VIR_MIGRATE_POSTCOPY_RESUME for Confirm phase
Posted by Peter Krempa 3 years, 9 months ago
On Tue, May 10, 2022 at 17:21:20 +0200, Jiri Denemark wrote:
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/qemu/qemu_migration.c | 49 +++++++++++++++++++++++++--------------
>  1 file changed, 32 insertions(+), 17 deletions(-)

[...]

>  
>      if (qemuMigrationJobStartPhase(vm, phase) < 0)
>          goto cleanup;
>  
>      virCloseCallbacksUnset(driver->closeCallbacks, vm,
>                             qemuMigrationSrcCleanup);
> +    qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob);

This looks out of place in context of this commit.


Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Re: [libvirt PATCH 59/80] qemu: Implement VIR_MIGRATE_POSTCOPY_RESUME for Confirm phase
Posted by Jiri Denemark 3 years, 8 months ago
On Thu, May 12, 2022 at 16:27:24 +0200, Peter Krempa wrote:
> On Tue, May 10, 2022 at 17:21:20 +0200, Jiri Denemark wrote:
> > Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> > ---
> >  src/qemu/qemu_migration.c | 49 +++++++++++++++++++++++++--------------
> >  1 file changed, 32 insertions(+), 17 deletions(-)
> 
> [...]
> 
> >  
> >      if (qemuMigrationJobStartPhase(vm, phase) < 0)
> >          goto cleanup;
> >  
> >      virCloseCallbacksUnset(driver->closeCallbacks, vm,
> >                             qemuMigrationSrcCleanup);
> > +    qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob);
> 
> This looks out of place in context of this commit.

Sigh. I was trying hard to remember the reason I put this change into
this patch because there must have been one... but it was just a mistake
and the change belongs to [14/80] qemu: Keep migration job active after
failed post-copy.

Jirka