From nobody Fri Oct 24 21:54:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421206368870.1840685522333; Wed, 7 Mar 2018 03:13:26 -0800 (PST) Received: from localhost ([::1]:60794 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etX0f-0007TT-K9 for importer@patchew.org; Wed, 07 Mar 2018 06:13:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoF-0004sq-1h for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWo9-000681-AU for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:35 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34482 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWo8-00064d-UA for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:29 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A86C4067734 for ; Wed, 7 Mar 2018 11:00:19 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 128B9215CDA7; Wed, 7 Mar 2018 11:00:17 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 11:59:47 +0100 Message-Id: <20180307110010.2205-2-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 11:00:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 11:00:19 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 01/24] tests: Add migration precopy test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu --- tests/migration-test.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index 74f9361bdd..65ce3ea4ab 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -513,7 +513,7 @@ static void test_deprecated(void) qtest_quit(from); } =20 -static void test_migrate(void) +static void test_postcopy(void) { char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; @@ -584,6 +584,45 @@ static void test_baddest(void) test_migrate_end(from, to, false); } =20 +static void test_precopy_unix(void) +{ + char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); + QTestState *from, *to; + + test_migrate_start(&from, &to, uri); + + /* We want to pick a speed slow enough that the test completes + * quickly, but that it doesn't complete precopy even on a slow + * machine, so also set the downtime. + */ + /* 1 ms should make it not converge*/ + migrate_set_parameter(from, "downtime-limit", "1"); + /* 1GB/s */ + migrate_set_parameter(from, "max-bandwidth", "1000000000"); + + /* Wait for the first serial output from the source */ + wait_for_serial("src_serial"); + + migrate(from, uri); + + wait_for_migration_pass(from); + + /* 300 ms should converge */ + migrate_set_parameter(from, "downtime-limit", "300"); + + if (!got_stop) { + qtest_qmp_eventwait(from, "STOP"); + } + + qtest_qmp_eventwait(to, "RESUME"); + + wait_for_serial("dest_serial"); + wait_for_migration_complete(from); + + test_migrate_end(from, to, true); + g_free(uri); +} + int main(int argc, char **argv) { char template[] =3D "/tmp/migration-test-XXXXXX"; @@ -603,9 +642,10 @@ int main(int argc, char **argv) =20 module_call_init(MODULE_INIT_QOM); =20 - qtest_add_func("/migration/postcopy/unix", test_migrate); + qtest_add_func("/migration/postcopy/unix", test_postcopy); qtest_add_func("/migration/deprecated", test_deprecated); qtest_add_func("/migration/bad_dest", test_baddest); + qtest_add_func("/migration/precopy/unix", test_precopy_unix); =20 ret =3D g_test_run(); =20 --=20 2.14.3 From nobody Fri Oct 24 21:54:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421337352271.4067554375505; Wed, 7 Mar 2018 03:15:37 -0800 (PST) Received: from localhost ([::1]:60805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etX2k-0001Dw-HM for importer@patchew.org; Wed, 07 Mar 2018 06:15:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoF-0004ss-2J for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWo9-00068A-AS for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:35 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45248 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWo8-00064a-UG for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:29 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 896C8818AAEB for ; Wed, 7 Mar 2018 11:00:20 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 713BE215CDA7; Wed, 7 Mar 2018 11:00:19 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 11:59:48 +0100 Message-Id: <20180307110010.2205-3-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 07 Mar 2018 11:00:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 07 Mar 2018 11:00:20 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 02/24] tests: Add migration xbzrle test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- tests/migration-test.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 64 insertions(+) diff --git a/tests/migration-test.c b/tests/migration-test.c index 65ce3ea4ab..fb67a88353 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -501,6 +501,20 @@ static void deprecated_set_speed(QTestState *who, cons= t char *value) migrate_check_parameter(who, "max-bandwidth", value); } =20 +static void deprecated_set_cache_size(QTestState *who, const char *value) +{ + QDict *rsp; + gchar *cmd; + + cmd =3D g_strdup_printf("{ 'execute': 'migrate-set-cache-size'," + "'arguments': { 'value': %s } }", value); + rsp =3D qtest_qmp(who, cmd); + g_free(cmd); + g_assert(qdict_haskey(rsp, "return")); + QDECREF(rsp); + migrate_check_parameter(who, "xbzrle-cache-size", value); +} + static void test_deprecated(void) { QTestState *from; @@ -509,6 +523,7 @@ static void test_deprecated(void) =20 deprecated_set_downtime(from, 0.12345); deprecated_set_speed(from, "12345"); + deprecated_set_cache_size(from, "4096"); =20 qtest_quit(from); } @@ -623,6 +638,54 @@ static void test_precopy_unix(void) g_free(uri); } =20 +static void test_xbzrle(const char *uri) +{ + QTestState *from, *to; + + test_migrate_start(&from, &to, uri); + + /* We want to pick a speed slow enough that the test completes + * quickly, but that it doesn't complete precopy even on a slow + * machine, so also set the downtime. + */ + /* 1 ms should make it not converge*/ + migrate_set_parameter(from, "downtime-limit", "1"); + /* 1GB/s */ + migrate_set_parameter(from, "max-bandwidth", "1000000000"); + + migrate_set_parameter(from, "xbzrle-cache-size", "33554432"); + + migrate_set_capability(from, "xbzrle", "true"); + migrate_set_capability(to, "xbzrle", "true"); + /* Wait for the first serial output from the source */ + wait_for_serial("src_serial"); + + migrate(from, uri); + + wait_for_migration_pass(from); + + /* 300ms should converge */ + migrate_set_parameter(from, "downtime-limit", "300"); + + if (!got_stop) { + qtest_qmp_eventwait(from, "STOP"); + } + qtest_qmp_eventwait(to, "RESUME"); + + wait_for_serial("dest_serial"); + wait_for_migration_complete(from); + + test_migrate_end(from, to, true); +} + +static void test_xbzrle_unix(void) +{ + char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); + + test_xbzrle(uri); + g_free(uri); +} + int main(int argc, char **argv) { char template[] =3D "/tmp/migration-test-XXXXXX"; @@ -646,6 +709,7 @@ int main(int argc, char **argv) qtest_add_func("/migration/deprecated", test_deprecated); qtest_add_func("/migration/bad_dest", test_baddest); qtest_add_func("/migration/precopy/unix", test_precopy_unix); + qtest_add_func("/migration/xbzrle/unix", test_xbzrle_unix); =20 ret =3D g_test_run(); =20 --=20 2.14.3 From nobody Fri Oct 24 21:54:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520420767117939.1358513177645; Wed, 7 Mar 2018 03:06:07 -0800 (PST) Received: from localhost ([::1]:60754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWta-0000gz-7t for importer@patchew.org; Wed, 07 Mar 2018 06:06:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoH-0004vH-DY for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWo9-00067x-9t for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:37 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44610 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWo8-00064b-U9 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:29 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E84574173BB6 for ; Wed, 7 Mar 2018 11:00:21 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF8A8215CDA7; Wed, 7 Mar 2018 11:00:20 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 11:59:49 +0100 Message-Id: <20180307110010.2205-4-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:21 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 03/24] migration: Create tcp_port parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It will be used to store the uri tcp_port parameter. This is the only parameter than can change and we can need to be able to connect to it. Signed-off-by: Juan Quintela -- This used to be uri parameter, but it has so many troubles to reproduce that it don't just make sense. --- hmp.c | 3 +++ migration/migration.c | 8 ++++++++ qapi/migration.json | 19 ++++++++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/hmp.c b/hmp.c index 016cb5c4f1..b37605d86a 100644 --- a/hmp.c +++ b/hmp.c @@ -355,6 +355,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QD= ict *qdict) monitor_printf(mon, "%s: %" PRIu64 "\n", MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), params->xbzrle_cache_size); + monitor_printf(mon, "%s: %d\n", + MigrationParameter_str(MIGRATION_PARAMETER_X_TCP_PORT), + params->x_tcp_port); } =20 qapi_free_MigrationParameters(params); diff --git a/migration/migration.c b/migration/migration.c index e345d0cc7e..31b16a335b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -545,6 +545,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->x_multifd_page_count =3D s->parameters.x_multifd_page_count; params->has_xbzrle_cache_size =3D true; params->xbzrle_cache_size =3D s->parameters.xbzrle_cache_size; + params->has_x_tcp_port =3D true; + params->x_tcp_port =3D s->parameters.x_tcp_port; =20 return params; } @@ -912,6 +914,9 @@ static void migrate_params_test_apply(MigrateSetParamet= ers *params, if (params->has_xbzrle_cache_size) { dest->xbzrle_cache_size =3D params->xbzrle_cache_size; } + if (params->has_x_tcp_port) { + dest->x_tcp_port =3D params->x_tcp_port; + } } =20 static void migrate_params_apply(MigrateSetParameters *params, Error **err= p) @@ -984,6 +989,9 @@ static void migrate_params_apply(MigrateSetParameters *= params, Error **errp) s->parameters.xbzrle_cache_size =3D params->xbzrle_cache_size; xbzrle_cache_resize(params->xbzrle_cache_size, errp); } + if (params->has_x_tcp_port) { + s->parameters.x_tcp_port =3D params->x_tcp_port; + } } =20 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) diff --git a/qapi/migration.json b/qapi/migration.json index 7f465a1902..b6ef193f47 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -490,6 +490,9 @@ # and a power of 2 # (Since 2.11) # +# @x-tcp-port: Only used for tcp, to know what the real port is +# (Since 2.12) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', @@ -498,7 +501,7 @@ 'tls-creds', 'tls-hostname', 'max-bandwidth', 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', 'x-multifd-channels', 'x-multifd-page-count', - 'xbzrle-cache-size' ] } + 'xbzrle-cache-size', 'x-tcp-port' ] } =20 ## # @MigrateSetParameters: @@ -566,6 +569,10 @@ # needs to be a multiple of the target page size # and a power of 2 # (Since 2.11) +# +# @x-tcp-port: Only used for tcp, to know what the real port is +# (Since 2.12) +# # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make @@ -584,7 +591,8 @@ '*block-incremental': 'bool', '*x-multifd-channels': 'int', '*x-multifd-page-count': 'int', - '*xbzrle-cache-size': 'size' } } + '*xbzrle-cache-size': 'size', + '*x-tcp-port': 'uint16'} } =20 ## # @migrate-set-parameters: @@ -667,6 +675,10 @@ # needs to be a multiple of the target page size # and a power of 2 # (Since 2.11) +# +# @x-tcp-port: Only used for tcp, to know what the real port is +# (Since 2.12) +# # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -683,7 +695,8 @@ '*block-incremental': 'bool' , '*x-multifd-channels': 'uint8', '*x-multifd-page-count': 'uint32', - '*xbzrle-cache-size': 'size' } } + '*xbzrle-cache-size': 'size', + '*x-tcp-port': 'uint16'} } =20 ## # @query-migrate-parameters: --=20 2.14.3 From nobody Fri Oct 24 21:54:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520420587946994.3027390573573; Wed, 7 Mar 2018 03:03:07 -0800 (PST) Received: from localhost ([::1]:60737 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWqb-0006Hl-DY for importer@patchew.org; Wed, 07 Mar 2018 06:03:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoE-0004sj-Eq for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWo9-00068X-Fr for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:34 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44614 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWo9-000653-9S for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:29 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 52A1A4173D27 for ; Wed, 7 Mar 2018 11:00:23 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A746215CDA7; Wed, 7 Mar 2018 11:00:22 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 11:59:50 +0100 Message-Id: <20180307110010.2205-5-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:23 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 04/24] migration: Set the migration tcp port X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We can set the port parameter as zero. This patch lets us know what port the system was choosen for us. Now we can migrate to this place. Signed-off-by: Juan Quintela -- This was migrate_set_uri(), but as we only need the tcp_port, change to that one. --- migration/migration.c | 10 ++++++++++ migration/migration.h | 2 ++ migration/socket.c | 35 ++++++++++++++++++++++++++++++----- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 31b16a335b..c398665de7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -268,6 +268,16 @@ int migrate_send_rp_req_pages(MigrationIncomingState *= mis, const char *rbname, return migrate_send_rp_message(mis, msg_type, msglen, bufc); } =20 +void migrate_set_port(const uint16_t port, Error **errp) +{ + MigrateSetParameters p =3D { + .has_x_tcp_port =3D true, + .x_tcp_port =3D port, + }; + + qmp_migrate_set_parameters(&p, errp); +} + void qemu_start_incoming_migration(const char *uri, Error **errp) { const char *p; diff --git a/migration/migration.h b/migration/migration.h index 08c5d2ded1..f40014cf94 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -234,4 +234,6 @@ void migrate_send_rp_pong(MigrationIncomingState *mis, int migrate_send_rp_req_pages(MigrationIncomingState *mis, const char* rbn= ame, ram_addr_t start, size_t len); =20 +void migrate_set_port(const uint16_t port, Error **errp); + #endif diff --git a/migration/socket.c b/migration/socket.c index e090097077..08606c665d 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -15,6 +15,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" =20 #include "qemu-common.h" #include "qemu/error-report.h" @@ -160,17 +161,24 @@ out: } =20 =20 -static void socket_start_incoming_migration(SocketAddress *saddr, - Error **errp) +static SocketAddress *socket_start_incoming_migration(SocketAddress *saddr, + Error **errp) { QIOChannelSocket *listen_ioc =3D qio_channel_socket_new(); + SocketAddress *address; =20 qio_channel_set_name(QIO_CHANNEL(listen_ioc), "migration-socket-listener"); =20 if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) { object_unref(OBJECT(listen_ioc)); - return; + return NULL; + } + + address =3D qio_channel_socket_get_local_address(listen_ioc, errp); + if (address < 0) { + object_unref(OBJECT(listen_ioc)); + return NULL; } =20 qio_channel_add_watch(QIO_CHANNEL(listen_ioc), @@ -178,14 +186,28 @@ static void socket_start_incoming_migration(SocketAdd= ress *saddr, socket_accept_incoming_migration, listen_ioc, (GDestroyNotify)object_unref); + return address; } =20 void tcp_start_incoming_migration(const char *host_port, Error **errp) { Error *err =3D NULL; SocketAddress *saddr =3D tcp_build_address(host_port, &err); + if (!err) { - socket_start_incoming_migration(saddr, &err); + SocketAddress *address =3D socket_start_incoming_migration(saddr, = &err); + + if (address) { + unsigned long long port; + + if (parse_uint_full(address->u.inet.port, &port, 10) < 0) { + error_setg(errp, "error parsing port in '%s'", + address->u.inet.port); + } else { + migrate_set_port(port, errp); + } + qapi_free_SocketAddress(address); + } } qapi_free_SocketAddress(saddr); error_propagate(errp, err); @@ -194,6 +216,9 @@ void tcp_start_incoming_migration(const char *host_port= , Error **errp) void unix_start_incoming_migration(const char *path, Error **errp) { SocketAddress *saddr =3D unix_build_address(path); - socket_start_incoming_migration(saddr, errp); + SocketAddress *address; + + address =3D socket_start_incoming_migration(saddr, errp); + qapi_free_SocketAddress(address); qapi_free_SocketAddress(saddr); } --=20 2.14.3 From nobody Fri Oct 24 21:54:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520420761293816.6968397314479; Wed, 7 Mar 2018 03:06:01 -0800 (PST) Received: from localhost ([::1]:60753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWtU-0000bl-GH for importer@patchew.org; Wed, 07 Mar 2018 06:06:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoC-0004sR-Aw for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoA-000694-5s for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:32 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44616 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoA-00065t-0J for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:30 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B18CB4173D2C for ; Wed, 7 Mar 2018 11:00:24 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9856B215CDA7; Wed, 7 Mar 2018 11:00:23 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 11:59:51 +0100 Message-Id: <20180307110010.2205-6-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:24 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 05/24] tests: Migration ppc now inlines its program X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" No need to write it to a file. Just need a proper firmware O:-) Signed-off-by: Juan Quintela CC: Laurent Vivier --- tests/migration-test.c | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index fb67a88353..a8db55ef83 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -19,9 +19,6 @@ #include "qemu/sockets.h" #include "chardev/char.h" #include "sysemu/sysemu.h" -#include "hw/nvram/chrp_nvram.h" - -#define MIN_NVRAM_SIZE 8192 /* from spapr_nvram.c */ =20 const unsigned start_address =3D 1024 * 1024; const unsigned end_address =3D 100 * 1024 * 1024; @@ -90,36 +87,6 @@ static void init_bootfile_x86(const char *bootpath) fclose(bootfile); } =20 -static void init_bootfile_ppc(const char *bootpath) -{ - FILE *bootfile; - char buf[MIN_NVRAM_SIZE]; - ChrpNvramPartHdr *header =3D (ChrpNvramPartHdr *)buf; - - memset(buf, 0, MIN_NVRAM_SIZE); - - /* Create a "common" partition in nvram to store boot-command property= */ - - header->signature =3D CHRP_NVPART_SYSTEM; - memcpy(header->name, "common", 6); - chrp_nvram_finish_partition(header, MIN_NVRAM_SIZE); - - /* FW_MAX_SIZE is 4MB, but slof.bin is only 900KB, - * so let's modify memory between 1MB and 100MB - * to do like PC bootsector - */ - - sprintf(buf + 16, - "boot-command=3Dhex .\" _\" begin %x %x do i c@ 1 + i c! 1000 = +loop " - ".\" B\" 0 until", end_address, start_address); - - /* Write partition to the NVRAM file */ - - bootfile =3D fopen(bootpath, "wb"); - g_assert_cmpint(fwrite(buf, MIN_NVRAM_SIZE, 1, bootfile), =3D=3D, 1); - fclose(bootfile); -} - /* * Wait for some output in the serial output file, * we get an 'A' followed by an endless string of 'B's @@ -410,12 +377,14 @@ static void test_migrate_start(QTestState **from, QTe= stState **to, if (access("/sys/module/kvm_hv", F_OK)) { accel =3D "tcg"; } - init_bootfile_ppc(bootpath); cmd_src =3D g_strdup_printf("-machine accel=3D%s -m 256M" " -name source,debug-threads=3Don" " -serial file:%s/src_serial" - " -drive file=3D%s,if=3Dpflash,format=3D= raw", - accel, tmpfs, bootpath); + " -prom-env '" + "boot-command=3Dhex .\" _\" begin %x %x " + "do i c@ 1 + i c! 1000 +loop .\" B\" 0 " + "until'", accel, tmpfs, end_address, + start_address); cmd_dst =3D g_strdup_printf("-machine accel=3D%s -m 256M" " -name target,debug-threads=3Don" " -serial file:%s/dest_serial" --=20 2.14.3 From nobody Fri Oct 24 21:54:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520420651172921.7597587451894; Wed, 7 Mar 2018 03:04:11 -0800 (PST) Received: from localhost ([::1]:60739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWri-0007TQ-DC for importer@patchew.org; Wed, 07 Mar 2018 06:04:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59631) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoF-0004t9-EP for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWo9-00068T-Eq for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:35 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36512 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWo9-00066b-9Y for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:29 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C6B7D144C for ; Wed, 7 Mar 2018 11:00:26 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04426215CDA7; Wed, 7 Mar 2018 11:00:24 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 11:59:52 +0100 Message-Id: <20180307110010.2205-7-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:26 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 06/24] tests: Add basic migration precopy tcp test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Not sharing code from precopy/unix because we have to read back the tcp parameter. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu --- tests/migration-test.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++= +--- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index a8db55ef83..6b718bb5dd 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -277,8 +277,7 @@ static void cleanup(const char *filename) g_free(path); } =20 -static void migrate_check_parameter(QTestState *who, const char *parameter, - const char *value) +static char *migrate_get_parameter(QTestState *who, const char *parameter) { QDict *rsp, *rsp_return; char *result; @@ -287,9 +286,18 @@ static void migrate_check_parameter(QTestState *who, c= onst char *parameter, rsp_return =3D qdict_get_qdict(rsp, "return"); result =3D g_strdup_printf("%" PRId64, qdict_get_try_int(rsp_return, parameter, -1)= ); + QDECREF(rsp); + return result; +} + +static void migrate_check_parameter(QTestState *who, const char *parameter, + const char *value) +{ + char *result; + + result =3D migrate_get_parameter(who, parameter); g_assert_cmpstr(result, =3D=3D, value); g_free(result); - QDECREF(rsp); } =20 static void migrate_set_parameter(QTestState *who, const char *parameter, @@ -655,6 +663,49 @@ static void test_xbzrle_unix(void) g_free(uri); } =20 +static void test_precopy_tcp(void) +{ + char *uri; + char *port; + QTestState *from, *to; + + test_migrate_start(&from, &to, "tcp:127.0.0.1:0"); + + /* We want to pick a speed slow enough that the test completes + * quickly, but that it doesn't complete precopy even on a slow + * machine, so also set the downtime. + */ + /* 1 ms should make it not converge*/ + migrate_set_parameter(from, "downtime-limit", "1"); + /* 1GB/s */ + migrate_set_parameter(from, "max-bandwidth", "1000000000"); + + /* Wait for the first serial output from the source */ + wait_for_serial("src_serial"); + + port =3D migrate_get_parameter(to, "x-tcp-port"); + uri =3D g_strdup_printf("tcp:127.0.0.1:%s", port); + + migrate(from, uri); + + wait_for_migration_pass(from); + + /* 300ms should converge */ + migrate_set_parameter(from, "downtime-limit", "300"); + + if (!got_stop) { + qtest_qmp_eventwait(from, "STOP"); + } + qtest_qmp_eventwait(to, "RESUME"); + + wait_for_serial("dest_serial"); + wait_for_migration_complete(from); + + test_migrate_end(from, to, true); + g_free(uri); + g_free(port); +} + int main(int argc, char **argv) { char template[] =3D "/tmp/migration-test-XXXXXX"; @@ -678,6 +729,7 @@ int main(int argc, char **argv) qtest_add_func("/migration/deprecated", test_deprecated); qtest_add_func("/migration/bad_dest", test_baddest); qtest_add_func("/migration/precopy/unix", test_precopy_unix); + qtest_add_func("/migration/precopy/tcp", test_precopy_tcp); qtest_add_func("/migration/xbzrle/unix", test_xbzrle_unix); =20 ret =3D g_test_run(); --=20 2.14.3 From nobody Fri Oct 24 21:54:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520420942763326.0365479431704; Wed, 7 Mar 2018 03:09:02 -0800 (PST) Received: from localhost ([::1]:60766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWwJ-0003Br-BG for importer@patchew.org; Wed, 07 Mar 2018 06:08:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoD-0004sb-Dz for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWo9-00068N-Dl for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:33 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34484 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWo9-00067C-9X for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:29 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A8A84023B98 for ; Wed, 7 Mar 2018 11:00:27 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6227E215CDA7; Wed, 7 Mar 2018 11:00:26 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 11:59:53 +0100 Message-Id: <20180307110010.2205-8-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 11:00:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 11:00:27 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 07/24] [RFH] tests: Add migration compress threads tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Yeap, it is still not working. trying to learn how to debug threads for guests running from the testt hardness. For some reason, compression is not working at the moment, test is disabled until I found why. Signed-off-by: Juan Quintela --- tests/migration-test.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 52 insertions(+) diff --git a/tests/migration-test.c b/tests/migration-test.c index 6b718bb5dd..6f9b4c8d7a 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -706,6 +706,55 @@ static void test_precopy_tcp(void) g_free(port); } =20 +static void test_compress(const char *uri) +{ + QTestState *from, *to; + + test_migrate_start(&from, &to, uri); + + /* We want to pick a speed slow enough that the test completes + * quickly, but that it doesn't complete precopy even on a slow + * machine, so also set the downtime. + */ + /* 1 ms should make it not converge*/ + migrate_set_parameter(from, "downtime-limit", "1"); + /* 1GB/s */ + migrate_set_parameter(from, "max-bandwidth", "1000000000"); + + migrate_set_parameter(from, "compress-threads", "4"); + migrate_set_parameter(to, "decompress-threads", "3"); + + migrate_set_capability(from, "compress", "true"); + migrate_set_capability(to, "compress", "true"); + /* Wait for the first serial output from the source */ + wait_for_serial("src_serial"); + + migrate(from, uri); + + wait_for_migration_pass(from); + + /* 300ms should converge */ + migrate_set_parameter(from, "downtime-limit", "300"); + + if (!got_stop) { + qtest_qmp_eventwait(from, "STOP"); + } + qtest_qmp_eventwait(to, "RESUME"); + + wait_for_serial("dest_serial"); + wait_for_migration_complete(from); + + test_migrate_end(from, to, true); +} + +static void test_compress_unix(void) +{ + char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); + + test_compress(uri); + g_free(uri); +} + int main(int argc, char **argv) { char template[] =3D "/tmp/migration-test-XXXXXX"; @@ -731,6 +780,9 @@ int main(int argc, char **argv) qtest_add_func("/migration/precopy/unix", test_precopy_unix); qtest_add_func("/migration/precopy/tcp", test_precopy_tcp); qtest_add_func("/migration/xbzrle/unix", test_xbzrle_unix); + if (0) { + qtest_add_func("/migration/compress/unix", test_compress_unix); + } =20 ret =3D g_test_run(); =20 --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520420938892140.50273062093174; Wed, 7 Mar 2018 03:08:58 -0800 (PST) Received: from localhost ([::1]:60765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWwC-000328-A6 for importer@patchew.org; Wed, 07 Mar 2018 06:08:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoE-0004sl-N3 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWo9-00068t-Rh for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:34 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36516 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWo9-00067m-Fk for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:29 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E4EA338375 for ; Wed, 7 Mar 2018 11:00:28 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id C140E215CDA7; Wed, 7 Mar 2018 11:00:27 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 11:59:54 +0100 Message-Id: <20180307110010.2205-9-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:28 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 08/24] migration: Add multifd test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We set the x-multifd-page-count and x-multifd-channels. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- tests/migration-test.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 50 insertions(+) diff --git a/tests/migration-test.c b/tests/migration-test.c index 6f9b4c8d7a..97d35f979d 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -755,6 +755,55 @@ static void test_compress_unix(void) g_free(uri); } =20 +static void test_multifd_tcp(void) +{ + char *uri; + char *port; + QTestState *from, *to; + + test_migrate_start(&from, &to, "tcp:127.0.0.1:0"); + + /* We want to pick a speed slow enough that the test completes + * quickly, but that it doesn't complete precopy even on a slow + * machine, so also set the downtime. + */ + /* 1 ms should make it not converge*/ + migrate_set_parameter(from, "downtime-limit", "1"); + /* 1GB/s */ + migrate_set_parameter(from, "max-bandwidth", "1000000000"); + + migrate_set_parameter(from, "x-multifd-channels", "4"); + migrate_set_parameter(to, "x-multifd-channels", "4"); + + migrate_set_parameter(from, "x-multifd-page-count", "64"); + migrate_set_parameter(to, "x-multifd-page-count", "64"); + + migrate_set_capability(from, "x-multifd", "true"); + migrate_set_capability(to, "x-multifd", "true"); + /* Wait for the first serial output from the source */ + wait_for_serial("src_serial"); + + port =3D migrate_get_parameter(to, "x-tcp-port"); + uri =3D g_strdup_printf("tcp:127.0.0.1:%s", port); + + migrate(from, uri); + + wait_for_migration_pass(from); + + /* 300ms it should converge */ + migrate_set_parameter(from, "downtime-limit", "300"); + + if (!got_stop) { + qtest_qmp_eventwait(from, "STOP"); + } + qtest_qmp_eventwait(to, "RESUME"); + + wait_for_serial("dest_serial"); + wait_for_migration_complete(from); + + test_migrate_end(from, to, true); +} + int main(int argc, char **argv) { char template[] =3D "/tmp/migration-test-XXXXXX"; @@ -783,6 +832,7 @@ int main(int argc, char **argv) if (0) { qtest_add_func("/migration/compress/unix", test_compress_unix); } + qtest_add_func("/migration/multifd/tcp", test_multifd_tcp); =20 ret =3D g_test_run(); =20 --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520420583249813.7861302696411; Wed, 7 Mar 2018 03:03:03 -0800 (PST) Received: from localhost ([::1]:60736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWqT-0006D2-5o for importer@patchew.org; Wed, 07 Mar 2018 06:02:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59570) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoC-0004sS-Ay for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoB-00069a-52 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:32 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44642 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoB-00069G-14 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:31 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4F308EBFE6 for ; Wed, 7 Mar 2018 11:00:30 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37256215CDA7; Wed, 7 Mar 2018 11:00:29 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 11:59:55 +0100 Message-Id: <20180307110010.2205-10-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 07 Mar 2018 11:00:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 07 Mar 2018 11:00:30 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 09/24] migration: Set error state in case of error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela --- migration/ram.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 3b6c077964..4a56a85d53 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -414,6 +414,16 @@ static void terminate_multifd_send_threads(Error *errp) { int i; =20 + if (errp) { + MigrationState *s =3D migrate_get_current(); + migrate_set_error(s, errp); + if (s->state =3D=3D MIGRATION_STATUS_SETUP || + s->state =3D=3D MIGRATION_STATUS_ACTIVE) { + migrate_set_state(&s->state, s->state, + MIGRATION_STATUS_FAILED); + } + } + for (i =3D 0; i < multifd_send_state->count; i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; =20 @@ -514,6 +524,16 @@ static void terminate_multifd_recv_threads(Error *errp) { int i; =20 + if (errp) { + MigrationState *s =3D migrate_get_current(); + migrate_set_error(s, errp); + if (s->state =3D=3D MIGRATION_STATUS_SETUP || + s->state =3D=3D MIGRATION_STATUS_ACTIVE) { + migrate_set_state(&s->state, s->state, + MIGRATION_STATUS_FAILED); + } + } + for (i =3D 0; i < multifd_recv_state->count; i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421077978435.4526428769407; Wed, 7 Mar 2018 03:11:17 -0800 (PST) Received: from localhost ([::1]:60786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWyb-0005iU-77 for importer@patchew.org; Wed, 07 Mar 2018 06:11:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoG-0004uD-EZ for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoC-0006AJ-C3 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:36 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34490 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoC-00069w-8g for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:32 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C2ABB4023B98 for ; Wed, 7 Mar 2018 11:00:31 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 960EE215CDA7; Wed, 7 Mar 2018 11:00:30 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 11:59:56 +0100 Message-Id: <20180307110010.2205-11-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 11:00:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 11:00:31 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 10/24] migration: In case of error just end the migration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Daniel P. Berrang=C3=A9 --- migration/socket.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/migration/socket.c b/migration/socket.c index 08606c665d..b12b0a462e 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -139,9 +139,8 @@ static gboolean socket_accept_incoming_migration(QIOCha= nnel *ioc, sioc =3D qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc), &err); if (!sioc) { - error_report("could not accept migration connection (%s)", - error_get_pretty(err)); - goto out; + migrate_set_error(migrate_get_current(), err); + return G_SOURCE_REMOVE; } =20 trace_migration_socket_incoming_accepted(); @@ -150,7 +149,6 @@ static gboolean socket_accept_incoming_migration(QIOCha= nnel *ioc, migration_channel_process_incoming(QIO_CHANNEL(sioc)); object_unref(OBJECT(sioc)); =20 -out: if (migration_has_all_channels()) { /* Close listening socket as its no longer needed */ qio_channel_close(ioc, NULL); --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421073373875.1857895049375; Wed, 7 Mar 2018 03:11:13 -0800 (PST) Received: from localhost ([::1]:60785 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWyW-0005dy-J9 for importer@patchew.org; Wed, 07 Mar 2018 06:11:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoE-0004sm-S1 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoD-0006BU-QY for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:34 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44646 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoD-0006B1-Lt for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:33 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2F364EBFE6 for ; Wed, 7 Mar 2018 11:00:33 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15859215CDA7; Wed, 7 Mar 2018 11:00:31 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 11:59:57 +0100 Message-Id: <20180307110010.2205-12-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 07 Mar 2018 11:00:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 07 Mar 2018 11:00:33 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 11/24] migration: terminate_* can be called for other threads X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Once there, make count field to always be accessed with atomic operations. To make blocking operations, we need to know that the thread is running, so create a bool to indicate that. Signed-off-by: Juan Quintela --- migration/ram.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 4a56a85d53..977e675f46 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -400,6 +400,7 @@ struct MultiFDSendParams { QemuThread thread; QemuSemaphore sem; QemuMutex mutex; + bool running; bool quit; }; typedef struct MultiFDSendParams MultiFDSendParams; @@ -424,7 +425,7 @@ static void terminate_multifd_send_threads(Error *errp) } } =20 - for (i =3D 0; i < multifd_send_state->count; i++) { + for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; =20 qemu_mutex_lock(&p->mutex); @@ -443,10 +444,13 @@ int multifd_save_cleanup(Error **errp) return 0; } terminate_multifd_send_threads(NULL); - for (i =3D 0; i < multifd_send_state->count; i++) { + for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; =20 - qemu_thread_join(&p->thread); + if (p->running) { + qemu_thread_join(&p->thread); + p->running =3D false; + } qemu_mutex_destroy(&p->mutex); qemu_sem_destroy(&p->sem); g_free(p->name); @@ -487,7 +491,7 @@ int multifd_save_setup(void) thread_count =3D migrate_multifd_channels(); multifd_send_state =3D g_malloc0(sizeof(*multifd_send_state)); multifd_send_state->params =3D g_new0(MultiFDSendParams, thread_count); - multifd_send_state->count =3D 0; + atomic_set(&multifd_send_state->count, 0); for (i =3D 0; i < thread_count; i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; =20 @@ -496,10 +500,11 @@ int multifd_save_setup(void) p->quit =3D false; p->id =3D i; p->name =3D g_strdup_printf("multifdsend_%d", i); + p->running =3D true; qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, QEMU_THREAD_JOINABLE); =20 - multifd_send_state->count++; + atomic_inc(&multifd_send_state->count); } return 0; } @@ -510,6 +515,7 @@ struct MultiFDRecvParams { QemuThread thread; QemuSemaphore sem; QemuMutex mutex; + bool running; bool quit; }; typedef struct MultiFDRecvParams MultiFDRecvParams; @@ -534,7 +540,7 @@ static void terminate_multifd_recv_threads(Error *errp) } } =20 - for (i =3D 0; i < multifd_recv_state->count; i++) { + for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 qemu_mutex_lock(&p->mutex); @@ -553,10 +559,13 @@ int multifd_load_cleanup(Error **errp) return 0; } terminate_multifd_recv_threads(NULL); - for (i =3D 0; i < multifd_recv_state->count; i++) { + for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 - qemu_thread_join(&p->thread); + if (p->running) { + qemu_thread_join(&p->thread); + p->running =3D false; + } qemu_mutex_destroy(&p->mutex); qemu_sem_destroy(&p->sem); g_free(p->name); @@ -598,7 +607,7 @@ int multifd_load_setup(void) thread_count =3D migrate_multifd_channels(); multifd_recv_state =3D g_malloc0(sizeof(*multifd_recv_state)); multifd_recv_state->params =3D g_new0(MultiFDRecvParams, thread_count); - multifd_recv_state->count =3D 0; + atomic_set(&multifd_recv_state->count, 0); for (i =3D 0; i < thread_count; i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 @@ -607,9 +616,10 @@ int multifd_load_setup(void) p->quit =3D false; p->id =3D i; p->name =3D g_strdup_printf("multifdrecv_%d", i); + p->running =3D true; qemu_thread_create(&p->thread, p->name, multifd_recv_thread, p, QEMU_THREAD_JOINABLE); - multifd_recv_state->count++; + atomic_inc(&multifd_recv_state->count); } return 0; } --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520420585090755.2335578126712; Wed, 7 Mar 2018 03:03:05 -0800 (PST) Received: from localhost ([::1]:60738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWqe-0006K4-Bn for importer@patchew.org; Wed, 07 Mar 2018 06:03:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoG-0004tk-3U for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoF-0006CV-5x for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:36 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44648 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoF-0006C5-1e for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:35 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E92AEBFE6 for ; Wed, 7 Mar 2018 11:00:34 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75D70215CDA7; Wed, 7 Mar 2018 11:00:33 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 11:59:58 +0100 Message-Id: <20180307110010.2205-13-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 07 Mar 2018 11:00:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 07 Mar 2018 11:00:34 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 12/24] migration: Reference counting recv channels correctly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela --- migration/socket.c | 11 +++++++++++ migration/socket.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/migration/socket.c b/migration/socket.c index b12b0a462e..26110739cf 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -27,6 +27,17 @@ #include "io/channel-socket.h" #include "trace.h" =20 +int socket_recv_channel_ref(QIOChannel *recv) +{ + object_ref(OBJECT(recv)); + return 0; +} + +int socket_recv_channel_unref(QIOChannel *recv) +{ + object_unref(OBJECT(recv)); + return 0; +} =20 static SocketAddress *tcp_build_address(const char *host_port, Error **err= p) { diff --git a/migration/socket.h b/migration/socket.h index 6b91e9db38..638a85255a 100644 --- a/migration/socket.h +++ b/migration/socket.h @@ -16,6 +16,13 @@ =20 #ifndef QEMU_MIGRATION_SOCKET_H #define QEMU_MIGRATION_SOCKET_H + +#include "io/channel.h" +#include "io/task.h" + +int socket_recv_channel_ref(QIOChannel *recv); +int socket_recv_channel_unref(QIOChannel *recv); + void tcp_start_incoming_migration(const char *host_port, Error **errp); =20 void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421208874501.74568051958147; Wed, 7 Mar 2018 03:13:28 -0800 (PST) Received: from localhost ([::1]:60795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etX0i-0007YL-4D for importer@patchew.org; Wed, 07 Mar 2018 06:13:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoK-0004yR-Kb for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoG-0006Dx-S7 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:40 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36520 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoG-0006Dc-NL for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:36 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F1C0D142B for ; Wed, 7 Mar 2018 11:00:36 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6F04215CDA7; Wed, 7 Mar 2018 11:00:34 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 11:59:59 +0100 Message-Id: <20180307110010.2205-14-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:36 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 13/24] migration: Introduce multifd_recv_new_channel() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela --- migration/migration.c | 3 ++- migration/ram.c | 6 ++++++ migration/ram.h | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index c398665de7..919343232e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -448,8 +448,9 @@ void migration_ioc_process_incoming(QIOChannel *ioc) if (!mis->from_src_file) { QEMUFile *f =3D qemu_fopen_channel_input(ioc); migration_fd_process_incoming(f); + return; } - /* We still only have a single channel. Nothing to do here yet */ + multifd_recv_new_channel(ioc); } =20 /** diff --git a/migration/ram.c b/migration/ram.c index 977e675f46..f48c74585f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -36,6 +36,7 @@ #include "xbzrle.h" #include "ram.h" #include "migration.h" +#include "socket.h" #include "migration/register.h" #include "migration/misc.h" #include "qemu-file.h" @@ -624,6 +625,11 @@ int multifd_load_setup(void) return 0; } =20 +void multifd_recv_new_channel(QIOChannel *ioc) +{ + /* nothing to do yet */ +} + /** * save_page_header: write page header to wire * diff --git a/migration/ram.h b/migration/ram.h index 53f0021c51..a2031acf59 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -32,6 +32,7 @@ #include "qemu-common.h" #include "qapi/qapi-types-migration.h" #include "exec/cpu-common.h" +#include "io/channel.h" =20 extern MigrationStats ram_counters; extern XBZRLECacheStats xbzrle_counters; @@ -44,6 +45,7 @@ int multifd_save_setup(void); int multifd_save_cleanup(Error **errp); int multifd_load_setup(void); int multifd_load_cleanup(Error **errp); +void multifd_recv_new_channel(QIOChannel *ioc); =20 uint64_t ram_pagesize_summary(void); int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t = len); --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520420825783571.1321519895298; Wed, 7 Mar 2018 03:07:05 -0800 (PST) Received: from localhost ([::1]:60756 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWuW-0001ZD-U8 for importer@patchew.org; Wed, 07 Mar 2018 06:07:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoL-0004zD-8K for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoI-0006F7-8A for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:41 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44632 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoI-0006Em-3r for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:38 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9DC72404084A for ; Wed, 7 Mar 2018 11:00:37 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 866DB215CDA7; Wed, 7 Mar 2018 11:00:36 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 12:00:00 +0100 Message-Id: <20180307110010.2205-15-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:37 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 14/24] migration: Be sure all recv channels are created X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We need them before we start migration. Signed-off-by: Juan Quintela --- migration/migration.c | 6 +++++- migration/ram.c | 11 +++++++++++ migration/ram.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 919343232e..c06c34ca0f 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -461,7 +461,11 @@ void migration_ioc_process_incoming(QIOChannel *ioc) */ bool migration_has_all_channels(void) { - return true; + bool all_channels; + + all_channels =3D multifd_recv_all_channels_created(); + + return all_channels; } =20 /* diff --git a/migration/ram.c b/migration/ram.c index f48c74585f..e502be5dda 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -625,6 +625,17 @@ int multifd_load_setup(void) return 0; } =20 +bool multifd_recv_all_channels_created(void) +{ + int thread_count =3D migrate_multifd_channels(); + + if (!migrate_use_multifd()) { + return true; + } + + return thread_count =3D=3D atomic_read(&multifd_recv_state->count); +} + void multifd_recv_new_channel(QIOChannel *ioc) { /* nothing to do yet */ diff --git a/migration/ram.h b/migration/ram.h index a2031acf59..3daf074bcc 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -45,6 +45,7 @@ int multifd_save_setup(void); int multifd_save_cleanup(Error **errp); int multifd_load_setup(void); int multifd_load_cleanup(Error **errp); +bool multifd_recv_all_channels_created(void); void multifd_recv_new_channel(QIOChannel *ioc); =20 uint64_t ram_pagesize_summary(void); --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421491624904.9234374913352; Wed, 7 Mar 2018 03:18:11 -0800 (PST) Received: from localhost ([::1]:60823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etX5G-0003AL-M4 for importer@patchew.org; Wed, 07 Mar 2018 06:18:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoP-000543-QG for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoJ-0006Fu-Lq for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:45 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44634 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoJ-0006Fi-Gz for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:39 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 07F4F404084A for ; Wed, 7 Mar 2018 11:00:39 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id E46E5215CDA7; Wed, 7 Mar 2018 11:00:37 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 12:00:01 +0100 Message-Id: <20180307110010.2205-16-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:39 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 15/24] migration: Synchronize send threads X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We synchronize all threads each RAM_SAVE_FLAG_EOS. Bitmap synchronizations don't happen inside a ram section, so we are safe about two channels trying to overwrite the same memory. Signed-off-by: Juan Quintela --- migration/ram.c | 38 +++++++++++++++++++++++++++++++++++++- migration/trace-events | 1 + 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index e502be5dda..153c7560cb 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -403,6 +403,7 @@ struct MultiFDSendParams { QemuMutex mutex; bool running; bool quit; + bool sync; }; typedef struct MultiFDSendParams MultiFDSendParams; =20 @@ -410,6 +411,8 @@ struct { MultiFDSendParams *params; /* number of created threads */ int count; + /* syncs main thread and channels */ + QemuSemaphore sem_main; } *multifd_send_state; =20 static void terminate_multifd_send_threads(Error *errp) @@ -457,6 +460,7 @@ int multifd_save_cleanup(Error **errp) g_free(p->name); p->name =3D NULL; } + qemu_sem_destroy(&multifd_send_state->sem_main); g_free(multifd_send_state->params); multifd_send_state->params =3D NULL; g_free(multifd_send_state); @@ -464,18 +468,44 @@ int multifd_save_cleanup(Error **errp) return ret; } =20 +static void multifd_send_sync_main(void) +{ + int i; + + if (!migrate_use_multifd()) { + return; + } + for (i =3D 0; i < migrate_multifd_channels(); i++) { + MultiFDSendParams *p =3D &multifd_send_state->params[i]; + qemu_mutex_lock(&p->mutex); + p->sync =3D true; + qemu_mutex_unlock(&p->mutex); + qemu_sem_post(&p->sem); + } + for (i =3D 0; i < migrate_multifd_channels(); i++) { + qemu_sem_wait(&multifd_send_state->sem_main); + } + trace_multifd_send_sync_main(); +} + static void *multifd_send_thread(void *opaque) { MultiFDSendParams *p =3D opaque; =20 while (true) { + qemu_sem_wait(&p->sem); qemu_mutex_lock(&p->mutex); + if (p->sync) { + p->sync =3D false; + qemu_mutex_unlock(&p->mutex); + qemu_sem_post(&multifd_send_state->sem_main); + continue; + } if (p->quit) { qemu_mutex_unlock(&p->mutex); break; } qemu_mutex_unlock(&p->mutex); - qemu_sem_wait(&p->sem); } =20 return NULL; @@ -493,6 +523,8 @@ int multifd_save_setup(void) multifd_send_state =3D g_malloc0(sizeof(*multifd_send_state)); multifd_send_state->params =3D g_new0(MultiFDSendParams, thread_count); atomic_set(&multifd_send_state->count, 0); + qemu_sem_init(&multifd_send_state->sem_main, 0); + for (i =3D 0; i < thread_count; i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; =20 @@ -507,6 +539,7 @@ int multifd_save_setup(void) =20 atomic_inc(&multifd_send_state->count); } + return 0; } =20 @@ -2283,6 +2316,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) ram_control_before_iterate(f, RAM_CONTROL_SETUP); ram_control_after_iterate(f, RAM_CONTROL_SETUP); =20 + multifd_send_sync_main(); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); =20 return 0; @@ -2351,6 +2385,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) */ ram_control_after_iterate(f, RAM_CONTROL_ROUND); =20 + multifd_send_sync_main(); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); ram_counters.transferred +=3D 8; =20 @@ -2403,6 +2438,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) =20 rcu_read_unlock(); =20 + multifd_send_sync_main(); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); =20 return 0; diff --git a/migration/trace-events b/migration/trace-events index 93961dea16..97b5ac564f 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -77,6 +77,7 @@ ram_load_postcopy_loop(uint64_t addr, int flags) "@%" PRI= x64 " %x" ram_postcopy_send_discard_bitmap(void) "" ram_save_page(const char *rbname, uint64_t offset, void *host) "%s: offset= : 0x%" PRIx64 " host: %p" ram_save_queue_pages(const char *rbname, size_t start, size_t len) "%s: st= art: 0x%zx len: 0x%zx" +multifd_send_sync_main(void) "" =20 # migration/migration.c await_return_path_close_on_source_close(void) "" --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520420990517483.23224211223624; Wed, 7 Mar 2018 03:09:50 -0800 (PST) Received: from localhost ([::1]:60768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWxB-0004IX-MN for importer@patchew.org; Wed, 07 Mar 2018 06:09:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoP-000544-QY for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoL-0006H2-1V for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:45 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44636 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoK-0006GZ-Sk for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:40 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 672BC404084A for ; Wed, 7 Mar 2018 11:00:40 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FD08215CDA7; Wed, 7 Mar 2018 11:00:39 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 12:00:02 +0100 Message-Id: <20180307110010.2205-17-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:40 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 16/24] migration: Synchronize recv threads X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We synchronize all threads each RAM_SAVE_FLAG_EOS. Bitmap synchronizations don't happen inside a ram section, so we are safe about two channels trying to overwrite the same memory. Signed-off-by: Juan Quintela --- migration/ram.c | 37 ++++++++++++++++++++++++++++++++++++- migration/trace-events | 1 + 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index 153c7560cb..0266bd200c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -551,6 +551,7 @@ struct MultiFDRecvParams { QemuMutex mutex; bool running; bool quit; + bool sync; }; typedef struct MultiFDRecvParams MultiFDRecvParams; =20 @@ -558,6 +559,8 @@ struct { MultiFDRecvParams *params; /* number of created threads */ int count; + /* syncs main thread and channels */ + QemuSemaphore sem_main; } *multifd_recv_state; =20 static void terminate_multifd_recv_threads(Error *errp) @@ -605,6 +608,7 @@ int multifd_load_cleanup(Error **errp) g_free(p->name); p->name =3D NULL; } + qemu_sem_destroy(&multifd_recv_state->sem_main); g_free(multifd_recv_state->params); multifd_recv_state->params =3D NULL; g_free(multifd_recv_state); @@ -613,18 +617,45 @@ int multifd_load_cleanup(Error **errp) return ret; } =20 +static void multifd_recv_sync_main(void) +{ + int i; + + if (!migrate_use_multifd()) { + return; + } + for (i =3D 0; i < migrate_multifd_channels(); i++) { + MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; + + qemu_mutex_lock(&p->mutex); + p->sync =3D true; + qemu_mutex_unlock(&p->mutex); + qemu_sem_post(&p->sem); + } + for (i =3D 0; i < migrate_multifd_channels(); i++) { + qemu_sem_wait(&multifd_recv_state->sem_main); + } + trace_multifd_recv_sync_main(); +} + static void *multifd_recv_thread(void *opaque) { MultiFDRecvParams *p =3D opaque; =20 while (true) { + qemu_sem_wait(&p->sem); qemu_mutex_lock(&p->mutex); + if (p->sync) { + p->sync =3D false; + qemu_mutex_unlock(&p->mutex); + qemu_sem_post(&multifd_recv_state->sem_main); + continue; + } if (p->quit) { qemu_mutex_unlock(&p->mutex); break; } qemu_mutex_unlock(&p->mutex); - qemu_sem_wait(&p->sem); } =20 return NULL; @@ -642,6 +673,7 @@ int multifd_load_setup(void) multifd_recv_state =3D g_malloc0(sizeof(*multifd_recv_state)); multifd_recv_state->params =3D g_new0(MultiFDRecvParams, thread_count); atomic_set(&multifd_recv_state->count, 0); + qemu_sem_init(&multifd_recv_state->sem_main, 0); for (i =3D 0; i < thread_count; i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 @@ -655,6 +687,7 @@ int multifd_load_setup(void) QEMU_THREAD_JOINABLE); atomic_inc(&multifd_recv_state->count); } + return 0; } =20 @@ -2868,6 +2901,7 @@ static int ram_load_postcopy(QEMUFile *f) break; case RAM_SAVE_FLAG_EOS: /* normal exit */ + multifd_recv_sync_main(); break; default: error_report("Unknown combination of migration flags: %#x" @@ -3053,6 +3087,7 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) break; case RAM_SAVE_FLAG_EOS: /* normal exit */ + multifd_recv_sync_main(); break; default: if (flags & RAM_SAVE_FLAG_HOOK) { diff --git a/migration/trace-events b/migration/trace-events index 97b5ac564f..76075c26bc 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -78,6 +78,7 @@ ram_postcopy_send_discard_bitmap(void) "" ram_save_page(const char *rbname, uint64_t offset, void *host) "%s: offset= : 0x%" PRIx64 " host: %p" ram_save_queue_pages(const char *rbname, size_t start, size_t len) "%s: st= art: 0x%zx len: 0x%zx" multifd_send_sync_main(void) "" +multifd_recv_sync_main(void) "" =20 # migration/migration.c await_return_path_close_on_source_close(void) "" --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421663778936.3777806318649; Wed, 7 Mar 2018 03:21:03 -0800 (PST) Received: from localhost ([::1]:60849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etX82-0005ot-U0 for importer@patchew.org; Wed, 07 Mar 2018 06:21:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoS-00055F-24 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoM-0006Hl-Dg for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:48 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45262 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoM-0006HY-8z for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:42 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8A3B814F0CF for ; Wed, 7 Mar 2018 11:00:41 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADB63215CDA7; Wed, 7 Mar 2018 11:00:40 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 12:00:03 +0100 Message-Id: <20180307110010.2205-18-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 07 Mar 2018 11:00:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 07 Mar 2018 11:00:41 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 17/24] migration: Export functions to create send channels X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela --- migration/socket.c | 28 +++++++++++++++++++++++++++- migration/socket.h | 3 +++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/migration/socket.c b/migration/socket.c index 26110739cf..b3b5571ebb 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -39,6 +39,28 @@ int socket_recv_channel_unref(QIOChannel *recv) return 0; } =20 +struct SocketOutgoingArgs { + SocketAddress *saddr; +} outgoing_args; + +void socket_send_channel_create(void (*f)(QIOTask *, gpointer), void *data) +{ + QIOChannelSocket *sioc =3D qio_channel_socket_new(); + qio_channel_socket_connect_async(sioc, outgoing_args.saddr, + f, data, NULL); +} + +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 =3D NULL; + } + return 0; +} + static SocketAddress *tcp_build_address(const char *host_port, Error **err= p) { SocketAddress *saddr; @@ -106,6 +128,11 @@ static void socket_start_outgoing_migration(MigrationS= tate *s, struct SocketConnectData *data =3D g_new0(struct SocketConnectData, 1); =20 data->s =3D s; + + /* in case previous migration leaked it */ + qapi_free_SocketAddress(outgoing_args.saddr); + outgoing_args.saddr =3D saddr; + if (saddr->type =3D=3D SOCKET_ADDRESS_TYPE_INET) { data->hostname =3D g_strdup(saddr->u.inet.host); } @@ -116,7 +143,6 @@ static void socket_start_outgoing_migration(MigrationSt= ate *s, socket_outgoing_migration, data, socket_connect_data_free); - qapi_free_SocketAddress(saddr); } =20 void tcp_start_outgoing_migration(MigrationState *s, diff --git a/migration/socket.h b/migration/socket.h index 638a85255a..cbdb8d64c3 100644 --- a/migration/socket.h +++ b/migration/socket.h @@ -23,6 +23,9 @@ int socket_recv_channel_ref(QIOChannel *recv); int socket_recv_channel_unref(QIOChannel *recv); =20 +void socket_send_channel_create(void (*f)(QIOTask *, gpointer), void *data= ); +int socket_send_channel_destroy(QIOChannel *send); + void tcp_start_incoming_migration(const char *host_port, Error **errp); =20 void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15204213388461010.4192812080538; Wed, 7 Mar 2018 03:15:38 -0800 (PST) Received: from localhost ([::1]:60807 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etX2n-0001Gq-Q5 for importer@patchew.org; Wed, 07 Mar 2018 06:15:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoO-00052h-MJ for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoN-0006If-R0 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:44 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44652 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoN-0006IS-MB for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:43 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 33D70EBFE6 for ; Wed, 7 Mar 2018 11:00:43 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BE13215CDA7; Wed, 7 Mar 2018 11:00:41 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 12:00:04 +0100 Message-Id: <20180307110010.2205-19-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 07 Mar 2018 11:00:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 07 Mar 2018 11:00:43 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 18/24] migration: Add multifd traces for start/end thread X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Daniel P. Berrang=C3=A9 --- migration/ram.c | 6 ++++++ migration/trace-events | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 0266bd200c..b57d9fd667 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -492,6 +492,8 @@ static void *multifd_send_thread(void *opaque) { MultiFDSendParams *p =3D opaque; =20 + trace_multifd_send_thread_start(p->id); + while (true) { qemu_sem_wait(&p->sem); qemu_mutex_lock(&p->mutex); @@ -507,6 +509,7 @@ static void *multifd_send_thread(void *opaque) } qemu_mutex_unlock(&p->mutex); } + trace_multifd_send_thread_end(p->id); =20 return NULL; } @@ -642,6 +645,8 @@ static void *multifd_recv_thread(void *opaque) { MultiFDRecvParams *p =3D opaque; =20 + trace_multifd_recv_thread_start(p->id); + while (true) { qemu_sem_wait(&p->sem); qemu_mutex_lock(&p->mutex); @@ -658,6 +663,7 @@ static void *multifd_recv_thread(void *opaque) qemu_mutex_unlock(&p->mutex); } =20 + trace_multifd_recv_thread_end(p->id); return NULL; } =20 diff --git a/migration/trace-events b/migration/trace-events index 76075c26bc..db88fa699f 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -79,6 +79,10 @@ ram_save_page(const char *rbname, uint64_t offset, void = *host) "%s: offset: 0x%" ram_save_queue_pages(const char *rbname, size_t start, size_t len) "%s: st= art: 0x%zx len: 0x%zx" multifd_send_sync_main(void) "" multifd_recv_sync_main(void) "" +multifd_send_thread_start(int id) "%d" +multifd_send_thread_end(int id) "%d" +multifd_recv_thread_start(int id) "%d" +multifd_recv_thread_end(int id) "%d" =20 # migration/migration.c await_return_path_close_on_source_close(void) "" --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421267833996.4010931243129; Wed, 7 Mar 2018 03:14:27 -0800 (PST) Received: from localhost ([::1]:60796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etX1U-0008KG-AY for importer@patchew.org; Wed, 07 Mar 2018 06:14:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoT-000568-9X for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoP-0006Js-8K for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:49 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45264 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoP-0006JL-33 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:45 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92AA3814F0CF for ; Wed, 7 Mar 2018 11:00:44 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79FD8215CDA7; Wed, 7 Mar 2018 11:00:43 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 12:00:05 +0100 Message-Id: <20180307110010.2205-20-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 07 Mar 2018 11:00:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 07 Mar 2018 11:00:44 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 19/24] migration: Create multifd channels X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In both sides. We still don't transmit anything through them. Signed-off-by: Juan Quintela --- migration/ram.c | 52 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index b57d9fd667..7ef0c2b7e2 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -399,6 +399,7 @@ struct MultiFDSendParams { uint8_t id; char *name; QemuThread thread; + QIOChannel *c; QemuSemaphore sem; QemuMutex mutex; bool running; @@ -455,6 +456,8 @@ int multifd_save_cleanup(Error **errp) qemu_thread_join(&p->thread); p->running =3D false; } + socket_send_channel_destroy(p->c); + p->c =3D NULL; qemu_mutex_destroy(&p->mutex); qemu_sem_destroy(&p->sem); g_free(p->name); @@ -514,6 +517,27 @@ static void *multifd_send_thread(void *opaque) return NULL; } =20 +static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) +{ + MultiFDSendParams *p =3D opaque; + QIOChannel *sioc =3D QIO_CHANNEL(qio_task_get_source(task)); + Error *local_err =3D NULL; + + if (qio_task_propagate_error(task, &local_err)) { + if (multifd_save_cleanup(&local_err) !=3D 0) { + migrate_set_error(migrate_get_current(), local_err); + } + } else { + p->c =3D QIO_CHANNEL(sioc); + qio_channel_set_delay(p->c, false); + p->running =3D true; + qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, + QEMU_THREAD_JOINABLE); + + atomic_inc(&multifd_send_state->count); + } +} + int multifd_save_setup(void) { int thread_count; @@ -536,11 +560,7 @@ int multifd_save_setup(void) p->quit =3D false; p->id =3D i; p->name =3D g_strdup_printf("multifdsend_%d", i); - p->running =3D true; - qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, - QEMU_THREAD_JOINABLE); - - atomic_inc(&multifd_send_state->count); + socket_send_channel_create(multifd_new_send_channel_async, p); } =20 return 0; @@ -550,6 +570,7 @@ struct MultiFDRecvParams { uint8_t id; char *name; QemuThread thread; + QIOChannel *c; QemuSemaphore sem; QemuMutex mutex; bool running; @@ -606,6 +627,8 @@ int multifd_load_cleanup(Error **errp) qemu_thread_join(&p->thread); p->running =3D false; } + socket_recv_channel_unref(p->c); + p->c =3D NULL; qemu_mutex_destroy(&p->mutex); qemu_sem_destroy(&p->sem); g_free(p->name); @@ -688,10 +711,6 @@ int multifd_load_setup(void) p->quit =3D false; p->id =3D i; p->name =3D g_strdup_printf("multifdrecv_%d", i); - p->running =3D true; - qemu_thread_create(&p->thread, p->name, multifd_recv_thread, p, - QEMU_THREAD_JOINABLE); - atomic_inc(&multifd_recv_state->count); } =20 return 0; @@ -710,7 +729,20 @@ bool multifd_recv_all_channels_created(void) =20 void multifd_recv_new_channel(QIOChannel *ioc) { - /* nothing to do yet */ + MultiFDRecvParams *p; + /* we need to invent channels id's until we transmit */ + /* we will remove this on a later patch */ + static int i =3D 0; + + p =3D &multifd_recv_state->params[i]; + i++; + p->c =3D ioc; + socket_recv_channel_ref(ioc); + + p->running =3D true; + qemu_thread_create(&p->thread, p->name, multifd_recv_thread, p, + QEMU_THREAD_JOINABLE); + atomic_inc(&multifd_recv_state->count); } =20 /** --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520420939554862.1605791398671; Wed, 7 Mar 2018 03:08:59 -0800 (PST) Received: from localhost ([::1]:60767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWwM-0003Te-Lo for importer@patchew.org; Wed, 07 Mar 2018 06:08:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoW-00058Y-9A for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoQ-0006L9-KR for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:52 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34502 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoQ-0006Kl-GF for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:46 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F099A4023ECC for ; Wed, 7 Mar 2018 11:00:45 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9808215CDA7; Wed, 7 Mar 2018 11:00:44 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 12:00:06 +0100 Message-Id: <20180307110010.2205-21-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 11:00:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 11:00:45 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 20/24] migration: Delay start of migration main routines X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We need to make sure that we have started all the multifd threads. Signed-off-by: Juan Quintela --- migration/migration.c | 4 ++-- migration/migration.h | 1 + migration/ram.c | 3 +++ migration/socket.c | 3 +++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index c06c34ca0f..a355618220 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -429,7 +429,7 @@ static void migration_incoming_setup(QEMUFile *f) qemu_file_set_blocking(f, false); } =20 -static void migration_incoming_process(void) +void migration_incoming_process(void) { Coroutine *co =3D qemu_coroutine_create(process_incoming_migration_co,= NULL); qemu_coroutine_enter(co); @@ -447,7 +447,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc) =20 if (!mis->from_src_file) { QEMUFile *f =3D qemu_fopen_channel_input(ioc); - migration_fd_process_incoming(f); + migration_incoming_setup(f); return; } multifd_recv_new_channel(ioc); diff --git a/migration/migration.h b/migration/migration.h index f40014cf94..03a940831d 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -184,6 +184,7 @@ void migrate_set_state(int *state, int old_state, int n= ew_state); =20 void migration_fd_process_incoming(QEMUFile *f); void migration_ioc_process_incoming(QIOChannel *ioc); +void migration_incoming_process(void); =20 bool migration_has_all_channels(void); =20 diff --git a/migration/ram.c b/migration/ram.c index 7ef0c2b7e2..1aab96bd5e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -743,6 +743,9 @@ void multifd_recv_new_channel(QIOChannel *ioc) qemu_thread_create(&p->thread, p->name, multifd_recv_thread, p, QEMU_THREAD_JOINABLE); atomic_inc(&multifd_recv_state->count); + if (multifd_recv_state->count =3D=3D migrate_multifd_channels()) { + migration_incoming_process(); + } } =20 /** diff --git a/migration/socket.c b/migration/socket.c index b3b5571ebb..deda193de7 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -189,6 +189,9 @@ static gboolean socket_accept_incoming_migration(QIOCha= nnel *ioc, if (migration_has_all_channels()) { /* Close listening socket as its no longer needed */ qio_channel_close(ioc, NULL); + if (!migrate_use_multifd()) { + migration_incoming_process(); + } return G_SOURCE_REMOVE; } else { return G_SOURCE_CONTINUE; --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421397098441.5518494940634; Wed, 7 Mar 2018 03:16:37 -0800 (PST) Received: from localhost ([::1]:60812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etX3k-000228-B9 for importer@patchew.org; Wed, 07 Mar 2018 06:16:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoV-00057S-1R for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoS-0006M6-10 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:51 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36526 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoR-0006Lm-S2 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:47 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C6F4D142B for ; Wed, 7 Mar 2018 11:00:47 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 430FE215CDA7; Wed, 7 Mar 2018 11:00:46 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 12:00:07 +0100 Message-Id: <20180307110010.2205-22-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:47 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 21/24] migration: Transmit initial package through the multifd channels X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela --- migration/ram.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 1aab96bd5e..4efac0c20c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -52,6 +52,8 @@ #include "qemu/rcu_queue.h" #include "migration/colo.h" #include "migration/block.h" +#include "sysemu/sysemu.h" +#include "qemu/uuid.h" =20 /***********************************************************/ /* ram save/restore */ @@ -491,12 +493,30 @@ static void multifd_send_sync_main(void) trace_multifd_send_sync_main(); } =20 +typedef struct { + uint32_t version; + unsigned char uuid[16]; /* QemuUUID */ + uint8_t id; +} __attribute__((packed)) MultiFDInit_t; + static void *multifd_send_thread(void *opaque) { MultiFDSendParams *p =3D opaque; + MultiFDInit_t msg; + Error *local_err =3D NULL; + size_t ret; =20 trace_multifd_send_thread_start(p->id); =20 + msg.version =3D 1; + msg.id =3D p->id; + memcpy(msg.uuid, &qemu_uuid.data, sizeof(msg.uuid)); + ret =3D qio_channel_write_all(p->c, (char *)&msg, sizeof(msg), &local_= err); + if (ret !=3D 0) { + terminate_multifd_send_threads(local_err); + return NULL; + } + while (true) { qemu_sem_wait(&p->sem); qemu_mutex_lock(&p->mutex); @@ -730,12 +750,32 @@ bool multifd_recv_all_channels_created(void) void multifd_recv_new_channel(QIOChannel *ioc) { MultiFDRecvParams *p; - /* we need to invent channels id's until we transmit */ - /* we will remove this on a later patch */ - static int i =3D 0; + MultiFDInit_t msg; + Error *local_err =3D NULL; + size_t ret; =20 - p =3D &multifd_recv_state->params[i]; - i++; + ret =3D qio_channel_read_all(ioc, (char *)&msg, sizeof(msg), &local_er= r); + if (ret !=3D 0) { + terminate_multifd_recv_threads(local_err); + return; + } + + if (memcmp(msg.uuid, &qemu_uuid, sizeof(qemu_uuid))) { + char *uuid =3D qemu_uuid_unparse_strdup(&qemu_uuid); + error_setg(&local_err, "multifd: received uuid '%s' and expected " + "uuid '%s' for channel %hhd", msg.uuid, uuid, msg.id); + g_free(uuid); + terminate_multifd_recv_threads(local_err); + return; + } + + p =3D &multifd_recv_state->params[msg.id]; + if (p->c !=3D NULL) { + error_setg(&local_err, "multifd: received id '%d' already setup'", + msg.id); + terminate_multifd_recv_threads(local_err); + return; + } p->c =3D ioc; socket_recv_channel_ref(ioc); =20 --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421555352364.47093572290544; Wed, 7 Mar 2018 03:19:15 -0800 (PST) Received: from localhost ([::1]:60826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etX6I-0004Bu-DD for importer@patchew.org; Wed, 07 Mar 2018 06:19:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoV-00057R-1O for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoT-0006NC-E7 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:51 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36528 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoT-0006Mw-7o for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:49 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BDFBA8D74A for ; Wed, 7 Mar 2018 11:00:48 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2BC1215CDA7; Wed, 7 Mar 2018 11:00:47 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 12:00:08 +0100 Message-Id: <20180307110010.2205-23-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:48 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 22/24] migration: Create ram_multifd_page X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The function still don't use multifd, but we have simplified ram_save_page, xbzrle and RDMA stuff is gone. We have added a new counter. Signed-off-by: Juan Quintela -- Add last_page parameter Add commets for done and address Remove multifd field, it is the same than normal pages Merge next patch, now we send multiple pages at a time Remove counter for multifd pages, it is identical to normal pages Use iovec's instead of creating the equivalent. Clear memory used by pages (dave) Use g_new0(danp) define MULTIFD_CONTINUE now pages member is a pointer Fix off-by-one in number of pages in one packet Remove RAM_SAVE_FLAG_MULTIFD_PAGE --- migration/ram.c | 144 +++++++++++++++++++++++++++++++++++++++++++++= +++- migration/trace-events | 3 +- 2 files changed, 144 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 4efac0c20c..df9646ed2e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -54,6 +54,7 @@ #include "migration/block.h" #include "sysemu/sysemu.h" #include "qemu/uuid.h" +#include "qemu/iov.h" =20 /***********************************************************/ /* ram save/restore */ @@ -397,7 +398,19 @@ static void compress_threads_save_setup(void) =20 /* Multiple fd's */ =20 +typedef struct { + /* number of used pages */ + uint32_t used; + /* number of allocated pages */ + uint32_t allocated; + /* global number of generated multifd packets */ + uint32_t seq; + struct iovec *iov; + RAMBlock *block; +} multifd_pages_t; + struct MultiFDSendParams { + /* not changed */ uint8_t id; char *name; QemuThread thread; @@ -405,8 +418,15 @@ struct MultiFDSendParams { QemuSemaphore sem; QemuMutex mutex; bool running; + /* protected by param mutex */ bool quit; bool sync; + multifd_pages_t *pages; + /* how many patches has sent this channel */ + uint32_t packets_sent; + /* protected by multifd mutex */ + /* has the thread finish the last submitted job */ + bool done; }; typedef struct MultiFDSendParams MultiFDSendParams; =20 @@ -416,8 +436,31 @@ struct { int count; /* syncs main thread and channels */ QemuSemaphore sem_main; + QemuMutex mutex; + QemuSemaphore sem; + multifd_pages_t *pages; } *multifd_send_state; =20 +static void multifd_pages_init(multifd_pages_t **ppages, size_t size) +{ + multifd_pages_t *pages =3D g_new0(multifd_pages_t, 1); + + pages->allocated =3D size; + pages->iov =3D g_new0(struct iovec, size); + *ppages =3D pages; +} + +static void multifd_pages_clear(multifd_pages_t *pages) +{ + pages->used =3D 0; + pages->allocated =3D 0; + pages->seq =3D 0; + pages->block =3D NULL; + g_free(pages->iov); + pages->iov =3D NULL; + g_free(pages); +} + static void terminate_multifd_send_threads(Error *errp) { int i; @@ -464,10 +507,14 @@ int multifd_save_cleanup(Error **errp) qemu_sem_destroy(&p->sem); g_free(p->name); p->name =3D NULL; + multifd_pages_clear(p->pages); + p->pages =3D NULL; } qemu_sem_destroy(&multifd_send_state->sem_main); g_free(multifd_send_state->params); multifd_send_state->params =3D NULL; + multifd_pages_clear(multifd_send_state->pages); + multifd_send_state->pages =3D NULL; g_free(multifd_send_state); multifd_send_state =3D NULL; return ret; @@ -516,6 +563,7 @@ static void *multifd_send_thread(void *opaque) terminate_multifd_send_threads(local_err); return NULL; } + qemu_sem_post(&multifd_send_state->sem); =20 while (true) { qemu_sem_wait(&p->sem); @@ -530,9 +578,23 @@ static void *multifd_send_thread(void *opaque) qemu_mutex_unlock(&p->mutex); break; } + if (p->pages->used) { + p->pages->used =3D 0; + qemu_mutex_unlock(&p->mutex); + + trace_multifd_send(p->id, p->pages->seq, p->pages->used); + /* ToDo: send page here */ + + qemu_mutex_lock(&multifd_send_state->mutex); + p->done =3D true; + p->packets_sent++; + qemu_mutex_unlock(&multifd_send_state->mutex); + qemu_sem_post(&multifd_send_state->sem); + continue; + } qemu_mutex_unlock(&p->mutex); } - trace_multifd_send_thread_end(p->id); + trace_multifd_send_thread_end(p->id, p->packets_sent); =20 return NULL; } @@ -571,7 +633,10 @@ int multifd_save_setup(void) multifd_send_state->params =3D g_new0(MultiFDSendParams, thread_count); atomic_set(&multifd_send_state->count, 0); qemu_sem_init(&multifd_send_state->sem_main, 0); - + qemu_mutex_init(&multifd_send_state->mutex); + qemu_sem_init(&multifd_send_state->sem, 0); + multifd_pages_init(&multifd_send_state->pages, + migrate_multifd_page_count()); for (i =3D 0; i < thread_count; i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; =20 @@ -579,6 +644,8 @@ int multifd_save_setup(void) qemu_sem_init(&p->sem, 0); p->quit =3D false; p->id =3D i; + p->done =3D true; + multifd_pages_init(&p->pages, migrate_multifd_page_count()); p->name =3D g_strdup_printf("multifdsend_%d", i); socket_send_channel_create(multifd_new_send_channel_async, p); } @@ -586,6 +653,50 @@ int multifd_save_setup(void) return 0; } =20 +static void multifd_send_page(RAMBlock *block, ram_addr_t offset, + bool last_page) +{ + int i; + static int next_channel =3D 0; + MultiFDSendParams *p =3D NULL; /* make happy gcc */ + multifd_pages_t *pages =3D multifd_send_state->pages; + + if (!pages->block) { + pages->block =3D block; + } + + pages->iov[pages->used].iov_base =3D block->host + offset; + pages->iov[pages->used].iov_len =3D TARGET_PAGE_SIZE; + pages->used++; + + if (!last_page) { + if (pages->used < pages->allocated) { + return; + } + } + + qemu_sem_wait(&multifd_send_state->sem); + qemu_mutex_lock(&multifd_send_state->mutex); + for (i =3D next_channel;; i =3D (i + 1) % migrate_multifd_channels() )= { + p =3D &multifd_send_state->params[i]; + + if (p->done) { + p->done =3D false; + next_channel =3D (i + 1) % migrate_multifd_channels(); + break; + } + } + qemu_mutex_unlock(&multifd_send_state->mutex); + qemu_mutex_lock(&p->mutex); + p->pages->used =3D 0; + p->pages->seq =3D pages->seq + 1; + p->pages->block =3D NULL; + multifd_send_state->pages =3D p->pages; + p->pages =3D pages; + qemu_mutex_unlock(&p->mutex); + qemu_sem_post(&p->sem); +} + struct MultiFDRecvParams { uint8_t id; char *name; @@ -1220,6 +1331,31 @@ static int ram_save_page(RAMState *rs, PageSearchSta= tus *pss, bool last_stage) return pages; } =20 +static int ram_multifd_page(RAMState *rs, PageSearchStatus *pss, + bool last_stage) +{ + int pages; + uint8_t *p; + RAMBlock *block =3D pss->block; + ram_addr_t offset =3D pss->page << TARGET_PAGE_BITS; + + p =3D block->host + offset; + + pages =3D save_zero_page(rs, block, offset); + if (pages =3D=3D -1) { + ram_counters.transferred +=3D + save_page_header(rs, rs->f, block, + offset | RAM_SAVE_FLAG_PAGE); + multifd_send_page(block, offset, rs->migration_dirty_pages =3D=3D = 1); + qemu_put_buffer(rs->f, p, TARGET_PAGE_SIZE); + ram_counters.transferred +=3D TARGET_PAGE_SIZE; + pages =3D 1; + ram_counters.normal++; + } + + return pages; +} + static int do_compress_ram_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset) { @@ -1648,6 +1784,8 @@ static int ram_save_target_page(RAMState *rs, PageSea= rchStatus *pss, if (migrate_use_compression() && (rs->ram_bulk_stage || !migrate_use_xbzrle())) { res =3D ram_save_compressed_page(rs, pss, last_stage); + } else if (migrate_use_multifd()) { + res =3D ram_multifd_page(rs, pss, last_stage); } else { res =3D ram_save_page(rs, pss, last_stage); } @@ -3047,6 +3185,7 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) if (!migrate_use_compression()) { invalid_flags |=3D RAM_SAVE_FLAG_COMPRESS_PAGE; } + /* This RCU critical section can be very long running. * When RCU reclaims in the code start to become numerous, * it will be necessary to reduce the granularity of this @@ -3166,6 +3305,7 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) break; } break; + case RAM_SAVE_FLAG_EOS: /* normal exit */ multifd_recv_sync_main(); diff --git a/migration/trace-events b/migration/trace-events index db88fa699f..f6ab2c7bcb 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -80,9 +80,10 @@ ram_save_queue_pages(const char *rbname, size_t start, s= ize_t len) "%s: start: 0 multifd_send_sync_main(void) "" multifd_recv_sync_main(void) "" multifd_send_thread_start(int id) "%d" -multifd_send_thread_end(int id) "%d" +multifd_send_thread_end(char id, uint32_t packets) "channel %d packets %d" multifd_recv_thread_start(int id) "%d" multifd_recv_thread_end(int id) "%d" +multifd_send(char id, int seq, int num) "channel %d sequence %d num pages = %d" =20 # migration/migration.c await_return_path_close_on_source_close(void) "" --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421125982592.484974135078; Wed, 7 Mar 2018 03:12:05 -0800 (PST) Received: from localhost ([::1]:60787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWzN-0006Ok-6h for importer@patchew.org; Wed, 07 Mar 2018 06:12:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoV-00057z-Mp for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoU-0006O3-PV for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:51 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44640 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoU-0006Nn-Kt for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:50 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 298F2404084A for ; Wed, 7 Mar 2018 11:00:50 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1135F215CDA7; Wed, 7 Mar 2018 11:00:48 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 12:00:09 +0100 Message-Id: <20180307110010.2205-24-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 11:00:50 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 23/24] migration: Create pages structure for reception X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela --- migration/ram.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index df9646ed2e..264d2e462a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -698,6 +698,7 @@ static void multifd_send_page(RAMBlock *block, ram_addr= _t offset, } =20 struct MultiFDRecvParams { + /* not changed */ uint8_t id; char *name; QemuThread thread; @@ -705,8 +706,13 @@ struct MultiFDRecvParams { QemuSemaphore sem; QemuMutex mutex; bool running; + /* protected by param mutex */ bool quit; bool sync; + /* how many patckets has recv this channel */ + uint32_t packets_recv; + multifd_pages_t *pages; + bool done; }; typedef struct MultiFDRecvParams MultiFDRecvParams; =20 @@ -716,6 +722,7 @@ struct { int count; /* syncs main thread and channels */ QemuSemaphore sem_main; + multifd_pages_t *pages; } *multifd_recv_state; =20 static void terminate_multifd_recv_threads(Error *errp) @@ -764,10 +771,14 @@ int multifd_load_cleanup(Error **errp) qemu_sem_destroy(&p->sem); g_free(p->name); p->name =3D NULL; + multifd_pages_clear(p->pages); + p->pages =3D NULL; } qemu_sem_destroy(&multifd_recv_state->sem_main); g_free(multifd_recv_state->params); multifd_recv_state->params =3D NULL; + multifd_pages_clear(multifd_recv_state->pages); + multifd_recv_state->pages =3D NULL; g_free(multifd_recv_state); multifd_recv_state =3D NULL; =20 @@ -834,6 +845,9 @@ int multifd_load_setup(void) multifd_recv_state->params =3D g_new0(MultiFDRecvParams, thread_count); atomic_set(&multifd_recv_state->count, 0); qemu_sem_init(&multifd_recv_state->sem_main, 0); + multifd_pages_init(&multifd_recv_state->pages, + migrate_multifd_page_count()); + for (i =3D 0; i < thread_count; i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 @@ -842,6 +856,7 @@ int multifd_load_setup(void) p->quit =3D false; p->id =3D i; p->name =3D g_strdup_printf("multifdrecv_%d", i); + multifd_pages_init(&p->pages, migrate_multifd_page_count()); } =20 return 0; --=20 2.14.3 From nobody Fri Oct 24 21:54:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421881847130.5967720378802; Wed, 7 Mar 2018 03:24:41 -0800 (PST) Received: from localhost ([::1]:60869 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etXBY-0000wa-Ux for importer@patchew.org; Wed, 07 Mar 2018 06:24:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoX-00059Q-Ns for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:01:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoW-0006Ou-7K for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:53 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36532 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoW-0006Oc-0W for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:52 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 895578D74A for ; Wed, 7 Mar 2018 11:00:51 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70080215CDA7; Wed, 7 Mar 2018 11:00:50 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 12:00:10 +0100 Message-Id: <20180307110010.2205-25-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:51 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 24/24] [RFC] migration: Send pages through the multifd channels X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Migration ends correctly, but there is still a race between clean up and last synchronization. Signed-off-by: Juan Quintela --- migration/ram.c | 132 +++++++++++++++++++++++++++++++++++++++++++++= +--- migration/trace-events | 3 +- 2 files changed, 126 insertions(+), 9 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 264d2e462a..577b448db3 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -398,6 +398,19 @@ static void compress_threads_save_setup(void) =20 /* Multiple fd's */ =20 +#define MULTIFD_MAGIC 0x112233d +#define MULTIFD_VERSION 1 + +typedef struct { + uint32_t magic; + uint32_t version; + uint32_t size; + uint32_t used; + uint32_t seq; + char ramblock[256]; + ram_addr_t offset[]; +} __attribute__((packed)) MultiFDPacket_t; + typedef struct { /* number of used pages */ uint32_t used; @@ -407,6 +420,8 @@ typedef struct { uint32_t seq; struct iovec *iov; RAMBlock *block; + uint32_t packet_len; + MultiFDPacket_t *packet; } multifd_pages_t; =20 struct MultiFDSendParams { @@ -447,6 +462,8 @@ static void multifd_pages_init(multifd_pages_t **ppages= , size_t size) =20 pages->allocated =3D size; pages->iov =3D g_new0(struct iovec, size); + pages->packet_len =3D sizeof(MultiFDPacket_t) + sizeof(ram_addr_t) * s= ize; + pages->packet =3D g_malloc0(pages->packet_len); *ppages =3D pages; } =20 @@ -458,6 +475,9 @@ static void multifd_pages_clear(multifd_pages_t *pages) pages->block =3D NULL; g_free(pages->iov); pages->iov =3D NULL; + pages->packet_len =3D 0; + g_free(pages->packet); + pages->packet =3D NULL; g_free(pages); } =20 @@ -499,7 +519,6 @@ int multifd_save_cleanup(Error **errp) =20 if (p->running) { qemu_thread_join(&p->thread); - p->running =3D false; } socket_send_channel_destroy(p->c); p->c =3D NULL; @@ -535,7 +554,16 @@ static void multifd_send_sync_main(void) qemu_sem_post(&p->sem); } for (i =3D 0; i < migrate_multifd_channels(); i++) { - qemu_sem_wait(&multifd_send_state->sem_main); + MultiFDSendParams *p =3D &multifd_send_state->params[i]; + bool wait =3D true; + + qemu_mutex_lock(&p->mutex); + wait =3D p->running; + qemu_mutex_unlock(&p->mutex); + + if (wait) { + qemu_sem_wait(&multifd_send_state->sem_main); + } } trace_multifd_send_sync_main(); } @@ -575,16 +603,37 @@ static void *multifd_send_thread(void *opaque) continue; } if (p->quit) { + p->running =3D false; qemu_mutex_unlock(&p->mutex); break; } if (p->pages->used) { + MultiFDPacket_t *packet =3D p->pages->packet; + Error *local_err =3D NULL; + size_t ret; + + packet->used =3D p->pages->used; p->pages->used =3D 0; qemu_mutex_unlock(&p->mutex); + packet->magic =3D MULTIFD_MAGIC; + packet->version =3D MULTIFD_VERSION; =20 - trace_multifd_send(p->id, p->pages->seq, p->pages->used); - /* ToDo: send page here */ - + strncpy(packet->ramblock, p->pages->block->idstr, 256); + packet->size =3D migrate_multifd_page_count(); + packet->seq =3D p->pages->seq; + ret =3D qio_channel_write_all(p->c, (void *)packet, + p->pages->packet_len, &local_err); + if (ret !=3D 0) { + terminate_multifd_send_threads(local_err); + return NULL; + } + trace_multifd_send(p->id, p->pages->seq, packet->used); + ret =3D qio_channel_writev_all(p->c, p->pages->iov, + packet->used, &local_err); + if (ret !=3D 0) { + terminate_multifd_send_threads(local_err); + return NULL; + } qemu_mutex_lock(&multifd_send_state->mutex); p->done =3D true; p->packets_sent++; @@ -763,7 +812,6 @@ int multifd_load_cleanup(Error **errp) =20 if (p->running) { qemu_thread_join(&p->thread); - p->running =3D false; } socket_recv_channel_unref(p->c); p->c =3D NULL; @@ -801,17 +849,48 @@ static void multifd_recv_sync_main(void) qemu_sem_post(&p->sem); } for (i =3D 0; i < migrate_multifd_channels(); i++) { - qemu_sem_wait(&multifd_recv_state->sem_main); + MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; + bool wait =3D true; + + qemu_mutex_lock(&p->mutex); + wait =3D p->running && !p->quit; + qemu_mutex_unlock(&p->mutex); + + if (wait) { + qemu_sem_wait(&multifd_recv_state->sem_main); + } } trace_multifd_recv_sync_main(); } =20 +static gboolean recv_channel_ready(QIOChannel *ioc, + GIOCondition condition, + gpointer opaque) +{ + MultiFDRecvParams *p =3D opaque; + + if (condition !=3D G_IO_IN) { + return G_SOURCE_REMOVE; + } + + qemu_mutex_lock(&p->mutex); + p->done =3D false; + qemu_mutex_unlock(&p->mutex); + qemu_sem_post(&p->sem); + + return G_SOURCE_CONTINUE; + +} + static void *multifd_recv_thread(void *opaque) { MultiFDRecvParams *p =3D opaque; =20 trace_multifd_recv_thread_start(p->id); =20 + qio_channel_add_watch(p->c, G_IO_IN | G_IO_HUP | G_IO_ERR, + recv_channel_ready, p, NULL); + while (true) { qemu_sem_wait(&p->sem); qemu_mutex_lock(&p->mutex); @@ -821,14 +900,50 @@ static void *multifd_recv_thread(void *opaque) qemu_sem_post(&multifd_recv_state->sem_main); continue; } + if (!p->done) { + MultiFDPacket_t *packet =3D p->pages->packet; + RAMBlock *block; + Error *local_err =3D NULL; + size_t ret; + int i; + + qemu_mutex_unlock(&p->mutex); + + ret =3D qio_channel_read_all(p->c, (void *)packet, + p->pages->packet_len, &local_err); + if (ret !=3D 0) { + terminate_multifd_recv_threads(local_err); + return NULL; + } + block =3D qemu_ram_block_by_name(packet->ramblock); + p->pages->seq =3D packet->seq; + for (i =3D 0; i < packet->used; i++) { + p->pages->iov[i].iov_base =3D block->host + packet->offset= [i]; + p->pages->iov[i].iov_len =3D TARGET_PAGE_SIZE; + } + trace_multifd_recv(p->id, p->pages->seq, packet->used); + ret =3D qio_channel_readv_all(p->c, p->pages->iov, + packet->used, &local_err); + if (ret !=3D 0) { + terminate_multifd_recv_threads(local_err); + return NULL; + } + qemu_mutex_lock(&p->mutex); + p->done =3D true; + p->packets_recv++; + qemu_mutex_unlock(&p->mutex); + + continue; + } if (p->quit) { + p->running =3D false; qemu_mutex_unlock(&p->mutex); break; } qemu_mutex_unlock(&p->mutex); } =20 - trace_multifd_recv_thread_end(p->id); + trace_multifd_recv_thread_end(p->id, p->packets_recv); return NULL; } =20 @@ -854,6 +969,7 @@ int multifd_load_setup(void) qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem, 0); p->quit =3D false; + p->done =3D true; p->id =3D i; p->name =3D g_strdup_printf("multifdrecv_%d", i); multifd_pages_init(&p->pages, migrate_multifd_page_count()); diff --git a/migration/trace-events b/migration/trace-events index f6ab2c7bcb..e9f1aae985 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -82,8 +82,9 @@ multifd_recv_sync_main(void) "" multifd_send_thread_start(int id) "%d" multifd_send_thread_end(char id, uint32_t packets) "channel %d packets %d" multifd_recv_thread_start(int id) "%d" -multifd_recv_thread_end(int id) "%d" +multifd_recv_thread_end(char id, uint32_t packets) "channel %d packets %d" multifd_send(char id, int seq, int num) "channel %d sequence %d num pages = %d" +multifd_recv(char id, int seq, int num) "channel %d sequence %d num pages = %d" =20 # migration/migration.c await_return_path_close_on_source_close(void) "" --=20 2.14.3