[Spice-devel] [PATCH] channel: build adapter for public core interface

Christophe Fergeau cfergeau at redhat.com
Mon Jan 11 08:04:53 PST 2016


Acked-by: Christophe Fergeau <cfergeau at redhat.com>

On Mon, Jan 11, 2016 at 03:50:50PM +0000, Frediano Ziglio wrote:
> Add wrapper functions for SpiceCoreInterface in order to present
> a SpiceCoreInterfaceInternal. These functions just expect
> SpiceCoreInterfaceInternal API and forward request to
> SpiceCoreInterface.
> This allows to change ABI details of internal one.
> 
> See comments in "channel: add interface parameters to
> SpiceCoreInterfaceInternal" patch.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/red-common.h |  2 --
>  server/reds.c       | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++---
>  2 files changed, 58 insertions(+), 5 deletions(-)
> 
> diff --git a/server/red-common.h b/server/red-common.h
> index 40da0b1..3c54fb8 100644
> --- a/server/red-common.h
> +++ b/server/red-common.h
> @@ -42,8 +42,6 @@
>  typedef struct SpiceCoreInterfaceInternal SpiceCoreInterfaceInternal;
>  
>  struct SpiceCoreInterfaceInternal {
> -    SpiceBaseInterface base;
> -
>      SpiceTimer *(*timer_add)(SpiceTimerFunc func, void *opaque);
>      void (*timer_start)(SpiceTimer *timer, uint32_t ms);
>      void (*timer_cancel)(SpiceTimer *timer);
> diff --git a/server/reds.c b/server/reds.c
> index 54a398e..d9d0e0a 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -74,6 +74,61 @@
>  
>  SpiceCoreInterfaceInternal *core = NULL;
>  
> +static SpiceCoreInterface *core_public = NULL;
> +
> +static SpiceTimer *adapter_timer_add(SpiceTimerFunc func, void *opaque)
> +{
> +    return core_public->timer_add(func, opaque);
> +}
> +
> +static void adapter_timer_start(SpiceTimer *timer, uint32_t ms)
> +{
> +    core_public->timer_start(timer, ms);
> +}
> +
> +static void adapter_timer_cancel(SpiceTimer *timer)
> +{
> +    core_public->timer_cancel(timer);
> +}
> +
> +static void adapter_timer_remove(SpiceTimer *timer)
> +{
> +    core_public->timer_remove(timer);
> +}
> +
> +static SpiceWatch *adapter_watch_add(int fd, int event_mask, SpiceWatchFunc func, void *opaque)
> +{
> +    return core_public->watch_add(fd, event_mask, func, opaque);
> +}
> +
> +static void adapter_watch_update_mask(SpiceWatch *watch, int event_mask)
> +{
> +    core_public->watch_update_mask(watch, event_mask);
> +}
> +
> +static void adapter_watch_remove(SpiceWatch *watch)
> +{
> +    core_public->watch_remove(watch);
> +}
> +
> +static void adapter_channel_event(int event, SpiceChannelEventInfo *info)
> +{
> +    if (core_public->base.minor_version >= 3 && core_public->channel_event != NULL)
> +        core_public->channel_event(event, info);
> +}
> +
> +
> +static SpiceCoreInterfaceInternal core_interface_adapter = {
> +    .timer_add = adapter_timer_add,
> +    .timer_start = adapter_timer_start,
> +    .timer_cancel = adapter_timer_cancel,
> +    .timer_remove = adapter_timer_remove,
> +    .watch_add = adapter_watch_add,
> +    .watch_update_mask = adapter_watch_update_mask,
> +    .watch_remove = adapter_watch_remove,
> +    .channel_event = adapter_channel_event,
> +};
> +
>  static SpiceCharDeviceInstance *vdagent = NULL;
>  static SpiceMigrateInstance *migration_interface = NULL;
>  
> @@ -177,8 +232,7 @@ static ChannelSecurityOptions *find_channel_security(int id)
>  
>  void reds_handle_channel_event(int event, SpiceChannelEventInfo *info)
>  {
> -    if (core->base.minor_version >= 3 && core->channel_event != NULL)
> -        core->channel_event(event, info);
> +    core->channel_event(event, info);
>  
>      if (event == SPICE_CHANNEL_EVENT_DISCONNECTED) {
>          free(info);
> @@ -3275,7 +3329,8 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
>          spice_warning("bad core interface version");
>          goto err;
>      }
> -    core = (SpiceCoreInterfaceInternal *) core_interface;
> +    core_public = core_interface;
> +    core = &core_interface_adapter;
>      reds->listen_socket = -1;
>      reds->secure_listen_socket = -1;
>      init_vd_agent_resources();
> -- 
> 2.4.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20160111/0cd33b15/attachment.sig>


More information about the Spice-devel mailing list