summaryrefslogtreecommitdiffstats
path: root/server/smartcard.c
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2011-07-20 13:40:12 +0300
committerAlon Levy <alevy@redhat.com>2011-07-21 15:09:28 +0300
commita3a62248209a8a5a7c623b2a870e983424396fb9 (patch)
tree409f0d0c521315643548d79368b84f3f6d5f7ba1 /server/smartcard.c
parentd830cf0553f1de1eb3a6eed1bf2e3dca880278d1 (diff)
downloadspice-a3a62248209a8a5a7c623b2a870e983424396fb9.tar.gz
spice-a3a62248209a8a5a7c623b2a870e983424396fb9.tar.xz
spice-a3a62248209a8a5a7c623b2a870e983424396fb9.zip
server/smartcard: register channel only when hardware is available
Diffstat (limited to 'server/smartcard.c')
-rw-r--r--server/smartcard.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/server/smartcard.c b/server/smartcard.c
index 272098e8..20a31f2e 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -77,6 +77,7 @@ static void smartcard_on_message_from_device(
SmartCardChannel *smartcard_channel, VSCMsgHeader *vheader);
static SmartCardDeviceState* smartcard_device_state_new();
static void smartcard_device_state_free(SmartCardDeviceState* st);
+static void smartcard_register_channel(void);
void smartcard_char_device_wakeup(SpiceCharDeviceInstance *sin)
{
@@ -162,6 +163,7 @@ static int smartcard_char_device_add_to_readers(SpiceCharDeviceInstance *char_de
}
state->reader_id = g_smartcard_readers.num;
g_smartcard_readers.sin[g_smartcard_readers.num++] = char_device;
+ smartcard_register_channel();
return 0;
}
@@ -520,10 +522,16 @@ static void smartcard_migrate(Channel *channel)
{
}
-void smartcard_channel_init()
+static void smartcard_register_channel(void)
{
Channel *channel;
+ static int registered = 0;
+ if (registered) {
+ return;
+ }
+ red_printf("registering smartcard channel");
+ registered = 1;
channel = spice_new0(Channel, 1);
channel->type = SPICE_CHANNEL_SMARTCARD;
channel->link = smartcard_link;
@@ -531,4 +539,3 @@ void smartcard_channel_init()
channel->migrate = smartcard_migrate;
reds_register_channel(channel);
}
-