From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X37W6-0008Nq-18 for qemu-devel@nongnu.org; Fri, 04 Jul 2014 13:43:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X37Vz-0000il-Qi for qemu-devel@nongnu.org; Fri, 04 Jul 2014 13:43:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64876) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X37Vz-0000hZ-1T for qemu-devel@nongnu.org; Fri, 04 Jul 2014 13:43:15 -0400 From: "Dr. David Alan Gilbert (git)" Date: Fri, 4 Jul 2014 18:41:54 +0100 Message-Id: <1404495717-4239-44-git-send-email-dgilbert@redhat.com> In-Reply-To: <1404495717-4239-1-git-send-email-dgilbert@redhat.com> References: <1404495717-4239-1-git-send-email-dgilbert@redhat.com> Subject: [Qemu-devel] [PATCH 43/46] postcopy: Wire up loadvm_postcopy_ram_handle_{run, end} commands List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, lilei@linux.vnet.ibm.com, quintela@redhat.com From: "Dr. David Alan Gilbert" Wire up more of the handlers for the commands on the destination side, in particular loadvm_postcopy_ram_handle_run now has enough to start the guest running. Signed-off-by: Dr. David Alan Gilbert --- savevm.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/savevm.c b/savevm.c index f4907db..8c79d37 100644 --- a/savevm.c +++ b/savevm.c @@ -1341,6 +1341,8 @@ static int loadvm_postcopy_ram_handle_listen(MigrationIncomingState *mis) /* After all discards we can start running and asking for pages */ static int loadvm_postcopy_ram_handle_run(MigrationIncomingState *mis) { + Error *local_err = NULL; + DPRINTF("%s", __func__); if (mis->postcopy_ram_state != POSTCOPY_RAM_INCOMING_LISTENING) { error_report("CMD_POSTCOPY_RAM_RUN in wrong postcopy state (%d)", @@ -1349,14 +1351,39 @@ static int loadvm_postcopy_ram_handle_run(MigrationIncomingState *mis) } mis->postcopy_ram_state = POSTCOPY_RAM_INCOMING_RUNNING; + + /* 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(); + bdrv_clear_incoming_migration_all(); + + /* Make sure all file formats flush their mutable metadata */ + bdrv_invalidate_cache_all(&local_err); + if (local_err) { + qerror_report_err(local_err); + error_free(local_err); + return -1; + } + + DPRINTF("loadvm_postcopy_ram_handle_run: cpu_synchronize_all_post_init"); + cpu_synchronize_all_post_init(); + + DPRINTF("loadvm_postcopy_ram_handle_run: vm_start"); /* Hold onto your hats, starting the CPU */ vm_start(); - return 0; + return LOADVM_EXITCODE_QUITLOOP; } -/* The end - with a byte from the source which can tell us to fail. */ -static int loadvm_postcopy_ram_handle_end(MigrationIncomingState *mis) +/* The end - with a byte from the source which can tell us to fail. + * The source sends this either if there is a failure, or if it believes it's + * sent everything + */ +static int loadvm_postcopy_ram_handle_end(MigrationIncomingState *mis, + uint8_t status) { DPRINTF("%s", __func__); if (mis->postcopy_ram_state == POSTCOPY_RAM_INCOMING_NONE) { @@ -1364,7 +1391,17 @@ static int loadvm_postcopy_ram_handle_end(MigrationIncomingState *mis) mis->postcopy_ram_state); return -1; } - return -1; /* TODO - expecting 1 byte good/fail */ + + DPRINTF("loadvm_postcopy_ram_handle_end status=%d", status); + + /* TODO: Give up on non-0 status + * TODO: If 0 status, check we've received everything (all outstanding + * requests should already have been completed) + * TODO: Indicate completion back to source + */ + /* TODO: Or should this be none? */ + mis->postcopy_ram_state = POSTCOPY_RAM_INCOMING_END; + return LOADVM_EXITCODE_QUITLOOP; } static int loadvm_process_command_simple_lencheck(const char *name, @@ -1505,7 +1542,7 @@ static int loadvm_process_command(QEMUFile *f, len, 1)) { return -1; } - return loadvm_postcopy_ram_handle_end(mis); + return loadvm_postcopy_ram_handle_end(mis, qemu_get_byte(f)); default: error_report("VM_COMMAND 0x%x unknown (len 0x%x)", com, len); -- 1.9.3