From 4947712047eb47f385b35cf5294cf886fc73c1ce Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Tue, 15 Sep 2020 11:03:57 +0800 Subject: [PATCH 01/15] migration/tls: save hostname into MigrationState MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hostname is need in multifd-tls, save hostname into MigrationState. Signed-off-by: Chuan Zheng Signed-off-by: Yan Jin Message-Id: <1600139042-104593-2-git-send-email-zhengchuan@huawei.com> Reviewed-by: Daniel P. Berrangé Signed-off-by: Dr. David Alan Gilbert --- ...ls-save-hostname-into-MigrationState.patch | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 migration-tls-save-hostname-into-MigrationState.patch diff --git a/migration-tls-save-hostname-into-MigrationState.patch b/migration-tls-save-hostname-into-MigrationState.patch new file mode 100644 index 00000000..538a8f69 --- /dev/null +++ b/migration-tls-save-hostname-into-MigrationState.patch @@ -0,0 +1,77 @@ +From 08ae1eda02ff08b3431b227ed702ea0fc5f8a4a2 Mon Sep 17 00:00:00 2001 +From: Chuan Zheng +Date: Tue, 15 Sep 2020 11:03:57 +0800 +Subject: [PATCH] migration/tls: save hostname into MigrationState +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +hostname is need in multifd-tls, save hostname into MigrationState. + +Signed-off-by: Chuan Zheng +Signed-off-by: Yan Jin +Message-Id: <1600139042-104593-2-git-send-email-zhengchuan@huawei.com> +Reviewed-by: Daniel P. Berrangé +Signed-off-by: Dr. David Alan Gilbert +--- + migration/channel.c | 1 + + migration/migration.c | 1 + + migration/migration.h | 5 +++++ + migration/tls.c | 2 ++ + 4 files changed, 9 insertions(+) + +diff --git a/migration/channel.c b/migration/channel.c +index 7462181484..46ed40b89c 100644 +--- a/migration/channel.c ++++ b/migration/channel.c +@@ -99,5 +99,6 @@ void migration_channel_connect(MigrationState *s, + } + } + migrate_fd_connect(s, error); ++ g_free(s->hostname); + error_free(error); + } +diff --git a/migration/migration.c b/migration/migration.c +index 7949f2a40b..993d77b7d6 100644 +--- a/migration/migration.c ++++ b/migration/migration.c +@@ -1710,6 +1710,7 @@ void migrate_init(MigrationState *s) + s->migration_thread_running = false; + error_free(s->error); + s->error = NULL; ++ s->hostname = NULL; + + migrate_set_state(&s->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP); + +diff --git a/migration/migration.h b/migration/migration.h +index feb344306a..e5aaf2ef70 100644 +--- a/migration/migration.h ++++ b/migration/migration.h +@@ -259,6 +259,11 @@ struct MigrationState + * (which is in 4M chunk). + */ + uint8_t clear_bitmap_shift; ++ ++ /* ++ * This save hostname when out-going migration starts ++ */ ++ char *hostname; + }; + + void migrate_set_state(int *state, int old_state, int new_state); +diff --git a/migration/tls.c b/migration/tls.c +index 5171afc6c4..a0eb553e14 100644 +--- a/migration/tls.c ++++ b/migration/tls.c +@@ -155,6 +155,8 @@ void migration_tls_channel_connect(MigrationState *s, + return; + } + ++ /* Save hostname into MigrationState for handshake */ ++ s->hostname = g_strdup(hostname); + trace_migration_tls_outgoing_handshake_start(hostname); + qio_channel_set_name(QIO_CHANNEL(tioc), "migration-tls-outgoing"); + qio_channel_tls_handshake(tioc, +-- +2.27.0 + -- Gitee From f16a84ef67871a39b2b53437f37c96c4f5943745 Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Tue, 15 Sep 2020 11:03:58 +0800 Subject: [PATCH 02/15] migration/tls: extract migration_tls_client_create for common-use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit migration_tls_client_create will be used in multifd-tls, let's extract it. Signed-off-by: Chuan Zheng Signed-off-by: Yan Jin Reviewed-by: Daniel P. Berrangé Message-Id: <1600139042-104593-3-git-send-email-zhengchuan@huawei.com> Signed-off-by: Dr. David Alan Gilbert --- ...tract-migration_tls_client_create-fo.patch | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 migration-tls-extract-migration_tls_client_create-fo.patch diff --git a/migration-tls-extract-migration_tls_client_create-fo.patch b/migration-tls-extract-migration_tls_client_create-fo.patch new file mode 100644 index 00000000..7f538332 --- /dev/null +++ b/migration-tls-extract-migration_tls_client_create-fo.patch @@ -0,0 +1,109 @@ +From 4ffa2ea3749066a0444b69ef16ec4e4d6cdad0e1 Mon Sep 17 00:00:00 2001 +From: Chuan Zheng +Date: Tue, 15 Sep 2020 11:03:58 +0800 +Subject: [PATCH] migration/tls: extract migration_tls_client_create for + common-use +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +migration_tls_client_create will be used in multifd-tls, let's +extract it. + +Signed-off-by: Chuan Zheng +Signed-off-by: Yan Jin +Reviewed-by: Daniel P. Berrangé +Message-Id: <1600139042-104593-3-git-send-email-zhengchuan@huawei.com> +Signed-off-by: Dr. David Alan Gilbert +--- + migration/tls.c | 26 ++++++++++++++++++-------- + migration/tls.h | 6 ++++++ + 2 files changed, 24 insertions(+), 8 deletions(-) + +diff --git a/migration/tls.c b/migration/tls.c +index a0eb553e14..1d5b571d8e 100644 +--- a/migration/tls.c ++++ b/migration/tls.c +@@ -22,7 +22,6 @@ + #include "channel.h" + #include "migration.h" + #include "tls.h" +-#include "io/channel-tls.h" + #include "crypto/tlscreds.h" + #include "qemu/error-report.h" + #include "qapi/error.h" +@@ -126,11 +125,10 @@ static void migration_tls_outgoing_handshake(QIOTask *task, + object_unref(OBJECT(ioc)); + } + +- +-void migration_tls_channel_connect(MigrationState *s, +- QIOChannel *ioc, +- const char *hostname, +- Error **errp) ++QIOChannelTLS *migration_tls_client_create(MigrationState *s, ++ QIOChannel *ioc, ++ const char *hostname, ++ Error **errp) + { + QCryptoTLSCreds *creds; + QIOChannelTLS *tioc; +@@ -138,7 +136,7 @@ void migration_tls_channel_connect(MigrationState *s, + creds = migration_tls_get_creds( + s, QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT, errp); + if (!creds) { +- return; ++ return NULL; + } + + if (s->parameters.tls_hostname && *s->parameters.tls_hostname) { +@@ -146,11 +144,23 @@ void migration_tls_channel_connect(MigrationState *s, + } + if (!hostname) { + error_setg(errp, "No hostname available for TLS"); +- return; ++ return NULL; + } + + tioc = qio_channel_tls_new_client( + ioc, creds, hostname, errp); ++ ++ return tioc; ++} ++ ++void migration_tls_channel_connect(MigrationState *s, ++ QIOChannel *ioc, ++ const char *hostname, ++ Error **errp) ++{ ++ QIOChannelTLS *tioc; ++ ++ tioc = migration_tls_client_create(s, ioc, hostname, errp); + if (!tioc) { + return; + } +diff --git a/migration/tls.h b/migration/tls.h +index cdd70001ed..0cfbe368ba 100644 +--- a/migration/tls.h ++++ b/migration/tls.h +@@ -22,11 +22,17 @@ + #define QEMU_MIGRATION_TLS_H + + #include "io/channel.h" ++#include "io/channel-tls.h" + + void migration_tls_channel_process_incoming(MigrationState *s, + QIOChannel *ioc, + Error **errp); + ++QIOChannelTLS *migration_tls_client_create(MigrationState *s, ++ QIOChannel *ioc, ++ const char *hostname, ++ Error **errp); ++ + void migration_tls_channel_connect(MigrationState *s, + QIOChannel *ioc, + const char *hostname, +-- +2.27.0 + -- Gitee From fde932816e27cf4c343d07d1b481d70a4e91f5e5 Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Wed, 2 Dec 2020 11:25:44 +0800 Subject: [PATCH 03/15] migration/tls: add tls_hostname into MultiFDSendParams MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since multifd creation is async with migration_channel_connect, we should pass the hostname from MigrationState to MultiFDSendParams. Signed-off-by: Chuan Zheng Signed-off-by: Yan Jin Message-Id: <1600139042-104593-4-git-send-email-zhengchuan@huawei.com> Reviewed-by: Daniel P. Berrangé Signed-off-by: Dr. David Alan Gilbert --- ...d-tls_hostname-into-MultiFDSendParam.patch | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 migration-tls-add-tls_hostname-into-MultiFDSendParam.patch diff --git a/migration-tls-add-tls_hostname-into-MultiFDSendParam.patch b/migration-tls-add-tls_hostname-into-MultiFDSendParam.patch new file mode 100644 index 00000000..3b06a42f --- /dev/null +++ b/migration-tls-add-tls_hostname-into-MultiFDSendParam.patch @@ -0,0 +1,66 @@ +From 0aff29297923b32e919ce944030a043e0826d9aa Mon Sep 17 00:00:00 2001 +From: Ying Fang +Date: Wed, 2 Dec 2020 11:25:44 +0800 +Subject: [PATCH] migration/tls: add tls_hostname into MultiFDSendParams +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Since multifd creation is async with migration_channel_connect, we should +pass the hostname from MigrationState to MultiFDSendParams. + +Signed-off-by: Chuan Zheng +Signed-off-by: Yan Jin +Message-Id: <1600139042-104593-4-git-send-email-zhengchuan@huawei.com> +Reviewed-by: Daniel P. Berrangé +Signed-off-by: Dr. David Alan Gilbert +--- + migration/ram.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/migration/ram.c b/migration/ram.c +index 1a33c7b3e2..bb8f383c3b 100644 +--- a/migration/ram.c ++++ b/migration/ram.c +@@ -621,6 +621,8 @@ typedef struct { + uint8_t id; + /* channel thread name */ + char *name; ++ /* tls hostname */ ++ char *tls_hostname; + /* channel thread id */ + QemuThread thread; + /* communication channel */ +@@ -1041,6 +1043,8 @@ void multifd_save_cleanup(void) + qemu_sem_destroy(&p->sem_sync); + g_free(p->name); + p->name = NULL; ++ g_free(p->tls_hostname); ++ p->tls_hostname = NULL; + multifd_pages_clear(p->pages); + p->pages = NULL; + p->packet_len = 0; +@@ -1229,10 +1233,12 @@ int multifd_save_setup(void) + int thread_count; + uint32_t page_count = MULTIFD_PACKET_SIZE / qemu_target_page_size(); + uint8_t i; ++ MigrationState *s; + + if (!migrate_use_multifd()) { + return 0; + } ++ s = migrate_get_current(); + thread_count = migrate_multifd_channels(); + multifd_send_state = g_malloc0(sizeof(*multifd_send_state)); + multifd_send_state->params = g_new0(MultiFDSendParams, thread_count); +@@ -1253,6 +1259,7 @@ int multifd_save_setup(void) + + sizeof(ram_addr_t) * page_count; + p->packet = g_malloc0(p->packet_len); + p->name = g_strdup_printf("multifdsend_%d", i); ++ p->tls_hostname = g_strdup(s->hostname); + socket_send_channel_create(multifd_new_send_channel_async, p); + } + return 0; +-- +2.27.0 + -- Gitee From 48ae5c26a4e7a18eb9a8579204f930310214814c Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Wed, 2 Dec 2020 11:32:44 +0800 Subject: [PATCH 04/15] migration/tls: extract cleanup function for common-use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit multifd channel cleanup is need if multifd handshake failed, let's extract it. Signed-off-by: Chuan Zheng Signed-off-by: Yan Jin Reviewed-by: Daniel P. Berrangé Message-Id: <1600139042-104593-5-git-send-email-zhengchuan@huawei.com> Signed-off-by: Dr. David Alan Gilbert --- ...tract-cleanup-function-for-common-us.patch | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 migration-tls-extract-cleanup-function-for-common-us.patch diff --git a/migration-tls-extract-cleanup-function-for-common-us.patch b/migration-tls-extract-cleanup-function-for-common-us.patch new file mode 100644 index 00000000..5ac83e92 --- /dev/null +++ b/migration-tls-extract-cleanup-function-for-common-us.patch @@ -0,0 +1,82 @@ +From 29914b97b20a6415476095c913607412a3f7572f Mon Sep 17 00:00:00 2001 +From: Ying Fang +Date: Wed, 2 Dec 2020 11:32:44 +0800 +Subject: [PATCH] migration/tls: extract cleanup function for common-use +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +multifd channel cleanup is need if multifd handshake failed, +let's extract it. + +Signed-off-by: Chuan Zheng +Signed-off-by: Yan Jin +Reviewed-by: Daniel P. Berrangé +Message-Id: <1600139042-104593-5-git-send-email-zhengchuan@huawei.com> +Signed-off-by: Dr. David Alan Gilbert +--- + migration/ram.c | 34 ++++++++++++++++++++++------------ + 1 file changed, 22 insertions(+), 12 deletions(-) + +diff --git a/migration/ram.c b/migration/ram.c +index bb8f383c3b..2b9d00745c 100644 +--- a/migration/ram.c ++++ b/migration/ram.c +@@ -1200,6 +1200,23 @@ out: + return NULL; + } + ++static void multifd_new_send_channel_cleanup(MultiFDSendParams *p, ++ QIOChannel *ioc, Error *err) ++{ ++ migrate_set_error(migrate_get_current(), err); ++ /* Error happen, we need to tell who pay attention to me */ ++ qemu_sem_post(&multifd_send_state->channels_ready); ++ qemu_sem_post(&p->sem_sync); ++ /* ++ * Although multifd_send_thread is not created, but main migration ++ * thread neet to judge whether it is running, so we need to mark ++ * its status. ++ */ ++ p->quit = true; ++ object_unref(OBJECT(ioc)); ++ error_free(err); ++} ++ + static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) + { + MultiFDSendParams *p = opaque; +@@ -1207,25 +1224,18 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) + Error *local_err = NULL; + + if (qio_task_propagate_error(task, &local_err)) { +- migrate_set_error(migrate_get_current(), local_err); +- /* Error happen, we need to tell who pay attention to me */ +- qemu_sem_post(&multifd_send_state->channels_ready); +- qemu_sem_post(&p->sem_sync); +- /* +- * Although multifd_send_thread is not created, but main migration +- * thread neet to judge whether it is running, so we need to mark +- * its status. +- */ +- p->quit = true; +- object_unref(OBJECT(sioc)); +- error_free(local_err); ++ goto cleanup; + } else { + p->c = QIO_CHANNEL(sioc); + qio_channel_set_delay(p->c, false); + p->running = true; + qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, + QEMU_THREAD_JOINABLE); ++ return; + } ++ ++cleanup: ++ multifd_new_send_channel_cleanup(p, sioc, local_err); + } + + int multifd_save_setup(void) +-- +2.27.0 + -- Gitee From 1a957606c55d7cb41fbb87952d4287481754f429 Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Wed, 2 Dec 2020 11:38:37 +0800 Subject: [PATCH 05/15] migration/tls: add support for multifd tls-handshake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar like migration main thread, we need to do handshake for each multifd thread. Signed-off-by: Chuan Zheng Signed-off-by: Yan Jin Reviewed-by: Daniel P. Berrangé Message-Id: <1600139042-104593-6-git-send-email-zhengchuan@huawei.com> Signed-off-by: Dr. David Alan Gilbert --- ...dd-support-for-multifd-tls-handshake.patch | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 migration-tls-add-support-for-multifd-tls-handshake.patch diff --git a/migration-tls-add-support-for-multifd-tls-handshake.patch b/migration-tls-add-support-for-multifd-tls-handshake.patch new file mode 100644 index 00000000..f81bb619 --- /dev/null +++ b/migration-tls-add-support-for-multifd-tls-handshake.patch @@ -0,0 +1,125 @@ +From e283c7dab15fed5af2904480230f86cf81b67aed Mon Sep 17 00:00:00 2001 +From: Ying Fang +Date: Wed, 2 Dec 2020 11:38:37 +0800 +Subject: [PATCH] migration/tls: add support for multifd tls-handshake +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Similar like migration main thread, we need to do handshake +for each multifd thread. + +Signed-off-by: Chuan Zheng +Signed-off-by: Yan Jin +Reviewed-by: Daniel P. Berrangé +Message-Id: <1600139042-104593-6-git-send-email-zhengchuan@huawei.com> +Signed-off-by: Dr. David Alan Gilbert +--- + migration/ram.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 75 insertions(+), 2 deletions(-) + +diff --git a/migration/ram.c b/migration/ram.c +index 2b9d00745c..b82c0e6562 100644 +--- a/migration/ram.c ++++ b/migration/ram.c +@@ -38,6 +38,7 @@ + #include "ram.h" + #include "migration.h" + #include "socket.h" ++#include "tls.h" + #include "migration/register.h" + #include "migration/misc.h" + #include "qemu-file.h" +@@ -1200,6 +1201,77 @@ out: + return NULL; + } + ++static bool multifd_channel_connect(MultiFDSendParams *p, ++ QIOChannel *ioc, ++ Error *error); ++ ++static void multifd_tls_outgoing_handshake(QIOTask *task, ++ gpointer opaque) ++{ ++ MultiFDSendParams *p = opaque; ++ QIOChannel *ioc = QIO_CHANNEL(qio_task_get_source(task)); ++ Error *err = NULL; ++ ++ qio_task_propagate_error(task, &err); ++ multifd_channel_connect(p, ioc, err); ++} ++ ++static void multifd_tls_channel_connect(MultiFDSendParams *p, ++ QIOChannel *ioc, ++ Error **errp) ++{ ++ MigrationState *s = migrate_get_current(); ++ const char *hostname = p->tls_hostname; ++ QIOChannelTLS *tioc; ++ ++ tioc = migration_tls_client_create(s, ioc, hostname, errp); ++ if (!tioc) { ++ return; ++ } ++ ++ qio_channel_set_name(QIO_CHANNEL(tioc), "multifd-tls-outgoing"); ++ qio_channel_tls_handshake(tioc, ++ multifd_tls_outgoing_handshake, ++ p, ++ NULL, ++ NULL); ++ ++} ++ ++static bool multifd_channel_connect(MultiFDSendParams *p, ++ QIOChannel *ioc, ++ Error *error) ++{ ++ MigrationState *s = migrate_get_current(); ++ ++ if (!error) { ++ if (s->parameters.tls_creds && ++ *s->parameters.tls_creds && ++ !object_dynamic_cast(OBJECT(ioc), ++ TYPE_QIO_CHANNEL_TLS)) { ++ multifd_tls_channel_connect(p, ioc, &error); ++ if (!error) { ++ /* ++ * tls_channel_connect will call back to this ++ * function after the TLS handshake, ++ * so we mustn't call multifd_send_thread until then ++ */ ++ return false; ++ } else { ++ return true; ++ } ++ } else { ++ /* update for tls qio channel */ ++ p->c = ioc; ++ qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, ++ QEMU_THREAD_JOINABLE); ++ } ++ return false; ++ } ++ ++ return true; ++} ++ + static void multifd_new_send_channel_cleanup(MultiFDSendParams *p, + QIOChannel *ioc, Error *err) + { +@@ -1229,8 +1301,9 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) + p->c = QIO_CHANNEL(sioc); + qio_channel_set_delay(p->c, false); + p->running = true; +- qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, +- QEMU_THREAD_JOINABLE); ++ if (multifd_channel_connect(p, sioc, local_err)) { ++ goto cleanup; ++ } + return; + } + +-- +2.27.0 + -- Gitee From e3a946c4fe7e43a8c9c1f9809c6a7d142fa34b94 Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Wed, 2 Dec 2020 13:56:11 +0800 Subject: [PATCH 06/15] migration/tls: add trace points for multifd-tls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add trace points for multifd-tls for debug. Signed-off-by: Chuan Zheng Signed-off-by: Yan Jin Reviewed-by: Daniel P. Berrangé Message-Id: <1600139042-104593-7-git-send-email-zhengchuan@huawei.com> Signed-off-by: Dr. David Alan Gilbert --- ...tls-add-trace-points-for-multifd-tls.patch | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 migration-tls-add-trace-points-for-multifd-tls.patch diff --git a/migration-tls-add-trace-points-for-multifd-tls.patch b/migration-tls-add-trace-points-for-multifd-tls.patch new file mode 100644 index 00000000..a49ef1fa --- /dev/null +++ b/migration-tls-add-trace-points-for-multifd-tls.patch @@ -0,0 +1,73 @@ +From 83cbd3a645e9376a25cd359e8f12f8db025bf071 Mon Sep 17 00:00:00 2001 +From: Ying Fang +Date: Wed, 2 Dec 2020 13:56:11 +0800 +Subject: [PATCH] migration/tls: add trace points for multifd-tls +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +add trace points for multifd-tls for debug. + +Signed-off-by: Chuan Zheng +Signed-off-by: Yan Jin +Reviewed-by: Daniel P. Berrangé +Message-Id: <1600139042-104593-7-git-send-email-zhengchuan@huawei.com> +Signed-off-by: Dr. David Alan Gilbert +--- + migration/ram.c | 10 +++++++++- + migration/trace-events | 4 ++++ + 2 files changed, 13 insertions(+), 1 deletion(-) + +diff --git a/migration/ram.c b/migration/ram.c +index b82c0e6562..3ded38c0be 100644 +--- a/migration/ram.c ++++ b/migration/ram.c +@@ -1212,7 +1212,11 @@ static void multifd_tls_outgoing_handshake(QIOTask *task, + QIOChannel *ioc = QIO_CHANNEL(qio_task_get_source(task)); + Error *err = NULL; + +- qio_task_propagate_error(task, &err); ++ if (qio_task_propagate_error(task, &err)) { ++ trace_multifd_tls_outgoing_handshake_error(ioc, error_get_pretty(err)); ++ } else { ++ trace_multifd_tls_outgoing_handshake_complete(ioc); ++ } + multifd_channel_connect(p, ioc, err); + } + +@@ -1229,6 +1233,7 @@ static void multifd_tls_channel_connect(MultiFDSendParams *p, + return; + } + ++ trace_multifd_tls_outgoing_handshake_start(ioc, tioc, hostname); + qio_channel_set_name(QIO_CHANNEL(tioc), "multifd-tls-outgoing"); + qio_channel_tls_handshake(tioc, + multifd_tls_outgoing_handshake, +@@ -1244,6 +1249,9 @@ static bool multifd_channel_connect(MultiFDSendParams *p, + { + MigrationState *s = migrate_get_current(); + ++ trace_multifd_set_outgoing_channel( ++ ioc, object_get_typename(OBJECT(ioc)), p->tls_hostname, error); ++ + if (!error) { + if (s->parameters.tls_creds && + *s->parameters.tls_creds && +diff --git a/migration/trace-events b/migration/trace-events +index 69620c43c2..c0640cd424 100644 +--- a/migration/trace-events ++++ b/migration/trace-events +@@ -93,6 +93,10 @@ multifd_send_sync_main_signal(uint8_t id) "channel %d" + multifd_send_sync_main_wait(uint8_t id) "channel %d" + multifd_send_thread_end(uint8_t id, uint64_t packets, uint64_t pages) "channel %d packets %" PRIu64 " pages %" PRIu64 + multifd_send_thread_start(uint8_t id) "%d" ++multifd_tls_outgoing_handshake_start(void *ioc, void *tioc, const char *hostname) "ioc=%p tioc=%p hostname=%s" ++multifd_tls_outgoing_handshake_error(void *ioc, const char *err) "ioc=%p err=%s" ++multifd_tls_outgoing_handshake_complete(void *ioc) "ioc=%p" ++multifd_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname, void *err) "ioc=%p ioctype=%s hostname=%s err=%p" + ram_discard_range(const char *rbname, uint64_t start, size_t len) "%s: start: %" PRIx64 " %zx" + ram_load_loop(const char *rbname, uint64_t addr, int flags, void *host) "%s: addr: 0x%" PRIx64 " flags: 0x%x host: %p" + ram_load_postcopy_loop(uint64_t addr, int flags) "@%" PRIx64 " %x" +-- +2.27.0 + -- Gitee From 4a589960c579dc3b06cbe23b86071d7d753be041 Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Wed, 2 Dec 2020 14:25:13 +0800 Subject: [PATCH 07/15] qemu-file: Don't do IO after shutdown Be sure that we are not doing neither read/write after shutdown of the QEMUFile. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- qemu-file-Don-t-do-IO-after-shutdown.patch | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 qemu-file-Don-t-do-IO-after-shutdown.patch diff --git a/qemu-file-Don-t-do-IO-after-shutdown.patch b/qemu-file-Don-t-do-IO-after-shutdown.patch new file mode 100644 index 00000000..72cfc4d7 --- /dev/null +++ b/qemu-file-Don-t-do-IO-after-shutdown.patch @@ -0,0 +1,81 @@ +From 1f8bc46e8af4ffe6d062f378bd11e0ad70d30ac8 Mon Sep 17 00:00:00 2001 +From: Ying Fang +Date: Wed, 2 Dec 2020 14:25:13 +0800 +Subject: [PATCH] qemu-file: Don't do IO after shutdown + +Be sure that we are not doing neither read/write after shutdown of the +QEMUFile. + +Signed-off-by: Juan Quintela +Reviewed-by: Dr. David Alan Gilbert +--- + migration/qemu-file.c | 22 +++++++++++++++++++++- + 1 file changed, 21 insertions(+), 1 deletion(-) + +diff --git a/migration/qemu-file.c b/migration/qemu-file.c +index 18f480529a..cd96d04e9a 100644 +--- a/migration/qemu-file.c ++++ b/migration/qemu-file.c +@@ -51,6 +51,8 @@ struct QEMUFile { + unsigned int iovcnt; + + int last_error; ++ /* has the file has been shutdown */ ++ bool shutdown; + }; + + /* +@@ -59,10 +61,18 @@ struct QEMUFile { + */ + int qemu_file_shutdown(QEMUFile *f) + { ++ int ret; ++ ++ f->shutdown = true; + if (!f->ops->shut_down) { + return -ENOSYS; + } +- return f->ops->shut_down(f->opaque, true, true); ++ ++ ret = f->ops->shut_down(f->opaque, true, true); ++ if (!f->last_error) { ++ qemu_file_set_error(f, -EIO); ++ } ++ return ret; + } + + /* +@@ -181,6 +191,10 @@ void qemu_fflush(QEMUFile *f) + return; + } + ++ if (f->shutdown) { ++ return; ++ } ++ + if (f->iovcnt > 0) { + expect = iov_size(f->iov, f->iovcnt); + ret = f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt, f->pos); +@@ -293,6 +307,9 @@ static ssize_t qemu_fill_buffer(QEMUFile *f) + f->buf_index = 0; + f->buf_size = pending; + ++ if (f->shutdown) { ++ return 0; ++ } + len = f->ops->get_buffer(f->opaque, f->buf + pending, f->pos, + IO_BUF_SIZE - pending); + if (len > 0) { +@@ -591,6 +608,9 @@ int64_t qemu_ftell(QEMUFile *f) + + int qemu_file_rate_limit(QEMUFile *f) + { ++ if (f->shutdown) { ++ return 1; ++ } + if (qemu_file_get_error(f)) { + return 1; + } +-- +2.27.0 + -- Gitee From 56eb10bb6213f0f71de844ae2a5235bb5aaafa46 Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Wed, 2 Dec 2020 14:31:07 +0800 Subject: [PATCH 08/15] multifd: Make sure that we don't do any IO after an error Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- ...e-that-we-don-t-do-any-IO-after-an-e.patch | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 multifd-Make-sure-that-we-don-t-do-any-IO-after-an-e.patch diff --git a/multifd-Make-sure-that-we-don-t-do-any-IO-after-an-e.patch b/multifd-Make-sure-that-we-don-t-do-any-IO-after-an-e.patch new file mode 100644 index 00000000..ef380e66 --- /dev/null +++ b/multifd-Make-sure-that-we-don-t-do-any-IO-after-an-e.patch @@ -0,0 +1,62 @@ +From 3db288bbddb730960430fb4907e100f19001ca0a Mon Sep 17 00:00:00 2001 +From: Ying Fang +Date: Wed, 2 Dec 2020 14:31:07 +0800 +Subject: [PATCH] multifd: Make sure that we don't do any IO after an error + +Signed-off-by: Juan Quintela +Reviewed-by: Dr. David Alan Gilbert +--- + migration/ram.c | 22 +++++++++++++--------- + 1 file changed, 13 insertions(+), 9 deletions(-) + +diff --git a/migration/ram.c b/migration/ram.c +index 3ded38c0be..b74929542d 100644 +--- a/migration/ram.c ++++ b/migration/ram.c +@@ -3617,7 +3617,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) + { + RAMState **temp = opaque; + RAMState *rs = *temp; +- int ret; ++ int ret = 0; + int i; + int64_t t0; + int done = 0; +@@ -3686,12 +3686,14 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) + ram_control_after_iterate(f, RAM_CONTROL_ROUND); + + out: +- multifd_send_sync_main(rs); +- qemu_put_be64(f, RAM_SAVE_FLAG_EOS); +- qemu_fflush(f); +- ram_counters.transferred += 8; ++ if (ret >= 0) { ++ multifd_send_sync_main(rs); ++ qemu_put_be64(f, RAM_SAVE_FLAG_EOS); ++ qemu_fflush(f); ++ ram_counters.transferred += 8; + +- ret = qemu_file_get_error(f); ++ ret = qemu_file_get_error(f); ++ } + if (ret < 0) { + return ret; + } +@@ -3745,9 +3747,11 @@ static int ram_save_complete(QEMUFile *f, void *opaque) + + rcu_read_unlock(); + +- multifd_send_sync_main(rs); +- qemu_put_be64(f, RAM_SAVE_FLAG_EOS); +- qemu_fflush(f); ++ if (ret >= 0) { ++ multifd_send_sync_main(rs); ++ qemu_put_be64(f, RAM_SAVE_FLAG_EOS); ++ qemu_fflush(f); ++ } + + return ret; + } +-- +2.27.0 + -- Gitee From 5955b9d9ab1c8bb7ad6135d319bf1aa96ff041dc Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Wed, 22 Jan 2020 11:36:12 +0100 Subject: [PATCH 09/15] migration: Don't send data if we have stopped If we do a cancel, we got out without one error, but we can't do the rest of the output as in a normal situation. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- ...n-Don-t-send-data-if-we-have-stopped.patch | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 migration-Don-t-send-data-if-we-have-stopped.patch diff --git a/migration-Don-t-send-data-if-we-have-stopped.patch b/migration-Don-t-send-data-if-we-have-stopped.patch new file mode 100644 index 00000000..08d5d3bb --- /dev/null +++ b/migration-Don-t-send-data-if-we-have-stopped.patch @@ -0,0 +1,31 @@ +From 855404b4766ddda851035587aa1b84768abbaf11 Mon Sep 17 00:00:00 2001 +From: Juan Quintela +Date: Wed, 22 Jan 2020 11:36:12 +0100 +Subject: [PATCH] migration: Don't send data if we have stopped + +If we do a cancel, we got out without one error, but we can't do the +rest of the output as in a normal situation. + +Signed-off-by: Juan Quintela +Reviewed-by: Dr. David Alan Gilbert +--- + migration/ram.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/migration/ram.c b/migration/ram.c +index b74929542d..dc9831d7f3 100644 +--- a/migration/ram.c ++++ b/migration/ram.c +@@ -3686,7 +3686,8 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) + ram_control_after_iterate(f, RAM_CONTROL_ROUND); + + out: +- if (ret >= 0) { ++ if (ret >= 0 ++ && migration_is_setup_or_active(migrate_get_current()->state)) { + multifd_send_sync_main(rs); + qemu_put_be64(f, RAM_SAVE_FLAG_EOS); + qemu_fflush(f); +-- +2.27.0 + -- Gitee From b536a2b9ad79a3d40b63537c7fbf8edb6ca06572 Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Wed, 2 Dec 2020 14:39:46 +0800 Subject: [PATCH 10/15] migration: Create migration_is_running() This function returns true if we are in the middle of a migration. It is like migration_is_setup_or_active() with CANCELLING and COLO. Adapt all callers that are needed. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration-Create-migration_is_running.patch | 107 ++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 migration-Create-migration_is_running.patch diff --git a/migration-Create-migration_is_running.patch b/migration-Create-migration_is_running.patch new file mode 100644 index 00000000..86f0e6d3 --- /dev/null +++ b/migration-Create-migration_is_running.patch @@ -0,0 +1,107 @@ +From 3d75adce1b9b465c45a9e841d285b3524e19cd7d Mon Sep 17 00:00:00 2001 +From: Ying Fang +Date: Wed, 2 Dec 2020 14:39:46 +0800 +Subject: [PATCH] migration: Create migration_is_running() + +This function returns true if we are in the middle of a migration. +It is like migration_is_setup_or_active() with CANCELLING and COLO. +Adapt all callers that are needed. + +Signed-off-by: Juan Quintela +Reviewed-by: Dr. David Alan Gilbert +--- + migration/migration.c | 28 +++++++++++++++++++++++----- + migration/migration.h | 1 + + migration/savevm.c | 4 +--- + 3 files changed, 25 insertions(+), 8 deletions(-) + +diff --git a/migration/migration.c b/migration/migration.c +index 993d77b7d6..923a1d9d3f 100644 +--- a/migration/migration.c ++++ b/migration/migration.c +@@ -822,6 +822,26 @@ bool migration_is_setup_or_active(int state) + } + } + ++bool migration_is_running(int state) ++{ ++ switch (state) { ++ case MIGRATION_STATUS_ACTIVE: ++ case MIGRATION_STATUS_POSTCOPY_ACTIVE: ++ case MIGRATION_STATUS_POSTCOPY_PAUSED: ++ case MIGRATION_STATUS_POSTCOPY_RECOVER: ++ case MIGRATION_STATUS_SETUP: ++ case MIGRATION_STATUS_PRE_SWITCHOVER: ++ case MIGRATION_STATUS_DEVICE: ++ case MIGRATION_STATUS_CANCELLING: ++ case MIGRATION_STATUS_COLO: ++ return true; ++ ++ default: ++ return false; ++ ++ } ++} ++ + static void populate_ram_info(MigrationInfo *info, MigrationState *s) + { + info->has_ram = true; +@@ -1074,7 +1094,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, + MigrationCapabilityStatusList *cap; + bool cap_list[MIGRATION_CAPABILITY__MAX]; + +- if (migration_is_setup_or_active(s->state)) { ++ if (migration_is_running(s->state)) { + error_setg(errp, QERR_MIGRATION_ACTIVE); + return; + } +@@ -1588,7 +1608,7 @@ static void migrate_fd_cancel(MigrationState *s) + + do { + old_state = s->state; +- if (!migration_is_setup_or_active(old_state)) { ++ if (!migration_is_running(old_state)) { + break; + } + /* If the migration is paused, kick it out of the pause */ +@@ -1873,9 +1893,7 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc, + return true; + } + +- if (migration_is_setup_or_active(s->state) || +- s->state == MIGRATION_STATUS_CANCELLING || +- s->state == MIGRATION_STATUS_COLO) { ++ if (migration_is_running(s->state)) { + error_setg(errp, QERR_MIGRATION_ACTIVE); + return false; + } +diff --git a/migration/migration.h b/migration/migration.h +index e5aaf2ef70..f2bd4ebe33 100644 +--- a/migration/migration.h ++++ b/migration/migration.h +@@ -282,6 +282,7 @@ void migrate_fd_error(MigrationState *s, const Error *error); + void migrate_fd_connect(MigrationState *s, Error *error_in); + + bool migration_is_setup_or_active(int state); ++bool migration_is_running(int state); + + void migrate_init(MigrationState *s); + bool migration_is_blocked(Error **errp); +diff --git a/migration/savevm.c b/migration/savevm.c +index 8163de7f21..f0974380e5 100644 +--- a/migration/savevm.c ++++ b/migration/savevm.c +@@ -1414,9 +1414,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) + MigrationState *ms = migrate_get_current(); + MigrationStatus status; + +- if (migration_is_setup_or_active(ms->state) || +- ms->state == MIGRATION_STATUS_CANCELLING || +- ms->state == MIGRATION_STATUS_COLO) { ++ if (migration_is_running(ms->state)) { + error_setg(errp, QERR_MIGRATION_ACTIVE); + return -EINVAL; + } +-- +2.27.0 + -- Gitee From 990c68bae31f071f7a21dd92875f2ac327138943 Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Wed, 2 Dec 2020 14:43:45 +0800 Subject: [PATCH 11/15] migration: fix COLO broken caused by a previous commit This commit "migration: Create migration_is_running()" broke COLO. Becuase there is a process broken by this commit. colo_process_checkpoint ->colo_do_checkpoint_transaction ->migrate_set_block_enabled ->qmp_migrate_set_capabilities It can be fixed by make COLO process as an exception, Maybe we need a better way to fix it. Cc: Juan Quintela Signed-off-by: zhanghailiang Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- ...LO-broken-caused-by-a-previous-commi.patch | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 migration-fix-COLO-broken-caused-by-a-previous-commi.patch diff --git a/migration-fix-COLO-broken-caused-by-a-previous-commi.patch b/migration-fix-COLO-broken-caused-by-a-previous-commi.patch new file mode 100644 index 00000000..3ac65d9c --- /dev/null +++ b/migration-fix-COLO-broken-caused-by-a-previous-commi.patch @@ -0,0 +1,39 @@ +From c635692b4e75db3f9547f6d4ed9d73d1cdb34989 Mon Sep 17 00:00:00 2001 +From: Ying Fang +Date: Wed, 2 Dec 2020 14:43:45 +0800 +Subject: [PATCH] migration: fix COLO broken caused by a previous commit + +This commit "migration: Create migration_is_running()" broke +COLO. Becuase there is a process broken by this commit. + +colo_process_checkpoint + ->colo_do_checkpoint_transaction + ->migrate_set_block_enabled + ->qmp_migrate_set_capabilities + +It can be fixed by make COLO process as an exception, +Maybe we need a better way to fix it. + +Cc: Juan Quintela +Signed-off-by: zhanghailiang +Reviewed-by: Juan Quintela +Signed-off-by: Juan Quintela +--- + migration/migration.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/migration/migration.c b/migration/migration.c +index 923a1d9d3f..0e396f22b4 100644 +--- a/migration/migration.c ++++ b/migration/migration.c +@@ -833,7 +833,6 @@ bool migration_is_running(int state) + case MIGRATION_STATUS_PRE_SWITCHOVER: + case MIGRATION_STATUS_DEVICE: + case MIGRATION_STATUS_CANCELLING: +- case MIGRATION_STATUS_COLO: + return true; + + default: +-- +2.27.0 + -- Gitee From 9de3a5da8826832458b6e5b1be5fb69d1ee7eccc Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Wed, 2 Dec 2020 14:50:12 +0800 Subject: [PATCH 12/15] migration/multifd: fix hangup with TLS-Multifd due to blocking handshake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The qemu main loop could hang up forever when we enable TLS+Multifd. The Src multifd_send_0 invokes tls handshake, it sends hello to sever and wait response. However, the Dst main qemu loop has been waiting recvmsg() for multifd_recv_1. Both of Src and Dst main qemu loop are blocking and waiting for reponse which results in hanging up forever. Src: (multifd_send_0) Dst: (multifd_recv_1) multifd_channel_connect migration_channel_process_incoming multifd_tls_channel_connect migration_tls_channel_process_incoming multifd_tls_channel_connect qio_channel_tls_handshake_task qio_channel_tls_handshake gnutls_handshake qio_channel_tls_handshake_task ... qcrypto_tls_session_handshake ... gnutls_handshake ... ... ... recvmsg (Blocking I/O waiting for response) recvmsg (Blocking I/O waiting for response) Fix this by offloadinig handshake work to a background thread. Reported-by: Yan Jin Suggested-by: Daniel P. Berrangé Signed-off-by: Chuan Zheng Message-Id: <1604643893-8223-1-git-send-email-zhengchuan@huawei.com> Reviewed-by: Daniel P. Berrangé Signed-off-by: Dr. David Alan Gilbert --- ...d-fix-hangup-with-TLS-Multifd-due-to.patch | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 migration-multifd-fix-hangup-with-TLS-Multifd-due-to.patch diff --git a/migration-multifd-fix-hangup-with-TLS-Multifd-due-to.patch b/migration-multifd-fix-hangup-with-TLS-Multifd-due-to.patch new file mode 100644 index 00000000..021fbcf8 --- /dev/null +++ b/migration-multifd-fix-hangup-with-TLS-Multifd-due-to.patch @@ -0,0 +1,83 @@ +From 26ffadd08711aa4ef62932ac0ecf5048518b2801 Mon Sep 17 00:00:00 2001 +From: Ying Fang +Date: Wed, 2 Dec 2020 14:50:12 +0800 +Subject: [PATCH] migration/multifd: fix hangup with TLS-Multifd due to + blocking handshake +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The qemu main loop could hang up forever when we enable TLS+Multifd. +The Src multifd_send_0 invokes tls handshake, it sends hello to sever +and wait response. +However, the Dst main qemu loop has been waiting recvmsg() for multifd_recv_1. +Both of Src and Dst main qemu loop are blocking and waiting for reponse which +results in hanging up forever. + +Src: (multifd_send_0) Dst: (multifd_recv_1) +multifd_channel_connect migration_channel_process_incoming + multifd_tls_channel_connect migration_tls_channel_process_incoming + multifd_tls_channel_connect qio_channel_tls_handshake_task + qio_channel_tls_handshake gnutls_handshake + qio_channel_tls_handshake_task ... + qcrypto_tls_session_handshake ... + gnutls_handshake ... + ... ... + recvmsg (Blocking I/O waiting for response) recvmsg (Blocking I/O waiting for response) + +Fix this by offloadinig handshake work to a background thread. + +Reported-by: Yan Jin +Suggested-by: Daniel P. Berrangé +Signed-off-by: Chuan Zheng +Message-Id: <1604643893-8223-1-git-send-email-zhengchuan@huawei.com> +Reviewed-by: Daniel P. Berrangé +Signed-off-by: Dr. David Alan Gilbert +--- + migration/ram.c | 23 +++++++++++++++++------ + 1 file changed, 17 insertions(+), 6 deletions(-) + +diff --git a/migration/ram.c b/migration/ram.c +index dc9831d7f3..a37dbfc049 100644 +--- a/migration/ram.c ++++ b/migration/ram.c +@@ -1220,6 +1220,19 @@ static void multifd_tls_outgoing_handshake(QIOTask *task, + multifd_channel_connect(p, ioc, err); + } + ++static void *multifd_tls_handshake_thread(void *opaque) ++{ ++ MultiFDSendParams *p = opaque; ++ QIOChannelTLS *tioc = QIO_CHANNEL_TLS(p->c); ++ ++ qio_channel_tls_handshake(tioc, ++ multifd_tls_outgoing_handshake, ++ p, ++ NULL, ++ NULL); ++ return NULL; ++} ++ + static void multifd_tls_channel_connect(MultiFDSendParams *p, + QIOChannel *ioc, + Error **errp) +@@ -1235,12 +1248,10 @@ static void multifd_tls_channel_connect(MultiFDSendParams *p, + + trace_multifd_tls_outgoing_handshake_start(ioc, tioc, hostname); + qio_channel_set_name(QIO_CHANNEL(tioc), "multifd-tls-outgoing"); +- qio_channel_tls_handshake(tioc, +- multifd_tls_outgoing_handshake, +- p, +- NULL, +- NULL); +- ++ p->c = QIO_CHANNEL(tioc); ++ qemu_thread_create(&p->thread, "multifd-tls-handshake-worker", ++ multifd_tls_handshake_thread, p, ++ QEMU_THREAD_JOINABLE); + } + + static bool multifd_channel_connect(MultiFDSendParams *p, +-- +2.27.0 + -- Gitee From 957b899777dee605e629d8239683789edd09b529 Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Wed, 2 Dec 2020 14:51:51 +0800 Subject: [PATCH 13/15] multifd/tls: fix memoryleak of the QIOChannelSocket object when cancelling migration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When creating new tls client, the tioc->master will be referenced which results in socket leaking after multifd_save_cleanup if we cancel migration. Fix it by do object_unref() after tls client creation. Suggested-by: Daniel P. Berrangé Signed-off-by: Chuan Zheng Message-Id: <1605104763-118687-1-git-send-email-zhengchuan@huawei.com> Reviewed-by: Daniel P. Berrangé Signed-off-by: Dr. David Alan Gilbert --- ...memoryleak-of-the-QIOChannelSocket-o.patch | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 multifd-tls-fix-memoryleak-of-the-QIOChannelSocket-o.patch diff --git a/multifd-tls-fix-memoryleak-of-the-QIOChannelSocket-o.patch b/multifd-tls-fix-memoryleak-of-the-QIOChannelSocket-o.patch new file mode 100644 index 00000000..a2209ef5 --- /dev/null +++ b/multifd-tls-fix-memoryleak-of-the-QIOChannelSocket-o.patch @@ -0,0 +1,37 @@ +From a4288f41b3af9f4f73f162b89007c6928509a43c Mon Sep 17 00:00:00 2001 +From: Ying Fang +Date: Wed, 2 Dec 2020 14:51:51 +0800 +Subject: [PATCH] multifd/tls: fix memoryleak of the QIOChannelSocket object + when cancelling migration +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When creating new tls client, the tioc->master will be referenced which results in socket +leaking after multifd_save_cleanup if we cancel migration. +Fix it by do object_unref() after tls client creation. + +Suggested-by: Daniel P. Berrangé +Signed-off-by: Chuan Zheng +Message-Id: <1605104763-118687-1-git-send-email-zhengchuan@huawei.com> +Reviewed-by: Daniel P. Berrangé +Signed-off-by: Dr. David Alan Gilbert +--- + migration/ram.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/migration/ram.c b/migration/ram.c +index a37dbfc049..92ce1a53e7 100644 +--- a/migration/ram.c ++++ b/migration/ram.c +@@ -1246,6 +1246,7 @@ static void multifd_tls_channel_connect(MultiFDSendParams *p, + return; + } + ++ object_unref(OBJECT(ioc)); + trace_multifd_tls_outgoing_handshake_start(ioc, tioc, hostname); + qio_channel_set_name(QIO_CHANNEL(tioc), "multifd-tls-outgoing"); + p->c = QIO_CHANNEL(tioc); +-- +2.27.0 + -- Gitee From dd0133f54bb75b6c7eab1edf6d49d56719e01582 Mon Sep 17 00:00:00 2001 From: Euler Robot Date: Thu, 3 Dec 2020 21:26:56 +0800 Subject: [PATCH 14/15] spec: Update patch and changelog with !38 migration/tls: save hostname into MigrationState migration/tls: extract migration_tls_client_create for common-use migration/tls: add tls_hostname into MultiFDSendParams migration/tls: extract cleanup function for common-use migration/tls: add support for multifd tls-handshake migration/tls: add trace points for multifd-tls qemu-file: Don't do IO after shutdown multifd: Make sure that we don't do any IO after an error migration: Don't send data if we have stopped migration: Create migration_is_running() migration: fix COLO broken caused by a previous commit migration/multifd: fix hangup with TLS-Multifd due to blocking handshake multifd/tls: fix memoryleak of the QIOChannelSocket object when cancelling migration Signed-off-by: Alex Chen --- qemu.spec | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/qemu.spec b/qemu.spec index 6d30aeb5..0721e446 100644 --- a/qemu.spec +++ b/qemu.spec @@ -264,6 +264,19 @@ Patch0251: migration-dirtyrate-Add-trace_calls-to-make-it-easie.patch Patch0252: migration-dirtyrate-record-start_time-and-calc_time-.patch Patch0253: migration-dirtyrate-present-dirty-rate-only-when-que.patch Patch0254: migration-dirtyrate-simplify-includes-in-dirtyrate.c.patch +Patch0255: migration-tls-save-hostname-into-MigrationState.patch +Patch0256: migration-tls-extract-migration_tls_client_create-fo.patch +Patch0257: migration-tls-add-tls_hostname-into-MultiFDSendParam.patch +Patch0258: migration-tls-extract-cleanup-function-for-common-us.patch +Patch0259: migration-tls-add-support-for-multifd-tls-handshake.patch +Patch0260: migration-tls-add-trace-points-for-multifd-tls.patch +Patch0261: qemu-file-Don-t-do-IO-after-shutdown.patch +Patch0262: multifd-Make-sure-that-we-don-t-do-any-IO-after-an-e.patch +Patch0263: migration-Don-t-send-data-if-we-have-stopped.patch +Patch0264: migration-Create-migration_is_running.patch +Patch0265: migration-fix-COLO-broken-caused-by-a-previous-commi.patch +Patch0266: migration-multifd-fix-hangup-with-TLS-Multifd-due-to.patch +Patch0267: multifd-tls-fix-memoryleak-of-the-QIOChannelSocket-o.patch BuildRequires: flex BuildRequires: bison @@ -610,6 +623,21 @@ getent passwd qemu >/dev/null || \ %endif %changelog +* Wed Dec 2 2020 Huawei Technologies Co., Ltd +- migration/tls: save hostname into MigrationState +- migration/tls: extract migration_tls_client_create for common-use +- migration/tls: add tls_hostname into MultiFDSendParams +- migration/tls: extract cleanup function for common-use +- migration/tls: add support for multifd tls-handshake +- migration/tls: add trace points for multifd-tls +- qemu-file: Don't do IO after shutdown +- multifd: Make sure that we don't do any IO after an error +- migration: Don't send data if we have stopped +- migration: Create migration_is_running() +- migration: fix COLO broken caused by a previous commit +- migration/multifd: fix hangup with TLS-Multifd due to blocking handshake +- multifd/tls: fix memoryleak of the QIOChannelSocket object when cancelling migration + * Fri Oct 30 2020 Huawei Technologies Co., Ltd - migration/dirtyrate: setup up query-dirtyrate framwork - migration/dirtyrate: add DirtyRateStatus to denote calculation status -- Gitee From 0f34d3b4073c44062cc24acc9a96cdfdda060ad4 Mon Sep 17 00:00:00 2001 From: Euler Robot Date: Thu, 3 Dec 2020 21:26:57 +0800 Subject: [PATCH 15/15] spec: Update release version with !38 increase release verison by one Signed-off-by: Euler Robot --- qemu.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu.spec b/qemu.spec index 0721e446..fc83f2aa 100644 --- a/qemu.spec +++ b/qemu.spec @@ -1,6 +1,6 @@ Name: qemu Version: 4.1.0 -Release: 30 +Release: 31 Epoch: 2 Summary: QEMU is a generic and open source machine emulator and virtualizer License: GPLv2 and BSD and MIT and CC-BY -- Gitee