From patchwork Thu Aug 16 08:23:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonit Halperin X-Patchwork-Id: 177919 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 31E642C008D for ; Thu, 16 Aug 2012 18:41:08 +1000 (EST) Received: from localhost ([::1]:60775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1vME-0008As-P6 for incoming@patchwork.ozlabs.org; Thu, 16 Aug 2012 04:23:10 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1vLX-0006J1-Gg for qemu-devel@nongnu.org; Thu, 16 Aug 2012 04:22:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T1vLW-00076R-A7 for qemu-devel@nongnu.org; Thu, 16 Aug 2012 04:22:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1vLW-00076I-1k for qemu-devel@nongnu.org; Thu, 16 Aug 2012 04:22:26 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7G8MPH6005782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 16 Aug 2012 04:22:25 -0400 Received: from dhcp-0-9.tlv.redhat.com (dhcp-4-73.tlv.redhat.com [10.35.4.73]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7G8MIN8006716; Thu, 16 Aug 2012 04:22:24 -0400 From: Yonit Halperin To: qemu-devel@nongnu.org Date: Thu, 16 Aug 2012 11:23:25 +0300 Message-Id: <1345105406-15082-4-git-send-email-yhalperi@redhat.com> In-Reply-To: <1345105406-15082-1-git-send-email-yhalperi@redhat.com> References: <1345105406-15082-1-git-send-email-yhalperi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: mprivozn@redhat.com, Yonit Halperin , kraxel@redhat.com Subject: [Qemu-devel] [PATCH 3/4] spice: add 'migrated' flag to spice info 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 The flag is 'true' when spice migration has completed on the src side. It is needed for a case where libvirt dies before migration completes and it misses the event QEVENT_SPICE_MIGRATE_COMPLETED. When libvirt is restored and queries the migration status, it also needs to query spice and check if its migration has completed. Signed-off-by: Yonit Halperin --- hmp.c | 2 ++ qapi-schema.json | 5 ++++- ui/spice-core.c | 4 ++++ 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/hmp.c b/hmp.c index a9d5675..62f4dee 100644 --- a/hmp.c +++ b/hmp.c @@ -413,6 +413,8 @@ void hmp_info_spice(Monitor *mon) monitor_printf(mon, " address: %s:%" PRId64 " [tls]\n", info->host, info->tls_port); } + monitor_printf(mon, " migrated: %s\n", + info->migrated ? "true" : "false"); monitor_printf(mon, " auth: %s\n", info->auth); monitor_printf(mon, " compiled: %s\n", info->compiled_version); monitor_printf(mon, " mouse-mode: %s\n", diff --git a/qapi-schema.json b/qapi-schema.json index 3d2b2d1..bf3f924 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -808,6 +808,9 @@ # # @enabled: true if the SPICE server is enabled, false otherwise # +# @migrated: true if the last guest migration completed and spice +# migration had completed as well. false otherwise. +# # @host: #optional The hostname the SPICE server is bound to. This depends on # the name resolution on the host and may be an IP address. # @@ -833,7 +836,7 @@ # Since: 0.14.0 ## { 'type': 'SpiceInfo', - 'data': {'enabled': 'bool', '*host': 'str', '*port': 'int', + 'data': {'enabled': 'bool', 'migrated': 'bool', '*host': 'str', '*port': 'int', '*tls-port': 'int', '*auth': 'str', '*compiled-version': 'str', 'mouse-mode': 'SpiceQueryMouseMode', '*channels': ['SpiceChannel']} } diff --git a/ui/spice-core.c b/ui/spice-core.c index 6b4d216..4d3d05e 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -45,6 +45,7 @@ static Notifier migration_state; static const char *auth = "spice"; static char *auth_passwd; static time_t auth_expires = TIME_MAX; +static int spice_migration_completed; int using_spice = 0; static QemuThread me; @@ -309,6 +310,7 @@ static void migrate_connect_complete_cb(SpiceMigrateInstance *sin) static void migrate_end_complete_cb(SpiceMigrateInstance *sin) { monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL); + spice_migration_completed = true; } #endif @@ -441,6 +443,7 @@ SpiceInfo *qmp_query_spice(Error **errp) } info->enabled = true; + info->migrated = spice_migration_completed; addr = qemu_opt_get(opts, "addr"); port = qemu_opt_get_number(opts, "port", 0); @@ -494,6 +497,7 @@ static void migration_state_notifier(Notifier *notifier, void *data) #ifndef SPICE_INTERFACE_MIGRATION spice_server_migrate_switch(spice_server); monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL); + spice_migration_completed = true; #else spice_server_migrate_end(spice_server, true); } else if (migration_has_failed(s)) {