[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
- [PATCH v2 0/7] multifd: Multiple interface support on top of Multifd, Het Gala, 2022/07/21
- [PATCH v2 2/7] multifd: modifying 'migrate' qmp command to add multifd socket on particular src and dest pair, Het Gala, 2022/07/21
- [PATCH v2 4/7] multifd: HMP changes for multifd source and destination side, Het Gala, 2022/07/21
- [PATCH v2 3/7] multifd: adding multi-interface support for multifd on destination side, Het Gala, 2022/07/21
- [PATCH v2 6/7] muitlfd: Correcting nit : whitespace error changes in qemu-sockets.c file, Het Gala, 2022/07/21
- [PATCH v2 5/7] multifd: establishing connection between any non-default src and dest pair, Het Gala, 2022/07/21
- [PATCH v2 1/7] multifd: adding more helper functions in util files for live migration, Het Gala, 2022/07/21
- [PATCH v2 7/7] multifd: adding support for multifd connections dynamically,
Het Gala <=