diff options
author | Yonit Halperin <yhalperi@redhat.com> | 2012-08-14 15:42:36 +0300 |
---|---|---|
committer | Yonit Halperin <yhalperi@redhat.com> | 2012-08-27 09:13:08 +0300 |
commit | 9c6a49c364699ea20d3603572fa5b829612d8914 (patch) | |
tree | e45fe05e5f7d82f84fed916af12d94efe1b756bc /server/char_device.c | |
parent | a180fc5e0b1efdecc3101fbe04d9478e18a940ec (diff) | |
download | spice-9c6a49c364699ea20d3603572fa5b829612d8914.tar.gz spice-9c6a49c364699ea20d3603572fa5b829612d8914.tar.xz spice-9c6a49c364699ea20d3603572fa5b829612d8914.zip |
char_device: don't connect a migrated client if the state of the device might have changed since it was created
If reading/writing from the device have occured before migration data
has arrived, the migration data might no longer be relvant, and we
disconnect the client.
Diffstat (limited to 'server/char_device.c')
-rw-r--r-- | server/char_device.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/server/char_device.c b/server/char_device.c index b85a24d1..ac2632d6 100644 --- a/server/char_device.c +++ b/server/char_device.c @@ -681,20 +681,25 @@ void spice_char_device_state_destroy(SpiceCharDeviceState *char_dev) spice_char_device_state_unref(char_dev); } -void spice_char_device_client_add(SpiceCharDeviceState *dev, - RedClient *client, - int do_flow_control, - uint32_t max_send_queue_size, - uint32_t num_client_tokens, - uint32_t num_send_tokens, - int wait_for_migrate_data) +int spice_char_device_client_add(SpiceCharDeviceState *dev, + RedClient *client, + int do_flow_control, + uint32_t max_send_queue_size, + uint32_t num_client_tokens, + uint32_t num_send_tokens, + int wait_for_migrate_data) { SpiceCharDeviceClientState *dev_client; spice_assert(dev); spice_assert(client); - spice_assert(!wait_for_migrate_data || (dev->num_clients == 0 && !dev->active)); + if (wait_for_migrate_data && (dev->num_clients > 0 || dev->active)) { + spice_warning("can't restore device %p from migration data. The device " + "has already been active", dev); + return FALSE; + } + dev->wait_for_migrate_data = wait_for_migrate_data; spice_debug("dev_state %p client %p", dev, client); @@ -721,6 +726,7 @@ void spice_char_device_client_add(SpiceCharDeviceState *dev, dev->num_clients++; /* Now that we have a client, forward any pending device data */ spice_char_device_wakeup(dev); + return TRUE; } void spice_char_device_client_remove(SpiceCharDeviceState *dev, |