Skip to content

Commit

Permalink
migration: Add an ability to ignore shared RAM blocks
Browse files Browse the repository at this point in the history
If ignore-shared capability is set then skip shared RAMBlocks during the
RAM migration.
Also, move qemu_ram_foreach_migratable_block (and rename) to the
migration code, because it requires access to the migration capabilities.

Signed-off-by: Yury Kotov <yury-kotov@yandex-team.ru>
Message-Id: <20190215174548.2630-4-yury-kotov@yandex-team.ru>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
  • Loading branch information
Yury Kotov authored and dagrh committed Mar 6, 2019
1 parent 1826906 commit fbd162e
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 54 deletions.
19 changes: 0 additions & 19 deletions exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -3985,25 +3985,6 @@ int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque)
return ret;
}

int qemu_ram_foreach_migratable_block(RAMBlockIterFunc func, void *opaque)
{
RAMBlock *block;
int ret = 0;

rcu_read_lock();
RAMBLOCK_FOREACH(block) {
if (!qemu_ram_is_migratable(block)) {
continue;
}
ret = func(block, opaque);
if (ret) {
break;
}
}
rcu_read_unlock();
return ret;
}

/*
* Unmap pages of memory from start to start+length such that
* they a) read as 0, b) Trigger whatever fault mechanism
Expand Down
1 change: 0 additions & 1 deletion include/exec/cpu-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ extern struct MemoryRegion io_mem_notdirty;
typedef int (RAMBlockIterFunc)(RAMBlock *rb, void *opaque);

int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque);
int qemu_ram_foreach_migratable_block(RAMBlockIterFunc func, void *opaque);
int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length);

#endif
Expand Down
4 changes: 3 additions & 1 deletion migration/migration.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,10 @@ 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);

int foreach_not_ignored_block(RAMBlockIterFunc func, void *opaque);

#define qemu_ram_foreach_block \
#warning "Use qemu_ram_foreach_block_migratable in migration code"
#warning "Use foreach_not_ignored_block in migration code"

void migration_make_urgent_request(void);
void migration_consume_urgent_request(void);
Expand Down
12 changes: 6 additions & 6 deletions migration/postcopy-ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis)
}

/* We don't support postcopy with shared RAM yet */
if (qemu_ram_foreach_migratable_block(test_ramblock_postcopiable, NULL)) {
if (foreach_not_ignored_block(test_ramblock_postcopiable, NULL)) {
goto out;
}

Expand Down Expand Up @@ -508,7 +508,7 @@ static int cleanup_range(RAMBlock *rb, void *opaque)
*/
int postcopy_ram_incoming_init(MigrationIncomingState *mis)
{
if (qemu_ram_foreach_migratable_block(init_range, NULL)) {
if (foreach_not_ignored_block(init_range, NULL)) {
return -1;
}

Expand Down Expand Up @@ -550,7 +550,7 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
return -1;
}

if (qemu_ram_foreach_migratable_block(cleanup_range, mis)) {
if (foreach_not_ignored_block(cleanup_range, mis)) {
return -1;
}

Expand Down Expand Up @@ -617,7 +617,7 @@ static int nhp_range(RAMBlock *rb, void *opaque)
*/
int postcopy_ram_prepare_discard(MigrationIncomingState *mis)
{
if (qemu_ram_foreach_migratable_block(nhp_range, mis)) {
if (foreach_not_ignored_block(nhp_range, mis)) {
return -1;
}

Expand All @@ -628,7 +628,7 @@ int postcopy_ram_prepare_discard(MigrationIncomingState *mis)

/*
* Mark the given area of RAM as requiring notification to unwritten areas
* Used as a callback on qemu_ram_foreach_migratable_block.
* Used as a callback on foreach_not_ignored_block.
* host_addr: Base of area to mark
* offset: Offset in the whole ram arena
* length: Length of the section
Expand Down Expand Up @@ -1122,7 +1122,7 @@ int postcopy_ram_enable_notify(MigrationIncomingState *mis)
mis->have_fault_thread = true;

/* Mark so that we get notified of accesses to unwritten areas */
if (qemu_ram_foreach_migratable_block(ram_block_enable_notify, mis)) {
if (foreach_not_ignored_block(ram_block_enable_notify, mis)) {
error_report("ram_block_enable_notify failed");
return -1;
}
Expand Down
Loading

0 comments on commit fbd162e

Please sign in to comment.