From nobody Sun May 5 10:12:35 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528216046825156.0444286474915; Tue, 5 Jun 2018 09:27:26 -0700 (PDT) Received: from localhost ([::1]:48004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQEnu-0001iZ-3B for importer@patchew.org; Tue, 05 Jun 2018 12:27:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQEmN-0000s4-AN for qemu-devel@nongnu.org; Tue, 05 Jun 2018 12:25:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQEmK-0004xj-53 for qemu-devel@nongnu.org; Tue, 05 Jun 2018 12:25:51 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53554 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQEmK-0004xU-0O for qemu-devel@nongnu.org; Tue, 05 Jun 2018 12:25:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 96E094075636; Tue, 5 Jun 2018 16:25:47 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-20.ams2.redhat.com [10.36.117.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3E5F2026DEF; Tue, 5 Jun 2018 16:25:46 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, peterx@redhat.com, clg@kaod.org Date: Tue, 5 Jun 2018 17:25:44 +0100 Message-Id: <20180605162545.80778-2-dgilbert@redhat.com> In-Reply-To: <20180605162545.80778-1-dgilbert@redhat.com> References: <20180605162545.80778-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 05 Jun 2018 16:25:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 05 Jun 2018 16:25:47 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dgilbert@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 1/2] migration: Fixes for non-migratable RAMBlocks 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: , 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: "Dr. David Alan Gilbert" There are still a few cases where migration code is using the macros and functions that do all RAMBlocks rather than just the migratable blocks; fix those up. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: C=C3=A9dric Le Goater =20 Reviewed-by: Peter Xu --- migration/ram.c | 4 ++-- migration/rdma.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index a500015a2f..a7807cea84 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2516,7 +2516,7 @@ static void ram_state_resume_prepare(RAMState *rs, QE= MUFile *out) * about dirty page logging as well. */ =20 - RAMBLOCK_FOREACH(block) { + RAMBLOCK_FOREACH_MIGRATABLE(block) { pages +=3D bitmap_count_one(block->bmap, block->used_length >> TARGET_PAGE_BITS); } @@ -3431,7 +3431,7 @@ static int ram_dirty_bitmap_sync_all(MigrationState *= s, RAMState *rs) =20 trace_ram_dirty_bitmap_sync_start(); =20 - RAMBLOCK_FOREACH(block) { + RAMBLOCK_FOREACH_MIGRATABLE(block) { qemu_savevm_send_recv_bitmap(file, block->idstr); trace_ram_dirty_bitmap_request(block->idstr); ramblock_count++; diff --git a/migration/rdma.c b/migration/rdma.c index 05aee3d591..8bd7159059 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -635,7 +635,7 @@ static int qemu_rdma_init_ram_blocks(RDMAContext *rdma) =20 assert(rdma->blockmap =3D=3D NULL); memset(local, 0, sizeof *local); - qemu_ram_foreach_block(qemu_rdma_init_one_block, rdma); + qemu_ram_foreach_migratable_block(qemu_rdma_init_one_block, rdma); trace_qemu_rdma_init_ram_blocks(local->nb_blocks); rdma->dest_blocks =3D g_new0(RDMADestBlock, rdma->local_ram_blocks.nb_blocks); --=20 2.17.0 From nobody Sun May 5 10:12:35 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528216045646991.3801685527006; Tue, 5 Jun 2018 09:27:25 -0700 (PDT) Received: from localhost ([::1]:48003 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQEnl-0001d0-Pb for importer@patchew.org; Tue, 05 Jun 2018 12:27:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQEmN-0000s6-Bt for qemu-devel@nongnu.org; Tue, 05 Jun 2018 12:25:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQEmL-0004y9-1k for qemu-devel@nongnu.org; Tue, 05 Jun 2018 12:25:51 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53558 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQEmK-0004xv-TQ for qemu-devel@nongnu.org; Tue, 05 Jun 2018 12:25:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 85F66407563F; Tue, 5 Jun 2018 16:25:48 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-20.ams2.redhat.com [10.36.117.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id D35452026DEF; Tue, 5 Jun 2018 16:25:47 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, peterx@redhat.com, clg@kaod.org Date: Tue, 5 Jun 2018 17:25:45 +0100 Message-Id: <20180605162545.80778-3-dgilbert@redhat.com> In-Reply-To: <20180605162545.80778-1-dgilbert@redhat.com> References: <20180605162545.80778-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 05 Jun 2018 16:25:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 05 Jun 2018 16:25:48 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dgilbert@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 2/2] migration: Poison ramblock loops in migration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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: "Dr. David Alan Gilbert" The migration code should be using the RAMBLOCK_FOREACH_MIGRATABLE and qemu_ram_foreach_block_migratable not the all-block versions; poison them so that we can't accidentally use them. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: C=C3=A9dric Le Goater =20 --- include/exec/ramlist.h | 4 +++- migration/migration.h | 3 +++ migration/ram.c | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/exec/ramlist.h b/include/exec/ramlist.h index 2e2ac6cb99..bc4faa1b00 100644 --- a/include/exec/ramlist.h +++ b/include/exec/ramlist.h @@ -56,8 +56,10 @@ typedef struct RAMList { extern RAMList ram_list; =20 /* Should be holding either ram_list.mutex, or the RCU lock. */ -#define RAMBLOCK_FOREACH(block) \ +#define INTERNAL_RAMBLOCK_FOREACH(block) \ QLIST_FOREACH_RCU(block, &ram_list.blocks, next) +/* Never use the INTERNAL_ version except for defining other macros */ +#define RAMBLOCK_FOREACH(block) INTERNAL_RAMBLOCK_FOREACH(block) =20 void qemu_mutex_lock_ramlist(void); void qemu_mutex_unlock_ramlist(void); diff --git a/migration/migration.h b/migration/migration.h index 5af57d616c..31d3ed12dc 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -284,4 +284,7 @@ void migrate_send_rp_resume_ack(MigrationIncomingState = *mis, uint32_t value); void dirty_bitmap_mig_before_vm_start(void); void init_dirty_bitmap_incoming_migration(void); =20 +#define qemu_ram_foreach_block \ + #warning "Use qemu_ram_foreach_block_migratable in migration code" + #endif diff --git a/migration/ram.c b/migration/ram.c index a7807cea84..e0d19305ee 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -159,9 +159,11 @@ out: =20 /* Should be holding either ram_list.mutex, or the RCU lock. */ #define RAMBLOCK_FOREACH_MIGRATABLE(block) \ - RAMBLOCK_FOREACH(block) \ + INTERNAL_RAMBLOCK_FOREACH(block) \ if (!qemu_ram_is_migratable(block)) {} else =20 +#undef RAMBLOCK_FOREACH + static void ramblock_recv_map_init(void) { RAMBlock *rb; --=20 2.17.0