[Spice-devel] [PATCH spice-server] char-device: Allow to more safely and quickly get device instance

Frediano Ziglio fziglio at redhat.com
Mon Sep 30 12:58:24 UTC 2019


ping

> 
> This information is retrieved multiple time.
> Avoid to use just g_object_get which is dynamic so potentially
> unsafe and slow.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/char-device.c | 5 +++++
>  server/char-device.h | 2 ++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/server/char-device.c b/server/char-device.c
> index 03ac9907c..36e22dee3 100644
> --- a/server/char-device.c
> +++ b/server/char-device.c
> @@ -1166,6 +1166,11 @@ SPICE_GNUC_VISIBLE void
> spice_server_port_event(SpiceCharDeviceInstance *sin, ui
>      return klass->port_event(sin->st, event);
>  }
>  
> +SpiceCharDeviceInstance *red_char_device_get_device_instance(RedCharDevice
> *dev)
> +{
> +    return dev->priv->sin;
> +}
> +
>  static void
>  red_char_device_init(RedCharDevice *self)
>  {
> diff --git a/server/char-device.h b/server/char-device.h
> index 0a87045b7..830ca456d 100644
> --- a/server/char-device.h
> +++ b/server/char-device.h
> @@ -243,6 +243,8 @@ RedCharDevice *spicevmc_device_connect(RedsState *reds,
>                                         uint8_t channel_type);
>  void spicevmc_device_disconnect(SpiceCharDeviceInstance *char_device);
>  
> +SpiceCharDeviceInstance *red_char_device_get_device_instance(RedCharDevice
> *dev);
> +
>  SpiceCharDeviceInterface
>  *spice_char_device_get_interface(SpiceCharDeviceInstance *instance);
>  
>  #endif /* CHAR_DEVICE_H_ */


More information about the Spice-devel mailing list