From patchwork Mon Aug 20 13:26:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonit Halperin X-Patchwork-Id: 178773 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 86A8F2C00AC for ; Mon, 20 Aug 2012 23:25:44 +1000 (EST) Received: from localhost ([::1]:41402 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3RzC-0002DS-I1 for incoming@patchwork.ozlabs.org; Mon, 20 Aug 2012 09:25:42 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3Ryn-0001uA-OK for qemu-devel@nongnu.org; Mon, 20 Aug 2012 09:25:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T3Ryl-0003Om-Pk for qemu-devel@nongnu.org; Mon, 20 Aug 2012 09:25:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49032) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3Ryl-0003OY-HQ for qemu-devel@nongnu.org; Mon, 20 Aug 2012 09:25:15 -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 (8.14.4/8.14.4) with ESMTP id q7KDPFNT031015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 20 Aug 2012 09:25:15 -0400 Received: from dhcp-0-9.tlv.redhat.com (dhcp-4-73.tlv.redhat.com [10.35.4.73]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7KDP2tu010465; Mon, 20 Aug 2012 09:25:13 -0400 From: Yonit Halperin To: qemu-devel@nongnu.org Date: Mon, 20 Aug 2012 16:26:14 +0300 Message-Id: <1345469176-1675-4-git-send-email-yhalperi@redhat.com> In-Reply-To: <1345469176-1675-1-git-send-email-yhalperi@redhat.com> References: <1345469176-1675-1-git-send-email-yhalperi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Yonit Halperin , kraxel@redhat.com Subject: [Qemu-devel] [PATCH v2 3/5] spice migration: add QEVENT_SPICE_MIGRATE_COMPLETED 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 When migrating, libvirt queries the migration status, and upon migration completions, it closes the migration src. On the other hand, when migration is completed, spice transfers data from the src to destination via the client. This data is required for keeping the spice session after migration, without suffering from data loss and inconsistencies. In order to allow this data transfer, we add QEVENT for signaling libvirt that spice migration has completed, and libvirt needs to wait for this event before quitting the src process. Signed-off-by: Yonit Halperin --- monitor.c | 1 + monitor.h | 1 + ui/spice-core.c | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/monitor.c b/monitor.c index ce42466..584efe0 100644 --- a/monitor.c +++ b/monitor.c @@ -455,6 +455,7 @@ static const char *monitor_event_names[] = { [QEVENT_SUSPEND_DISK] = "SUSPEND_DISK", [QEVENT_WAKEUP] = "WAKEUP", [QEVENT_BALLOON_CHANGE] = "BALLOON_CHANGE", + [QEVENT_SPICE_MIGRATE_COMPLETED] = "SPICE_MIGRATE_COMPLETED", }; QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX) diff --git a/monitor.h b/monitor.h index 47d556b..5fc2983 100644 --- a/monitor.h +++ b/monitor.h @@ -43,6 +43,7 @@ typedef enum MonitorEvent { QEVENT_SUSPEND_DISK, QEVENT_WAKEUP, QEVENT_BALLOON_CHANGE, + QEVENT_SPICE_MIGRATE_COMPLETED, /* Add to 'monitor_event_names' array in monitor.c when * defining new events here */ diff --git a/ui/spice-core.c b/ui/spice-core.c index 97b45f8..ad7c866 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -295,6 +295,7 @@ typedef struct SpiceMigration { } SpiceMigration; static void migrate_connect_complete_cb(SpiceMigrateInstance *sin); +static void migrate_end_complete_cb(SpiceMigrateInstance *sin); static const SpiceMigrateInterface migrate_interface = { .base.type = SPICE_INTERFACE_MIGRATION, @@ -302,7 +303,7 @@ static const SpiceMigrateInterface migrate_interface = { .base.major_version = SPICE_INTERFACE_MIGRATION_MAJOR, .base.minor_version = SPICE_INTERFACE_MIGRATION_MINOR, .migrate_connect_complete = migrate_connect_complete_cb, - .migrate_end_complete = NULL, + .migrate_end_complete = migrate_end_complete_cb, }; static SpiceMigration spice_migrate; @@ -315,6 +316,11 @@ static void migrate_connect_complete_cb(SpiceMigrateInstance *sin) } sm->connect_complete.cb = NULL; } + +static void migrate_end_complete_cb(SpiceMigrateInstance *sin) +{ + monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL); +} #endif /* config string parsing */ @@ -498,6 +504,7 @@ static void migration_state_notifier(Notifier *notifier, void *data) } else if (migration_has_finished(s)) { #ifndef SPICE_INTERFACE_MIGRATION spice_server_migrate_switch(spice_server); + monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL); #else spice_server_migrate_end(spice_server, true); } else if (migration_has_failed(s)) {