From patchwork Tue Sep 29 08:38:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 523883 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 29ED21402D8 for ; Wed, 30 Sep 2015 00:29:58 +1000 (AEST) Received: from localhost ([::1]:52935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgvul-00009d-W4 for incoming@patchwork.ozlabs.org; Tue, 29 Sep 2015 10:29:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgqSH-0006NK-9h for qemu-devel@nongnu.org; Tue, 29 Sep 2015 04:40:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgqSE-0002dF-07 for qemu-devel@nongnu.org; Tue, 29 Sep 2015 04:40:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36068) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgqSD-0002cB-PX for qemu-devel@nongnu.org; Tue, 29 Sep 2015 04:40:05 -0400 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 732588E708; Tue, 29 Sep 2015 08:40:05 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-104.ams2.redhat.com [10.36.116.104]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8T8cJZV015509; Tue, 29 Sep 2015 04:40:03 -0400 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, amit.shah@redhat.com Date: Tue, 29 Sep 2015 09:38:14 +0100 Message-Id: <1443515898-3594-51-git-send-email-dgilbert@redhat.com> In-Reply-To: <1443515898-3594-1-git-send-email-dgilbert@redhat.com> References: <1443515898-3594-1-git-send-email-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: aarcange@redhat.com, pbonzini@redhat.com, liang.z.li@intel.com, luis@cs.umu.se, bharata@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v8 50/54] postcopy: Wire up loadvm_postcopy_handle_ commands X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Dr. David Alan Gilbert" Wire up more of the handlers for the commands on the destination side, in particular loadvm_postcopy_handle_run now has enough to start the guest running. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Reviewed-by: Amit Shah --- migration/savevm.c | 28 +++++++++++++++++++++++++++- trace-events | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/migration/savevm.c b/migration/savevm.c index fe683d6..7c5b9d1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1477,12 +1477,33 @@ static int loadvm_postcopy_handle_listen(MigrationIncomingState *mis) static int loadvm_postcopy_handle_run(MigrationIncomingState *mis) { PostcopyState ps = postcopy_state_set(POSTCOPY_INCOMING_RUNNING); + Error *local_err = NULL; + trace_loadvm_postcopy_handle_run(); if (ps != POSTCOPY_INCOMING_LISTENING) { error_report("CMD_POSTCOPY_RUN in wrong postcopy state (%d)", ps); return -1; } + /* TODO we should move all of this lot into postcopy_ram.c or a shared code + * in migration.c + */ + cpu_synchronize_all_post_init(); + + qemu_announce_self(); + + /* Make sure all file formats flush their mutable metadata */ + bdrv_invalidate_cache_all(&local_err); + if (local_err) { + error_report_err(local_err); + return -1; + } + + trace_loadvm_postcopy_handle_run_cpu_sync(); + cpu_synchronize_all_post_init(); + + trace_loadvm_postcopy_handle_run_vmstart(); + if (autostart) { /* Hold onto your hats, starting the CPU */ vm_start(); @@ -1491,7 +1512,12 @@ static int loadvm_postcopy_handle_run(MigrationIncomingState *mis) runstate_set(RUN_STATE_PAUSED); } - return 0; + /* We need to finish reading the stream from the package + * and also stop reading anything more from the stream that loaded the + * package (since it's now being read by the listener thread). + * LOADVM_QUIT will quit all the layers of nested loadvm loops. + */ + return LOADVM_QUIT; } /** diff --git a/trace-events b/trace-events index cb956e3..42a7577 100644 --- a/trace-events +++ b/trace-events @@ -1208,6 +1208,8 @@ loadvm_handle_cmd_packaged_received(int ret) "%d" loadvm_postcopy_handle_advise(void) "" loadvm_postcopy_handle_listen(void) "" loadvm_postcopy_handle_run(void) "" +loadvm_postcopy_handle_run_cpu_sync(void) "" +loadvm_postcopy_handle_run_vmstart(void) "" loadvm_postcopy_ram_handle_discard(void) "" loadvm_postcopy_ram_handle_discard_end(void) "" loadvm_postcopy_ram_handle_discard_header(const char *ramid, uint16_t len) "%s: %ud"