diff mbox series

[RFC,09/26] migration: Add send/receive header for postcopy preempt channel

Message ID c20eb7fda0094cdea044051aa9123798e28664f3.1713269378.git.maciej.szmigiero@oracle.com
State New
Headers show
Series Multifd 🔀 device state transfer support with VFIO consumer | 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 postcopy preempt
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    | 5 +++++
 migration/postcopy-ram.c | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/migration/channel.h b/migration/channel.h
index 95d281828aaa..c59ccedc7b6b 100644
--- a/migration/channel.h
+++ b/migration/channel.h
@@ -31,6 +31,7 @@  int migration_channel_read_peek(QIOChannel *ioc,
                                 Error **errp);
 typedef enum {
     MIG_CHANNEL_TYPE_MAIN,
+    MIG_CHANNEL_TYPE_POSTCOPY_PREEMPT,
 } MigChannelTypes;
 
 typedef struct QEMU_PACKED {
diff --git a/migration/migration.c b/migration/migration.c
index 0eb5b4f4f5a1..ac9ecf1f4f22 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1019,6 +1019,11 @@  void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
         migration_incoming_setup(f);
         default_channel = true;
         break;
+    case MIG_CHANNEL_TYPE_POSTCOPY_PREEMPT:
+        assert(migrate_postcopy_preempt());
+        f = qemu_file_new_input(ioc);
+        postcopy_preempt_new_channel(migration_incoming_get_current(), f);
+        break;
     default:
         error_setg(errp, "Received unknown migration channel type %u",
                    header.channel_type);
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 53c90344acce..c7e9f7345970 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -1775,8 +1775,11 @@  int postcopy_preempt_establish_channel(MigrationState *s)
 void postcopy_preempt_setup(MigrationState *s)
 {
     PostcopyPChannelConnectData *data;
+    MigChannelHeader header = {};
 
-    data = pcopy_preempt_connect_data_new(s, NULL);
+    header.channel_type = MIG_CHANNEL_TYPE_POSTCOPY_PREEMPT;
+
+    data = pcopy_preempt_connect_data_new(s, &header);
     /* Kick an async task to connect */
     socket_send_channel_create(postcopy_preempt_send_channel_new,
                                data, pcopy_preempt_connect_data_unref);