summaryrefslogtreecommitdiffstats
path: root/server/smartcard.c
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2011-06-29 14:13:16 +0200
committerAlon Levy <alevy@redhat.com>2011-07-05 14:04:36 +0200
commit8b5be0609f5226234aaefdb9197b2e189b1a0339 (patch)
tree0162dd5a107ac3cf7459e13b66d135cdf2b505ef /server/smartcard.c
parent392bb921dc985baf748dead1c29a93ae808aed4f (diff)
downloadspice-8b5be0609f5226234aaefdb9197b2e189b1a0339.tar.gz
spice-8b5be0609f5226234aaefdb9197b2e189b1a0339.tar.xz
spice-8b5be0609f5226234aaefdb9197b2e189b1a0339.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 f948e5b2..49bf3cb2 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -81,6 +81,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)
{
@@ -166,6 +167,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;
}
@@ -534,10 +536,16 @@ static void smartcard_migrate(Channel *channel)
{
}
-void smartcard_channel_init(void)
+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;
@@ -545,4 +553,3 @@ void smartcard_channel_init(void)
channel->migrate = smartcard_migrate;
reds_register_channel(channel);
}
-