From 91787bf41fc200626f3e048cf593da7ee9477291 Mon Sep 17 00:00:00 2001
Message-Id: <91787bf41fc200626f3e048cf593da7ee9477291.1346761472.git.minovotn@redhat.com>
In-Reply-To: <66350080c56dd39cd894591e70182434d5d2de75.1346761472.git.minovotn@redhat.com>
References: <66350080c56dd39cd894591e70182434d5d2de75.1346761472.git.minovotn@redhat.com>
From: Yonit Halperin <yhalperi@redhat.com>
Date: Sun, 26 Aug 2012 09:54:11 +0200
Subject: [PATCH 08/10] spice: adding seamless-migration option to the command
 line

RH-Author: Yonit Halperin <yhalperi@redhat.com>
Message-id: <1345974852-592-5-git-send-email-yhalperi@redhat.com>
Patchwork-id: 41273
O-Subject: [PATCH 5/6] spice: adding seamless-migration option to the command line
Bugzilla: 836133
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
RH-Acked-by: Alon Levy <alevy@redhat.com>
RH-Acked-by: Uri Lublin <uril@redhat.com>

The seamless-migration flag is required in order to identify
whether libvirt supports the new QEVENT_SPICE_MIGRATE_COMPLETED or not
(by default the flag is off).
New libvirt versions that wait for QEVENT_SPICE_MIGRATE_COMPLETED should turn on this flag.
When this flag is off, spice fallbacks to its old migration method, which
can result in data loss.

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
---
 qemu-config.c   |    3 +++
 qemu-options.hx |    3 +++
 ui/spice-core.c |    8 ++++++++
 3 files changed, 14 insertions(+), 0 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 qemu-config.c   | 3 +++
 qemu-options.hx | 3 +++
 ui/spice-core.c | 8 ++++++++
 3 files changed, 14 insertions(+)

diff --git a/qemu-config.c b/qemu-config.c
index adb9970..8d9ead6 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -395,6 +395,9 @@ QemuOptsList qemu_spice_opts = {
         },{
             .name = "playback-compression",
             .type = QEMU_OPT_BOOL,
+        },{
+            .name = "seamless-migration",
+            .type = QEMU_OPT_BOOL,
         },
         { /* end if list */ }
     },
diff --git a/qemu-options.hx b/qemu-options.hx
index 75b2f88..b93a4a0 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -629,6 +629,9 @@ Enable/disable passing mouse events via vdagent.  Default is on.
 @item playback-compression=[on|off]
 Enable/disable audio stream compression (using celt 0.5.1).  Default is on.
 
+@item seamless-migration=[on|off]
+Enable/disable spice seamless migration. Default is off.
+
 @end table
 ETEXI
 
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 4823047..1d43fee 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -632,6 +632,9 @@ void qemu_spice_init(void)
     int port, tls_port, len, addr_flags;
     spice_image_compression_t compression;
     spice_wan_compression_t wan_compr;
+#if SPICE_SERVER_VERSION >= 0x000b02 /* 0.11.2 */
+    bool seamless_migration;
+#endif
 
     me = pthread_self();
 
@@ -762,6 +765,11 @@ void qemu_spice_init(void)
 
     qemu_opt_foreach(opts, add_channel, &tls_port, 0);
 
+#if SPICE_SERVER_VERSION >= 0x000b02 /* 0.11.2 */
+    seamless_migration = qemu_opt_get_bool(opts, "seamless-migration", 0);
+    spice_server_set_seamless_migration(spice_server, seamless_migration);
+#endif
+
     if (0 != spice_server_init(spice_server, &core_interface)) {
         fprintf(stderr, "failed to initialize spice server");
         exit(1);
-- 
1.7.11.4

