Go to file
Uri Lublin 2d1c00a659 migration: Don't assert() if MIGRATE_DATA comes before attaching the agent
During seamless migration, after switching host, if a client was connected
during the migration, it will have data to send back to the new
qemu/spice-server instance. This is handled through MIGRATE_DATA messages.
SPICE char devices use such MIGRATE_DATA messages to restore their state.

However, the MIGRATE_DATA message can arrive any time after the new qemu
instance has started, this can happen before or after the SPICE char
devices have been created. In order to handle this, if the migrate data
arrives early, it's stored in reds->agent_state.mig_data, and
attach_to_red_agent() will restore the agent state as appropriate.

Unfortunately this does not work as expected, for main
channel (agent messages).
If attach_to_red_agent() is called before the MIGRATE_DATA
message reaches the server, all goes well,
but if MIGRATE_DATA reaches the server before
attach_to_red_agent() gets called, then some assert() gets
triggered in spice_char_device_state_restore():

((null):32507): Spice-ERROR **: char_device.c:937:spice_char_device_state_restore: assertion `dev->num_clients == 1 && dev->wait_for_migrate_data' failed
Thread 3 (Thread 0x7f406b543700 (LWP 32543)):
Thread 2 (Thread 0x7f40697ff700 (LWP 32586)):
Thread 1 (Thread 0x7f4079b45a40 (LWP 32507)):

When restoring state, a client must already be added to the
spice-char-device.
What happens is that a client is not being added to the char-device
when when MIGRATE_DATA arrives first, which leaves both
dev->num_clients and dev->wait_for_migrate_data value at 0.

This commit changes the logic in spice_server_char_device_add_interface(),
such that if there is migrate data pending in reds->agent_state.mig_data
but no client was added to the spice-char-device yet,
then first the client is added to the device by calling
spice_char_device_client_add(), and only then the state is restored.

=== How to Reproduce
To reproduce, add delays to the migration connection between
qmeu-kvm on the source host (SRC) and on the destination (DST).

Specifically I added a man in the middle DLY host between
migration ports from SRC to DST.

+-----+    +-----+     +-----+
| SRC |--> | DLY | --> | DST |
+-----+    +-----+     +-----+

DLY listens on port P1 (e.g. 4444) and DST listens on port
PINCOMING (e.g. 4444, from qemu-kvm '-incoming' command line option)

Precondition: make sure port P1 on DLY is accessible in iptables.
Option 1: use ssh tcp port forwarding
On DLY host run ssh:
  ssh DLY:P1:DST:PINCOMING DST
Then use the following migration command (on qemu-kvm monitor):
  client_migrate_info spice DST PSPICE
  migrate -d tcp:DLY:P1

Option 2: Use a simple proxy program that forwards
packets from SRC to DST while adding some delays.
The program runs on DLY, listens to port D1, upon
accept connects to DST:PINCOMING and forward all
packets from DLY:D1 to DST:PINCOMING.
Then use the same migrate command as in option 1:
  client_migrate_info spice DST PSPICE
  migrate -d tcp:DLY:P1

=== How to Reproduce Ends

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1035184

Based-on-a-patch-by: Christophe Fergeau <cfergeau@redhat.com>
2014-10-14 15:48:02 +03:00
build-aux Update git-version-gen to latest version 2013-12-11 16:32:36 +01:00
client Fix typo; sampel --> sample 2014-01-02 12:39:04 +01:00
docs docs: Fix make distcheck 2014-05-15 15:26:51 +02:00
m4 m4: Update manywarnings from gnulib 2014-10-10 12:39:11 +02:00
server migration: Don't assert() if MIGRATE_DATA comes before attaching the agent 2014-10-14 15:48:02 +03:00
spice-common@b3a00f4411 Fix submodule reference 2014-04-16 22:51:05 +02:00
tests tests/migrate.py: add --vdagent 2011-08-23 17:01:14 +03:00
tools Add casts for compatibility purposes 2012-02-14 10:44:49 +02:00
uncrustify_cfg fresh start 2009-10-14 15:06:41 +02:00
.gitignore Don't ignore all of m4/ in .gitignore 2013-10-10 11:17:17 +02:00
.gitmodules Use the spice-common submodule 2012-03-25 18:59:10 +02:00
.mailmap Add recent new committers to AUTHORS file / mailmap 2012-04-25 09:49:29 +01:00
AUTHORS syntax-check: update AUTHORS 2013-07-16 23:37:28 +03:00
autogen.sh Use the spice-common submodule 2012-03-25 18:59:10 +02:00
cfg.mk Add a few more syntax-check exemptions 2012-04-25 09:49:32 +01:00
ChangeLog fresh start 2009-10-14 15:06:41 +02:00
configure.ac build-sys: check for spicy-screenshot 2014-09-08 14:49:29 +02:00
COPYING Relicense everything from GPL to LGPL 2.1+ 2010-04-13 22:22:15 +02:00
GNUmakefile Add a 'syntax-check' make target 2012-01-13 18:12:00 +02:00
maint.mk syntax-check: trailing whitespaces -- ignore binary files 2013-07-17 01:59:32 +03:00
Makefile.am Add reference manual 2014-01-20 12:18:15 +01:00
NEWS Update NEWS 2014-05-19 11:35:14 +02:00
README Revise the spice client and server to use the new snd_codec functions in spice-common. 2014-01-02 12:34:34 +01:00
spice-server.pc.in spice-server.pc.in: move Requires to Requires.private 2011-10-23 11:26:30 +02:00
TODO.multiclient Remove trailing whitespace from end of lines 2012-01-13 18:11:59 +02:00

   SPICE: Simple Protocol for Independent Computing Environments
   =============================================================

SPICE is a remote display system built for virtual environments which
allows you to view a computing 'desktop' environment not only on the
machine where it is running, but from anywhere on the Internet and
from a wide variety of machine architectures.

Installation
------------

The SPICE package uses GNU autotools, so the build install process
follows the standard process documented in the INSTALL file. As a
quick start you can do

  ./configure --prefix=/usr --sysconfdir=/etc \
        --localstatedir=/var --libdir=/usr/lib
  make
  sudo make install

Or to install into a private user specific location

  ./configure --prefix=$HOME/spice
  make
  make install

The following mandatory dependancies are required in order to
build SPICE

    Spice protocol >= 0.9.0
    Pixman         >= 0.17.7
    OpenSSL
    libjpeg
    zlib
    Cyrus-SASL

The following optional dependancies increase the available
functionality

    GE Gui         >= 0.6.0,  < 0.7.0   (GUI app support)
    OpenGL                              (GUI app support)
    Alsa                                (Linux support)
    XRandR         >= 1.2               (X11 support)
    Xinerama       >= 1.0               (X11 support)
    libcacard      >= 0.1.2             (Smartcard support)

Communication
-------------

To communicate with the development team, or to post patches
there is a technical mailing list:

   http://lists.freedesktop.org/mailman/listinfo/spice-devel

There is also a mailing list for new release announcements:

   http://lists.freedesktop.org/archives/spice-announce/

To view known bugs, or report new bugs, in SPICE visit

   https://bugs.freedesktop.org/describecomponents.cgi?product=Spice

Bugs found when using an OS distribution's binary packages should
be reported to the OS vendors' own bug tracker first.

The latest SPICE code can be found in GIT at:

   http://cgit.freedesktop.org/spice/

Licensing
---------

SPICE is provided under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

Please see the COPYING file for the complete LGPLv2+ license
terms, or visit <http://www.gnu.org/licenses/>.

Experimental Features
---------------------
To enable multiple client connections, set:
SPICE_DEBUG_ALLOW_MC=1

-- End of readme