[Spice-devel] [spice-server 2/3] char-device: Make send_tokens_to_client() optional

Uri Lublin uril at redhat.com
Thu Feb 7 15:46:05 UTC 2019


On 2/7/19 3:02 PM, Christophe Fergeau wrote:
> Only RedCharDeviceVDIPortClass implements this vfunc, rather than
> forcing every classes deriving from RedCharDeviceClass to implement it,
> red_char_device_send_tokens_to_client() can deal with it.

Ack.

This is related to dev_client->do_flow_control and only vdagent messages
are flow-controlled.

Uri.

> ---
>   server/char-device.c       |  3 +++
>   server/red-stream-device.c |  7 -------
>   server/smartcard.c         |  8 --------
>   server/spicevmc.c          | 11 -----------
>   4 files changed, 3 insertions(+), 26 deletions(-)
> 
> diff --git a/server/char-device.c b/server/char-device.c
> index 64b41a941..c86c3a2f0 100644
> --- a/server/char-device.c
> +++ b/server/char-device.c
> @@ -124,6 +124,9 @@ red_char_device_send_tokens_to_client(RedCharDevice *dev,
>   {
>      RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
>   
> +   if (klass->send_tokens_to_client == NULL) {
> +       return;
> +   }
>      klass->send_tokens_to_client(dev, client, tokens);
>   }
>   
> diff --git a/server/red-stream-device.c b/server/red-stream-device.c
> index 70829fbff..b9e0827af 100644
> --- a/server/red-stream-device.c
> +++ b/server/red-stream-device.c
> @@ -573,12 +573,6 @@ stream_device_send_msg_to_client(RedCharDevice *self, RedPipeItem *msg, RedClien
>   {
>   }
>   
> -static void
> -stream_device_send_tokens_to_client(RedCharDevice *self, RedClient *client, uint32_t tokens)
> -{
> -    g_warning("%s: Not implemented!", G_STRFUNC);
> -}
> -
>   static void
>   stream_device_remove_client(RedCharDevice *self, RedClient *client)
>   {
> @@ -795,7 +789,6 @@ stream_device_class_init(StreamDeviceClass *klass)
>   
>       char_dev_class->read_one_msg_from_device = stream_device_read_msg_from_dev;
>       char_dev_class->send_msg_to_client = stream_device_send_msg_to_client;
> -    char_dev_class->send_tokens_to_client = stream_device_send_tokens_to_client;
>       char_dev_class->remove_client = stream_device_remove_client;
>       char_dev_class->port_event = stream_device_port_event;
>   }
> diff --git a/server/smartcard.c b/server/smartcard.c
> index 95dd90108..c08228271 100644
> --- a/server/smartcard.c
> +++ b/server/smartcard.c
> @@ -186,13 +186,6 @@ static void smartcard_send_msg_to_client(RedCharDevice *self,
>       red_channel_client_pipe_add_push(rcc, msg);
>   }
>   
> -static void smartcard_send_tokens_to_client(RedCharDevice *self,
> -                                            RedClient *client,
> -                                            uint32_t tokens)
> -{
> -    spice_error("not implemented");
> -}
> -
>   static void smartcard_remove_client(RedCharDevice *self, RedClient *client)
>   {
>       RedCharDeviceSmartcard *dev = RED_CHAR_DEVICE_SMARTCARD(self);
> @@ -613,7 +606,6 @@ red_char_device_smartcard_class_init(RedCharDeviceSmartcardClass *klass)
>   
>       char_dev_class->read_one_msg_from_device = smartcard_read_msg_from_device;
>       char_dev_class->send_msg_to_client = smartcard_send_msg_to_client;
> -    char_dev_class->send_tokens_to_client = smartcard_send_tokens_to_client;
>       char_dev_class->remove_client = smartcard_remove_client;
>   }
>   
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index c03bc4001..51550c1a0 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -420,16 +420,6 @@ static void spicevmc_port_send_event(RedChannelClient *rcc, uint8_t event)
>       red_channel_client_pipe_add_push(rcc, &item->base);
>   }
>   
> -static void spicevmc_char_dev_send_tokens_to_client(RedCharDevice *self,
> -                                                    RedClient *client,
> -                                                    uint32_t tokens)
> -{
> -    RedCharDeviceSpiceVmc *vmc = RED_CHAR_DEVICE_SPICEVMC(self);
> -    RedVmcChannel *channel = RED_VMC_CHANNEL(vmc->channel);
> -
> -    red_channel_warning(RED_CHANNEL(channel), "%s: Not implemented!", G_STRFUNC);
> -}
> -
>   static void spicevmc_char_dev_remove_client(RedCharDevice *self,
>                                               RedClient *client)
>   {
> @@ -905,7 +895,6 @@ red_char_device_spicevmc_class_init(RedCharDeviceSpiceVmcClass *klass)
>   
>       char_dev_class->read_one_msg_from_device = spicevmc_chardev_read_msg_from_dev;
>       char_dev_class->send_msg_to_client = spicevmc_chardev_send_msg_to_client;
> -    char_dev_class->send_tokens_to_client = spicevmc_char_dev_send_tokens_to_client;
>       char_dev_class->remove_client = spicevmc_char_dev_remove_client;
>       char_dev_class->port_event = spicevmc_port_event;
>   
> 



More information about the Spice-devel mailing list