@@ -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++) {
@@ -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);
}
@@ -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);
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(-)