aboutsummaryrefslogtreecommitdiff
path: root/migration
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2017-03-20 22:25:28 +0100
committerJuan Quintela <quintela@redhat.com>2017-04-21 12:25:39 +0200
commit5727309d254b4942645888574a16d36942ec439c (patch)
tree9a09abab8e668ca62d67ffbf11289b1799a2e958 /migration
parent6d358d94943076846328cc292e4f45c31e1d5d96 (diff)
migration: Remove MigrationState from migration_in_postcopy
We need to call for the migrate_get_current() in more that half of the uses, so call that inside. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
Diffstat (limited to 'migration')
-rw-r--r--migration/migration.c6
-rw-r--r--migration/ram.c22
-rw-r--r--migration/savevm.c4
3 files changed, 16 insertions, 16 deletions
diff --git a/migration/migration.c b/migration/migration.c
index 2990c4069c..7da16cf44e 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1062,14 +1062,16 @@ bool migration_has_failed(MigrationState *s)
s->state == MIGRATION_STATUS_FAILED);
}
-bool migration_in_postcopy(MigrationState *s)
+bool migration_in_postcopy(void)
{
+ MigrationState *s = migrate_get_current();
+
return (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE);
}
bool migration_in_postcopy_after_devices(MigrationState *s)
{
- return migration_in_postcopy(s) && s->postcopy_after_devices;
+ return migration_in_postcopy() && s->postcopy_after_devices;
}
bool migration_is_idle(MigrationState *s)
diff --git a/migration/ram.c b/migration/ram.c
index fa5a2901dc..289d7eb5c9 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -776,10 +776,9 @@ static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
return pages;
}
-static void ram_release_pages(MigrationState *ms, const char *rbname,
- uint64_t offset, int pages)
+static void ram_release_pages(const char *rbname, uint64_t offset, int pages)
{
- if (!migrate_release_ram() || !migration_in_postcopy(ms)) {
+ if (!migrate_release_ram() || !migration_in_postcopy()) {
return;
}
@@ -845,9 +844,9 @@ static int ram_save_page(RAMState *rs, MigrationState *ms,
* page would be stale
*/
xbzrle_cache_zero_page(rs, current_addr);
- ram_release_pages(ms, block->idstr, pss->offset, pages);
+ ram_release_pages(block->idstr, pss->offset, pages);
} else if (!rs->ram_bulk_stage &&
- !migration_in_postcopy(ms) && migrate_use_xbzrle()) {
+ !migration_in_postcopy() && migrate_use_xbzrle()) {
pages = save_xbzrle_page(rs, &p, current_addr, block,
offset, last_stage);
if (!last_stage) {
@@ -866,7 +865,7 @@ static int ram_save_page(RAMState *rs, MigrationState *ms,
if (send_async) {
qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE,
migrate_release_ram() &
- migration_in_postcopy(ms));
+ migration_in_postcopy());
} else {
qemu_put_buffer(rs->f, p, TARGET_PAGE_SIZE);
}
@@ -896,8 +895,7 @@ static int do_compress_ram_page(QEMUFile *f, RAMBlock *block,
error_report("compressed data failed!");
} else {
bytes_sent += blen;
- ram_release_pages(migrate_get_current(), block->idstr,
- offset & TARGET_PAGE_MASK, 1);
+ ram_release_pages(block->idstr, offset & TARGET_PAGE_MASK, 1);
}
return bytes_sent;
@@ -1033,7 +1031,7 @@ static int ram_save_compressed_page(RAMState *rs, MigrationState *ms,
}
}
if (pages > 0) {
- ram_release_pages(ms, block->idstr, pss->offset, pages);
+ ram_release_pages(block->idstr, pss->offset, pages);
}
} else {
offset |= RAM_SAVE_FLAG_CONTINUE;
@@ -1041,7 +1039,7 @@ static int ram_save_compressed_page(RAMState *rs, MigrationState *ms,
if (pages == -1) {
pages = compress_page_with_multi_thread(rs, block, offset);
} else {
- ram_release_pages(ms, block->idstr, pss->offset, pages);
+ ram_release_pages(block->idstr, pss->offset, pages);
}
}
}
@@ -2200,7 +2198,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
rcu_read_lock();
- if (!migration_in_postcopy(migrate_get_current())) {
+ if (!migration_in_postcopy()) {
migration_bitmap_sync(rs);
}
@@ -2238,7 +2236,7 @@ static void ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size,
remaining_size = rs->migration_dirty_pages * TARGET_PAGE_SIZE;
- if (!migration_in_postcopy(migrate_get_current()) &&
+ if (!migration_in_postcopy() &&
remaining_size < max_size) {
qemu_mutex_lock_iothread();
rcu_read_lock();
diff --git a/migration/savevm.c b/migration/savevm.c
index 3b19a4a274..853a81a080 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1062,7 +1062,7 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy)
static bool should_send_vmdesc(void)
{
MachineState *machine = MACHINE(qdev_get_machine());
- bool in_postcopy = migration_in_postcopy(migrate_get_current());
+ bool in_postcopy = migration_in_postcopy();
return !machine->suppress_vmdesc && !in_postcopy;
}
@@ -1111,7 +1111,7 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only)
int vmdesc_len;
SaveStateEntry *se;
int ret;
- bool in_postcopy = migration_in_postcopy(migrate_get_current());
+ bool in_postcopy = migration_in_postcopy();
trace_savevm_state_complete_precopy();