[Spice-commits] server/smartcard.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Dec 3 17:07:59 UTC 2018


 server/smartcard.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

New commits:
commit 69a5cfc74131ec0459f2eb5a231139f5a69a8037
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Aug 7 17:26:18 2018 +0200

    smartcard: set char device state
    
    Follow all other char devices implementation (spicevmc, agent,
    stream-device) and set the char device state when
    connected/disconnected. This allows qemu to discard writes, optimize a
    bit the source polling, and will trigger HUP events.
    
    See related qemu "char/spice: discard write() if backend is
    disconnected".
    
    Note: sif->state() should probably be handled at the char-device
    level. I am not sure what the smartcard channel really brings over
    plain spicevmc...
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/smartcard.c b/server/smartcard.c
index 5a47814d..4c849450 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -345,6 +345,11 @@ void smartcard_char_device_attach_client(SpiceCharDeviceInstance *char_device,
         dev->priv->scc = NULL;
         smartcard_channel_client_set_char_device(scc, NULL);
         red_channel_client_disconnect(RED_CHANNEL_CLIENT(scc));
+    } else {
+        SpiceCharDeviceInterface *sif = spice_char_device_get_interface(char_device);
+        if (sif->state) {
+            sif->state(char_device, 1);
+        }
     }
 }
 
@@ -377,11 +382,21 @@ gboolean smartcard_char_device_notify_reader_remove(RedCharDeviceSmartcard *dev)
 void smartcard_char_device_detach_client(RedCharDeviceSmartcard *smartcard,
                                          SmartCardChannelClient *scc)
 {
+    SpiceCharDeviceInterface *sif;
+    SpiceCharDeviceInstance *sin;
+
+    g_object_get(smartcard, "sin", &sin, NULL);
+    sif = spice_char_device_get_interface(sin);
+
     spice_assert(smartcard->priv->scc == scc);
     red_char_device_client_remove(RED_CHAR_DEVICE(smartcard),
                                   red_channel_client_get_client(RED_CHANNEL_CLIENT(scc)));
     smartcard_channel_client_set_char_device(scc, NULL);
     smartcard->priv->scc = NULL;
+
+    if (sif->state) {
+        sif->state(sin, 0);
+    }
 }
 
 SmartCardChannelClient* smartcard_char_device_get_client(RedCharDeviceSmartcard *smartcard)


More information about the Spice-commits mailing list