From 877d1c24783755c3dba33f77cc57058b083913cf Mon Sep 17 00:00:00 2001
From: Jiri Denemark <jdenemar@redhat.com>
Date: Wed, 8 Dec 2021 16:19:26 +0100
Subject: [PATCH] qemu: Add support for return-path migration capability

When return-path is enabled, QEMU on the source host won't report
completed migration until the destination QEMU sends a confirmation it
successfully loaded all data. Libvirt would detect such situation in the
Finish phase and report the error read from QEMU's stderr back to the
source, but using return-path could give use a bit better error
reporting with an earlier restart of vCPUs on the source.

The capability is only enabled when the connection between QEMU
processes on the source and destination hosts is bidirectional. In other
words, only when VIR_MIGRATE_TUNNELLED is not set, because our tunnel
only allows one-way communication from the source to the destination.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_migration_params.c | 6 ++++++
 src/qemu/qemu_migration_params.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index f5364a5ca2..7b225fdf4b 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -95,6 +95,7 @@ VIR_ENUM_IMPL(qemuMigrationCapability,
               "late-block-activate",
               "multifd",
               "dirty-bitmaps",
+              "return-path",
 );
 
 
@@ -171,6 +172,11 @@ static const qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMap[] = {
      VIR_MIGRATE_PARALLEL,
      QEMU_MIGRATION_CAP_MULTIFD,
      QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION},
+
+    {QEMU_MIGRATION_FLAG_FORBIDDEN,
+     VIR_MIGRATE_TUNNELLED,
+     QEMU_MIGRATION_CAP_RETURN_PATH,
+     QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION},
 };
 
 /* Translation from VIR_MIGRATE_PARAM_* typed parameters to
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
index f770bd2576..b4de8dda7b 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_RETURN_PATH,
 
     QEMU_MIGRATION_CAP_LAST
 } qemuMigrationCapability;