From patchwork Tue Feb 23 14:24:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 8392621 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9B4A3C0553 for ; Tue, 23 Feb 2016 14:24:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E007820253 for ; Tue, 23 Feb 2016 14:24:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1089B20103 for ; Tue, 23 Feb 2016 14:24:45 +0000 (UTC) Received: from localhost ([::1]:57471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYDtL-0006tx-VN for patchwork-qemu-devel@patchwork.kernel.org; Tue, 23 Feb 2016 09:24:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYDt8-0006sA-Om for qemu-devel@nongnu.org; Tue, 23 Feb 2016 09:24:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYDt5-0001So-QJ for qemu-devel@nongnu.org; Tue, 23 Feb 2016 09:24:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57166) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYDt5-0001SG-Ig for qemu-devel@nongnu.org; Tue, 23 Feb 2016 09:24:27 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 4232B34156D for ; Tue, 23 Feb 2016 14:24:27 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1NEOPqc002595; Tue, 23 Feb 2016 09:24:26 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 4B673822C3; Tue, 23 Feb 2016 15:24:24 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 23 Feb 2016 15:24:22 +0100 Message-Id: <1456237462-3687-9-git-send-email-kraxel@redhat.com> In-Reply-To: <1456237462-3687-1-git-send-email-kraxel@redhat.com> References: <1456237462-3687-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Amit Shah , Juan Quintela , "Dr. David Alan Gilbert" , Gerd Hoffmann Subject: [Qemu-devel] [PULL 8/8] Postcopy+spice: Pass spice migration data earlier 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Dr. David Alan Gilbert" Spice hooks the migration status changes to figure out when to transmit information to the new spice server; but the migration status in postcopy doesn't quite fit - the destination starts running before the end of the source migration. It's not a case of hanging off the migration status change to postcopy-active either, since that happens before we stop the guest CPU. Fix it by sending a notify just after sending the device state, and adding a flag that can be tested by the notify receiver. Symptom: spice handover doesn't work with the error: red_worker.c:11540:display_channel_wait_for_migrate_data: timeout Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Amit Shah Message-id: 1456161452-25318-1-git-send-email-dgilbert@redhat.com Signed-off-by: Gerd Hoffmann --- include/migration/migration.h | 4 ++++ migration/migration.c | 14 ++++++++++++++ ui/spice-core.c | 3 ++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 74684ad..97622e4 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -159,6 +159,8 @@ struct MigrationState /* Flag set once the migration has been asked to enter postcopy */ bool start_postcopy; + /* Flag set after postcopy has sent the device state */ + bool postcopy_after_devices; /* Flag set once the migration thread is running (and needs joining) */ bool migration_thread_running; @@ -212,6 +214,8 @@ bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); /* True if outgoing migration has entered postcopy phase */ bool migration_in_postcopy(MigrationState *); +/* ...and after the device transmission */ +bool migration_in_postcopy_after_devices(MigrationState *); MigrationState *migrate_get_current(void); void migrate_compress_threads_create(void); diff --git a/migration/migration.c b/migration/migration.c index a64cfcd..fc5e50b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -905,6 +905,11 @@ bool migration_in_postcopy(MigrationState *s) return (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE); } +bool migration_in_postcopy_after_devices(MigrationState *s) +{ + return migration_in_postcopy(s) && s->postcopy_after_devices; +} + MigrationState *migrate_init(const MigrationParams *params) { MigrationState *s = migrate_get_current(); @@ -930,6 +935,7 @@ MigrationState *migrate_init(const MigrationParams *params) s->setup_time = 0; s->dirty_sync_count = 0; s->start_postcopy = false; + s->postcopy_after_devices = false; s->migration_thread_running = false; s->last_req_rb = NULL; @@ -1489,6 +1495,14 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) goto fail_closefb; } qemu_fclose(fb); + + /* Send a notify to give a chance for anything that needs to happen + * at the transition to postcopy and after the device state; in particular + * spice needs to trigger a transition now + */ + ms->postcopy_after_devices = true; + notifier_list_notify(&migration_state_notifiers, ms); + ms->downtime = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - time_at_stop; qemu_mutex_unlock_iothread(); diff --git a/ui/spice-core.c b/ui/spice-core.c index 5abec17..a68a665 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -573,7 +573,8 @@ static void migration_state_notifier(Notifier *notifier, void *data) if (migration_in_setup(s)) { spice_server_migrate_start(spice_server); - } else if (migration_has_finished(s)) { + } else if (migration_has_finished(s) || + migration_in_postcopy_after_devices(s)) { spice_server_migrate_end(spice_server, true); spice_have_target_host = false; } else if (migration_has_failed(s)) {