server/smartcard: register channel only when hardware is available

This commit is contained in:
Alon Levy 2011-06-29 14:13:16 +02:00
parent 392bb921dc
commit 8b5be0609f
2 changed files with 9 additions and 6 deletions

View File

@ -3522,10 +3522,6 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
reds->main_channel = NULL;
inputs_init();
#ifdef USE_SMARTCARD
smartcard_channel_init();
#endif
reds->mouse_mode = SPICE_MOUSE_MODE_SERVER;
atexit(reds_exit);
return 0;

View File

@ -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);
}