summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2012-08-05 10:46:40 +0300
committerYonit Halperin <yhalperi@redhat.com>2012-08-27 09:13:04 +0300
commit733a804c992752a9e5a15b08ddadc370a21a6b24 (patch)
tree1faf522edbb8b8eb67dbc410ca290326461ce95a
parentef44c5eff9b25b990434db91a055ca9229f80593 (diff)
downloadspice-733a804c992752a9e5a15b08ddadc370a21a6b24.tar.gz
spice-733a804c992752a9e5a15b08ddadc370a21a6b24.tar.xz
spice-733a804c992752a9e5a15b08ddadc370a21a6b24.zip
spicevmc migration: restore migration dest state from migration data
-rw-r--r--server/spicevmc.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/server/spicevmc.c b/server/spicevmc.c
index b14ba639..1ce3169d 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -206,12 +206,39 @@ static void spicevmc_red_channel_client_on_disconnect(RedChannelClient *rcc)
}
}
+static SpiceVmcState *spicevmc_red_channel_client_get_state(RedChannelClient *rcc)
+{
+ return SPICE_CONTAINEROF(rcc->channel, SpiceVmcState, channel);
+}
+
static int spicevmc_channel_client_handle_migrate_flush_mark(RedChannelClient *rcc)
{
red_channel_client_pipe_add_type(rcc, PIPE_ITEM_TYPE_SPICEVMC_MIGRATE_DATA);
return TRUE;
}
+static int spicevmc_channel_client_handle_migrate_data(RedChannelClient *rcc,
+ uint32_t size, void *message)
+{
+ SpiceMigrateDataHeader *header;
+ SpiceMigrateDataSpiceVmc *mig_data;
+ SpiceVmcState *state;
+
+ state = spicevmc_red_channel_client_get_state(rcc);
+
+ header = (SpiceMigrateDataHeader *)message;
+ mig_data = (SpiceMigrateDataSpiceVmc *)(header + 1);
+ spice_assert(size >= sizeof(SpiceMigrateDataHeader) + sizeof(SpiceMigrateDataSpiceVmc));
+
+ if (!migration_protocol_validate_header(header,
+ SPICE_MIGRATE_DATA_SPICEVMC_MAGIC,
+ SPICE_MIGRATE_DATA_SPICEVMC_VERSION)) {
+ spice_error("bad header");
+ return FALSE;
+ }
+ return spice_char_device_state_restore(state->chardev_st, &mig_data->base);
+}
+
static int spicevmc_red_channel_client_handle_message(RedChannelClient *rcc,
uint16_t type,
uint32_t size,
@@ -219,8 +246,7 @@ static int spicevmc_red_channel_client_handle_message(RedChannelClient *rcc,
{
SpiceVmcState *state;
- state = SPICE_CONTAINEROF(rcc->channel, SpiceVmcState, channel);
-
+ state = spicevmc_red_channel_client_get_state(rcc);
if (type != SPICE_MSGC_SPICEVMC_DATA) {
return red_channel_client_handle_message(rcc, size, type, msg);
}
@@ -383,6 +409,7 @@ SpiceCharDeviceState *spicevmc_device_connect(SpiceCharDeviceInstance *sin,
channel_cbs.alloc_recv_buf = spicevmc_red_channel_alloc_msg_rcv_buf;
channel_cbs.release_recv_buf = spicevmc_red_channel_release_msg_rcv_buf;
channel_cbs.handle_migrate_flush_mark = spicevmc_channel_client_handle_migrate_flush_mark;
+ channel_cbs.handle_migrate_data = spicevmc_channel_client_handle_migrate_data;
state = (SpiceVmcState*)red_channel_create(sizeof(SpiceVmcState),
core, channel_type, id[channel_type]++,