diff mbox series

[RFC,10/26] migration: Add send/receive header for multifd channel

Message ID ee0bbaa7e7e9147a96f60a1a3a228fddc958c990.1713269378.git.maciej.szmigiero@oracle.com (mailing list archive)
State New, archived
Headers show
Series Multifd | expand

Commit Message

Maciej S. Szmigiero April 16, 2024, 2:42 p.m. UTC
From: Avihai Horon <avihaih@nvidia.com>

Add send and receive migration channel header for multifd channel.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
[MSS: Adapt to rewritten migration header passing commit]
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
---
 migration/channel.h   |  1 +
 migration/migration.c | 16 ++++++++++++++++
 migration/multifd.c   |  4 +++-
 3 files changed, 20 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/migration/channel.h b/migration/channel.h
index c59ccedc7b6b..4232ee649939 100644
--- a/migration/channel.h
+++ b/migration/channel.h
@@ -32,6 +32,7 @@  int migration_channel_read_peek(QIOChannel *ioc,
 typedef enum {
     MIG_CHANNEL_TYPE_MAIN,
     MIG_CHANNEL_TYPE_POSTCOPY_PREEMPT,
+    MIG_CHANNEL_TYPE_MULTIFD,
 } MigChannelTypes;
 
 typedef struct QEMU_PACKED {
diff --git a/migration/migration.c b/migration/migration.c
index ac9ecf1f4f22..8fe8be71a0e3 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1024,6 +1024,22 @@  void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
         f = qemu_file_new_input(ioc);
         postcopy_preempt_new_channel(migration_incoming_get_current(), f);
         break;
+    case MIG_CHANNEL_TYPE_MULTIFD:
+    {
+        Error *local_err = NULL;
+
+        assert(migrate_multifd());
+        if (multifd_recv_setup(errp) != 0) {
+            return;
+        }
+
+        multifd_recv_new_channel(ioc, &local_err);
+        if (local_err) {
+            error_propagate(errp, local_err);
+            return;
+        }
+        break;
+    }
     default:
         error_setg(errp, "Received unknown migration channel type %u",
                    header.channel_type);
diff --git a/migration/multifd.c b/migration/multifd.c
index 8eecda68ac0f..c2575e3d6dbf 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -1191,8 +1191,10 @@  out:
 static bool multifd_new_send_channel_create(MultiFDSendParams *p, Error **errp)
 {
     g_autoptr(MFDSendChannelConnectData) data = NULL;
+    MigChannelHeader header = {};
 
-    data = mfd_send_channel_connect_data_new(p, NULL);
+    header.channel_type = MIG_CHANNEL_TYPE_MULTIFD;
+    data = mfd_send_channel_connect_data_new(p, &header);
 
     if (!multifd_use_packets()) {
         return file_send_channel_create(data, errp);