mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice-protocol
synced 2025-12-26 14:18:31 +00:00
The main difference between semi-seamless and seamless migration is that
while in semi-seamless migration the state of all the channels is
being completely reset after migration is complete, in seamless migration
the essential parts of the state are restored on the server side, and
are left the same on the client side. semi-seamless migration is
equivalent to having the client disconnect from the src and connected
from scratch to the dest, with the exception, that the handshake with
the dest server occurs before the client has disconnected from the src.
In semi-seamless migration in-flight data gets lost, e.g., a file
transfer to a usb device might be disrupted.
=======================
===protocol details====
=======================
Let s1, s2, and c be the src server, dest server and client, respectively.
Semi-Seamless migration protocol
================================
pre-migration phase:
--------------------
(1) s1->c: SPICE_MSG_MAIN_MIGRATE_BEGIN
In response, c tries to establish a connection to s2. After the connection is
established, it is inactive (the client doesn't attempt to read or
write messages from/to it)
(2) c->s1: SPICE_MSGC_MAIN_MIGRATE_CONNECTED or
SPICE_MSGC_MAIN_MIGRATE_CONNECT_ERROR
post migration phase:
---------------------
(1) s1->c: SPICE_MSG_MAIN_MIGRATE_END or
SPICE_MSG_MAIN_MIGRATE_CANCEL
In case of the former, c disconnects from s1, resets all its
channels states and switches to an active connection with s2.
(2) c->s2: SPICE_MSGC_MAIN_MIGRATE_END
The msg signals that all the channels have been migrated successfully to s2.
Seamless migration protocol
===========================
pre-migration phase:
--------------------
In case qemu/libvirt/client do not support seamless migration,
s1 takes the semi-seamless pathway for migration. Otherwise:
(1) s1->c: SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS (*New*)
The msg includes the version of the migration protocol
of s1.
In response c tries to establish a connection to s2.
(2)
If the connection fails:
(2.1) c->s1: SPICE_MSGC_MAIN_MIGRATE_CONNECT_ERROR
If s2 supports SPICE_MAIN_CAP_SEAMLESS_MIGRATE:
(2.2) c->s2: SPICE_MSGC_MAIN_MIGRATE_DST_DO_SEAMLESS (*New*)
The msg includes the version of the migration protocol
of s1. The msg is used for querying s2 if seamless migration
is possible, given the migration protocol version of s1.
(2.2.1) s2->c: SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_ACK/NACK (*New*)
(2.2.2) c->s1: SPICE_MSGC_MAIN_MIGRATE_CONNECTED_SEAMLESS (*New*) or
SPICE_MSGC_MAIN_MIGRATE_CONNECTED
The latter is sent when c receives SEAMLESS_NACK, and
indicates s1 to apply semi-seamless protocol on post
migraion phase.
If s2 does not support SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE:
(2.3) c->s1: SPICE_MSGC_MAIN_MIGRATE_CONNECTED
(see 2.2.2)
post migration phase:
---------------------
While the pre migration phase was conducted by the main channel, this
phase's protocol occurs in all the migrated channels.
(1) s1->c: SPICE_MSG_MIGRATE
The msg marks the client that the connection is paused from s1 side, and
next to this msg, the only possible msg s1 can send is
SPICE_MSG_MIGRATE_DATA
msg optional flags:
(a) MIGRATE_FLUSH_MARK
This flag is required for finalizing the channel connection
without losing any in-flight data.
This flag indicates that s1 expects SPICE_MSGC_MIGRATE_FLUSH_MARK,
for signaling that c will pause the connection and not send any more messages
to s1.
(b) MIGRATE_DATA
The flag indicates that c should receive from s1
SPICE_MSG_MIGRATE_DATA
(2) c->s1: SPICE_MSGC_MIGRATE_FLUSH_MARK (if required)
c pushes the msg to the head of its output msg queue,
and sends it before all its other pending msgs - they will be sent to s2
later.
(3) s1->c: SPICE_MSG_MIGRATE_DATA (if required)
The msg contains all the data that the server requires for restoring
the channel's state on s2 side correctly.
(4) c disconnects the channel from s1 and switches to an active connection
with s2.
(4) c->s2: SPICE_MSGC_MIGRATE_DATA
136 lines
4.1 KiB
C
136 lines
4.1 KiB
C
/*
|
|
Copyright (C) 2009 Red Hat, Inc.
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
modification, are permitted provided that the following conditions are
|
|
met:
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
notice, this list of conditions and the following disclaimer.
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
notice, this list of conditions and the following disclaimer in
|
|
the documentation and/or other materials provided with the
|
|
distribution.
|
|
* Neither the name of the copyright holder nor the names of its
|
|
contributors may be used to endorse or promote products derived
|
|
from this software without specific prior written permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
|
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
|
|
#ifndef _H_SPICE_PROTOCOL
|
|
#define _H_SPICE_PROTOCOL
|
|
|
|
#include <spice/types.h>
|
|
#include <spice/enums.h>
|
|
#include <spice/start-packed.h>
|
|
|
|
#define SPICE_MAGIC (*(uint32_t*)"REDQ")
|
|
#define SPICE_VERSION_MAJOR 2
|
|
#define SPICE_VERSION_MINOR 2
|
|
|
|
// Encryption & Ticketing Parameters
|
|
#define SPICE_MAX_PASSWORD_LENGTH 60
|
|
#define SPICE_TICKET_KEY_PAIR_LENGTH 1024
|
|
#define SPICE_TICKET_PUBKEY_BYTES (SPICE_TICKET_KEY_PAIR_LENGTH / 8 + 34)
|
|
|
|
typedef struct SPICE_ATTR_PACKED SpiceLinkHeader {
|
|
uint32_t magic;
|
|
uint32_t major_version;
|
|
uint32_t minor_version;
|
|
uint32_t size;
|
|
} SpiceLinkHeader;
|
|
|
|
enum {
|
|
SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION,
|
|
SPICE_COMMON_CAP_AUTH_SPICE,
|
|
SPICE_COMMON_CAP_AUTH_SASL,
|
|
SPICE_COMMON_CAP_MINI_HEADER,
|
|
};
|
|
|
|
typedef struct SPICE_ATTR_PACKED SpiceLinkMess {
|
|
uint32_t connection_id;
|
|
uint8_t channel_type;
|
|
uint8_t channel_id;
|
|
uint32_t num_common_caps;
|
|
uint32_t num_channel_caps;
|
|
uint32_t caps_offset;
|
|
} SpiceLinkMess;
|
|
|
|
typedef struct SPICE_ATTR_PACKED SpiceLinkReply {
|
|
uint32_t error;
|
|
uint8_t pub_key[SPICE_TICKET_PUBKEY_BYTES];
|
|
uint32_t num_common_caps;
|
|
uint32_t num_channel_caps;
|
|
uint32_t caps_offset;
|
|
} SpiceLinkReply;
|
|
|
|
typedef struct SPICE_ATTR_PACKED SpiceLinkEncryptedTicket {
|
|
uint8_t encrypted_data[SPICE_TICKET_KEY_PAIR_LENGTH / 8];
|
|
} SpiceLinkEncryptedTicket;
|
|
|
|
typedef struct SPICE_ATTR_PACKED SpiceLinkAuthMechanism {
|
|
uint32_t auth_mechanism;
|
|
} SpiceLinkAuthMechanism;
|
|
|
|
typedef struct SPICE_ATTR_PACKED SpiceDataHeader {
|
|
uint64_t serial;
|
|
uint16_t type;
|
|
uint32_t size;
|
|
uint32_t sub_list; //offset to SpiceSubMessageList[]
|
|
} SpiceDataHeader;
|
|
|
|
typedef struct SPICE_ATTR_PACKED SpiceMiniDataHeader {
|
|
uint16_t type;
|
|
uint32_t size;
|
|
} SpiceMiniDataHeader;
|
|
|
|
typedef struct SPICE_ATTR_PACKED SpiceSubMessage {
|
|
uint16_t type;
|
|
uint32_t size;
|
|
} SpiceSubMessage;
|
|
|
|
typedef struct SPICE_ATTR_PACKED SpiceSubMessageList {
|
|
uint16_t size;
|
|
uint32_t sub_messages[0]; //offsets to SpicedSubMessage
|
|
} SpiceSubMessageList;
|
|
|
|
#define SPICE_INPUT_MOTION_ACK_BUNCH 4
|
|
|
|
enum {
|
|
SPICE_PLAYBACK_CAP_CELT_0_5_1,
|
|
SPICE_PLAYBACK_CAP_VOLUME,
|
|
};
|
|
|
|
enum {
|
|
SPICE_RECORD_CAP_CELT_0_5_1,
|
|
SPICE_RECORD_CAP_VOLUME,
|
|
};
|
|
|
|
enum {
|
|
SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE,
|
|
SPICE_MAIN_CAP_NAME_AND_UUID,
|
|
SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS,
|
|
SPICE_MAIN_CAP_SEAMLESS_MIGRATE,
|
|
};
|
|
|
|
enum {
|
|
SPICE_DISPLAY_CAP_SIZED_STREAM,
|
|
SPICE_DISPLAY_CAP_MONITORS_CONFIG,
|
|
SPICE_DISPLAY_CAP_COMPOSITE,
|
|
};
|
|
|
|
#include <spice/end-packed.h>
|
|
|
|
#endif /* _H_SPICE_PROTOCOL */
|