[PATCH v20 10/15] migration/channel: check that transfer is UNIX socket when "local" set

Vladimir Sementsov-Ogievskiy <[email protected]>
Newsgroups gmane.comp.emulators.qemu
Message-ID <[email protected]>
As documented, for "local", the migration channel must be direct
UNIX socket connection from source to target. We can't check for
it being "direct", but let's at least check that we deal with
UNIX socket (fd-passing supported).

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
---
 migration/channel.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/migration/channel.c b/migration/channel.c
index 1e2935f926b..537673c29e9 100644
--- a/migration/channel.c
+++ b/migration/channel.c
@@ -214,6 +214,13 @@ void migration_channel_process_incoming(QIOChannel *ioc)
     trace_migration_set_incoming_channel(
         ioc, object_get_typename(OBJECT(ioc)));
 
+    if (migrate_local() && migrate_mode() != MIG_MODE_CPR_EXEC &&
+        !qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_FD_PASS)) {
+        error_setg(&local_err,
+                   "local migration requires a UNIX domain socket channel");
+        goto out;
+    }
+
     if (migrate_channel_requires_tls_upgrade(ioc)) {
         migration_tls_channel_process_incoming(ioc, &local_err);
     } else {
@@ -241,6 +248,16 @@ void migration_channel_connect_outgoing(MigrationState *s, QIOChannel *ioc)
 {
     trace_migration_set_outgoing_channel(ioc, object_get_typename(OBJECT(ioc)));
 
+    if (migrate_local() && migrate_mode() != MIG_MODE_CPR_EXEC &&
+        !qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_FD_PASS)) {
+        Error *local_err = NULL;
+
+        error_setg(&local_err,
+                   "local migration requires a UNIX domain socket channel");
+        migration_connect_error_propagate(s, local_err);
+        return;
+    }
+
     if (migrate_channel_requires_tls_upgrade(ioc)) {
         Error *local_err = NULL;
 
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.