Commit 343f632c authored by Dr. David Alan Gilbert's avatar Dr. David Alan Gilbert
Browse files

migration: Poison ramblock loops in migration



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: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20180605162545.80778-3-dgilbert@redhat.com>
Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
Reviewed-by: default avatarCédric Le Goater <clg@kaod.org>
Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
parent ff0769a4
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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);
+3 −0
Original line number Diff line number Diff line
@@ -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
+3 −1
Original line number Diff line number Diff line
@@ -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;