qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 7/7] multifd: adding support for multifd connections dynamical


From: Het Gala
Subject: [PATCH v2 7/7] multifd: adding support for multifd connections dynamically
Date: Thu, 21 Jul 2022 19:56:20 +0000

i) Dynamically decide appropriate source and destination ip pairs for the
   corresponding multifd channel to be connected.

Suggested-by: Manish Mishra <manish.mishra@nutanix.com>
Signed-off-by: Het Gala <het.gala@nutanix.com>
---
 migration/multifd.c |  6 +++---
 migration/socket.c  | 37 ++++++++++++++++++++++---------------
 migration/socket.h  |  3 ++-
 3 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/migration/multifd.c b/migration/multifd.c
index 586ddc9d65..2d9d50239a 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -903,7 +903,7 @@ int multifd_save_setup(Error **errp)
     int thread_count;
     uint32_t page_count = MULTIFD_PACKET_SIZE / qemu_target_page_size();
     uint8_t i;
-
+    int idx;
     if (!migrate_use_multifd()) {
         return 0;
     }
@@ -945,8 +945,8 @@ int multifd_save_setup(Error **errp)
         } else {
             p->write_flags = 0;
         }
-
-        socket_send_channel_create(multifd_new_send_channel_async, p);
+        idx = multifd_index(i);
+        socket_send_channel_create(multifd_new_send_channel_async, p, idx);
     }
 
     for (i = 0; i < thread_count; i++) {
diff --git a/migration/socket.c b/migration/socket.c
index 69fda774ba..b81b819584 100644
--- a/migration/socket.c
+++ b/migration/socket.c
@@ -28,10 +28,6 @@
 #include "trace.h"
 #include "postcopy-ram.h"
 
-struct SocketOutgoingArgs {
-    SocketAddress *saddr;
-} outgoing_args;
-
 struct SocketArgs {
     struct SrcDestAddr address;
     uint8_t multifd_channels;
@@ -54,11 +50,30 @@ int outgoing_param_total_multifds(void)
     return total_multifd_channels;
 }
 
-void socket_send_channel_create(QIOTaskFunc f, void *data)
+
+int multifd_index(int i)
+{
+    int length = outgoing_migrate_params.socket_args_arr_len;
+    int j = 0;
+    int runn_sum = 0;
+    while (j < length) {
+        runn_sum += outgoing_migrate_params.socket_args[j].multifd_channels;
+        if (i >= runn_sum) {
+            j++;
+        } else {
+            break;
+        }
+    }
+    return j;
+}
+
+ void socket_send_channel_create(QIOTaskFunc f, void *data, int idx)
 {
     QIOChannelSocket *sioc = qio_channel_socket_new();
-    qio_channel_socket_connect_all_async(sioc, outgoing_args.saddr,
-                                     f, data, NULL, NULL, NULL);
+    qio_channel_socket_connect_all_async(sioc,
+                    outgoing_migrate_params.socket_args[idx].address.dst_addr,
+                    f, data, NULL, NULL,
+                    outgoing_migrate_params.socket_args[idx].address.src_addr);
 }
 
 QIOChannel *socket_send_channel_create_sync(Error **errp)
@@ -83,10 +98,6 @@ int socket_send_channel_destroy(QIOChannel *send)
 {
     /* Remove channel */
     object_unref(OBJECT(send));
-    if (outgoing_args.saddr) {
-        qapi_free_SocketAddress(outgoing_args.saddr);
-        outgoing_args.saddr = NULL;
-    }
     g_free(outgoing_migrate_params.socket_args);
     outgoing_migrate_params.socket_args = NULL;
     outgoing_migrate_params.socket_args_arr_len = 0;
@@ -142,10 +153,6 @@ socket_start_outgoing_migration_internal(MigrationState *s,
 
     data->s = s;
 
-    /* in case previous migration leaked it */
-    qapi_free_SocketAddress(outgoing_args.saddr);
-    outgoing_args.saddr = saddr;
-
     if (saddr->type == SOCKET_ADDRESS_TYPE_INET) {
         data->hostname = g_strdup(saddr->u.inet.host);
     }
diff --git a/migration/socket.h b/migration/socket.h
index 7c82278d33..80d03fc7d6 100644
--- a/migration/socket.h
+++ b/migration/socket.h
@@ -29,7 +29,8 @@ typedef struct SrcDestAddr {
 
 
 int outgoing_param_total_multifds(void);
-void socket_send_channel_create(QIOTaskFunc f, void *data);
+int multifd_index(int i);
+void socket_send_channel_create(QIOTaskFunc f, void *data, int idx);
 QIOChannel *socket_send_channel_create_sync(Error **errp);
 int socket_send_channel_destroy(QIOChannel *send);
 
-- 
2.22.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]