From nobody Sat May 4 03:03:59 2024 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 1506035588548315.17413004364016; Thu, 21 Sep 2017 16:13:08 -0700 (PDT) Received: from localhost ([::1]:55839 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAeT-0000cG-K0 for importer@patchew.org; Thu, 21 Sep 2017 19:13:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAZy-0005ZU-8Q for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAZw-0001Fe-5X for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36133) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAZv-0001E1-Tq for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A8A27D0C9 for ; Thu, 21 Sep 2017 23:08:19 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB95260C9A; Thu, 21 Sep 2017 23:08:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0A8A27D0C9 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:07:55 +0200 Message-Id: <20170921230812.7095-2-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 21 Sep 2017 23:08:19 +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] [PULL 01/18] migration: Create migration_ioc_process_incoming() 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 pass the ioc instead of the fd. This will allow us to have more than one channel open. We also make sure that we set the from_src_file sooner, so we don't need to pass it as a parameter. Signed-off-by: Juan Quintela Reviewed-by: Daniel P. Berrange -- Do not assing mis->from_src_file (peterxu) --- migration/channel.c | 3 +-- migration/migration.c | 22 ++++++++++++++++++---- migration/migration.h | 2 ++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/migration/channel.c b/migration/channel.c index 3b7252f5a2..edceebdb7b 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -36,8 +36,7 @@ void migration_channel_process_incoming(QIOChannel *ioc) error_report_err(local_err); } } else { - QEMUFile *f =3D qemu_fopen_channel_input(ioc); - migration_fd_process_incoming(f); + migration_ioc_process_incoming(ioc); } } =20 diff --git a/migration/migration.c b/migration/migration.c index 959e8ec88e..2d4c56e612 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -306,17 +306,16 @@ static void process_incoming_migration_bh(void *opaqu= e) =20 static void process_incoming_migration_co(void *opaque) { - QEMUFile *f =3D opaque; MigrationIncomingState *mis =3D migration_incoming_get_current(); PostcopyState ps; int ret; =20 - mis->from_src_file =3D f; + assert(mis->from_src_file); mis->largest_page_size =3D qemu_ram_pagesize_largest(); postcopy_state_set(POSTCOPY_INCOMING_NONE); migrate_set_state(&mis->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_ACTIVE); - ret =3D qemu_loadvm_state(f); + ret =3D qemu_loadvm_state(mis->from_src_file); =20 ps =3D postcopy_state_get(); trace_process_incoming_migration_co_end(ret, ps); @@ -364,12 +363,27 @@ static void process_incoming_migration_co(void *opaqu= e) =20 void migration_fd_process_incoming(QEMUFile *f) { - Coroutine *co =3D qemu_coroutine_create(process_incoming_migration_co,= f); + Coroutine *co =3D qemu_coroutine_create(process_incoming_migration_co,= NULL); + MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 + if (!mis->from_src_file) { + mis->from_src_file =3D f; + } qemu_file_set_blocking(f, false); qemu_coroutine_enter(co); } =20 +void migration_ioc_process_incoming(QIOChannel *ioc) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + + if (!mis->from_src_file) { + 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 */ +} + /* * Send a 'SHUT' message on the return channel with the given value * to indicate that we've finished with the RP. Non-0 value indicates diff --git a/migration/migration.h b/migration/migration.h index 148c9facbc..99c398d484 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -20,6 +20,7 @@ #include "exec/cpu-common.h" #include "qemu/coroutine_int.h" #include "hw/qdev.h" +#include "io/channel.h" =20 /* State for the incoming migration */ struct MigrationIncomingState { @@ -152,6 +153,7 @@ struct MigrationState void migrate_set_state(int *state, int old_state, int new_state); =20 void migration_fd_process_incoming(QEMUFile *f); +void migration_ioc_process_incoming(QIOChannel *ioc); =20 uint64_t migrate_max_downtime(void); =20 --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506035758041848.9594029019822; Thu, 21 Sep 2017 16:15:58 -0700 (PDT) Received: from localhost ([::1]:55853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAh7-0003EJ-2e for importer@patchew.org; Thu, 21 Sep 2017 19:15:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAZy-0005Zu-Mz for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAZx-0001IX-PF for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47014) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAZx-0001HS-Im for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B284D80F7A for ; Thu, 21 Sep 2017 23:08:20 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F0BE60C9A; Thu, 21 Sep 2017 23:08:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B284D80F7A Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:07:56 +0200 Message-Id: <20170921230812.7095-3-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 21 Sep 2017 23:08:20 +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] [PULL 02/18] migration: Teach it about G_SOURCE_REMOVE 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" As this is defined on glib 2.32, add compatibility macros for older glibs. Signed-off-by: Juan Quintela Reviewed-by: Daniel P. Berrange Reviewed-by: Peter Xu --- include/glib-compat.h | 2 ++ migration/exec.c | 2 +- migration/fd.c | 2 +- migration/socket.c | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/glib-compat.h b/include/glib-compat.h index fcffcd3f07..e15aca2d40 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -223,6 +223,8 @@ static inline gboolean g_hash_table_contains(GHashTable= *hash_table, { return g_hash_table_lookup_extended(hash_table, key, NULL, NULL); } +#define G_SOURCE_CONTINUE TRUE +#define G_SOURCE_REMOVE FALSE #endif =20 #ifndef g_assert_true diff --git a/migration/exec.c b/migration/exec.c index 08b599e0e2..f3be1baf2e 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -49,7 +49,7 @@ static gboolean exec_accept_incoming_migration(QIOChannel= *ioc, { migration_channel_process_incoming(ioc); object_unref(OBJECT(ioc)); - return FALSE; /* unregister */ + return G_SOURCE_REMOVE; } =20 void exec_start_incoming_migration(const char *command, Error **errp) diff --git a/migration/fd.c b/migration/fd.c index 30f5258a6a..30de4b9847 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -49,7 +49,7 @@ static gboolean fd_accept_incoming_migration(QIOChannel *= ioc, { migration_channel_process_incoming(ioc); object_unref(OBJECT(ioc)); - return FALSE; /* unregister */ + return G_SOURCE_REMOVE; } =20 void fd_start_incoming_migration(const char *infd, Error **errp) diff --git a/migration/socket.c b/migration/socket.c index 757d3821a1..b02d37d7a3 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -154,7 +154,7 @@ static gboolean socket_accept_incoming_migration(QIOCha= nnel *ioc, out: /* Close listening socket as its no longer needed */ qio_channel_close(ioc, NULL); - return FALSE; /* unregister */ + return G_SOURCE_REMOVE; } =20 =20 --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506035612657213.4940652309699; Thu, 21 Sep 2017 16:13:32 -0700 (PDT) Received: from localhost ([::1]:55842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAew-000172-Np for importer@patchew.org; Thu, 21 Sep 2017 19:13:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAa0-0005bg-Ek for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAZz-0001LC-E4 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59712) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAZz-0001Jy-8M for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:23 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 655E713A53 for ; Thu, 21 Sep 2017 23:08:22 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 120ED60C9A; Thu, 21 Sep 2017 23:08:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 655E713A53 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:07:57 +0200 Message-Id: <20170921230812.7095-4-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 21 Sep 2017 23:08:22 +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] [PULL 03/18] migration: Add comments to channel functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Daniel P. Berrange --- migration/channel.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/migration/channel.c b/migration/channel.c index edceebdb7b..70ec7ea3b7 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -19,6 +19,14 @@ #include "qapi/error.h" #include "io/channel-tls.h" =20 +/** + * @migration_channel_process_incoming - Create new incoming migration cha= nnel + * + * Notice that TLS is special. For it we listen in a listener socket, + * and then create a new client socket from the TLS library. + * + * @ioc: Channel to which we are connecting + */ void migration_channel_process_incoming(QIOChannel *ioc) { MigrationState *s =3D migrate_get_current(); @@ -41,6 +49,13 @@ void migration_channel_process_incoming(QIOChannel *ioc) } =20 =20 +/** + * @migration_channel_connect - Create new outgoing migration channel + * + * @s: Current migration state + * @ioc: Channel to which we are connecting + * @hostname: Where we want to connect + */ void migration_channel_connect(MigrationState *s, QIOChannel *ioc, const char *hostname) --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506035514747665.2237549505567; Thu, 21 Sep 2017 16:11:54 -0700 (PDT) Received: from localhost ([::1]:55836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAdD-0007wr-Tn for importer@patchew.org; Thu, 21 Sep 2017 19:11:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAa2-0005dq-7j for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAa1-0001O9-93 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14519) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAa1-0001NJ-2X for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:25 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C9B9267C0 for ; Thu, 21 Sep 2017 23:08:24 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id B871460C9A; Thu, 21 Sep 2017 23:08:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3C9B9267C0 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:07:58 +0200 Message-Id: <20170921230812.7095-5-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 21 Sep 2017 23:08:24 +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] [PULL 04/18] migration: Create migration_has_all_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" This function allows us to decide when to close the listener socket. For now, we only need one connection. Signed-off-by: Juan Quintela Reviewed-by: Daniel P. Berrange --- migration/migration.c | 11 +++++++++++ migration/migration.h | 2 ++ migration/socket.c | 10 +++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 2d4c56e612..bac4a99277 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -384,6 +384,17 @@ void migration_ioc_process_incoming(QIOChannel *ioc) /* We still only have a single channel. Nothing to do here yet */ } =20 +/** + * @migration_has_all_channels: We have received all channels that we need + * + * Returns true when we have got connections to all the channels that + * we need for migration. + */ +bool migration_has_all_channels(void) +{ + return true; +} + /* * Send a 'SHUT' message on the return channel with the given value * to indicate that we've finished with the RP. Non-0 value indicates diff --git a/migration/migration.h b/migration/migration.h index 99c398d484..1881e4a754 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -155,6 +155,8 @@ void migrate_set_state(int *state, int old_state, int n= ew_state); void migration_fd_process_incoming(QEMUFile *f); void migration_ioc_process_incoming(QIOChannel *ioc); =20 +bool migration_has_all_channels(void); + uint64_t migrate_max_downtime(void); =20 void migrate_fd_error(MigrationState *s, const Error *error); diff --git a/migration/socket.c b/migration/socket.c index b02d37d7a3..dee869044a 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -152,9 +152,13 @@ static gboolean socket_accept_incoming_migration(QIOCh= annel *ioc, object_unref(OBJECT(sioc)); =20 out: - /* Close listening socket as its no longer needed */ - qio_channel_close(ioc, NULL); - return G_SOURCE_REMOVE; + if (migration_has_all_channels()) { + /* Close listening socket as its no longer needed */ + qio_channel_close(ioc, NULL); + return G_SOURCE_REMOVE; + } else { + return G_SOURCE_CONTINUE; + } } =20 =20 --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506035674990273.5438183745415; Thu, 21 Sep 2017 16:14:34 -0700 (PDT) Received: from localhost ([::1]:55844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAfw-00027d-8Q for importer@patchew.org; Thu, 21 Sep 2017 19:14:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAa4-0005gn-40 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAa3-0001Q7-4E for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42596) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAa2-0001PF-UZ for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 24A7E80E6A for ; Thu, 21 Sep 2017 23:08:26 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 915EB60246; Thu, 21 Sep 2017 23:08:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 24A7E80E6A Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:07:59 +0200 Message-Id: <20170921230812.7095-6-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 21 Sep 2017 23:08:26 +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] [PULL 05/18] migration: Add multifd capability X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu Reviewed-by: Daniel P. Berrange -- Use new DEFINE_PROP --- migration/migration.c | 10 ++++++++++ migration/migration.h | 1 + qapi/migration.json | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index bac4a99277..958b783bcf 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1449,6 +1449,15 @@ bool migrate_use_events(void) return s->enabled_capabilities[MIGRATION_CAPABILITY_EVENTS]; } =20 +bool migrate_use_multifd(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->enabled_capabilities[MIGRATION_CAPABILITY_X_MULTIFD]; +} + int migrate_use_xbzrle(void) { MigrationState *s; @@ -2227,6 +2236,7 @@ static Property migration_properties[] =3D { DEFINE_PROP_MIG_CAP("x-release-ram", MIGRATION_CAPABILITY_RELEASE_RAM), DEFINE_PROP_MIG_CAP("x-block", MIGRATION_CAPABILITY_BLOCK), DEFINE_PROP_MIG_CAP("x-return-path", MIGRATION_CAPABILITY_RETURN_PATH), + DEFINE_PROP_MIG_CAP("x-multifd", MIGRATION_CAPABILITY_X_MULTIFD), =20 DEFINE_PROP_END_OF_LIST(), }; diff --git a/migration/migration.h b/migration/migration.h index 1881e4a754..b7437f16ce 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -174,6 +174,7 @@ bool migrate_postcopy_ram(void); bool migrate_zero_blocks(void); =20 bool migrate_auto_converge(void); +bool migrate_use_multifd(void); =20 int migrate_use_xbzrle(void); int64_t migrate_xbzrle_cache_size(void); diff --git a/qapi/migration.json b/qapi/migration.json index ee2b3b8733..ec4a88a43a 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -341,12 +341,14 @@ # @return-path: If enabled, migration will use the return path even # for precopy. (since 2.10) # +# @x-multifd: Use more than one fd for migration (since 2.11) +# # Since: 1.2 ## { 'enum': 'MigrationCapability', 'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks', 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram', - 'block', 'return-path' ] } + 'block', 'return-path', 'x-multifd' ] } =20 ## # @MigrationCapabilityStatus: --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506035776457904.0257221940968; Thu, 21 Sep 2017 16:16:16 -0700 (PDT) Received: from localhost ([::1]:55856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAhb-0003eS-K9 for importer@patchew.org; Thu, 21 Sep 2017 19:16:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAa7-0005h4-Be for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAa5-0001Sk-GS for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42658) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAa5-0001Rp-7D for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5970981E18 for ; Thu, 21 Sep 2017 23:08:28 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A3AD60246; Thu, 21 Sep 2017 23:08:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5970981E18 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:08:00 +0200 Message-Id: <20170921230812.7095-7-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 21 Sep 2017 23:08:28 +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] [PULL 06/18] migration: Create x-multifd-channels parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Indicates the number of channels that we will create. By default we create 2 channels. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu -- Catch inconsistent defaults (eric). Improve comment stating that number of threads is the same than number of sockets Use new DEFIN_PROP_* Rename x-multifd-threads to x-multifd-threads --- hmp.c | 7 +++++++ migration/migration.c | 26 ++++++++++++++++++++++++++ migration/migration.h | 1 + qapi/migration.json | 24 +++++++++++++++++++++--- 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/hmp.c b/hmp.c index 0fb2bc7043..bebe19ebe4 100644 --- a/hmp.c +++ b/hmp.c @@ -336,6 +336,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QD= ict *qdict) monitor_printf(mon, "%s: %s\n", MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL), params->block_incremental ? "on" : "off"); + monitor_printf(mon, "%s: %" PRId64 "\n", + MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_CHANNELS), + params->x_multifd_channels); } =20 qapi_free_MigrationParameters(params); @@ -1621,6 +1624,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) p->has_block_incremental =3D true; visit_type_bool(v, param, &p->block_incremental, &err); break; + case MIGRATION_PARAMETER_X_MULTIFD_CHANNELS: + p->has_x_multifd_channels =3D true; + visit_type_int(v, param, &p->x_multifd_channels, &err); + break; default: assert(0); } diff --git a/migration/migration.c b/migration/migration.c index 958b783bcf..7e79310d03 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -77,6 +77,7 @@ * Note: Please change this default value to 10000 when we support hybrid = mode. */ #define DEFAULT_MIGRATE_X_CHECKPOINT_DELAY 200 +#define DEFAULT_MIGRATE_MULTIFD_CHANNELS 2 =20 static NotifierList migration_state_notifiers =3D NOTIFIER_LIST_INITIALIZER(migration_state_notifiers); @@ -481,6 +482,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->x_checkpoint_delay =3D s->parameters.x_checkpoint_delay; params->has_block_incremental =3D true; params->block_incremental =3D s->parameters.block_incremental; + params->has_x_multifd_channels =3D true; + params->x_multifd_channels =3D s->parameters.x_multifd_channels; =20 return params; } @@ -762,6 +765,13 @@ static bool migrate_params_check(MigrationParameters *= params, Error **errp) "is invalid, it should be positive"); return false; } + if (params->has_x_multifd_channels && + (params->x_multifd_channels < 1 || params->x_multifd_channels > 25= 5)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, + "multifd_channels", + "is invalid, it should be in the range of 1 to 255"); + return false; + } =20 return true; } @@ -880,6 +890,9 @@ static void migrate_params_apply(MigrateSetParameters *= params) if (params->has_block_incremental) { s->parameters.block_incremental =3D params->block_incremental; } + if (params->has_x_multifd_channels) { + s->parameters.x_multifd_channels =3D params->x_multifd_channels; + } } =20 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) @@ -1458,6 +1471,15 @@ bool migrate_use_multifd(void) return s->enabled_capabilities[MIGRATION_CAPABILITY_X_MULTIFD]; } =20 +int migrate_multifd_channels(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->parameters.x_multifd_channels; +} + int migrate_use_xbzrle(void) { MigrationState *s; @@ -2223,6 +2245,9 @@ static Property migration_properties[] =3D { DEFINE_PROP_INT64("x-checkpoint-delay", MigrationState, parameters.x_checkpoint_delay, DEFAULT_MIGRATE_X_CHECKPOINT_DELAY), + DEFINE_PROP_INT64("x-multifd-channels", MigrationState, + parameters.x_multifd_channels, + DEFAULT_MIGRATE_MULTIFD_CHANNELS), =20 /* Migration capabilities */ DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), @@ -2280,6 +2305,7 @@ static void migration_instance_init(Object *obj) params->has_downtime_limit =3D true; params->has_x_checkpoint_delay =3D true; params->has_block_incremental =3D true; + params->has_x_multifd_channels =3D true; } =20 /* diff --git a/migration/migration.h b/migration/migration.h index b7437f16ce..3060cbc374 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -175,6 +175,7 @@ bool migrate_zero_blocks(void); =20 bool migrate_auto_converge(void); bool migrate_use_multifd(void); +int migrate_multifd_channels(void); =20 int migrate_use_xbzrle(void); int64_t migrate_xbzrle_cache_size(void); diff --git a/qapi/migration.json b/qapi/migration.json index ec4a88a43a..c766fb1e52 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -466,13 +466,19 @@ # migrated and the destination must already have access to the # same backing chain as was used on the source. (since 2.10) # +# @x-multifd-channels: Number of channels used to migrate data in +# parallel. This is the same number that the +# number of sockets used for migration. The +# default value is 2 (since 2.11) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', 'tls-creds', 'tls-hostname', 'max-bandwidth', - 'downtime-limit', 'x-checkpoint-delay', 'block-incremental' ] } + 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', + 'x-multifd-channels'] } =20 ## # @MigrateSetParameters: @@ -528,6 +534,11 @@ # migrated and the destination must already have access to the # same backing chain as was used on the source. (since 2.10) # +# @x-multifd-channels: Number of channels used to migrate data in +# parallel. This is the same number that the +# number of sockets used for migration. The +# default value is 2 (since 2.11) +# # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make @@ -543,7 +554,8 @@ '*max-bandwidth': 'int', '*downtime-limit': 'int', '*x-checkpoint-delay': 'int', - '*block-incremental': 'bool' } } + '*block-incremental': 'bool', + '*x-multifd-channels': 'int' } } =20 ## # @migrate-set-parameters: @@ -614,6 +626,11 @@ # migrated and the destination must already have access to the # same backing chain as was used on the source. (since 2.10) # +# @x-multifd-channels: Number of channels used to migrate data in +# parallel. This is the same number that the +# number of sockets used for migration. +# The default value is 2 (since 2.11) +# # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -627,7 +644,8 @@ '*max-bandwidth': 'int', '*downtime-limit': 'int', '*x-checkpoint-delay': 'int', - '*block-incremental': 'bool' } } + '*block-incremental': 'bool' , + '*x-multifd-channels': 'int' } } =20 ## # @query-migrate-parameters: --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506035953029728.2068275796543; Thu, 21 Sep 2017 16:19:13 -0700 (PDT) Received: from localhost ([::1]:55865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAkQ-0006Ct-6p for importer@patchew.org; Thu, 21 Sep 2017 19:19:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAa8-0005iY-UX for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAa7-0001UT-93 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59904) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAa6-0001TW-VZ for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:31 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D41B13AAD for ; Thu, 21 Sep 2017 23:08:30 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC58A60246; Thu, 21 Sep 2017 23:08:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2D41B13AAD Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:08:01 +0200 Message-Id: <20170921230812.7095-8-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 21 Sep 2017 23:08: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] [PULL 07/18] migration: Create x-multifd-page-count parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Indicates how many pages we are going to send in each batch to a multifd thread. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu -- Be consistent with defaults and documentation Use new DEFINE_PROP_* Rename x-multifd-group to x-multifd-page-count --- hmp.c | 7 +++++++ migration/migration.c | 27 +++++++++++++++++++++++++++ migration/migration.h | 1 + qapi/migration.json | 17 ++++++++++++++--- 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/hmp.c b/hmp.c index bebe19ebe4..ace729d03f 100644 --- a/hmp.c +++ b/hmp.c @@ -339,6 +339,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QD= ict *qdict) monitor_printf(mon, "%s: %" PRId64 "\n", MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_CHANNELS), params->x_multifd_channels); + monitor_printf(mon, "%s: %" PRId64 "\n", + MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUN= T), + params->x_multifd_page_count); } =20 qapi_free_MigrationParameters(params); @@ -1628,6 +1631,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) p->has_x_multifd_channels =3D true; visit_type_int(v, param, &p->x_multifd_channels, &err); break; + case MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUNT: + p->has_x_multifd_page_count =3D true; + visit_type_int(v, param, &p->x_multifd_page_count, &err); + break; default: assert(0); } diff --git a/migration/migration.c b/migration/migration.c index 7e79310d03..494c6eb435 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -78,6 +78,7 @@ */ #define DEFAULT_MIGRATE_X_CHECKPOINT_DELAY 200 #define DEFAULT_MIGRATE_MULTIFD_CHANNELS 2 +#define DEFAULT_MIGRATE_MULTIFD_PAGE_COUNT 16 =20 static NotifierList migration_state_notifiers =3D NOTIFIER_LIST_INITIALIZER(migration_state_notifiers); @@ -484,6 +485,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->block_incremental =3D s->parameters.block_incremental; params->has_x_multifd_channels =3D true; params->x_multifd_channels =3D s->parameters.x_multifd_channels; + params->has_x_multifd_page_count =3D true; + params->x_multifd_page_count =3D s->parameters.x_multifd_page_count; =20 return params; } @@ -772,6 +775,14 @@ static bool migrate_params_check(MigrationParameters *= params, Error **errp) "is invalid, it should be in the range of 1 to 255"); return false; } + if (params->has_x_multifd_page_count && + (params->x_multifd_page_count < 1 || + params->x_multifd_page_count > 10000)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, + "multifd_page_count", + "is invalid, it should be in the range of 1 to 10000"); + return false; + } =20 return true; } @@ -893,6 +904,9 @@ static void migrate_params_apply(MigrateSetParameters *= params) if (params->has_x_multifd_channels) { s->parameters.x_multifd_channels =3D params->x_multifd_channels; } + if (params->has_x_multifd_page_count) { + s->parameters.x_multifd_page_count =3D params->x_multifd_page_coun= t; + } } =20 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) @@ -1480,6 +1494,15 @@ int migrate_multifd_channels(void) return s->parameters.x_multifd_channels; } =20 +int migrate_multifd_page_count(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->parameters.x_multifd_page_count; +} + int migrate_use_xbzrle(void) { MigrationState *s; @@ -2248,6 +2271,9 @@ static Property migration_properties[] =3D { DEFINE_PROP_INT64("x-multifd-channels", MigrationState, parameters.x_multifd_channels, DEFAULT_MIGRATE_MULTIFD_CHANNELS), + DEFINE_PROP_INT64("x-multifd-page-count", MigrationState, + parameters.x_multifd_page_count, + DEFAULT_MIGRATE_MULTIFD_PAGE_COUNT), =20 /* Migration capabilities */ DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), @@ -2306,6 +2332,7 @@ static void migration_instance_init(Object *obj) params->has_x_checkpoint_delay =3D true; params->has_block_incremental =3D true; params->has_x_multifd_channels =3D true; + params->has_x_multifd_page_count =3D true; } =20 /* diff --git a/migration/migration.h b/migration/migration.h index 3060cbc374..641290f51b 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -176,6 +176,7 @@ bool migrate_zero_blocks(void); bool migrate_auto_converge(void); bool migrate_use_multifd(void); int migrate_multifd_channels(void); +int migrate_multifd_page_count(void); =20 int migrate_use_xbzrle(void); int64_t migrate_xbzrle_cache_size(void); diff --git a/qapi/migration.json b/qapi/migration.json index c766fb1e52..f8b365e3f5 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -471,6 +471,9 @@ # number of sockets used for migration. The # default value is 2 (since 2.11) # +# @x-multifd-page-count: Number of pages sent together to a thread +# The default value is 16 (since 2.11) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', @@ -478,7 +481,7 @@ 'cpu-throttle-initial', 'cpu-throttle-increment', 'tls-creds', 'tls-hostname', 'max-bandwidth', 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', - 'x-multifd-channels'] } + 'x-multifd-channels', 'x-multifd-page-count' ] } =20 ## # @MigrateSetParameters: @@ -539,6 +542,9 @@ # number of sockets used for migration. The # default value is 2 (since 2.11) # +# @x-multifd-page-count: Number of pages sent together to a thread +# The default value is 16 (since 2.11) +# # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make @@ -555,7 +561,8 @@ '*downtime-limit': 'int', '*x-checkpoint-delay': 'int', '*block-incremental': 'bool', - '*x-multifd-channels': 'int' } } + '*x-multifd-channels': 'int', + '*x-multifd-page-count': 'int' } } =20 ## # @migrate-set-parameters: @@ -631,6 +638,9 @@ # number of sockets used for migration. # The default value is 2 (since 2.11) # +# @x-multifd-page-count: Number of pages sent together to a thread +# The default value is 16 (since 2.11) +# # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -645,7 +655,8 @@ '*downtime-limit': 'int', '*x-checkpoint-delay': 'int', '*block-incremental': 'bool' , - '*x-multifd-channels': 'int' } } + '*x-multifd-channels': 'int', + '*x-multifd-page-count': 'int' } } =20 ## # @query-migrate-parameters: --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506035612680522.0129854242731; Thu, 21 Sep 2017 16:13:32 -0700 (PDT) Received: from localhost ([::1]:55841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAer-000135-RM for importer@patchew.org; Thu, 21 Sep 2017 19:13:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAaA-0005kl-Pb for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAa9-0001Wb-0P for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35546) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAa8-0001VZ-O9 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:32 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEABD267C4 for ; Thu, 21 Sep 2017 23:08:31 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8194E60246; Thu, 21 Sep 2017 23:08:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DEABD267C4 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:08:02 +0200 Message-Id: <20170921230812.7095-9-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 21 Sep 2017 23:08:32 +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] [PULL 08/18] migration: Create multifd migration threads X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Creation of the threads, nothing inside yet. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert -- Use pointers instead of long array names Move to use semaphores instead of conditions as paolo suggestion Put all the state inside one struct. Use a counter for the number of threads created. Needed during cancellatio= n. Add error return to thread creation Add id field Rename functions to multifd_save/load_setup/cleanup Change recv parameters to a pointer to struct Change back to a struct Use Error * for _cleanup --- migration/migration.c | 26 +++++++ migration/ram.c | 202 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ migration/ram.h | 5 ++ 3 files changed, 233 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 494c6eb435..336da038f5 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -281,6 +281,10 @@ static void process_incoming_migration_bh(void *opaque) */ qemu_announce_self(); =20 + if (multifd_load_cleanup(&local_err) !=3D 0) { + error_report_err(local_err); + autostart =3D false; + } /* If global state section was not received or we are in running state, we need to obey autostart. Any other state is set with runstate_set. */ @@ -353,10 +357,15 @@ static void process_incoming_migration_co(void *opaqu= e) } =20 if (ret < 0) { + Error *local_err =3D NULL; + migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_FAILED); error_report("load of migration failed: %s", strerror(-ret)); qemu_fclose(mis->from_src_file); + if (multifd_load_cleanup(&local_err) !=3D 0) { + error_report_err(local_err); + } exit(EXIT_FAILURE); } mis->bh =3D qemu_bh_new(process_incoming_migration_bh, mis); @@ -368,6 +377,12 @@ void migration_fd_process_incoming(QEMUFile *f) Coroutine *co =3D qemu_coroutine_create(process_incoming_migration_co,= NULL); MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 + if (multifd_load_setup() !=3D 0) { + /* We haven't been able to create multifd threads + nothing better to do */ + exit(EXIT_FAILURE); + } + if (!mis->from_src_file) { mis->from_src_file =3D f; } @@ -1020,6 +1035,8 @@ static void migrate_fd_cleanup(void *opaque) s->cleanup_bh =3D NULL; =20 if (s->to_dst_file) { + Error *local_err =3D NULL; + trace_migrate_fd_cleanup(); qemu_mutex_unlock_iothread(); if (s->migration_thread_running) { @@ -1028,6 +1045,9 @@ static void migrate_fd_cleanup(void *opaque) } qemu_mutex_lock_iothread(); =20 + if (multifd_save_cleanup(&local_err) !=3D 0) { + error_report_err(local_err); + } qemu_fclose(s->to_dst_file); s->to_dst_file =3D NULL; } @@ -2217,6 +2237,12 @@ void migrate_fd_connect(MigrationState *s) } } =20 + if (multifd_save_setup() !=3D 0) { + migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, + MIGRATION_STATUS_FAILED); + migrate_fd_cleanup(s); + return; + } qemu_thread_create(&s->thread, "live_migration", migration_thread, s, QEMU_THREAD_JOINABLE); s->migration_thread_running =3D true; diff --git a/migration/ram.c b/migration/ram.c index e18b3e2d4f..bb369e72d4 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -356,6 +356,208 @@ static void compress_threads_save_setup(void) } } =20 +/* Multiple fd's */ + +struct MultiFDSendParams { + uint8_t id; + char *name; + QemuThread thread; + QemuSemaphore sem; + QemuMutex mutex; + bool quit; +}; +typedef struct MultiFDSendParams MultiFDSendParams; + +struct { + MultiFDSendParams *params; + /* number of created threads */ + int count; +} *multifd_send_state; + +static void terminate_multifd_send_threads(Error *errp) +{ + int i; + + for (i =3D 0; i < multifd_send_state->count; i++) { + MultiFDSendParams *p =3D &multifd_send_state->params[i]; + + qemu_mutex_lock(&p->mutex); + p->quit =3D true; + qemu_sem_post(&p->sem); + qemu_mutex_unlock(&p->mutex); + } +} + +int multifd_save_cleanup(Error **errp) +{ + int i; + int ret =3D 0; + + if (!migrate_use_multifd()) { + return 0; + } + terminate_multifd_send_threads(NULL); + for (i =3D 0; i < multifd_send_state->count; i++) { + MultiFDSendParams *p =3D &multifd_send_state->params[i]; + + qemu_thread_join(&p->thread); + qemu_mutex_destroy(&p->mutex); + qemu_sem_destroy(&p->sem); + g_free(p->name); + p->name =3D NULL; + } + g_free(multifd_send_state->params); + multifd_send_state->params =3D NULL; + g_free(multifd_send_state); + multifd_send_state =3D NULL; + return ret; +} + +static void *multifd_send_thread(void *opaque) +{ + MultiFDSendParams *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_save_setup(void) +{ + int thread_count; + uint8_t i; + + if (!migrate_use_multifd()) { + return 0; + } + thread_count =3D migrate_multifd_channels(); + multifd_send_state =3D g_malloc0(sizeof(*multifd_send_state)); + multifd_send_state->params =3D g_new0(MultiFDSendParams, thread_count); + multifd_send_state->count =3D 0; + for (i =3D 0; i < thread_count; i++) { + MultiFDSendParams *p =3D &multifd_send_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("multifdsend_%d", i); + qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, + QEMU_THREAD_JOINABLE); + + multifd_send_state->count++; + } + return 0; +} + +struct MultiFDRecvParams { + uint8_t id; + char *name; + QemuThread thread; + QemuSemaphore sem; + QemuMutex mutex; + bool quit; +}; +typedef struct MultiFDRecvParams MultiFDRecvParams; + +struct { + MultiFDRecvParams *params; + /* number of created threads */ + int count; +} *multifd_recv_state; + +static void terminate_multifd_recv_threads(Error *errp) +{ + int i; + + for (i =3D 0; i < multifd_recv_state->count; i++) { + MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; + + qemu_mutex_lock(&p->mutex); + p->quit =3D true; + qemu_sem_post(&p->sem); + qemu_mutex_unlock(&p->mutex); + } +} + +int multifd_load_cleanup(Error **errp) +{ + int i; + int ret =3D 0; + + if (!migrate_use_multifd()) { + return 0; + } + terminate_multifd_recv_threads(NULL); + for (i =3D 0; i < multifd_recv_state->count; i++) { + MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; + + qemu_thread_join(&p->thread); + qemu_mutex_destroy(&p->mutex); + qemu_sem_destroy(&p->sem); + g_free(p->name); + p->name =3D NULL; + } + g_free(multifd_recv_state->params); + multifd_recv_state->params =3D NULL; + g_free(multifd_recv_state); + multifd_recv_state =3D NULL; + + return ret; +} + +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; + + if (!migrate_use_multifd()) { + return 0; + } + thread_count =3D migrate_multifd_channels(); + multifd_recv_state =3D g_malloc0(sizeof(*multifd_recv_state)); + multifd_recv_state->params =3D g_new0(MultiFDRecvParams, thread_count); + multifd_recv_state->count =3D 0; + 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++; + } + return 0; +} + /** * save_page_header: write page header to wire * diff --git a/migration/ram.h b/migration/ram.h index c081fde86c..4a72d66503 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -39,6 +39,11 @@ int64_t xbzrle_cache_resize(int64_t new_size); uint64_t ram_bytes_remaining(void); uint64_t ram_bytes_total(void); =20 +int multifd_save_setup(void); +int multifd_save_cleanup(Error **errp); +int multifd_load_setup(void); +int multifd_load_cleanup(Error **errp); + uint64_t ram_pagesize_summary(void); int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t = len); void acct_update_position(QEMUFile *f, size_t size, bool zero); --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 15060361222921020.2651717231759; Thu, 21 Sep 2017 16:22:02 -0700 (PDT) Received: from localhost ([::1]:55880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAn6-0000Cc-Dj for importer@patchew.org; Thu, 21 Sep 2017 19:21:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAaG-0005pf-M2 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAaD-0001bX-Gj for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11725) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAaD-0001ad-AI for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6AF5ACD16F for ; Thu, 21 Sep 2017 23:08:36 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FFC760246; Thu, 21 Sep 2017 23:08:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6AF5ACD16F Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:08:03 +0200 Message-Id: <20170921230812.7095-10-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 21 Sep 2017 23:08:36 +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] [PULL 09/18] migration: Split migration_fd_process_incoming X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We need that on later patches. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu Reviewed-by: Daniel P. Berrange --- migration/migration.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 336da038f5..067dd929c4 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -372,9 +372,8 @@ static void process_incoming_migration_co(void *opaque) qemu_bh_schedule(mis->bh); } =20 -void migration_fd_process_incoming(QEMUFile *f) +static void migration_incoming_setup(QEMUFile *f) { - Coroutine *co =3D qemu_coroutine_create(process_incoming_migration_co,= NULL); MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 if (multifd_load_setup() !=3D 0) { @@ -387,9 +386,20 @@ void migration_fd_process_incoming(QEMUFile *f) mis->from_src_file =3D f; } qemu_file_set_blocking(f, false); +} + +static void migration_incoming_process(void) +{ + Coroutine *co =3D qemu_coroutine_create(process_incoming_migration_co,= NULL); qemu_coroutine_enter(co); } =20 +void migration_fd_process_incoming(QEMUFile *f) +{ + migration_incoming_setup(f); + migration_incoming_process(); +} + void migration_ioc_process_incoming(QIOChannel *ioc) { MigrationIncomingState *mis =3D migration_incoming_get_current(); --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506035916673990.0847125680059; Thu, 21 Sep 2017 16:18:36 -0700 (PDT) Received: from localhost ([::1]:55862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAjm-0005gB-Ud for importer@patchew.org; Thu, 21 Sep 2017 19:18:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAaG-0005pe-LY for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAaF-0001dv-DZ for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42952) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAaF-0001cx-6W for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:39 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5FBD581E01 for ; Thu, 21 Sep 2017 23:08:38 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id C084E60246; Thu, 21 Sep 2017 23:08:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5FBD581E01 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:08:04 +0200 Message-Id: <20170921230812.7095-11-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 21 Sep 2017 23:08:38 +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] [PULL 10/18] bitmap: remove BITOP_WORD() 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" From: Peter Xu We have BIT_WORD(). It's the same. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- util/bitops.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/util/bitops.c b/util/bitops.c index b0c35dd5f1..f2364015c4 100644 --- a/util/bitops.c +++ b/util/bitops.c @@ -14,15 +14,13 @@ #include "qemu/osdep.h" #include "qemu/bitops.h" =20 -#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) - /* * Find the next set bit in a memory region. */ unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset) { - const unsigned long *p =3D addr + BITOP_WORD(offset); + const unsigned long *p =3D addr + BIT_WORD(offset); unsigned long result =3D offset & ~(BITS_PER_LONG-1); unsigned long tmp; =20 @@ -87,7 +85,7 @@ found_middle: unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long = size, unsigned long offset) { - const unsigned long *p =3D addr + BITOP_WORD(offset); + const unsigned long *p =3D addr + BIT_WORD(offset); unsigned long result =3D offset & ~(BITS_PER_LONG-1); unsigned long tmp; =20 --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506036282496944.0357498551922; Thu, 21 Sep 2017 16:24:42 -0700 (PDT) Received: from localhost ([::1]:55889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvApg-0002Ws-Mf for importer@patchew.org; Thu, 21 Sep 2017 19:24:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAaI-0005qi-8H for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAaH-0001fx-7c for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44660) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAaH-0001ey-2A for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 445C9C0587C9 for ; Thu, 21 Sep 2017 23:08:40 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id B497560246; Thu, 21 Sep 2017 23:08:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 445C9C0587C9 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:08:05 +0200 Message-Id: <20170921230812.7095-12-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 21 Sep 2017 23:08:40 +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] [PULL 11/18] bitmap: introduce bitmap_count_one() 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" From: Peter Xu Count how many bits set in the bitmap. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- include/qemu/bitmap.h | 10 ++++++++++ util/bitmap.c | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h index c318da12d7..2718706edb 100644 --- a/include/qemu/bitmap.h +++ b/include/qemu/bitmap.h @@ -82,6 +82,7 @@ int slow_bitmap_andnot(unsigned long *dst, const unsigned= long *bitmap1, const unsigned long *bitmap2, long bits); int slow_bitmap_intersects(const unsigned long *bitmap1, const unsigned long *bitmap2, long bits); +long slow_bitmap_count_one(const unsigned long *bitmap, long nbits); =20 static inline unsigned long *bitmap_try_new(long nbits) { @@ -216,6 +217,15 @@ static inline int bitmap_intersects(const unsigned lon= g *src1, } } =20 +static inline long bitmap_count_one(const unsigned long *bitmap, long nbit= s) +{ + if (small_nbits(nbits)) { + return ctpopl(*bitmap & BITMAP_LAST_WORD_MASK(nbits)); + } else { + return slow_bitmap_count_one(bitmap, nbits); + } +} + void bitmap_set(unsigned long *map, long i, long len); void bitmap_set_atomic(unsigned long *map, long i, long len); void bitmap_clear(unsigned long *map, long start, long nr); diff --git a/util/bitmap.c b/util/bitmap.c index efced9a7d8..90a42ff625 100644 --- a/util/bitmap.c +++ b/util/bitmap.c @@ -355,3 +355,18 @@ int slow_bitmap_intersects(const unsigned long *bitmap= 1, } return 0; } + +long slow_bitmap_count_one(const unsigned long *bitmap, long nbits) +{ + long k, lim =3D nbits / BITS_PER_LONG, result =3D 0; + + for (k =3D 0; k < lim; k++) { + result +=3D ctpopl(bitmap[k]); + } + + if (nbits % BITS_PER_LONG) { + result +=3D ctpopl(bitmap[k] & BITMAP_LAST_WORD_MASK(nbits)); + } + + return result; +} --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506036442559317.3786402828954; Thu, 21 Sep 2017 16:27:22 -0700 (PDT) Received: from localhost ([::1]:55906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAsB-0004zP-NI for importer@patchew.org; Thu, 21 Sep 2017 19:27:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAaK-0005tD-BE for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAaJ-0001iV-8R for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35786) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAaI-0001hW-Vb for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:43 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E818356E8 for ; Thu, 21 Sep 2017 23:08:42 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 964CB60C9A; Thu, 21 Sep 2017 23:08:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1E818356E8 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:08:06 +0200 Message-Id: <20170921230812.7095-13-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 21 Sep 2017 23:08:42 +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] [PULL 12/18] bitmap: provide to_le/from_le helpers 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" From: Peter Xu Provide helpers to convert bitmaps to little endian format. It can be used when we want to send one bitmap via network to some other hosts. One thing to mention is that, these helpers only solve the problem of endianess, but it does not solve the problem of different word size on machines (the bitmaps managing same count of bits may contains different size when malloced). So we need to take care of the size alignment issue on the callers for now. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- include/qemu/bitmap.h | 7 +++++++ util/bitmap.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h index 2718706edb..509eeddece 100644 --- a/include/qemu/bitmap.h +++ b/include/qemu/bitmap.h @@ -39,6 +39,8 @@ * bitmap_clear(dst, pos, nbits) Clear specified bit area * bitmap_test_and_clear_atomic(dst, pos, nbits) Test and clear area * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area + * bitmap_to_le(dst, src, nbits) Convert bitmap to little endian + * bitmap_from_le(dst, src, nbits) Convert bitmap from little endian */ =20 /* @@ -247,4 +249,9 @@ static inline unsigned long *bitmap_zero_extend(unsigne= d long *old, return new; } =20 +void bitmap_to_le(unsigned long *dst, const unsigned long *src, + long nbits); +void bitmap_from_le(unsigned long *dst, const unsigned long *src, + long nbits); + #endif /* BITMAP_H */ diff --git a/util/bitmap.c b/util/bitmap.c index 90a42ff625..e80bcc74e2 100644 --- a/util/bitmap.c +++ b/util/bitmap.c @@ -370,3 +370,35 @@ long slow_bitmap_count_one(const unsigned long *bitmap= , long nbits) =20 return result; } + +static void bitmap_to_from_le(unsigned long *dst, + const unsigned long *src, long nbits) +{ + long len =3D BITS_TO_LONGS(nbits); + +#ifdef HOST_WORDS_BIGENDIAN + long index; + + for (index =3D 0; index < len; index++) { +# if __WORD_SIZE =3D=3D 64 + dst[index] =3D bswap64(src[index]); +# else + dst[index] =3D bswap32(src[index]); +# endif + } +#else + memcpy(dst, src, len * sizeof(unsigned long)); +#endif +} + +void bitmap_from_le(unsigned long *dst, const unsigned long *src, + long nbits) +{ + bitmap_to_from_le(dst, src, nbits); +} + +void bitmap_to_le(unsigned long *dst, const unsigned long *src, + long nbits) +{ + bitmap_to_from_le(dst, src, nbits); +} --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506036090380485.6809122241074; Thu, 21 Sep 2017 16:21:30 -0700 (PDT) Received: from localhost ([::1]:55877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAmV-00087a-Ot for importer@patchew.org; Thu, 21 Sep 2017 19:21:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAaM-0005vq-Nu for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAaL-0001li-LU for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42766) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAaL-0001kC-Bj for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:45 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 516CACD268; Thu, 21 Sep 2017 23:08:44 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 735B1610B0; Thu, 21 Sep 2017 23:08:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 516CACD268 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:08:07 +0200 Message-Id: <20170921230812.7095-14-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 21 Sep 2017 23:08:44 +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] [PULL 13/18] migration: add has_postcopy savevm handler 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, Vladimir Sementsov-Ogievskiy , 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" From: Vladimir Sementsov-Ogievskiy Now postcopy-able states are recognized by not NULL save_live_complete_postcopy handler. But when we have several different postcopy-able states, it is not convenient. Ram postcopy may be disabled, while some other postcopy enabled, in this case Ram state should behave as it is not postcopy-able. This patch add separate has_postcopy handler to specify behaviour of savevm state. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- include/migration/register.h | 1 + migration/ram.c | 6 ++++++ migration/savevm.c | 6 ++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index a0f1edd8c7..f4f7bdc177 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -24,6 +24,7 @@ typedef struct SaveVMHandlers { =20 /* This runs both outside and inside the iothread lock. */ bool (*is_active)(void *opaque); + bool (*has_postcopy)(void *opaque); =20 /* This runs outside the iothread lock in the migration case, and * within the lock in the savevm case. The callback had better only diff --git a/migration/ram.c b/migration/ram.c index bb369e72d4..cedbeae48d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2849,11 +2849,17 @@ static int ram_load(QEMUFile *f, void *opaque, int = version_id) return ret; } =20 +static bool ram_has_postcopy(void *opaque) +{ + return migrate_postcopy_ram(); +} + static SaveVMHandlers savevm_ram_handlers =3D { .save_setup =3D ram_save_setup, .save_live_iterate =3D ram_save_iterate, .save_live_complete_postcopy =3D ram_save_complete, .save_live_complete_precopy =3D ram_save_complete, + .has_postcopy =3D ram_has_postcopy, .save_live_pending =3D ram_save_pending, .load_state =3D ram_load, .save_cleanup =3D ram_save_cleanup, diff --git a/migration/savevm.c b/migration/savevm.c index 7a55023d1a..9a48b7b4cb 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1008,7 +1008,8 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postc= opy) * call that's already run, it might get confused if we call * iterate afterwards. */ - if (postcopy && !se->ops->save_live_complete_postcopy) { + if (postcopy && + !(se->ops->has_postcopy && se->ops->has_postcopy(se->opaque)))= { continue; } if (qemu_file_rate_limit(f)) { @@ -1097,7 +1098,8 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, b= ool iterable_only, =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (!se->ops || - (in_postcopy && se->ops->save_live_complete_postcopy) || + (in_postcopy && se->ops->has_postcopy && + se->ops->has_postcopy(se->opaque)) || (in_postcopy && !iterable_only) || !se->ops->save_live_complete_precopy) { continue; --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506035929111284.1502542865809; Thu, 21 Sep 2017 16:18:49 -0700 (PDT) Received: from localhost ([::1]:55863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAjx-0005np-Af for importer@patchew.org; Thu, 21 Sep 2017 19:18:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAaP-0005yr-VT for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAaN-0001nn-EE for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47230) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAaN-0001ms-7u for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:47 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C1F3C047B70; Thu, 21 Sep 2017 23:08:46 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id A686160C9A; Thu, 21 Sep 2017 23:08:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5C1F3C047B70 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:08:08 +0200 Message-Id: <20170921230812.7095-15-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 21 Sep 2017 23:08:46 +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] [PULL 14/18] migration: fix ram_save_pending 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, Vladimir Sementsov-Ogievskiy , 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" From: Vladimir Sementsov-Ogievskiy Fill postcopy-able pending only if ram postcopy is enabled. It is necessary because of there will be other postcopy-able states and when ram postcopy is disabled, it should not spoil common postcopy related pending. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index cedbeae48d..88ca69e7b2 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2276,8 +2276,12 @@ static void ram_save_pending(QEMUFile *f, void *opaq= ue, uint64_t max_size, remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SIZE; } =20 - /* We can do postcopy, and all the data is postcopiable */ - *postcopiable_pending +=3D remaining_size; + if (migrate_postcopy_ram()) { + /* We can do postcopy, and all the data is postcopiable */ + *postcopiable_pending +=3D remaining_size; + } else { + *non_postcopiable_pending +=3D remaining_size; + } } =20 static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host) --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506036090959923.8939276060212; Thu, 21 Sep 2017 16:21:30 -0700 (PDT) Received: from localhost ([::1]:55879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAmg-0008FO-6t for importer@patchew.org; Thu, 21 Sep 2017 19:21:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAaQ-0005zf-TK for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAaP-0001py-Cb for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35882) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAaP-0001p0-2o for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:49 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3EC1A267C4; Thu, 21 Sep 2017 23:08:48 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id B019A60246; Thu, 21 Sep 2017 23:08:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3EC1A267C4 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:08:09 +0200 Message-Id: <20170921230812.7095-16-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 21 Sep 2017 23:08: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] [PULL 15/18] migration: split common postcopy out of ram postcopy 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, Vladimir Sementsov-Ogievskiy , 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" From: Vladimir Sementsov-Ogievskiy Split common postcopy staff from ram postcopy staff. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/migration.c | 39 ++++++++++++++++++++++++++------------- migration/migration.h | 2 ++ migration/savevm.c | 48 +++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 067dd929c4..266cd39c36 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1443,6 +1443,11 @@ bool migrate_postcopy_ram(void) return s->enabled_capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM]; } =20 +bool migrate_postcopy(void) +{ + return migrate_postcopy_ram(); +} + bool migrate_auto_converge(void) { MigrationState *s; @@ -1826,9 +1831,11 @@ static int postcopy_start(MigrationState *ms, bool *= old_vm_running) * need to tell the destination to throw any pages it's already receiv= ed * that are dirty */ - if (ram_postcopy_send_discard_bitmap(ms)) { - error_report("postcopy send discard bitmap failed"); - goto fail; + if (migrate_postcopy_ram()) { + if (ram_postcopy_send_discard_bitmap(ms)) { + error_report("postcopy send discard bitmap failed"); + goto fail; + } } =20 /* @@ -1837,8 +1844,10 @@ static int postcopy_start(MigrationState *ms, bool *= old_vm_running) * wrap their state up here */ qemu_file_set_rate_limit(ms->to_dst_file, INT64_MAX); - /* Ping just for debugging, helps line traces up */ - qemu_savevm_send_ping(ms->to_dst_file, 2); + if (migrate_postcopy_ram()) { + /* Ping just for debugging, helps line traces up */ + qemu_savevm_send_ping(ms->to_dst_file, 2); + } =20 /* * While loading the device state we may trigger page transfer @@ -1863,7 +1872,9 @@ static int postcopy_start(MigrationState *ms, bool *o= ld_vm_running) qemu_savevm_send_postcopy_listen(fb); =20 qemu_savevm_state_complete_precopy(fb, false, false); - qemu_savevm_send_ping(fb, 3); + if (migrate_postcopy_ram()) { + qemu_savevm_send_ping(fb, 3); + } =20 qemu_savevm_send_postcopy_run(fb); =20 @@ -1898,11 +1909,13 @@ static int postcopy_start(MigrationState *ms, bool = *old_vm_running) =20 qemu_mutex_unlock_iothread(); =20 - /* - * Although this ping is just for debug, it could potentially be - * used for getting a better measurement of downtime at the source. - */ - qemu_savevm_send_ping(ms->to_dst_file, 4); + if (migrate_postcopy_ram()) { + /* + * Although this ping is just for debug, it could potentially be + * used for getting a better measurement of downtime at the source. + */ + qemu_savevm_send_ping(ms->to_dst_file, 4); + } =20 if (migrate_release_ram()) { ram_postcopy_migrated_memory_release(ms); @@ -2080,7 +2093,7 @@ static void *migration_thread(void *opaque) qemu_savevm_send_ping(s->to_dst_file, 1); } =20 - if (migrate_postcopy_ram()) { + if (migrate_postcopy()) { /* * Tell the destination that we *might* want to do postcopy later; * if the other end can't do postcopy it should fail now, nice and @@ -2113,7 +2126,7 @@ static void *migration_thread(void *opaque) if (pending_size && pending_size >=3D threshold_size) { /* Still a significant amount to transfer */ =20 - if (migrate_postcopy_ram() && + if (migrate_postcopy() && s->state !=3D MIGRATION_STATUS_POSTCOPY_ACTIVE && pend_nonpost <=3D threshold_size && atomic_read(&s->start_postcopy)) { diff --git a/migration/migration.h b/migration/migration.h index 641290f51b..b83cceadc4 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -169,6 +169,8 @@ bool migration_is_blocked(Error **errp); bool migration_in_postcopy(void); MigrationState *migrate_get_current(void); =20 +bool migrate_postcopy(void); + bool migrate_release_ram(void); bool migrate_postcopy_ram(void); bool migrate_zero_blocks(void); diff --git a/migration/savevm.c b/migration/savevm.c index 9a48b7b4cb..231474da34 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -89,7 +89,7 @@ static struct mig_cmd_args { [MIG_CMD_INVALID] =3D { .len =3D -1, .name =3D "INVALID" }, [MIG_CMD_OPEN_RETURN_PATH] =3D { .len =3D 0, .name =3D "OPEN_RETURN_P= ATH" }, [MIG_CMD_PING] =3D { .len =3D sizeof(uint32_t), .name =3D = "PING" }, - [MIG_CMD_POSTCOPY_ADVISE] =3D { .len =3D 16, .name =3D "POSTCOPY_ADVI= SE" }, + [MIG_CMD_POSTCOPY_ADVISE] =3D { .len =3D -1, .name =3D "POSTCOPY_ADVI= SE" }, [MIG_CMD_POSTCOPY_LISTEN] =3D { .len =3D 0, .name =3D "POSTCOPY_LIST= EN" }, [MIG_CMD_POSTCOPY_RUN] =3D { .len =3D 0, .name =3D "POSTCOPY_RUN"= }, [MIG_CMD_POSTCOPY_RAM_DISCARD] =3D { @@ -98,6 +98,23 @@ static struct mig_cmd_args { [MIG_CMD_MAX] =3D { .len =3D -1, .name =3D "MAX" }, }; =20 +/* Note for MIG_CMD_POSTCOPY_ADVISE: + * The format of arguments is depending on postcopy mode: + * - postcopy RAM only + * uint64_t host page size + * uint64_t taget page size + * + * - postcopy RAM and postcopy dirty bitmaps + * format is the same as for postcopy RAM only + * + * - postcopy dirty bitmaps only + * Nothing. Command length field is 0. + * + * Be careful: adding a new postcopy entity with some other parameters sho= uld + * not break format self-description ability. Good way is to introduce some + * generic extendable format with an exception for two old entities. + */ + static int announce_self_create(uint8_t *buf, uint8_t *mac_addr) { @@ -861,12 +878,17 @@ int qemu_savevm_send_packaged(QEMUFile *f, const uint= 8_t *buf, size_t len) /* Send prior to any postcopy transfer */ void qemu_savevm_send_postcopy_advise(QEMUFile *f) { - uint64_t tmp[2]; - tmp[0] =3D cpu_to_be64(ram_pagesize_summary()); - tmp[1] =3D cpu_to_be64(qemu_target_page_size()); + if (migrate_postcopy_ram()) { + uint64_t tmp[2]; + tmp[0] =3D cpu_to_be64(ram_pagesize_summary()); + tmp[1] =3D cpu_to_be64(qemu_target_page_size()); =20 - trace_qemu_savevm_send_postcopy_advise(); - qemu_savevm_command_send(f, MIG_CMD_POSTCOPY_ADVISE, 16, (uint8_t *)tm= p); + trace_qemu_savevm_send_postcopy_advise(); + qemu_savevm_command_send(f, MIG_CMD_POSTCOPY_ADVISE, + 16, (uint8_t *)tmp); + } else { + qemu_savevm_command_send(f, MIG_CMD_POSTCOPY_ADVISE, 0, NULL); + } } =20 /* Sent prior to starting the destination running in postcopy, discard pag= es @@ -1354,6 +1376,10 @@ static int loadvm_postcopy_handle_advise(MigrationIn= comingState *mis) return -1; } =20 + if (!migrate_postcopy_ram()) { + return 0; + } + if (!postcopy_ram_supported_by_host()) { postcopy_state_set(POSTCOPY_INCOMING_NONE); return -1; @@ -1564,7 +1590,9 @@ static int loadvm_postcopy_handle_listen(MigrationInc= omingState *mis) * A rare case, we entered listen without having to do any discard= s, * so do the setup that's normally done at the time of the 1st dis= card. */ - postcopy_ram_prepare_discard(mis); + if (migrate_postcopy_ram()) { + postcopy_ram_prepare_discard(mis); + } } =20 /* @@ -1572,8 +1600,10 @@ static int loadvm_postcopy_handle_listen(MigrationIn= comingState *mis) * However, at this point the CPU shouldn't be running, and the IO * shouldn't be doing anything yet so don't actually expect requests */ - if (postcopy_ram_enable_notify(mis)) { - return -1; + if (migrate_postcopy_ram()) { + if (postcopy_ram_enable_notify(mis)) { + return -1; + } } =20 if (mis->have_listen_thread) { --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 15060362650151007.3392779581334; Thu, 21 Sep 2017 16:24:25 -0700 (PDT) Received: from localhost ([::1]:55888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvApI-00029r-3G for importer@patchew.org; Thu, 21 Sep 2017 19:24:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAaS-0005zn-Uq for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAaR-0001tc-Kl for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58312) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAaR-0001sF-Bk for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:51 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78677883BC; Thu, 21 Sep 2017 23:08:50 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9238160246; Thu, 21 Sep 2017 23:08:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 78677883BC Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:08:10 +0200 Message-Id: <20170921230812.7095-17-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 21 Sep 2017 23:08: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] [PULL 16/18] migration: pass MigrationIncomingState* into migration check functions 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, Alexey Perevalov 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" From: Alexey Perevalov That tiny refactoring is necessary to be able to set UFFD_FEATURE_THREAD_ID while requesting features, and then to create downtime context in case when kernel supports it. Signed-off-by: Alexey Perevalov Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/migration.c | 3 ++- migration/postcopy-ram.c | 10 +++++----- migration/postcopy-ram.h | 2 +- migration/savevm.c | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 266cd39c36..98429dc843 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -659,6 +659,7 @@ static bool migrate_caps_check(bool *cap_list, { MigrationCapabilityStatusList *cap; bool old_postcopy_cap; + MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 old_postcopy_cap =3D cap_list[MIGRATION_CAPABILITY_POSTCOPY_RAM]; =20 @@ -692,7 +693,7 @@ static bool migrate_caps_check(bool *cap_list, * special support. */ if (!old_postcopy_cap && runstate_check(RUN_STATE_INMIGRATE) && - !postcopy_ram_supported_by_host()) { + !postcopy_ram_supported_by_host(mis)) { /* postcopy_ram_supported_by_host will have emitted a more * detailed message */ diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 7e21e6fd36..c70305ccc7 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -61,7 +61,7 @@ struct PostcopyDiscardState { #include #include =20 -static bool ufd_version_check(int ufd) +static bool ufd_version_check(int ufd, MigrationIncomingState *mis) { struct uffdio_api api_struct; uint64_t ioctl_mask; @@ -124,7 +124,7 @@ static int test_ramblock_postcopiable(const char *block= _name, void *host_addr, * normally fine since if the postcopy succeeds it gets turned back on at = the * end. */ -bool postcopy_ram_supported_by_host(void) +bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) { long pagesize =3D getpagesize(); int ufd =3D -1; @@ -147,7 +147,7 @@ bool postcopy_ram_supported_by_host(void) } =20 /* Version and features check */ - if (!ufd_version_check(ufd)) { + if (!ufd_version_check(ufd, mis)) { goto out; } =20 @@ -523,7 +523,7 @@ int postcopy_ram_enable_notify(MigrationIncomingState *= mis) * Although the host check already tested the API, we need to * do the check again as an ABI handshake on the new fd. */ - if (!ufd_version_check(mis->userfault_fd)) { + if (!ufd_version_check(mis->userfault_fd, mis)) { return -1; } =20 @@ -661,7 +661,7 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mis) =20 #else /* No target OS support, stubs just fail */ -bool postcopy_ram_supported_by_host(void) +bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) { error_report("%s: No OS support", __func__); return false; diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index 52d51e8007..587a8b86a7 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -14,7 +14,7 @@ #define QEMU_POSTCOPY_RAM_H =20 /* Return true if the host supports everything we need to do postcopy-ram = */ -bool postcopy_ram_supported_by_host(void); +bool postcopy_ram_supported_by_host(MigrationIncomingState *mis); =20 /* * Make all of RAM sensitive to accesses to areas that haven't yet been wr= itten diff --git a/migration/savevm.c b/migration/savevm.c index 231474da34..2478352baf 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1380,7 +1380,7 @@ static int loadvm_postcopy_handle_advise(MigrationInc= omingState *mis) return 0; } =20 - if (!postcopy_ram_supported_by_host()) { + if (!postcopy_ram_supported_by_host(mis)) { postcopy_state_set(POSTCOPY_INCOMING_NONE); return -1; } --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506035773510707.5150855116344; Thu, 21 Sep 2017 16:16:13 -0700 (PDT) Received: from localhost ([::1]:55855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAhY-0003bt-N9 for importer@patchew.org; Thu, 21 Sep 2017 19:16:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAaY-00064z-I2 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAaV-000211-Dd for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58366) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAaV-0001yj-7F for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:55 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 32C11883BC; Thu, 21 Sep 2017 23:08:54 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC88560246; Thu, 21 Sep 2017 23:08:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 32C11883BC Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:08:11 +0200 Message-Id: <20170921230812.7095-18-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 21 Sep 2017 23:08: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] [PULL 17/18] migration: fix hardcoded function name in error report 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, Alexey Perevalov 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" From: Alexey Perevalov Reviewed-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Alexey Perevalov Signed-off-by: Juan Quintela --- migration/postcopy-ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index c70305ccc7..cf62fc756f 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -69,7 +69,7 @@ static bool ufd_version_check(int ufd, MigrationIncomingS= tate *mis) api_struct.api =3D UFFD_API; api_struct.features =3D 0; if (ioctl(ufd, UFFDIO_API, &api_struct)) { - error_report("postcopy_ram_supported_by_host: UFFDIO_API failed: %= s", + error_report("%s: UFFDIO_API failed: %s", __func__, strerror(errno)); return false; } --=20 2.13.5 From nobody Sat May 4 03:03:59 2024 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 1506035948249486.95326565968276; Thu, 21 Sep 2017 16:19:08 -0700 (PDT) Received: from localhost ([::1]:55864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAkK-00068f-Dm for importer@patchew.org; Thu, 21 Sep 2017 19:19:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAaY-00064y-I1 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAaX-00023D-5B for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60264) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvAaW-000227-ST for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:08:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11B8213AAD; Thu, 21 Sep 2017 23:08:56 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8657660C9A; Thu, 21 Sep 2017 23:08:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 11B8213AAD Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:08:12 +0200 Message-Id: <20170921230812.7095-19-quintela@redhat.com> In-Reply-To: <20170921230812.7095-1-quintela@redhat.com> References: <20170921230812.7095-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 21 Sep 2017 23:08: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] [PULL 18/18] migration: split ufd_version_check onto receive/request features part 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, Alexey Perevalov 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" From: Alexey Perevalov This modification is necessary for userfault fd features which are required to be requested from userspace. UFFD_FEATURE_THREAD_ID is a one of such "on demand" feature, which will be introduced in the next patch. QEMU have to use separate userfault file descriptor, due to userfault context has internal state, and after first call of ioctl UFFD_API it changes its state to UFFD_STATE_RUNNING (in case of success), but kernel while handling ioctl UFFD_API expects UFFD_STATE_WAIT_= API. So only one ioctl with UFFD_API is possible per ufd. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Alexey Perevalov Signed-off-by: Juan Quintela --- migration/postcopy-ram.c | 94 ++++++++++++++++++++++++++++++++++++++++++++= ---- 1 file changed, 88 insertions(+), 6 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index cf62fc756f..0de68e8b25 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -61,16 +61,67 @@ struct PostcopyDiscardState { #include #include =20 -static bool ufd_version_check(int ufd, MigrationIncomingState *mis) + +/** + * receive_ufd_features: check userfault fd features, to request only supp= orted + * features in the future. + * + * Returns: true on success + * + * __NR_userfaultfd - should be checked before + * @features: out parameter will contain uffdio_api.features provided by = kernel + * in case of success + */ +static bool receive_ufd_features(uint64_t *features) { - struct uffdio_api api_struct; - uint64_t ioctl_mask; + struct uffdio_api api_struct =3D {0}; + int ufd; + bool ret =3D true; =20 + /* if we are here __NR_userfaultfd should exists */ + ufd =3D syscall(__NR_userfaultfd, O_CLOEXEC); + if (ufd =3D=3D -1) { + error_report("%s: syscall __NR_userfaultfd failed: %s", __func__, + strerror(errno)); + return false; + } + + /* ask features */ api_struct.api =3D UFFD_API; api_struct.features =3D 0; if (ioctl(ufd, UFFDIO_API, &api_struct)) { error_report("%s: UFFDIO_API failed: %s", __func__, strerror(errno)); + ret =3D false; + goto release_ufd; + } + + *features =3D api_struct.features; + +release_ufd: + close(ufd); + return ret; +} + +/** + * request_ufd_features: this function should be called only once on a new= ly + * opened ufd, subsequent calls will lead to error. + * + * Returns: true on succes + * + * @ufd: fd obtained from userfaultfd syscall + * @features: bit mask see UFFD_API_FEATURES + */ +static bool request_ufd_features(int ufd, uint64_t features) +{ + struct uffdio_api api_struct =3D {0}; + uint64_t ioctl_mask; + + api_struct.api =3D UFFD_API; + api_struct.features =3D features; + if (ioctl(ufd, UFFDIO_API, &api_struct)) { + error_report("%s failed: UFFDIO_API failed: %s", __func__, + strerror(errno)); return false; } =20 @@ -82,11 +133,42 @@ static bool ufd_version_check(int ufd, MigrationIncomi= ngState *mis) return false; } =20 + return true; +} + +static bool ufd_check_and_apply(int ufd, MigrationIncomingState *mis) +{ + uint64_t asked_features =3D 0; + static uint64_t supported_features; + + /* + * it's not possible to + * request UFFD_API twice per one fd + * userfault fd features is persistent + */ + if (!supported_features) { + if (!receive_ufd_features(&supported_features)) { + error_report("%s failed", __func__); + return false; + } + } + + /* + * request features, even if asked_features is 0, due to + * kernel expects UFFD_API before UFFDIO_REGISTER, per + * userfault file descriptor + */ + if (!request_ufd_features(ufd, asked_features)) { + error_report("%s failed: features %" PRIu64, __func__, + asked_features); + return false; + } + if (getpagesize() !=3D ram_pagesize_summary()) { bool have_hp =3D false; /* We've got a huge page */ #ifdef UFFD_FEATURE_MISSING_HUGETLBFS - have_hp =3D api_struct.features & UFFD_FEATURE_MISSING_HUGETLBFS; + have_hp =3D supported_features & UFFD_FEATURE_MISSING_HUGETLBFS; #endif if (!have_hp) { error_report("Userfault on this host does not support huge pag= es"); @@ -147,7 +229,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingSt= ate *mis) } =20 /* Version and features check */ - if (!ufd_version_check(ufd, mis)) { + if (!ufd_check_and_apply(ufd, mis)) { goto out; } =20 @@ -523,7 +605,7 @@ int postcopy_ram_enable_notify(MigrationIncomingState *= mis) * Although the host check already tested the API, we need to * do the check again as an ABI handshake on the new fd. */ - if (!ufd_version_check(mis->userfault_fd, mis)) { + if (!ufd_check_and_apply(mis->userfault_fd, mis)) { return -1; } =20 --=20 2.13.5