]> xenbits.xensource.com Git - people/pauldu/qemu.git/commitdiff
migration: Poison ramblock loops in migration
authorDr. David Alan Gilbert <dgilbert@redhat.com>
Tue, 5 Jun 2018 16:25:45 +0000 (17:25 +0100)
committerDr. David Alan Gilbert <dgilbert@redhat.com>
Fri, 15 Jun 2018 13:40:56 +0000 (14:40 +0100)
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 <dgilbert@redhat.com>
Message-Id: <20180605162545.80778-3-dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
include/exec/ramlist.h
migration/migration.h
migration/ram.c

index 2e2ac6cb999bc8eee63b98992d41095dcef0b880..bc4faa1b001aef822b3b22762aa73d873f891d92 100644 (file)
@@ -56,8 +56,10 @@ typedef struct RAMList {
 extern RAMList ram_list;
 
 /* 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)
 
 void qemu_mutex_lock_ramlist(void);
 void qemu_mutex_unlock_ramlist(void);
index 5af57d616cf98b550340a53cfdde208ab23674c3..31d3ed12dcd710fb51ecb0222508331983cb737f 100644 (file)
@@ -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);
 
+#define qemu_ram_foreach_block \
+  #warning "Use qemu_ram_foreach_block_migratable in migration code"
+
 #endif
index a7807cea846da6ed47701a15f9d380b13ad28b6f..e0d19305ee55f5d5497be91f804109be90f35139 100644 (file)
@@ -159,9 +159,11 @@ out:
 
 /* 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
 
+#undef RAMBLOCK_FOREACH
+
 static void ramblock_recv_map_init(void)
 {
     RAMBlock *rb;