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/smartcard.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/smartcard.c')
-rw-r--r-- | server/smartcard.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/server/smartcard.c b/server/smartcard.c index 0ec8a13e..7c3a0701 100644 --- a/server/smartcard.c +++ b/server/smartcard.c @@ -339,17 +339,25 @@ static void smartcard_char_device_attach_client(SpiceCharDeviceInstance *char_de SmartCardChannelClient *scc) { SmartCardDeviceState *st = spice_char_device_state_opaque_get(char_device->st); + int client_added; spice_assert(!scc->smartcard_state && !st->scc); st->scc = scc; - spice_char_device_client_add(st->chardev_st, - scc->base.client, - FALSE, /* no flow control yet */ - 0, /* send queue size */ - ~0, - ~0, - red_channel_client_waits_for_migrate_data(&scc->base)); scc->smartcard_state = st; + client_added = spice_char_device_client_add(st->chardev_st, + scc->base.client, + FALSE, /* no flow control yet */ + 0, /* send queue size */ + ~0, + ~0, + red_channel_client_waits_for_migrate_data( + &scc->base)); + if (!client_added) { + spice_warning("failed"); + st->scc = NULL; + scc->smartcard_state = NULL; + red_channel_client_disconnect(&scc->base); + } } static void smartcard_char_device_notify_reader_remove(SmartCardDeviceState *st) |