Skip to content

Commit

Permalink
migration/ram: Expose ramblock_is_ignored() as migrate_ram_is_ignored()
Browse files Browse the repository at this point in the history
virtio-mem wants to know whether it should not mess with the RAMBlock
content (e.g., discard RAM, preallocate memory) on incoming migration.

So let's expose that function as migrate_ram_is_ignored() in
migration/misc.h

Message-ID: <20230706075612.67404-4-david@redhat.com>
Acked-by: Peter Xu <peterx@redhat.com>
Tested-by: Mario Casquero <mcasquer@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
  • Loading branch information
davidhildenbrand committed Jul 12, 2023
1 parent 836f657 commit f161c88
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions include/migration/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int precopy_notify(PrecopyNotifyReason reason, Error **errp);

void ram_mig_init(void);
void qemu_guest_free_page_hint(void *addr, size_t len);
bool migrate_ram_is_ignored(RAMBlock *block);

/* migration/block.c */

Expand Down
2 changes: 1 addition & 1 deletion migration/postcopy-ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis, Error **errp)
/*
* We don't support postcopy with some type of ramblocks.
*
* NOTE: we explicitly ignored ramblock_is_ignored() instead we checked
* NOTE: we explicitly ignored migrate_ram_is_ignored() instead we checked
* all possible ramblocks. This is because this function can be called
* when creating the migration object, during the phase RAM_MIGRATABLE
* is not even properly set for all the ramblocks.
Expand Down
14 changes: 7 additions & 7 deletions migration/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ static bool postcopy_preempt_active(void)
return migrate_postcopy_preempt() && migration_in_postcopy();
}

bool ramblock_is_ignored(RAMBlock *block)
bool migrate_ram_is_ignored(RAMBlock *block)
{
return !qemu_ram_is_migratable(block) ||
(migrate_ignore_shared() && qemu_ram_is_shared(block)
Expand Down Expand Up @@ -696,7 +696,7 @@ static void pss_find_next_dirty(PageSearchStatus *pss)
unsigned long size = rb->used_length >> TARGET_PAGE_BITS;
unsigned long *bitmap = rb->bmap;

if (ramblock_is_ignored(rb)) {
if (migrate_ram_is_ignored(rb)) {
/* Points directly to the end, so we know no dirty page */
pss->page = size;
return;
Expand Down Expand Up @@ -780,7 +780,7 @@ unsigned long colo_bitmap_find_dirty(RAMState *rs, RAMBlock *rb,

*num = 0;

if (ramblock_is_ignored(rb)) {
if (migrate_ram_is_ignored(rb)) {
return size;
}

Expand Down Expand Up @@ -2260,7 +2260,7 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss)
unsigned long start_page = pss->page;
int res;

if (ramblock_is_ignored(pss->block)) {
if (migrate_ram_is_ignored(pss->block)) {
error_report("block %s should not be migrated !", pss->block->idstr);
return 0;
}
Expand Down Expand Up @@ -3347,7 +3347,7 @@ static inline RAMBlock *ram_block_from_stream(MigrationIncomingState *mis,
return NULL;
}

if (ramblock_is_ignored(block)) {
if (migrate_ram_is_ignored(block)) {
error_report("block %s should not be migrated !", id);
return NULL;
}
Expand Down Expand Up @@ -3958,7 +3958,7 @@ static int ram_load_precopy(QEMUFile *f)
}
if (migrate_ignore_shared()) {
hwaddr addr = qemu_get_be64(f);
if (ramblock_is_ignored(block) &&
if (migrate_ram_is_ignored(block) &&
block->mr->addr != addr) {
error_report("Mismatched GPAs for block %s "
"%" PRId64 "!= %" PRId64,
Expand Down Expand Up @@ -4254,7 +4254,7 @@ static void ram_mig_ram_block_resized(RAMBlockNotifier *n, void *host,
RAMBlock *rb = qemu_ram_block_from_host(host, false, &offset);
Error *err = NULL;

if (ramblock_is_ignored(rb)) {
if (migrate_ram_is_ignored(rb)) {
return;
}

Expand Down
3 changes: 1 addition & 2 deletions migration/ram.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@
extern XBZRLECacheStats xbzrle_counters;
extern CompressionStats compression_counters;

bool ramblock_is_ignored(RAMBlock *block);
/* Should be holding either ram_list.mutex, or the RCU lock. */
#define RAMBLOCK_FOREACH_NOT_IGNORED(block) \
INTERNAL_RAMBLOCK_FOREACH(block) \
if (ramblock_is_ignored(block)) {} else
if (migrate_ram_is_ignored(block)) {} else

#define RAMBLOCK_FOREACH_MIGRATABLE(block) \
INTERNAL_RAMBLOCK_FOREACH(block) \
Expand Down

0 comments on commit f161c88

Please sign in to comment.