[libvirt PATCH 67/80] qemu: Start a migration phase in qemuMigrationAnyConnectionClosed

Jiri Denemark posted 80 patches 3 years, 9 months ago
There is a newer version of this series
[libvirt PATCH 67/80] qemu: Start a migration phase in qemuMigrationAnyConnectionClosed
Posted by Jiri Denemark 3 years, 9 months ago
Non-postcopy case talks to QEMU monitor and thus needs to create a
nested job. Since qemuMigrationAnyConnectionClosed is called in case
there's no thread processing a migration API, we need to make the
current thread a temporary owner of the migration job to avoid "This
thread doesn't seem to be the async job owner: 0". This is done by
starting a migration phase.

While no monitor interaction happens in postcopy case and just setting
the phase (to indicate a broken postcopy migration) would be enough,
being consistent and setting the owner does not hurt anything.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_migration.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index c1a60c90ef..2e9235e1d5 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2345,6 +2345,7 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm,
     qemuDomainObjPrivate *priv = vm->privateData;
     qemuDomainJobPrivate *jobPriv = priv->job.privateData;
     bool postcopy = false;
+    int phase;
 
     VIR_DEBUG("vm=%s, conn=%p, asyncJob=%s, phase=%s",
               vm->def->name, conn,
@@ -2404,12 +2405,17 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm,
         return;
     }
 
+    if (postcopy)
+        phase = QEMU_MIGRATION_PHASE_POSTCOPY_FAILED;
+    else
+        phase = QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED;
+    ignore_value(qemuMigrationJobStartPhase(vm, phase));
+
     if (postcopy) {
         if (priv->job.asyncJob == VIR_ASYNC_JOB_MIGRATION_OUT)
             qemuMigrationSrcPostcopyFailed(vm);
         else
             qemuMigrationDstPostcopyFailed(vm);
-        ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POSTCOPY_FAILED));
         qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob);
         qemuMigrationJobContinue(vm);
     } else {
-- 
2.35.1
Re: [libvirt PATCH 67/80] qemu: Start a migration phase in qemuMigrationAnyConnectionClosed
Posted by Peter Krempa 3 years, 9 months ago
On Tue, May 10, 2022 at 17:21:28 +0200, Jiri Denemark wrote:
> Non-postcopy case talks to QEMU monitor and thus needs to create a
> nested job. Since qemuMigrationAnyConnectionClosed is called in case
> there's no thread processing a migration API, we need to make the
> current thread a temporary owner of the migration job to avoid "This
> thread doesn't seem to be the async job owner: 0". This is done by
> starting a migration phase.
> 
> While no monitor interaction happens in postcopy case and just setting
> the phase (to indicate a broken postcopy migration) would be enough,
> being consistent and setting the owner does not hurt anything.

Especially since you clear it right after that :)

> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/qemu/qemu_migration.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>