From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvqGq-0005Fd-FD for qemu-devel@nongnu.org; Mon, 09 Nov 2015 12:30:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZvqGp-00054J-Aj for qemu-devel@nongnu.org; Mon, 09 Nov 2015 12:30:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46158) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvqGp-00054B-3o for qemu-devel@nongnu.org; Mon, 09 Nov 2015 12:30:19 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id D62CBB8BA5 for ; Mon, 9 Nov 2015 17:30:18 +0000 (UTC) From: Juan Quintela Date: Mon, 9 Nov 2015 18:28:51 +0100 Message-Id: <1447090141-29074-48-git-send-email-quintela@redhat.com> In-Reply-To: <1447090141-29074-1-git-send-email-quintela@redhat.com> References: <1447090141-29074-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PULL 47/57] Don't iterate on precopy-only devices during postcopy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, dgilbert@redhat.com From: "Dr. David Alan Gilbert" During the postcopy phase we must not call the iterate method on precopy-only devices, since they may have done some cleanup during the _complete call at the end of the precopy phase. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- include/sysemu/sysemu.h | 2 +- migration/migration.c | 2 +- migration/savevm.c | 13 +++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 76a0b36..05d1982 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -109,7 +109,7 @@ bool qemu_savevm_state_blocked(Error **errp); void qemu_savevm_state_begin(QEMUFile *f, const MigrationParams *params); void qemu_savevm_state_header(QEMUFile *f); -int qemu_savevm_state_iterate(QEMUFile *f); +int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy); void qemu_savevm_state_cleanup(void); void qemu_savevm_state_complete_postcopy(QEMUFile *f); void qemu_savevm_state_complete_precopy(QEMUFile *f); diff --git a/migration/migration.c b/migration/migration.c index 6470a18..a12ba15 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1628,7 +1628,7 @@ static void *migration_thread(void *opaque) continue; } /* Just another iteration step */ - qemu_savevm_state_iterate(s->file); + qemu_savevm_state_iterate(s->file, entered_postcopy); } else { trace_migration_thread_low_pending(pending_size); migration_completion(s, current_active_state, diff --git a/migration/savevm.c b/migration/savevm.c index 9fd276e..9794945 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -931,7 +931,7 @@ void qemu_savevm_state_begin(QEMUFile *f, * 0 : We haven't finished, caller have to go again * 1 : We have finished, we can go to complete phase */ -int qemu_savevm_state_iterate(QEMUFile *f) +int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy) { SaveStateEntry *se; int ret = 1; @@ -946,6 +946,15 @@ int qemu_savevm_state_iterate(QEMUFile *f) continue; } } + /* + * In the postcopy phase, any device that doesn't know how to + * do postcopy should have saved it's state in the _complete + * call that's already run, it might get confused if we call + * iterate afterwards. + */ + if (postcopy && !se->ops->save_live_complete_postcopy) { + continue; + } if (qemu_file_rate_limit(f)) { return 0; } @@ -1160,7 +1169,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) qemu_mutex_lock_iothread(); while (qemu_file_get_error(f) == 0) { - if (qemu_savevm_state_iterate(f) > 0) { + if (qemu_savevm_state_iterate(f, false) > 0) { break; } } -- 2.5.0