char-device: Allow to more safely and quickly get device instance

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@redhat.com>
This commit is contained in:
Frediano Ziglio 2019-02-09 10:29:41 +00:00
parent 8a8bd3e1c8
commit 8ec691f056
2 changed files with 7 additions and 0 deletions

View File

@ -1164,6 +1164,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)
{

View File

@ -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_ */