From patchwork Tue Dec 11 12:46:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [22/35] migration: move exit condition to migration thread Date: Tue, 11 Dec 2012 02:46:58 -0000 From: Juan Quintela X-Patchwork-Id: 205222 Message-Id: <1355230031-28233-23-git-send-email-quintela@redhat.com> To: qemu-devel@nongnu.org Signed-off-by: Juan Quintela --- migration.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/migration.c b/migration.c index 031302b..5c2f413 100644 --- a/migration.c +++ b/migration.c @@ -676,12 +676,6 @@ static bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size) bool last_round = false; qemu_mutex_lock_iothread(); - if (s->state != MIG_STATE_ACTIVE) { - DPRINTF("put_ready returning because of non-active state\n"); - qemu_mutex_unlock_iothread(); - return false; - } - DPRINTF("iterate\n"); pending_size = qemu_savevm_state_pending(s->file, max_size); DPRINTF("pending size %lu max %lu\n", pending_size, max_size); @@ -748,9 +742,18 @@ static void *buffered_file_thread(void *opaque) while (true) { int64_t current_time = qemu_get_clock_ms(rt_clock); - if (s->migration_state->complete) { + qemu_mutex_lock_iothread(); + if (m->state != MIG_STATE_ACTIVE) { + DPRINTF("put_ready returning because of non-active state\n"); + qemu_mutex_unlock_iothread(); break; } + if (m->complete) { + qemu_mutex_unlock_iothread(); + break; + } + qemu_mutex_unlock_iothread(); + if (current_time >= initial_time + BUFFER_DELAY) { uint64_t transferred_bytes = s->bytes_xfer; uint64_t time_spent = current_time - initial_time;