From nobody Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515588608693293.45218640272594; Wed, 10 Jan 2018 04:50:08 -0800 (PST) Received: from localhost ([::1]:39000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFpO-0007No-Uf for importer@patchew.org; Wed, 10 Jan 2018 07:49:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFn5-00063o-Ll for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFn2-0004Io-DH for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59546) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFn2-0004FU-45 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:32 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 163AD7EA93 for ; Wed, 10 Jan 2018 12:47:30 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 996BF7B8DC; Wed, 10 Jan 2018 12:47:28 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:10 +0100 Message-Id: <20180110124723.11879-2-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 10 Jan 2018 12:47:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 01/14] migration: Make migrate_fd_error() the owner of the 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" So far, we had to free the error after each caller, so just do it here. Once there, tls.c was leaking the error. Signed-off-by: Juan Quintela --- migration/channel.c | 1 - migration/migration.c | 10 ++++------ migration/migration.h | 4 ++-- migration/socket.c | 1 - 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/migration/channel.c b/migration/channel.c index 70ec7ea3b7..1dd2ae1530 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -71,7 +71,6 @@ void migration_channel_connect(MigrationState *s, migration_tls_channel_connect(s, ioc, hostname, &local_err); if (local_err) { migrate_fd_error(s, local_err); - error_free(local_err); } } else { QEMUFile *f =3D qemu_fopen_channel_output(ioc); diff --git a/migration/migration.c b/migration/migration.c index a5be4592a6..085e88c625 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1159,16 +1159,14 @@ static void migrate_fd_cleanup(void *opaque) block_cleanup_parameters(s); } =20 -void migrate_set_error(MigrationState *s, const Error *error) +void migrate_set_error(MigrationState *s, Error *error) { qemu_mutex_lock(&s->error_mutex); - if (!s->error) { - s->error =3D error_copy(error); - } + error_propagate(&s->error, error); qemu_mutex_unlock(&s->error_mutex); } =20 -void migrate_fd_error(MigrationState *s, const Error *error) +void migrate_fd_error(MigrationState *s, Error *error) { trace_migrate_fd_error(error_get_pretty(error)); assert(s->to_dst_file =3D=3D NULL); @@ -1448,7 +1446,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool = blk, } =20 if (local_err) { - migrate_fd_error(s, local_err); + migrate_fd_error(s, error_copy(local_err)); error_propagate(errp, local_err); return; } diff --git a/migration/migration.h b/migration/migration.h index 2c8c53847a..29a7b79a39 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -177,8 +177,8 @@ bool migration_has_all_channels(void); =20 uint64_t migrate_max_downtime(void); =20 -void migrate_set_error(MigrationState *s, const Error *error); -void migrate_fd_error(MigrationState *s, const Error *error); +void migrate_set_error(MigrationState *s, Error *error); +void migrate_fd_error(MigrationState *s, Error *error); =20 void migrate_fd_connect(MigrationState *s); =20 diff --git a/migration/socket.c b/migration/socket.c index 248a798543..6d49903978 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -81,7 +81,6 @@ static void socket_outgoing_migration(QIOTask *task, if (qio_task_propagate_error(task, &err)) { trace_migration_socket_outgoing_error(error_get_pretty(err)); migrate_fd_error(data->s, err); - error_free(err); } else { trace_migration_socket_outgoing_connected(data->hostname); migration_channel_connect(data->s, sioc, data->hostname); --=20 2.14.3 From nobody Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515588608639809.0810957384051; Wed, 10 Jan 2018 04:50:08 -0800 (PST) Received: from localhost ([::1]:38999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFpO-0007NJ-9u for importer@patchew.org; Wed, 10 Jan 2018 07:49:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFn5-00063n-L7 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFn2-0004JV-W2 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45582) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFn2-0004IT-QE for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:32 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEF8BC049D42 for ; Wed, 10 Jan 2018 12:47:31 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54DB07B8DC; Wed, 10 Jan 2018 12:47:30 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:11 +0100 Message-Id: <20180110124723.11879-3-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 10 Jan 2018 12:47:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 02/14] migration: Rename initial_bytes 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" Now it is called qemu_file_bytes that reflects better what it does, and we create qemu_file_bytes_now to not have to call qemu_ftell() twice. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/migration.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 085e88c625..e506b9c2c6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2217,13 +2217,13 @@ static void *migration_thread(void *opaque) /* Used by the bandwidth calcs, updated later */ int64_t initial_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); int64_t setup_start =3D qemu_clock_get_ms(QEMU_CLOCK_HOST); - int64_t initial_bytes =3D 0; /* * The final stage happens when the remaining data is smaller than * this threshold; it's calculated from the requested downtime and * measured bandwidth */ int64_t threshold_size =3D 0; + int64_t qemu_file_bytes =3D 0; int64_t start_time =3D initial_time; int64_t end_time; bool old_vm_running =3D false; @@ -2311,8 +2311,9 @@ static void *migration_thread(void *opaque) } current_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); if (current_time >=3D initial_time + BUFFER_DELAY) { - uint64_t transferred_bytes =3D qemu_ftell(s->to_dst_file) - - initial_bytes; + uint64_t qemu_file_bytes_now =3D qemu_ftell(s->to_dst_file); + uint64_t transferred_bytes =3D + qemu_file_bytes_now - qemu_file_bytes; uint64_t time_spent =3D current_time - initial_time; double bandwidth =3D (double)transferred_bytes / time_spent; threshold_size =3D bandwidth * s->parameters.downtime_limit; @@ -2331,7 +2332,7 @@ static void *migration_thread(void *opaque) =20 qemu_file_reset_rate_limit(s->to_dst_file); initial_time =3D current_time; - initial_bytes =3D qemu_ftell(s->to_dst_file); + qemu_file_bytes =3D qemu_file_bytes_now; } if (qemu_file_rate_limit(s->to_dst_file)) { /* usleep expects microseconds */ --=20 2.14.3 From nobody Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515588606642330.22936612289016; Wed, 10 Jan 2018 04:50:06 -0800 (PST) Received: from localhost ([::1]:39001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFpR-0007Pj-6d for importer@patchew.org; Wed, 10 Jan 2018 07:50:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFn6-00064A-Rm for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFn5-0004Nl-NA for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54054) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFn5-0004Mj-FP for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:35 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 968AD7CB89 for ; Wed, 10 Jan 2018 12:47:34 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3645F7B8DC; Wed, 10 Jan 2018 12:47:32 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:12 +0100 Message-Id: <20180110124723.11879-4-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 10 Jan 2018 12:47:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 03/14] migration: Drop current address parameter from save_zero_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" It already has RAMBlock and offset, it can calculate it itself. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index cb1950f3eb..5a109efeda 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -907,11 +907,10 @@ static void migration_bitmap_sync(RAMState *rs) * @rs: current RAM state * @block: block that contains the page we want to send * @offset: offset inside the block for the page - * @p: pointer to the page */ -static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset, - uint8_t *p) +static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset) { + uint8_t *p =3D block->host + offset; int pages =3D -1; =20 if (is_zero_range(p, TARGET_PAGE_SIZE)) { @@ -984,7 +983,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus= *pss, bool last_stage) } } } else { - pages =3D save_zero_page(rs, block, offset, p); + pages =3D save_zero_page(rs, block, offset); if (pages > 0) { /* Must let xbzrle know, otherwise a previous (now 0'd) cached * page would be stale @@ -1160,7 +1159,7 @@ static int ram_save_compressed_page(RAMState *rs, Pag= eSearchStatus *pss, */ if (block !=3D rs->last_sent_block) { flush_compressed_data(rs); - pages =3D save_zero_page(rs, block, offset, p); + pages =3D save_zero_page(rs, block, offset); if (pages =3D=3D -1) { /* Make sure the first page is sent out before other pages= */ bytes_xmit =3D save_page_header(rs, rs->f, block, offset | @@ -1180,7 +1179,7 @@ static int ram_save_compressed_page(RAMState *rs, Pag= eSearchStatus *pss, ram_release_pages(block->idstr, offset, pages); } } else { - pages =3D save_zero_page(rs, block, offset, p); + pages =3D save_zero_page(rs, block, offset); if (pages =3D=3D -1) { pages =3D compress_page_with_multi_thread(rs, block, offse= t); } else { --=20 2.14.3 From nobody Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515588959600652.590125434991; Wed, 10 Jan 2018 04:55:59 -0800 (PST) Received: from localhost ([::1]:39141 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFv3-0003xW-W0 for importer@patchew.org; Wed, 10 Jan 2018 07:55:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFnF-00068j-1I for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFnB-0004WO-QT for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50218) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFnB-0004V0-EX for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:41 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5526A272A3 for ; Wed, 10 Jan 2018 12:47:35 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8FC37B608; Wed, 10 Jan 2018 12:47:33 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:13 +0100 Message-Id: <20180110124723.11879-5-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 10 Jan 2018 12:47:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 04/14] migration: Start of multiple fd work 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 create new channels for each new thread created. We send through them in a packed struct. This way we can check we connect the right channels in both sides. Signed-off-by: Juan Quintela -- Split SocketArgs into incoming and outgoing args Use UUID's on the initial message, so we are sure we are connecting to the right channel. Remove init semaphore. Now that we use uuids on the init message, we know that this is our channel. Fix recv socket destwroy, we were destroying send channels. This was very interesting, because we were using an unreferred object without problems. Move to struct of pointers init channel sooner. split recv thread creation. listen on main thread We count the number of created threads to know when we need to stop listeni= ng Use g_strdup_printf report channel id on errors Add name parameter Use local_err Add Error * parameter to socket_send_channel_create() Use qio_channel_*_all Use asynchronous connect Use an struct to send all fields Use default uuid Fix local_err =3D NULL (dave) Make lines 80 lines long (checkpatch) Move multifd_new_channel() and multifd_recv_thread() to later patches when used. Add __attribute__(packad) Use UUIDs are opaques isntead of the ASCII represantation rename migrate_new_channel_async to migrate_new_send_channel_async rename recv_channel_destroy to _unref. And create the pairing _ref. --- migration/migration.c | 7 +++- migration/ram.c | 114 +++++++++++++++++++++++++++++++++++-----------= ---- migration/ram.h | 3 ++ migration/socket.c | 39 ++++++++++++++++- migration/socket.h | 10 +++++ 5 files changed, 137 insertions(+), 36 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index e506b9c2c6..77fc17f723 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -426,7 +426,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc) QEMUFile *f =3D qemu_fopen_channel_input(ioc); migration_fd_process_incoming(f); } - /* We still only have a single channel. Nothing to do here yet */ + multifd_recv_new_channel(ioc); } =20 /** @@ -437,6 +437,11 @@ void migration_ioc_process_incoming(QIOChannel *ioc) */ bool migration_has_all_channels(void) { + if (migrate_use_multifd()) { + int thread_count =3D migrate_multifd_channels(); + + return thread_count =3D=3D multifd_created_channels(); + } return true; } =20 diff --git a/migration/ram.c b/migration/ram.c index 5a109efeda..aef5a323f3 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" @@ -49,6 +50,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 */ @@ -396,6 +399,7 @@ struct MultiFDSendParams { uint8_t id; char *name; QemuThread thread; + QIOChannel *c; QemuSemaphore sem; QemuMutex mutex; bool quit; @@ -412,6 +416,15 @@ 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 @@ -437,6 +450,7 @@ int multifd_save_cleanup(Error **errp) qemu_thread_join(&p->thread); qemu_mutex_destroy(&p->mutex); qemu_sem_destroy(&p->sem); + socket_send_channel_destroy(p->c); g_free(p->name); p->name =3D NULL; } @@ -447,9 +461,27 @@ int multifd_save_cleanup(Error **errp) return ret; } =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; + + 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; + } =20 while (true) { qemu_mutex_lock(&p->mutex); @@ -464,6 +496,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); + + qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, + QEMU_THREAD_JOINABLE); + + multifd_send_state->count++; + } +} + int multifd_save_setup(void) { int thread_count; @@ -484,10 +537,7 @@ int multifd_save_setup(void) p->quit =3D false; p->id =3D i; p->name =3D g_strdup_printf("multifdsend_%d", i); - qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, - QEMU_THREAD_JOINABLE); - - multifd_send_state->count++; + socket_send_channel_create(multifd_new_send_channel_async, p); } return 0; } @@ -496,6 +546,7 @@ struct MultiFDRecvParams { uint8_t id; char *name; QemuThread thread; + QIOChannel *c; QemuSemaphore sem; QemuMutex mutex; bool quit; @@ -506,12 +557,25 @@ struct { MultiFDRecvParams *params; /* number of created threads */ int count; + /* Should we finish */ + bool quit; } *multifd_recv_state; =20 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); + } + } + multifd_recv_state->quit =3D true; + for (i =3D 0; i < multifd_recv_state->count; i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 @@ -537,6 +601,7 @@ int multifd_load_cleanup(Error **errp) qemu_thread_join(&p->thread); qemu_mutex_destroy(&p->mutex); qemu_sem_destroy(&p->sem); + socket_recv_channel_unref(p->c); g_free(p->name); p->name =3D NULL; } @@ -548,27 +613,9 @@ int multifd_load_cleanup(Error **errp) return ret; } =20 -static void *multifd_recv_thread(void *opaque) -{ - MultiFDRecvParams *p =3D opaque; - - while (true) { - qemu_mutex_lock(&p->mutex); - if (p->quit) { - qemu_mutex_unlock(&p->mutex); - break; - } - qemu_mutex_unlock(&p->mutex); - qemu_sem_wait(&p->sem); - } - - return NULL; -} - int multifd_load_setup(void) { int thread_count; - uint8_t i; =20 if (!migrate_use_multifd()) { return 0; @@ -577,21 +624,20 @@ 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); multifd_recv_state->count =3D 0; - for (i =3D 0; i < thread_count; i++) { - MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; - - qemu_mutex_init(&p->mutex); - qemu_sem_init(&p->sem, 0); - p->quit =3D false; - p->id =3D i; - p->name =3D g_strdup_printf("multifdrecv_%d", i); - qemu_thread_create(&p->thread, p->name, multifd_recv_thread, p, - QEMU_THREAD_JOINABLE); - multifd_recv_state->count++; - } + multifd_recv_state->quit =3D false; return 0; } =20 +int multifd_created_channels(void) +{ + return multifd_recv_state->count; +} + +void multifd_recv_new_channel(QIOChannel *ioc) +{ + socket_recv_channel_unref(ioc); +} + /** * save_page_header: write page header to wire * diff --git a/migration/ram.h b/migration/ram.h index 64d81e9f1d..be7d09d0ec 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -31,6 +31,7 @@ =20 #include "qemu-common.h" #include "exec/cpu-common.h" +#include "io/channel.h" =20 extern MigrationStats ram_counters; extern XBZRLECacheStats xbzrle_counters; @@ -43,6 +44,8 @@ int multifd_save_setup(void); int multifd_save_cleanup(Error **errp); int multifd_load_setup(void); int multifd_load_cleanup(Error **errp); +int multifd_created_channels(void); +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); diff --git a/migration/socket.c b/migration/socket.c index 6d49903978..aedabee8a1 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -27,6 +27,39 @@ #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; +} + +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; +} =20 static SocketAddress *tcp_build_address(const char *host_port, Error **err= p) { @@ -96,6 +129,11 @@ static void socket_start_outgoing_migration(MigrationSt= ate *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); } @@ -106,7 +144,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 6b91e9db38..cbdb8d64c3 100644 --- a/migration/socket.h +++ b/migration/socket.h @@ -16,6 +16,16 @@ =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 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 Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515588608699896.9334275842962; Wed, 10 Jan 2018 04:50:08 -0800 (PST) Received: from localhost ([::1]:39002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFpV-0007Ss-2U for importer@patchew.org; Wed, 10 Jan 2018 07:50:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFn9-000666-Vj for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFn8-0004Rj-Bb for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59958) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFn8-0004Qm-2a for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:38 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D28F20262 for ; Wed, 10 Jan 2018 12:47:37 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id A36227B8E6; Wed, 10 Jan 2018 12:47:35 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:14 +0100 Message-Id: <20180110124723.11879-6-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 10 Jan 2018 12:47:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 05/14] 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 and a new flag for this type of pages. 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 --- migration/ram.c | 159 +++++++++++++++++++++++++++++++++++++++++++++= +++- migration/trace-events | 2 + 2 files changed, 160 insertions(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index aef5a323f3..5d6b46ac23 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -52,6 +52,7 @@ #include "migration/block.h" #include "sysemu/sysemu.h" #include "qemu/uuid.h" +#include "qemu/iov.h" =20 /***********************************************************/ /* ram save/restore */ @@ -71,6 +72,7 @@ #define RAM_SAVE_FLAG_XBZRLE 0x40 /* 0x80 is reserved in migration.h start with 0x100 next */ #define RAM_SAVE_FLAG_COMPRESS_PAGE 0x100 +#define RAM_SAVE_FLAG_MULTIFD_PAGE 0x200 =20 static inline bool is_zero_range(uint8_t *p, uint64_t size) { @@ -395,14 +397,36 @@ static void compress_threads_save_setup(void) =20 /* Multiple fd's */ =20 +/* used to continue on the same multifd group */ +#define MULTIFD_CONTINUE UINT16_MAX + +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; QIOChannel *c; QemuSemaphore sem; QemuMutex mutex; + /* protected by param mutex */ bool quit; + 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 @@ -410,8 +434,31 @@ struct { MultiFDSendParams *params; /* number of created threads */ int count; + 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; @@ -453,9 +500,13 @@ int multifd_save_cleanup(Error **errp) socket_send_channel_destroy(p->c); g_free(p->name); p->name =3D NULL; + multifd_pages_clear(p->pages); + p->pages =3D NULL; } 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; @@ -482,6 +533,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_mutex_lock(&p->mutex); @@ -489,9 +541,24 @@ 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); qemu_sem_wait(&p->sem); } + trace_multifd_send_thread(p->id, p->packets_sent); =20 return NULL; } @@ -529,6 +596,10 @@ 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); multifd_send_state->count =3D 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 @@ -536,12 +607,58 @@ 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); } return 0; } =20 +static uint16_t multifd_send_page(RAMBlock *block, ram_addr_t offset, + bool last_page) +{ + int i; + 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 MULTIFD_CONTINUE; + } + } + + qemu_sem_wait(&multifd_send_state->sem); + qemu_mutex_lock(&multifd_send_state->mutex); + for (i =3D 0; i < multifd_send_state->count; i++) { + p =3D &multifd_send_state->params[i]; + + if (p->done) { + p->done =3D false; + 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); + + return i; +} + struct MultiFDRecvParams { uint8_t id; char *name; @@ -1070,6 +1187,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_MULTIFD_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) { @@ -1498,6 +1640,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); } @@ -2878,6 +3022,10 @@ static int ram_load(QEMUFile *f, void *opaque, int v= ersion_id) if (!migrate_use_compression()) { invalid_flags |=3D RAM_SAVE_FLAG_COMPRESS_PAGE; } + + if (!migrate_use_multifd()) { + invalid_flags |=3D RAM_SAVE_FLAG_MULTIFD_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 @@ -2902,13 +3050,17 @@ static int ram_load(QEMUFile *f, void *opaque, int = version_id) if (flags & invalid_flags & RAM_SAVE_FLAG_COMPRESS_PAGE) { error_report("Received an unexpected compressed page"); } + if (flags & invalid_flags & RAM_SAVE_FLAG_MULTIFD_PAGE) { + error_report("Received an unexpected multifd page"); + } =20 ret =3D -EINVAL; break; } =20 if (flags & (RAM_SAVE_FLAG_ZERO | RAM_SAVE_FLAG_PAGE | - RAM_SAVE_FLAG_COMPRESS_PAGE | RAM_SAVE_FLAG_XBZRLE)) { + RAM_SAVE_FLAG_COMPRESS_PAGE | RAM_SAVE_FLAG_XBZRLE | + RAM_SAVE_FLAG_MULTIFD_PAGE)) { RAMBlock *block =3D ram_block_from_stream(f, flags); =20 host =3D host_from_ram_block_offset(block, addr); @@ -2997,6 +3149,11 @@ static int ram_load(QEMUFile *f, void *opaque, int v= ersion_id) break; } break; + + case RAM_SAVE_FLAG_MULTIFD_PAGE: + qemu_get_buffer(f, host, TARGET_PAGE_SIZE); + break; + case RAM_SAVE_FLAG_EOS: /* normal exit */ break; diff --git a/migration/trace-events b/migration/trace-events index 141e773305..61ee21a13e 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -77,6 +77,8 @@ 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(char id, int seq, int num) "channel %d sequence %d num pages = %d" +multifd_send_thread(char id, uint32_t packets) "channel %d packets %d" =20 # migration/migration.c await_return_path_close_on_source_close(void) "" --=20 2.14.3 From nobody Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151558878755538.829031420082856; Wed, 10 Jan 2018 04:53:07 -0800 (PST) Received: from localhost ([::1]:39028 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFsQ-0001ZT-Oy for importer@patchew.org; Wed, 10 Jan 2018 07:53:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFnE-00068h-Vv for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFnA-0004UT-Ad for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59970) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFnA-0004TJ-5e for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:40 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53F1020262 for ; Wed, 10 Jan 2018 12:47:39 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 801D67B8E6; Wed, 10 Jan 2018 12:47:37 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:15 +0100 Message-Id: <20180110124723.11879-7-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 10 Jan 2018 12:47:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 06/14] migration: Send the fd number which we are going to use for this 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" We are still sending the page through the main channel, that would change later in the series Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index 5d6b46ac23..19c8089c4b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1191,6 +1191,7 @@ static int ram_multifd_page(RAMState *rs, PageSearchS= tatus *pss, bool last_stage) { int pages; + uint16_t fd_num; uint8_t *p; RAMBlock *block =3D pss->block; ram_addr_t offset =3D pss->page << TARGET_PAGE_BITS; @@ -1202,7 +1203,10 @@ static int ram_multifd_page(RAMState *rs, PageSearch= Status *pss, ram_counters.transferred +=3D save_page_header(rs, rs->f, block, offset | RAM_SAVE_FLAG_MULTIFD_PAGE); - multifd_send_page(block, offset, rs->migration_dirty_pages =3D=3D = 1); + fd_num =3D multifd_send_page(block, offset, + rs->migration_dirty_pages =3D=3D 1); + qemu_put_be16(rs->f, fd_num); + ram_counters.transferred +=3D 2; /* size of fd_num */ qemu_put_buffer(rs->f, p, TARGET_PAGE_SIZE); ram_counters.transferred +=3D TARGET_PAGE_SIZE; pages =3D 1; @@ -3040,6 +3044,7 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) while (!postcopy_running && !ret && !(flags & RAM_SAVE_FLAG_EOS)) { ram_addr_t addr, total_ram_bytes; void *host =3D NULL; + uint16_t fd_num; uint8_t ch; =20 addr =3D qemu_get_be64(f); @@ -3151,6 +3156,11 @@ static int ram_load(QEMUFile *f, void *opaque, int v= ersion_id) break; =20 case RAM_SAVE_FLAG_MULTIFD_PAGE: + fd_num =3D qemu_get_be16(f); + if (fd_num !=3D 0) { + /* this is yet an unused variable, changed later */ + fd_num =3D fd_num; + } qemu_get_buffer(f, host, TARGET_PAGE_SIZE); break; =20 --=20 2.14.3 From nobody Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151558877800896.53561144070352; Wed, 10 Jan 2018 04:52:58 -0800 (PST) Received: from localhost ([::1]:39025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFsH-0001Tl-4a for importer@patchew.org; Wed, 10 Jan 2018 07:52:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFnF-00068i-02 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFnC-0004XC-J5 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50222) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFnC-0004W7-AL for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:42 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6246A61D07 for ; Wed, 10 Jan 2018 12:47:41 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACD877B608; Wed, 10 Jan 2018 12:47:39 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:16 +0100 Message-Id: <20180110124723.11879-8-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 10 Jan 2018 12:47:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 07/14] migration: Create thread infrastructure for multifd recv side 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 make the locking and the transfer of information specific, even if we are still receiving things through the main thread. Signed-off-by: Juan Quintela -- We split when we create the main channel and where we start the main migration thread, so we wait for the creation of the other threads. Use multifd_clear_pages(). Don't remove object_unref() We use correctly the channel numbres Denife multifd_new_channel/multifd_recv_thread in this patch, that is where it is used. rename migrate_new_channel to migrate_new_send_channel Add ToDo comment Add trace --- migration/migration.c | 5 +- migration/migration.h | 1 + migration/ram.c | 129 +++++++++++++++++++++++++++++++++++++++++++++= +--- migration/socket.c | 3 ++ migration/trace-events | 2 + 5 files changed, 132 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 77fc17f723..1545f3a0b0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -406,7 +406,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); @@ -424,7 +424,8 @@ 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 29a7b79a39..7de193a9c0 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -172,6 +172,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 19c8089c4b..8443806f12 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -660,13 +660,20 @@ static uint16_t multifd_send_page(RAMBlock *block, ra= m_addr_t offset, } =20 struct MultiFDRecvParams { + /* not changed */ uint8_t id; char *name; QemuThread thread; QIOChannel *c; + QemuSemaphore ready; QemuSemaphore sem; QemuMutex mutex; + /* proteced by param mutex */ bool quit; + /* how many patches has sent this channel */ + uint32_t packets_recv; + multifd_pages_t *pages; + bool done; }; typedef struct MultiFDRecvParams MultiFDRecvParams; =20 @@ -676,6 +683,7 @@ struct { int count; /* Should we finish */ bool quit; + multifd_pages_t *pages; } *multifd_recv_state; =20 static void terminate_multifd_recv_threads(Error *errp) @@ -721,15 +729,51 @@ int multifd_load_cleanup(Error **errp) socket_recv_channel_unref(p->c); g_free(p->name); p->name =3D NULL; + multifd_pages_clear(p->pages); + p->pages =3D NULL; } 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 return ret; } =20 +static void *multifd_recv_thread(void *opaque) +{ + MultiFDRecvParams *p =3D opaque; + + qemu_sem_post(&p->ready); + while (true) { + qemu_mutex_lock(&p->mutex); + if (p->quit) { + qemu_mutex_unlock(&p->mutex); + break; + } + if (p->pages->used) { + p->pages->used =3D 0; + + trace_multifd_recv(p->id, p->pages->seq, p->pages->used); + + /* ToDo: receive pages here */ + + p->done =3D true; + p->packets_recv++; + qemu_mutex_unlock(&p->mutex); + qemu_sem_post(&p->ready); + continue; + } + qemu_mutex_unlock(&p->mutex); + qemu_sem_wait(&p->sem); + } + trace_multifd_recv_thread(p->id, p->packets_recv); + + return NULL; +} + int multifd_load_setup(void) { int thread_count; @@ -742,6 +786,8 @@ int multifd_load_setup(void) multifd_recv_state->params =3D g_new0(MultiFDRecvParams, thread_count); multifd_recv_state->count =3D 0; multifd_recv_state->quit =3D false; + multifd_pages_init(&multifd_recv_state->pages, + migrate_multifd_page_count()); return 0; } =20 @@ -752,7 +798,80 @@ int multifd_created_channels(void) =20 void multifd_recv_new_channel(QIOChannel *ioc) { - socket_recv_channel_unref(ioc); + MultiFDRecvParams *p; + MultiFDInit_t msg; + Error *local_err =3D NULL; + size_t ret; + + 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->id !=3D 0) { + error_setg(&local_err, "multifd: received id '%d' already setup'", + msg.id); + terminate_multifd_recv_threads(local_err); + return; + } + qemu_mutex_init(&p->mutex); + qemu_sem_init(&p->sem, 0); + qemu_sem_init(&p->ready, 0); + p->quit =3D false; + p->id =3D msg.id; + p->done =3D false; + multifd_pages_init(&p->pages, migrate_multifd_page_count()); + p->c =3D ioc; + multifd_recv_state->count++; + p->name =3D g_strdup_printf("multifdrecv_%d", msg.id); + socket_recv_channel_ref(ioc); + + qemu_thread_create(&p->thread, p->name, multifd_recv_thread, p, + QEMU_THREAD_JOINABLE); + if (multifd_recv_state->count =3D=3D migrate_multifd_channels()) { + migration_incoming_process(); + } +} + +static void multifd_recv_page(RAMBlock *block, ram_addr_t offset, + uint8_t *address, uint16_t fd_num) +{ + int thread_count; + MultiFDRecvParams *p; + multifd_pages_t *pages =3D multifd_recv_state->pages; + + pages->iov[pages->used].iov_base =3D address; + pages->iov[pages->used].iov_len =3D TARGET_PAGE_SIZE; + pages->used++; + + if (fd_num =3D=3D MULTIFD_CONTINUE) { + return; + } + + thread_count =3D migrate_multifd_channels(); + assert(fd_num < thread_count); + p =3D &multifd_recv_state->params[fd_num]; + + qemu_sem_wait(&p->ready); + + qemu_mutex_lock(&p->mutex); + p->done =3D false; + p->pages->used =3D 0; + multifd_recv_state->pages =3D p->pages; + p->pages =3D pages; + qemu_mutex_unlock(&p->mutex); + qemu_sem_post(&p->sem); } =20 /** @@ -3042,6 +3161,7 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) } =20 while (!postcopy_running && !ret && !(flags & RAM_SAVE_FLAG_EOS)) { + RAMBlock *block =3D NULL; ram_addr_t addr, total_ram_bytes; void *host =3D NULL; uint16_t fd_num; @@ -3066,7 +3186,7 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) if (flags & (RAM_SAVE_FLAG_ZERO | RAM_SAVE_FLAG_PAGE | RAM_SAVE_FLAG_COMPRESS_PAGE | RAM_SAVE_FLAG_XBZRLE | RAM_SAVE_FLAG_MULTIFD_PAGE)) { - RAMBlock *block =3D ram_block_from_stream(f, flags); + block =3D ram_block_from_stream(f, flags); =20 host =3D host_from_ram_block_offset(block, addr); if (!host) { @@ -3157,10 +3277,7 @@ static int ram_load(QEMUFile *f, void *opaque, int v= ersion_id) =20 case RAM_SAVE_FLAG_MULTIFD_PAGE: fd_num =3D qemu_get_be16(f); - if (fd_num !=3D 0) { - /* this is yet an unused variable, changed later */ - fd_num =3D fd_num; - } + multifd_recv_page(block, addr, host, fd_num); qemu_get_buffer(f, host, TARGET_PAGE_SIZE); break; =20 diff --git a/migration/socket.c b/migration/socket.c index aedabee8a1..ba23442175 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -192,6 +192,9 @@ out: 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; diff --git a/migration/trace-events b/migration/trace-events index 61ee21a13e..06aef4d4a3 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -77,7 +77,9 @@ 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_recv(char id, int seq, int num) "channel %d sequence %d num pages = %d" multifd_send(char id, int seq, int num) "channel %d sequence %d num pages = %d" +multifd_recv_thread(char id, uint32_t packets) "channel %d packets %d" multifd_send_thread(char id, uint32_t packets) "channel %d packets %d" =20 # migration/migration.c --=20 2.14.3 From nobody Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15155887799581014.785788107011; Wed, 10 Jan 2018 04:52:59 -0800 (PST) Received: from localhost ([::1]:39027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFsJ-0001Vj-3b for importer@patchew.org; Wed, 10 Jan 2018 07:52:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFnF-00068s-PP for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFnE-0004ao-OD for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59626) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFnE-0004Zn-Fs for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:44 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95C9D7854B for ; Wed, 10 Jan 2018 12:47:43 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id B09A57B8E4; Wed, 10 Jan 2018 12:47:41 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:17 +0100 Message-Id: <20180110124723.11879-9-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 10 Jan 2018 12:47:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 08/14] migration: Transfer pages over new 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" We switch for sending the page number to send real pages. Signed-off-by: Juan Quintela -- Remove the HACK bit, now we have the function that calculates the size of a page exported. Rename multifd_pages{_now}, to sent pages Remove multifd pages field, it is the same than normal pages Merge test channels here Make sent_pages also work for non multifd case Reviewed-by: Dr. David Alan Gilbert --- migration/migration.c | 10 +++++++++- migration/ram.c | 41 +++++++++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 1545f3a0b0..6ebcfa36cc 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2230,6 +2230,8 @@ static void *migration_thread(void *opaque) */ int64_t threshold_size =3D 0; int64_t qemu_file_bytes =3D 0; + /* Stores how many pages we have sent */ + int64_t sent_pages =3D 0; int64_t start_time =3D initial_time; int64_t end_time; bool old_vm_running =3D false; @@ -2318,8 +2320,13 @@ static void *migration_thread(void *opaque) current_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); if (current_time >=3D initial_time + BUFFER_DELAY) { uint64_t qemu_file_bytes_now =3D qemu_ftell(s->to_dst_file); + uint64_t sent_pages_now =3D ram_counters.normal; + /* multifd sends data out of the qemu_file */ + uint64_t multifd_transferred =3D migrate_use_multifd() ? + (sent_pages_now - sent_pages) * qemu_target_page_size() : = 0; uint64_t transferred_bytes =3D - qemu_file_bytes_now - qemu_file_bytes; + (qemu_file_bytes_now - qemu_file_bytes) + + multifd_transferred; uint64_t time_spent =3D current_time - initial_time; double bandwidth =3D (double)transferred_bytes / time_spent; threshold_size =3D bandwidth * s->parameters.downtime_limit; @@ -2339,6 +2346,7 @@ static void *migration_thread(void *opaque) qemu_file_reset_rate_limit(s->to_dst_file); initial_time =3D current_time; qemu_file_bytes =3D qemu_file_bytes_now; + sent_pages =3D sent_pages_now; } if (qemu_file_rate_limit(s->to_dst_file)) { /* usleep expects microseconds */ diff --git a/migration/ram.c b/migration/ram.c index 8443806f12..20f3726909 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -542,12 +542,20 @@ static void *multifd_send_thread(void *opaque) break; } if (p->pages->used) { + Error *local_err =3D NULL; + size_t ret; + uint32_t used; + + used =3D p->pages->used; p->pages->used =3D 0; qemu_mutex_unlock(&p->mutex); =20 - trace_multifd_send(p->id, p->pages->seq, p->pages->used); - /* ToDo: send page here */ - + trace_multifd_send(p->id, p->pages->seq, used); + ret =3D qio_channel_writev_all(p->c, p->pages->iov, used, &loc= al_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++; @@ -754,12 +762,21 @@ static void *multifd_recv_thread(void *opaque) break; } if (p->pages->used) { + Error *local_err =3D NULL; + size_t ret; + uint32_t used; + + used =3D p->pages->used; p->pages->used =3D 0; + qemu_mutex_unlock(&p->mutex); =20 - trace_multifd_recv(p->id, p->pages->seq, p->pages->used); - - /* ToDo: receive pages here */ - + trace_multifd_recv(p->id, p->pages->seq, used); + ret =3D qio_channel_readv_all(p->c, p->pages->iov, used, &loca= l_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); @@ -1311,12 +1328,9 @@ static int ram_multifd_page(RAMState *rs, PageSearch= Status *pss, { int pages; uint16_t fd_num; - uint8_t *p; RAMBlock *block =3D pss->block; ram_addr_t offset =3D pss->page << TARGET_PAGE_BITS; =20 - p =3D block->host + offset; - pages =3D save_zero_page(rs, block, offset); if (pages =3D=3D -1) { ram_counters.transferred +=3D @@ -1325,8 +1339,12 @@ static int ram_multifd_page(RAMState *rs, PageSearch= Status *pss, fd_num =3D multifd_send_page(block, offset, rs->migration_dirty_pages =3D=3D 1); qemu_put_be16(rs->f, fd_num); + if (fd_num !=3D MULTIFD_CONTINUE) { + /* We start with a different channel. + Flush pending work */ + qemu_fflush(rs->f); + } ram_counters.transferred +=3D 2; /* size of fd_num */ - qemu_put_buffer(rs->f, p, TARGET_PAGE_SIZE); ram_counters.transferred +=3D TARGET_PAGE_SIZE; pages =3D 1; ram_counters.normal++; @@ -3278,7 +3296,6 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) case RAM_SAVE_FLAG_MULTIFD_PAGE: fd_num =3D qemu_get_be16(f); multifd_recv_page(block, addr, host, fd_num); - qemu_get_buffer(f, host, TARGET_PAGE_SIZE); break; =20 case RAM_SAVE_FLAG_EOS: --=20 2.14.3 From nobody Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515589017002443.0211510544973; Wed, 10 Jan 2018 04:56:57 -0800 (PST) Received: from localhost ([::1]:39143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFw7-0004uA-Tg for importer@patchew.org; Wed, 10 Jan 2018 07:56:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFnM-0006FJ-1U for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFnJ-0004fo-H4 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59654) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFnJ-0004ev-8a for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:49 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 602908B101 for ; Wed, 10 Jan 2018 12:47:48 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3ED97B608; Wed, 10 Jan 2018 12:47:43 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:18 +0100 Message-Id: <20180110124723.11879-10-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 10 Jan 2018 12:47:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 09/14] migration: Flush receive queue 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" Each time that we sync the bitmap, it is a possiblity that we receive a page that is being processed by a different thread. We fix this problem just making sure that we wait for all receiving threads to finish its work before we procedeed with the next stage. We are low on page flags, so we use a combination that is not valid to emit that message: MULTIFD_PAGE and COMPRESSED. I tried to make a migration command for it, but it don't work because we sync the bitmap sometimes when we have already sent the beggining of the section, so I just added a new page flag. Signed-off-by: Juan Quintela -- Create RAM_SAVE_FLAG_MULTIFD_SYNC (dave suggestion) Move the set of need_flush to inside the bitmap_sync code (peter suggestion) --- migration/ram.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++= ++ 1 file changed, 55 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 20f3726909..b1ad7b2730 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -74,6 +74,14 @@ #define RAM_SAVE_FLAG_COMPRESS_PAGE 0x100 #define RAM_SAVE_FLAG_MULTIFD_PAGE 0x200 =20 +/* We are getting low on pages flags, so we start using combinations + When we need to flush a page, we sent it as + RAM_SAVE_FLAG_MULTIFD_PAGE | RAM_SAVE_FLAG_ZERO + We don't allow that combination +*/ +#define RAM_SAVE_FLAG_MULTIFD_SYNC \ + (RAM_SAVE_FLAG_MULTIFD_PAGE | RAM_SAVE_FLAG_ZERO) + static inline bool is_zero_range(uint8_t *p, uint64_t size) { return buffer_is_zero(p, size); @@ -226,6 +234,9 @@ struct RAMState { uint64_t iterations_prev; /* Iterations since start */ uint64_t iterations; + /* Indicates if we have synced the bitmap and we need to assure that + target has processeed all previous pages */ + bool multifd_needs_flush; /* number of dirty bits in the bitmap */ uint64_t migration_dirty_pages; /* protects modification of the bitmap */ @@ -675,11 +686,13 @@ struct MultiFDRecvParams { QIOChannel *c; QemuSemaphore ready; QemuSemaphore sem; + QemuCond cond_sync; QemuMutex mutex; /* proteced by param mutex */ bool quit; /* how many patches has sent this channel */ uint32_t packets_recv; + bool sync; multifd_pages_t *pages; bool done; }; @@ -734,6 +747,7 @@ int multifd_load_cleanup(Error **errp) qemu_thread_join(&p->thread); qemu_mutex_destroy(&p->mutex); qemu_sem_destroy(&p->sem); + qemu_cond_destroy(&p->cond_sync); socket_recv_channel_unref(p->c); g_free(p->name); p->name =3D NULL; @@ -779,6 +793,10 @@ static void *multifd_recv_thread(void *opaque) qemu_mutex_lock(&p->mutex); p->done =3D true; p->packets_recv++; + if (p->sync) { + qemu_cond_signal(&p->cond_sync); + p->sync =3D false; + } qemu_mutex_unlock(&p->mutex); qemu_sem_post(&p->ready); continue; @@ -845,9 +863,11 @@ void multifd_recv_new_channel(QIOChannel *ioc) qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem, 0); qemu_sem_init(&p->ready, 0); + qemu_cond_init(&p->cond_sync); p->quit =3D false; p->id =3D msg.id; p->done =3D false; + p->sync =3D false; multifd_pages_init(&p->pages, migrate_multifd_page_count()); p->c =3D ioc; multifd_recv_state->count++; @@ -891,6 +911,27 @@ static void multifd_recv_page(RAMBlock *block, ram_add= r_t offset, qemu_sem_post(&p->sem); } =20 +static int multifd_flush(void) +{ + int i, thread_count; + + if (!migrate_use_multifd()) { + return 0; + } + thread_count =3D migrate_multifd_channels(); + for (i =3D 0; i < thread_count; i++) { + MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; + + qemu_mutex_lock(&p->mutex); + while (!p->done) { + p->sync =3D true; + qemu_cond_wait(&p->cond_sync, &p->mutex); + } + qemu_mutex_unlock(&p->mutex); + } + return 0; +} + /** * save_page_header: write page header to wire * @@ -908,6 +949,12 @@ static size_t save_page_header(RAMState *rs, QEMUFile = *f, RAMBlock *block, { size_t size, len; =20 + if (rs->multifd_needs_flush && + (offset & RAM_SAVE_FLAG_MULTIFD_PAGE)) { + offset |=3D RAM_SAVE_FLAG_ZERO; + rs->multifd_needs_flush =3D false; + } + if (block =3D=3D rs->last_sent_block) { offset |=3D RAM_SAVE_FLAG_CONTINUE; } @@ -1196,6 +1243,9 @@ static void migration_bitmap_sync(RAMState *rs) if (migrate_use_events()) { qapi_event_send_migration_pass(ram_counters.dirty_sync_count, NULL= ); } + if (!rs->ram_bulk_stage && migrate_use_multifd()) { + rs->multifd_needs_flush =3D true; + } } =20 /** @@ -3201,6 +3251,11 @@ static int ram_load(QEMUFile *f, void *opaque, int v= ersion_id) break; } =20 + if ((flags & RAM_SAVE_FLAG_MULTIFD_SYNC) + =3D=3D RAM_SAVE_FLAG_MULTIFD_SYNC) { + multifd_flush(); + flags =3D flags & ~RAM_SAVE_FLAG_ZERO; + } if (flags & (RAM_SAVE_FLAG_ZERO | RAM_SAVE_FLAG_PAGE | RAM_SAVE_FLAG_COMPRESS_PAGE | RAM_SAVE_FLAG_XBZRLE | RAM_SAVE_FLAG_MULTIFD_PAGE)) { --=20 2.14.3 From nobody Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515589126637933.8394613756981; Wed, 10 Jan 2018 04:58:46 -0800 (PST) Received: from localhost ([::1]:39179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFxt-0006de-PQ for importer@patchew.org; Wed, 10 Jan 2018 07:58:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFnO-0006Fb-GO for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFnL-0004h8-Am for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41464) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFnL-0004gM-49 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:51 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 387607C840 for ; Wed, 10 Jan 2018 12:47:50 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE8997B8DC; Wed, 10 Jan 2018 12:47:48 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:19 +0100 Message-Id: <20180110124723.11879-11-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 10 Jan 2018 12:47:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 10/14] 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 eb44a95aa9..488ae89f34 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -826,6 +826,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", "100000000"); + + 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, "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); +} + int main(int argc, char **argv) { char template[] =3D "/tmp/migration-test-XXXXXX"; @@ -853,6 +902,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 Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515588959522674.6079426745147; Wed, 10 Jan 2018 04:55:59 -0800 (PST) Received: from localhost ([::1]:39142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFvA-00043I-HE for importer@patchew.org; Wed, 10 Jan 2018 07:55:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFnO-0006Fc-HE for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFnN-0004j4-9O for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFnN-0004iH-3U for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:53 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3FBC35FD76 for ; Wed, 10 Jan 2018 12:47:52 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74D777B608; Wed, 10 Jan 2018 12:47:50 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:20 +0100 Message-Id: <20180110124723.11879-12-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 10 Jan 2018 12:47:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 11/14] LOCAL: use trace events for migration-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 --- tests/migration-test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/migration-test.c b/tests/migration-test.c index 488ae89f34..d0b0c1b64b 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -457,11 +457,13 @@ static void test_migrate_start(QTestState **from, QTe= stState **to, if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { init_bootfile_x86(bootpath); cmd_src =3D g_strdup_printf("-machine accel=3D%s -m 256M" + " -trace events=3D/home/quintela/tmp/eve= nts" " -name source,debug-threads=3Don" " -serial file:%s/src_serial" " -drive file=3D%s,format=3Draw", accel, tmpfs, bootpath); cmd_dst =3D g_strdup_printf("-machine accel=3D%s -m 256M" + " -trace events=3D/home/quintela/tmp/eve= nts" " -name target,debug-threads=3Don" " -serial file:%s/dest_serial" " -drive file=3D%s,format=3Draw" --=20 2.14.3 From nobody Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151558912268676.79984043693764; Wed, 10 Jan 2018 04:58:42 -0800 (PST) Received: from localhost ([::1]:39178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFxp-0006YM-SA for importer@patchew.org; Wed, 10 Jan 2018 07:58:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFnQ-0006GM-B2 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFnP-0004kv-C7 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41212) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFnP-0004kC-3A for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:55 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38E5849023 for ; Wed, 10 Jan 2018 12:47:54 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90CD77B8E1; Wed, 10 Jan 2018 12:47:52 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:21 +0100 Message-Id: <20180110124723.11879-13-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 10 Jan 2018 12:47:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 12/14] migration: Sent the page list over the normal 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 --- migration/ram.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++----= ---- 1 file changed, 60 insertions(+), 9 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index b1ad7b2730..f636c7da0a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -411,6 +411,19 @@ static void compress_threads_save_setup(void) /* used to continue on the same multifd group */ #define MULTIFD_CONTINUE UINT16_MAX =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; @@ -420,6 +433,8 @@ typedef struct { uint32_t seq; struct iovec *iov; RAMBlock *block; + uint32_t packet_len; + MultiFDPacket_t *packet; } multifd_pages_t; =20 struct MultiFDSendParams { @@ -456,6 +471,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 @@ -467,6 +484,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 @@ -553,16 +573,27 @@ static void *multifd_send_thread(void *opaque) break; } if (p->pages->used) { + MultiFDPacket_t *packet =3D p->pages->packet; Error *local_err =3D NULL; size_t ret; - uint32_t used; =20 - used =3D p->pages->used; + packet->used =3D p->pages->used; p->pages->used =3D 0; qemu_mutex_unlock(&p->mutex); - - trace_multifd_send(p->id, p->pages->seq, used); - ret =3D qio_channel_writev_all(p->c, p->pages->iov, used, &loc= al_err); + packet->magic =3D MULTIFD_MAGIC; + packet->version =3D MULTIFD_VERSION; + 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; @@ -645,6 +676,7 @@ static uint16_t multifd_send_page(RAMBlock *block, ram_= addr_t offset, pages->block =3D block; } =20 + pages->packet->offset[pages->used] =3D offset; pages->iov[pages->used].iov_base =3D block->host + offset; pages->iov[pages->used].iov_len =3D TARGET_PAGE_SIZE; pages->used++; @@ -776,16 +808,35 @@ static void *multifd_recv_thread(void *opaque) break; } if (p->pages->used) { + MultiFDPacket_t *packet =3D p->pages->packet; + RAMBlock *block; Error *local_err =3D NULL; size_t ret; - uint32_t used; + int i; =20 - used =3D p->pages->used; p->pages->used =3D 0; qemu_mutex_unlock(&p->mutex); =20 - trace_multifd_recv(p->id, p->pages->seq, used); - ret =3D qio_channel_readv_all(p->c, p->pages->iov, used, &loca= l_err); + 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++) { + if (block->host + packet->offset[i] + !=3D p->pages->iov[i].iov_base) { + printf("page offset %d packet %p pages %p\n", i, + block->host + packet->offset[i], + p->pages->iov[i].iov_base); + break; + } + } + 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; --=20 2.14.3 From nobody Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151558931253199.93491435799194; Wed, 10 Jan 2018 05:01:52 -0800 (PST) Received: from localhost ([::1]:39351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZG0k-0001QA-4C for importer@patchew.org; Wed, 10 Jan 2018 08:01:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFnR-0006Ic-Sl for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFnR-0004mp-34 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50352) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFnQ-0004ls-TE for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:57 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F1C9863705 for ; Wed, 10 Jan 2018 12:47:55 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74A1F7B8E7; Wed, 10 Jan 2018 12:47:54 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:22 +0100 Message-Id: <20180110124723.11879-14-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 10 Jan 2018 12:47:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 13/14] migration: Add multifd_send_packet trace 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" I need the block name, so I can't do that sooner. Signed-off-by: Juan Quintela --- migration/ram.c | 2 ++ migration/trace-events | 1 + 2 files changed, 3 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index f636c7da0a..6e45f668d1 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -705,6 +705,8 @@ static uint16_t multifd_send_page(RAMBlock *block, ram_= addr_t offset, multifd_send_state->pages =3D p->pages; p->pages =3D pages; qemu_mutex_unlock(&p->mutex); + trace_multifd_send_packet(p->id, p->pages->block->idstr, p->pages->seq, + p->pages->used, last_page); qemu_sem_post(&p->sem); =20 return i; diff --git a/migration/trace-events b/migration/trace-events index 06aef4d4a3..598620c58e 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -81,6 +81,7 @@ multifd_recv(char id, int seq, int num) "channel %d seque= nce %d num pages %d" multifd_send(char id, int seq, int num) "channel %d sequence %d num pages = %d" multifd_recv_thread(char id, uint32_t packets) "channel %d packets %d" multifd_send_thread(char id, uint32_t packets) "channel %d packets %d" +multifd_send_packet(char id, char *block_name, uint32_t seq, uint32_t pack= ets_used, bool last) "channel %d block %s seq %d used %d last %d" =20 # migration/migration.c await_return_path_close_on_source_close(void) "" --=20 2.14.3 From nobody Tue Oct 28 01:56:30 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515589185731300.27049689438445; Wed, 10 Jan 2018 04:59:45 -0800 (PST) Received: from localhost ([::1]:39180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFyq-0007fG-Qp for importer@patchew.org; Wed, 10 Jan 2018 07:59:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZFnU-0006Ko-13 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:48:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZFnT-0004oW-21 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:48:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41228) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZFnS-0004nt-Q3 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 07:47:59 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E63F063E03 for ; Wed, 10 Jan 2018 12:47:57 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BDD07B608; Wed, 10 Jan 2018 12:47:56 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Jan 2018 13:47:23 +0100 Message-Id: <20180110124723.11879-15-quintela@redhat.com> In-Reply-To: <20180110124723.11879-1-quintela@redhat.com> References: <20180110124723.11879-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 10 Jan 2018 12:47:57 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 14/14] all works 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 | 69 ++++++++++++++++++++++++++++-------------------------= ---- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 6e45f668d1..a689d4a218 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -671,22 +671,25 @@ static uint16_t multifd_send_page(RAMBlock *block, ra= m_addr_t offset, int i; MultiFDSendParams *p =3D NULL; /* make happy gcc */ multifd_pages_t *pages =3D multifd_send_state->pages; + bool same_block; =20 if (!pages->block) { pages->block =3D block; } =20 - pages->packet->offset[pages->used] =3D offset; - pages->iov[pages->used].iov_base =3D block->host + offset; - pages->iov[pages->used].iov_len =3D TARGET_PAGE_SIZE; - pages->used++; + same_block =3D pages->block =3D=3D block; + if (same_block) { + pages->packet->offset[pages->used] =3D offset; + pages->iov[pages->used].iov_base =3D block->host + offset; + pages->iov[pages->used].iov_len =3D TARGET_PAGE_SIZE; + pages->used++; =20 - if (!last_page) { - if (pages->used < pages->allocated) { - return MULTIFD_CONTINUE; + if (!last_page) { + if (pages->used < pages->allocated) { + return MULTIFD_CONTINUE; + } } } - qemu_sem_wait(&multifd_send_state->sem); qemu_mutex_lock(&multifd_send_state->mutex); for (i =3D 0; i < multifd_send_state->count; i++) { @@ -709,7 +712,10 @@ static uint16_t multifd_send_page(RAMBlock *block, ram= _addr_t offset, p->pages->used, last_page); qemu_sem_post(&p->sem); =20 - return i; + if (!same_block) { + multifd_send_page(block, offset, last_page); + } + return 0; } =20 struct MultiFDRecvParams { @@ -809,14 +815,13 @@ static void *multifd_recv_thread(void *opaque) qemu_mutex_unlock(&p->mutex); break; } - if (p->pages->used) { + if (true) { MultiFDPacket_t *packet =3D p->pages->packet; RAMBlock *block; Error *local_err =3D NULL; size_t ret; int i; =20 - p->pages->used =3D 0; qemu_mutex_unlock(&p->mutex); =20 ret =3D qio_channel_read_all(p->c, (void *)packet, @@ -828,13 +833,8 @@ static void *multifd_recv_thread(void *opaque) block =3D qemu_ram_block_by_name(packet->ramblock); p->pages->seq =3D packet->seq; for (i =3D 0; i < packet->used; i++) { - if (block->host + packet->offset[i] - !=3D p->pages->iov[i].iov_base) { - printf("page offset %d packet %p pages %p\n", i, - block->host + packet->offset[i], - p->pages->iov[i].iov_base); - break; - } + 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, @@ -851,11 +851,11 @@ static void *multifd_recv_thread(void *opaque) p->sync =3D false; } qemu_mutex_unlock(&p->mutex); - qemu_sem_post(&p->ready); +// qemu_sem_post(&p->ready); continue; } qemu_mutex_unlock(&p->mutex); - qemu_sem_wait(&p->sem); +// qemu_sem_wait(&p->sem); } trace_multifd_recv_thread(p->id, p->packets_recv); =20 @@ -953,7 +953,7 @@ static void multifd_recv_page(RAMBlock *block, ram_addr= _t offset, assert(fd_num < thread_count); p =3D &multifd_recv_state->params[fd_num]; =20 - qemu_sem_wait(&p->ready); +// qemu_sem_wait(&p->ready); =20 qemu_mutex_lock(&p->mutex); p->done =3D false; @@ -961,7 +961,7 @@ static void multifd_recv_page(RAMBlock *block, ram_addr= _t offset, multifd_recv_state->pages =3D p->pages; p->pages =3D pages; qemu_mutex_unlock(&p->mutex); - qemu_sem_post(&p->sem); +// qemu_sem_post(&p->sem); } =20 static int multifd_flush(void) @@ -1430,24 +1430,23 @@ static int ram_multifd_page(RAMState *rs, PageSearc= hStatus *pss, bool last_stage) { int pages; - uint16_t fd_num; +// uint16_t fd_num; RAMBlock *block =3D pss->block; ram_addr_t offset =3D pss->page << TARGET_PAGE_BITS; =20 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_MULTIFD_PAGE); - fd_num =3D multifd_send_page(block, offset, - rs->migration_dirty_pages =3D=3D 1); - qemu_put_be16(rs->f, fd_num); - if (fd_num !=3D MULTIFD_CONTINUE) { - /* We start with a different channel. - Flush pending work */ - qemu_fflush(rs->f); - } - ram_counters.transferred +=3D 2; /* size of fd_num */ +// ram_counters.transferred +=3D +// save_page_header(rs, rs->f, block, +// offset | RAM_SAVE_FLAG_MULTIFD_PAGE); + multifd_send_page(block, offset, rs->migration_dirty_pages =3D=3D = 1); +// qemu_put_be16(rs->f, fd_num); +// if (fd_num !=3D MULTIFD_CONTINUE) { +// /* We start with a different channel. +// Flush pending work */ +// qemu_fflush(rs->f); +// } +// ram_counters.transferred +=3D 2; /* size of fd_num */ ram_counters.transferred +=3D TARGET_PAGE_SIZE; pages =3D 1; ram_counters.normal++; --=20 2.14.3