Re: [spice-server 5/8] Use QXLInstance instead of QXLState in red_qxl_*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2016-03-15 at 17:25 -0400, Frediano Ziglio wrote:
> > 
> > This seems to make more sense this way, QXLInstance is the 'main' object
> > with QXLState being its private data. External users then use QXLInstance
> > rather than passing a pointer to the private data to red-qxl.h methods.
> > ---
> >  server/dcc-send.c        |   4 +-
> >  server/display-channel.c |   2 +-
> >  server/red-qxl.c         | 123
> >  ++++++++++++++++++++++++-----------------------
> >  server/red-qxl.h         |  36 +++++++-------
> >  server/red-worker.c      |   4 +-
> >  server/reds-private.h    |   2 +-
> >  server/reds.c            |  87 +++++++++++++++++----------------
> >  7 files changed, 132 insertions(+), 126 deletions(-)
> > 
> > diff --git a/server/dcc-send.c b/server/dcc-send.c
> > index 16c5098..a1f9214 100644
> > --- a/server/dcc-send.c
> > +++ b/server/dcc-send.c
> > @@ -2307,12 +2307,12 @@ static void marshall_gl_scanout(RedChannelClient
> > *rcc,
> >      DisplayChannel *display_channel = DCC_TO_DC(dcc);
> >      QXLInstance* qxl = display_channel->common.qxl;
> >  
> > -    SpiceMsgDisplayGlScanoutUnix *so = red_qxl_get_gl_scanout(qxl->st);
> > +    SpiceMsgDisplayGlScanoutUnix *so = red_qxl_get_gl_scanout(qxl);
> >      if (so != NULL) {
> >          red_channel_client_init_send_data(rcc,
> >          SPICE_MSG_DISPLAY_GL_SCANOUT_UNIX, NULL);
> >          spice_marshall_msg_display_gl_scanout_unix(m, so);
> >      }
> > -    red_qxl_put_gl_scanout(qxl->st, so);
> > +    red_qxl_put_gl_scanout(qxl, so);
> >  }
> >  
> >  static void marshall_gl_draw(RedChannelClient *rcc,
> > diff --git a/server/display-channel.c b/server/display-channel.c
> > index ff9aeac..f5f3527 100644
> > --- a/server/display-channel.c
> > +++ b/server/display-channel.c
> > @@ -2163,7 +2163,7 @@ static void set_gl_draw_async_count(DisplayChannel
> > *display, int num)
> >      display->gl_draw_async_count = num;
> >  
> >      if (num == 0) {
> > -        red_qxl_gl_draw_async_complete(qxl->st);
> > +        red_qxl_gl_draw_async_complete(qxl);
> >      }
> >  }
> >  
> > diff --git a/server/red-qxl.c b/server/red-qxl.c
> > index 408159d..1550ec8 100644
> > --- a/server/red-qxl.c
> > +++ b/server/red-qxl.c
> > @@ -63,10 +63,10 @@ struct QXLState {
> >      struct AsyncCommand *gl_draw_async;
> >  };
> >  
> > -static int red_qxl_check_qxl_version(QXLState *rq, int major, int minor)
> > +int red_qxl_check_qxl_version(QXLInstance *qxl, int major, int minor)
> >  {
> 
> This change should go in 8/8.
> 
> > -    int qxl_major = qxl_get_interface(rq->qxl)->base.major_version;
> > -    int qxl_minor = qxl_get_interface(rq->qxl)->base.minor_version;
> > +    int qxl_major = qxl_get_interface(qxl)->base.major_version;
> > +    int qxl_minor = qxl_get_interface(qxl)->base.minor_version;
> >  
> >      return ((qxl_major > major) ||
> >              ((qxl_major == major) && (qxl_minor >= minor)));
> > @@ -207,19 +207,18 @@ static void red_qxl_update_area(QXLState *qxl_state,
> > uint32_t surface_id,
> >                              &payload);
> >  }
> >  
> > -gboolean red_qxl_use_client_monitors_config(QXLState *qxl_state)
> > +gboolean red_qxl_use_client_monitors_config(QXLInstance *qxl)
> >  {
> > -    return (red_qxl_check_qxl_version(qxl_state, 3, 3) &&
> > -        qxl_get_interface(qxl_state->qxl)->client_monitors_config &&
> > -
> > qxl_get_interface(qxl_state->qxl)->client_monitors_config(qxl_state->qxl,
> > NULL));
> > +    return (red_qxl_check_qxl_version(qxl, 3, 3) &&
> > +        qxl_get_interface(qxl)->client_monitors_config &&
> > +        qxl_get_interface(qxl)->client_monitors_config(qxl, NULL));
> >  }
> >  
> > -gboolean red_qxl_client_monitors_config(QXLState *qxl_state,
> > +gboolean red_qxl_client_monitors_config(QXLInstance *qxl,
> >                                          VDAgentMonitorsConfig
> >                                          *monitors_config)
> >  {
> > -    return (qxl_get_interface(qxl_state->qxl)->client_monitors_config &&
> > -
> > qxl_get_interface(qxl_state->qxl)->client_monitors_config(qxl_state->qxl,
> > -
> > monitors_config));
> > +    return (qxl_get_interface(qxl)->client_monitors_config &&
> > +        qxl_get_interface(qxl)->client_monitors_config(qxl,
> > monitors_config));
> >  }
> >  
> >  static AsyncCommand *async_command_alloc(QXLState *qxl_state,
> > @@ -559,18 +558,19 @@ static void qxl_worker_oom(QXLWorker *qxl_worker)
> >      red_qxl_oom((QXLState*)qxl_worker);
> >  }
> >  
> > -void red_qxl_start(QXLState *qxl_state)
> > +void red_qxl_start(QXLInstance *qxl)
> >  {
> >      RedWorkerMessageStart payload;
> >  
> > -    dispatcher_send_message(&qxl_state->dispatcher,
> > +    dispatcher_send_message(&qxl->st->dispatcher,
> >                              RED_WORKER_MESSAGE_START,
> >                              &payload);
> >  }
> >  
> >  static void qxl_worker_start(QXLWorker *qxl_worker)
> >  {
> > -    red_qxl_start((QXLState*)qxl_worker);
> > +    QXLState *state = (QXLState *)qxl_worker;
> > +    red_qxl_start(state->qxl);
> >  }
> >  
> >  static void red_qxl_flush_surfaces_async(QXLState *qxl_state, uint64_t
> >  cookie)
> > @@ -607,18 +607,19 @@ static void red_qxl_driver_unload(QXLState *qxl_state)
> >                              &payload);
> >  }
> >  
> > -void red_qxl_stop(QXLState *qxl_state)
> > +void red_qxl_stop(QXLInstance *qxl)
> >  {
> >      RedWorkerMessageStop payload;
> >  
> > -    dispatcher_send_message(&qxl_state->dispatcher,
> > +    dispatcher_send_message(&qxl->st->dispatcher,
> >                              RED_WORKER_MESSAGE_STOP,
> >                              &payload);
> >  }
> >  
> >  static void qxl_worker_stop(QXLWorker *qxl_worker)
> >  {
> > -    red_qxl_stop((QXLState*)qxl_worker);
> > +    QXLState *state = (QXLState *)qxl_worker;
> > +    red_qxl_stop(state->qxl);
> >  }
> >  
> >  static void red_qxl_loadvm_commands(QXLState *qxl_state,
> > @@ -642,26 +643,28 @@ static void qxl_worker_loadvm_commands(QXLWorker
> > *qxl_worker,
> >      red_qxl_loadvm_commands((QXLState*)qxl_worker, ext, count);
> >  }
> >  
> > -void red_qxl_set_mm_time(QXLState *qxl_state, uint32_t mm_time)
> > +void red_qxl_set_mm_time(QXLInstance *qxl, uint32_t mm_time)
> >  {
> > -    qxl_get_interface(qxl_state->qxl)->set_mm_time(qxl_state->qxl,
> > mm_time);
> > +    QXLInterface *interface = qxl_get_interface(qxl);
> > +    interface->set_mm_time(qxl, mm_time);
> >  }
> >  
> > -void red_qxl_attach_worker(QXLState *qxl_state)
> > +void red_qxl_attach_worker(QXLInstance *qxl)
> >  {
> > -    QXLInstance *qxl = qxl_state->qxl;
> > -    qxl_get_interface(qxl_state->qxl)->attache_worker(qxl,
> > &qxl_state->base);
> > +    QXLInterface *interface = qxl_get_interface(qxl);
> > +    interface->attache_worker(qxl, &qxl->st->base);
> >  }
> >  
> > -void red_qxl_set_compression_level(QXLState *qxl_state, int level)
> > +void red_qxl_set_compression_level(QXLInstance *qxl, int level)
> >  {
> > -    qxl_get_interface(qxl_state->qxl)->set_compression_level(qxl_state
> > ->qxl,
> > level);
> > +    QXLInterface *interface = qxl_get_interface(qxl);
> > +    interface->set_compression_level(qxl, level);
> >  }
> >  
> > -uint32_t red_qxl_get_ram_size(QXLState *qxl_state)
> > +uint32_t red_qxl_get_ram_size(QXLInstance *qxl)
> >  {
> >      QXLDevInitInfo qxl_info;
> > -    qxl_get_interface(qxl_state->qxl)->get_init_info(qxl_state->qxl,
> > &qxl_info);
> > +    qxl_get_interface(qxl)->get_init_info(qxl, &qxl_info);
> >      return qxl_info.qxl_ram_size;
> >  }
> >  
> > @@ -680,13 +683,13 @@ void spice_qxl_oom(QXLInstance *instance)
> >  SPICE_GNUC_VISIBLE
> >  void spice_qxl_start(QXLInstance *instance)
> >  {
> > -    red_qxl_start(instance->st);
> > +    red_qxl_start(instance);
> >  }
> >  
> >  SPICE_GNUC_VISIBLE
> >  void spice_qxl_stop(QXLInstance *instance)
> >  {
> > -    red_qxl_stop(instance->st);
> > +    red_qxl_stop(instance);
> >  }
> >  
> >  SPICE_GNUC_VISIBLE
> > @@ -823,20 +826,20 @@ void spice_qxl_driver_unload(QXLInstance *instance)
> >      red_qxl_driver_unload(instance->st);
> >  }
> >  
> > -SpiceMsgDisplayGlScanoutUnix *red_qxl_get_gl_scanout(QXLState *qxl_state)
> > +SpiceMsgDisplayGlScanoutUnix *red_qxl_get_gl_scanout(QXLInstance *qxl)
> >  {
> > -    pthread_mutex_lock(&qxl_state->scanout_mutex);
> > -    if (qxl_state->scanout.drm_dma_buf_fd >= 0) {
> > -        return &qxl_state->scanout;
> > +    pthread_mutex_lock(&qxl->st->scanout_mutex);
> > +    if (qxl->st->scanout.drm_dma_buf_fd >= 0) {
> > +        return &qxl->st->scanout;
> >      }
> > -    pthread_mutex_unlock(&qxl_state->scanout_mutex);
> > +    pthread_mutex_unlock(&qxl->st->scanout_mutex);
> >      return NULL;
> >  }
> >  
> > -void red_qxl_put_gl_scanout(QXLState *qxl_state,
> > SpiceMsgDisplayGlScanoutUnix *scanout)
> > +void red_qxl_put_gl_scanout(QXLInstance *qxl, SpiceMsgDisplayGlScanoutUnix
> > *scanout)
> >  {
> >      if (scanout) {
> > -        pthread_mutex_unlock(&qxl_state->scanout_mutex);
> > +        pthread_mutex_unlock(&qxl->st->scanout_mutex);
> >      }
> >  }
> >  
> > @@ -898,9 +901,10 @@ void spice_qxl_gl_draw_async(QXLInstance *qxl,
> >      dispatcher_send_message(&qxl_state->dispatcher, message, &draw);
> >  }
> >  
> > -void red_qxl_async_complete(QXLState *qxl_state,
> > -                            AsyncCommand *async_command)
> > +void red_qxl_async_complete(QXLInstance *qxl, AsyncCommand *async_command)
> >  {
> > +    QXLInterface *interface = qxl_get_interface(qxl);
> > +
> >      spice_debug("%p: cookie %" PRId64, async_command,
> >      async_command->cookie);
> >      switch (async_command->message) {
> >      case RED_WORKER_MESSAGE_UPDATE_ASYNC:
> > @@ -912,25 +916,24 @@ void red_qxl_async_complete(QXLState *qxl_state,
> >      case RED_WORKER_MESSAGE_GL_DRAW_ASYNC:
> >          break;
> >      case RED_WORKER_MESSAGE_CREATE_PRIMARY_SURFACE_ASYNC:
> > -        red_qxl_create_primary_surface_complete(qxl_state);
> > +        red_qxl_create_primary_surface_complete(qxl->st);
> >          break;
> >      case RED_WORKER_MESSAGE_DESTROY_PRIMARY_SURFACE_ASYNC:
> > -        red_qxl_destroy_primary_surface_complete(qxl_state);
> > +        red_qxl_destroy_primary_surface_complete(qxl->st);
> >          break;
> >      default:
> >          spice_warning("unexpected message %d", async_command->message);
> >      }
> > -    qxl_get_interface(qxl_state->qxl)->async_complete(qxl_state->qxl,
> > -
> > async_command->cookie);
> > +    interface->async_complete(qxl, async_command->cookie);
> >      free(async_command);
> >  }
> >  
> > -void red_qxl_gl_draw_async_complete(QXLState *qxl_state)
> > +void red_qxl_gl_draw_async_complete(QXLInstance *qxl)
> >  {
> >      /* this reset before usage prevent a possible race condition */
> > -    struct AsyncCommand *async = qxl_state->gl_draw_async;
> > -    qxl_state->gl_draw_async = NULL;
> > -    red_qxl_async_complete(qxl_state, async);
> > +    struct AsyncCommand *async = qxl->st->gl_draw_async;
> > +    qxl->st->gl_draw_async = NULL;
> > +    red_qxl_async_complete(qxl, async);
> >  }
> >  
> >  void red_qxl_init(RedsState *reds, QXLInstance *qxl)
> > @@ -1000,9 +1003,9 @@ void red_qxl_init(RedsState *reds, QXLInstance *qxl)
> >      red_worker_run(worker);
> >  }
> >  
> > -struct Dispatcher *red_qxl_get_dispatcher(QXLState *qxl_state)
> > +struct Dispatcher *red_qxl_get_dispatcher(QXLInstance *qxl)
> >  {
> > -    return &qxl_state->dispatcher;
> > +    return &qxl->st->dispatcher;
> >  }
> >  
> >  void red_qxl_clear_pending(QXLState *qxl_state, int pending)
> > @@ -1012,45 +1015,45 @@ void red_qxl_clear_pending(QXLState *qxl_state, int
> > pending)
> >      clear_bit(pending, &qxl_state->pending);
> >  }
> >  
> > -gboolean red_qxl_get_primary_active(QXLState *qxl_state)
> > +gboolean red_qxl_get_primary_active(QXLInstance *qxl)
> >  {
> > -    return qxl_state->primary_active;
> > +    return qxl->st->primary_active;
> >  }
> >  
> > -gboolean red_qxl_get_allow_client_mouse(QXLState *qxl_state, gint *x_res,
> > gint *y_res)
> > +gboolean red_qxl_get_allow_client_mouse(QXLInstance *qxl, gint *x_res, gint
> > *y_res)
> >  {
> > -    if (qxl_state->use_hardware_cursor) {
> > +    if (qxl->st->use_hardware_cursor) {
> >          if (x_res)
> > -            *x_res = qxl_state->x_res;
> > +            *x_res = qxl->st->x_res;
> >          if (y_res)
> > -            *y_res = qxl_state->y_res;
> > +            *y_res = qxl->st->y_res;
> >      }
> > -    return qxl_state->use_hardware_cursor;
> > +    return qxl->st->use_hardware_cursor;
> >  }
> >  
> > -void red_qxl_on_ic_change(QXLState *qxl_state, SpiceImageCompression ic)
> > +void red_qxl_on_ic_change(QXLInstance *qxl, SpiceImageCompression ic)
> >  {
> >      RedWorkerMessageSetCompression payload;
> >      payload.image_compression = ic;
> > -    dispatcher_send_message(&qxl_state->dispatcher,
> > +    dispatcher_send_message(&qxl->st->dispatcher,
> >                              RED_WORKER_MESSAGE_SET_COMPRESSION,
> >                              &payload);
> >  }
> >  
> > -void red_qxl_on_sv_change(QXLState *qxl_state, int sv)
> > +void red_qxl_on_sv_change(QXLInstance *qxl, int sv)
> >  {
> >      RedWorkerMessageSetStreamingVideo payload;
> >      payload.streaming_video = sv;
> > -    dispatcher_send_message(&qxl_state->dispatcher,
> > +    dispatcher_send_message(&qxl->st->dispatcher,
> >                              RED_WORKER_MESSAGE_SET_STREAMING_VIDEO,
> >                              &payload);
> >  }
> >  
> > -void red_qxl_set_mouse_mode(QXLState *qxl_state, uint32_t mode)
> > +void red_qxl_set_mouse_mode(QXLInstance *qxl, uint32_t mode)
> >  {
> >      RedWorkerMessageSetMouseMode payload;
> >      payload.mode = mode;
> > -    dispatcher_send_message(&qxl_state->dispatcher,
> > +    dispatcher_send_message(&qxl->st->dispatcher,
> >                              RED_WORKER_MESSAGE_SET_MOUSE_MODE,
> >                              &payload);
> >  }
> > diff --git a/server/red-qxl.h b/server/red-qxl.h
> > index f100cb4..7e158c2 100644
> > --- a/server/red-qxl.h
> > +++ b/server/red-qxl.h
> > @@ -26,24 +26,24 @@ typedef struct AsyncCommand AsyncCommand;
> >  
> >  void red_qxl_init(SpiceServer *reds, QXLInstance *qxl);
> >  
> > -void red_qxl_set_mm_time(QXLState *qxl_state, uint32_t);
> > -void red_qxl_on_ic_change(QXLState *qxl_state, SpiceImageCompression ic);
> > -void red_qxl_on_sv_change(QXLState *qxl_state, int sv);
> > -void red_qxl_set_mouse_mode(QXLState *qxl_state, uint32_t mode);
> > -void red_qxl_attach_worker(QXLState *qxl_state);
> > -void red_qxl_set_compression_level(QXLState *qxl_state, int level);
> > -void red_qxl_stop(QXLState *qxl_state);
> > -void red_qxl_start(QXLState *qxl_state);
> > -uint32_t red_qxl_get_ram_size(QXLState *qxl_state);
> > -void red_qxl_async_complete(QXLState *qxl_state, AsyncCommand *cmd);
> > -struct Dispatcher *red_qxl_get_dispatcher(QXLState *qxl_state);
> > -gboolean red_qxl_use_client_monitors_config(QXLState *qxl_state);
> > -gboolean red_qxl_client_monitors_config(QXLState *qxl_state,
> > VDAgentMonitorsConfig *monitors_config);
> > -gboolean red_qxl_get_primary_active(QXLState *qxl_state);
> > -gboolean red_qxl_get_allow_client_mouse(QXLState *qxl_state, gint *x_res,
> > gint *y_res);
> > -SpiceMsgDisplayGlScanoutUnix *red_qxl_get_gl_scanout(QXLState *qxl_state);
> > -void red_qxl_put_gl_scanout(QXLState *qxl_state,
> > SpiceMsgDisplayGlScanoutUnix *scanout);
> > -void red_qxl_gl_draw_async_complete(QXLState *qxl);
> > +void red_qxl_set_mm_time(QXLInstance *qxl, uint32_t);
> > +void red_qxl_on_ic_change(QXLInstance *qxl, SpiceImageCompression ic);
> > +void red_qxl_on_sv_change(QXLInstance *qxl, int sv);
> > +void red_qxl_set_mouse_mode(QXLInstance *qxl, uint32_t mode);
> > +void red_qxl_attach_worker(QXLInstance *qxl);
> > +void red_qxl_set_compression_level(QXLInstance *qxl, int level);
> > +void red_qxl_stop(QXLInstance *qxl);
> > +void red_qxl_start(QXLInstance *qxl);
> > +uint32_t red_qxl_get_ram_size(QXLInstance *qxl);
> > +void red_qxl_async_complete(QXLInstance *qxl, AsyncCommand *async_command);
> > +struct Dispatcher *red_qxl_get_dispatcher(QXLInstance *qxl);
> > +gboolean red_qxl_use_client_monitors_config(QXLInstance *qxl);
> > +gboolean red_qxl_client_monitors_config(QXLInstance *qxl,
> > VDAgentMonitorsConfig *monitors_config);
> > +gboolean red_qxl_get_primary_active(QXLInstance *qxl);
> > +gboolean red_qxl_get_allow_client_mouse(QXLInstance *qxl, gint *x_res, gint
> > *y_res);
> > +SpiceMsgDisplayGlScanoutUnix *red_qxl_get_gl_scanout(QXLInstance *qxl);
> > +void red_qxl_put_gl_scanout(QXLInstance *qxl, SpiceMsgDisplayGlScanoutUnix
> > *scanout);
> > +void red_qxl_gl_draw_async_complete(QXLInstance *qxl);
> >  SpiceServer* red_qxl_get_server(QXLState *qxl);
> >  
> >  typedef uint32_t RedWorkerMessage;
> > diff --git a/server/red-worker.c b/server/red-worker.c
> > index 0b61ec4..2eb4fee 100644
> > --- a/server/red-worker.c
> > +++ b/server/red-worker.c
> > @@ -1197,7 +1197,7 @@ static void worker_handle_dispatcher_async_done(void
> > *opaque,
> >      RedWorkerMessageAsync *msg_async = payload;
> >  
> >      spice_debug(NULL);
> > -    red_qxl_async_complete(worker->qxl->st, msg_async->cmd);
> > +    red_qxl_async_complete(worker->qxl, msg_async->cmd);
> >  }
> >  
> >  static void worker_dispatcher_record(void *opaque, uint32_t message_type,
> >  void *payload)
> > @@ -1491,7 +1491,7 @@ RedWorker* red_worker_new(QXLInstance *qxl)
> >              spice_error("failed to write replay header");
> >          }
> >      }
> > -    dispatcher = red_qxl_get_dispatcher(qxl->st);
> > +    dispatcher = red_qxl_get_dispatcher(qxl);
> >      dispatcher_set_opaque(dispatcher, worker);
> >  
> >      worker->qxl = qxl;
> > diff --git a/server/reds-private.h b/server/reds-private.h
> > index 032f9f0..3001990 100644
> > --- a/server/reds-private.h
> > +++ b/server/reds-private.h
> > @@ -231,7 +231,7 @@ struct RedsState {
> >  
> >      RedSSLParameters ssl_parameters;
> >      SpiceCoreInterfaceInternal *core;
> > -    GList *qxl_states;
> > +    GList *qxl_instances;
> >      MainDispatcher *main_dispatcher;
> >  };
> >  
> > diff --git a/server/reds.c b/server/reds.c
> > index 5d0a66e..0ac4ec0 100644
> > --- a/server/reds.c
> > +++ b/server/reds.c
> > @@ -570,8 +570,10 @@ static void reds_set_mouse_mode(RedsState *reds,
> > uint32_t mode)
> >      }
> >      reds->mouse_mode = mode;
> >  
> > -    for (l = reds->qxl_states; l != NULL; l = l->next)
> > -        red_qxl_set_mouse_mode((QXLState*) l->data, mode);
> > +    for (l = reds->qxl_instances; l != NULL; l = l->next) {
> > +        QXLInstance *qxl = (QXLInstance *)l->data;
> > +        red_qxl_set_mouse_mode(qxl, mode);
> > +    }
> >  
> >      main_channel_push_mouse_mode(reds->main_channel, reds->mouse_mode,
> >      reds->is_client_mouse_allowed);
> >  }
> > @@ -584,7 +586,7 @@ gboolean reds_get_agent_mouse(const RedsState *reds)
> >  static void reds_update_mouse_mode(RedsState *reds)
> >  {
> >      int allowed = 0;
> > -    int qxl_count = g_list_length(reds->qxl_states);
> > +    int qxl_count = g_list_length(reds->qxl_instances);
> >  
> >      if ((reds->agent_mouse && reds->vdagent) ||
> >          (inputs_channel_has_tablet(reds->inputs_channel) && qxl_count ==
> > 1))
> >          {
> > @@ -1681,7 +1683,7 @@ static void reds_handle_main_link(RedsState *reds,
> > RedLinkInfo *link)
> >      }
> >  
> >      if (!mig_target) {
> > -        main_channel_push_init(mcc, g_list_length(reds->qxl_states),
> > +        main_channel_push_init(mcc, g_list_length(reds->qxl_instances),
> >              reds->mouse_mode, reds->is_client_mouse_allowed,
> >              reds_get_mm_time() - MM_TIME_DELTA,
> >              reds_qxl_ram_size(reds));
> > @@ -1836,7 +1838,7 @@ void
> > reds_on_client_semi_seamless_migrate_complete(RedsState *reds, RedClient *c
> >      mcc = red_client_get_main(client);
> >  
> >      // TODO: not doing net test. consider doing it on client_migrate_info
> > -    main_channel_push_init(mcc, g_list_length(reds->qxl_states),
> > +    main_channel_push_init(mcc, g_list_length(reds->qxl_instances),
> >                             reds->mouse_mode, reds->is_client_mouse_allowed,
> >                             reds_get_mm_time() - MM_TIME_DELTA,
> >                             reds_qxl_ram_size(reds));
> > @@ -3184,7 +3186,6 @@ SPICE_GNUC_VISIBLE int
> > spice_server_add_interface(SpiceServer *s,
> >          }
> >      } else if (strcmp(interface->type, SPICE_INTERFACE_QXL) == 0) {
> >          QXLInstance *qxl;
> > -        QXLState *qxl_state;
> >  
> >          spice_info("SPICE_INTERFACE_QXL");
> >          if (interface->major_version != SPICE_INTERFACE_QXL_MAJOR ||
> > @@ -3195,16 +3196,15 @@ SPICE_GNUC_VISIBLE int
> > spice_server_add_interface(SpiceServer *s,
> >  
> >          qxl = SPICE_CONTAINEROF(sin, QXLInstance, base);
> >          red_qxl_init(reds, qxl);
> > -        qxl_state = qxl->st;
> > -        reds->qxl_states = g_list_prepend(reds->qxl_states, qxl_state);
> > +        reds->qxl_instances = g_list_prepend(reds->qxl_instances, qxl);
> >  
> >          /* this function has to be called after the qxl is on the list
> >           * as QXLInstance clients expect the qxl to be on the list when
> >           * this callback is called. This as clients assume they can start
> >           the
> > -         * qxl_states. Also note that this should be the first callback to
> > +         * qxl_instances. Also note that this should be the first callback
> > to
> >           * be called. */
> > -        red_qxl_attach_worker(qxl_state);
> > -        red_qxl_set_compression_level(qxl_state,
> > calc_compression_level(reds));
> > +        red_qxl_attach_worker(qxl);
> > +        red_qxl_set_compression_level(qxl, calc_compression_level(reds));
> >      } else if (strcmp(interface->type, SPICE_INTERFACE_TABLET) == 0) {
> >          SpiceTabletInstance *tablet = SPICE_CONTAINEROF(sin,
> >          SpiceTabletInstance, base);
> >          spice_info("SPICE_INTERFACE_TABLET");
> > @@ -4118,15 +4118,14 @@ void reds_update_client_mouse_allowed(RedsState
> > *reds)
> >      int x_res = 0;
> >      int y_res = 0;
> >      GList *l;
> > -    int num_active_workers = g_list_length(reds->qxl_states);
> > +    int num_active_workers = g_list_length(reds->qxl_instances);
> >  
> >      if (num_active_workers > 0) {
> >          allow_now = TRUE;
> > -        for (l = reds->qxl_states; l != NULL && allow_now; l = l->next) {
> > -
> > -            QXLState *now = l->data;
> > -            if (red_qxl_get_primary_active(now)) {
> > -                allow_now = red_qxl_get_allow_client_mouse(now, &x_res,
> > &y_res);
> > +        for (l = reds->qxl_instances; l != NULL && allow_now; l = l->next)
> > {
> > +            QXLInstance *qxl = l->data;
> > +            if (red_qxl_get_primary_active(qxl)) {
> > +                allow_now = red_qxl_get_allow_client_mouse(qxl, &x_res,
> > &y_res);
> >                  break;
> >              }
> >          }
> > @@ -4142,14 +4141,14 @@ gboolean reds_use_client_monitors_config(RedsState
> > *reds)
> >  {
> >      GList *l;
> >  
> > -    if (reds->qxl_states == NULL) {
> > +    if (reds->qxl_instances == NULL) {
> >          return FALSE;
> >      }
> >  
> > -    for (l = reds->qxl_states; l != NULL ; l = l->next) {
> > -        QXLState *now = l->data;
> > +    for (l = reds->qxl_instances; l != NULL ; l = l->next) {
> > +        QXLInstance *qxl = l->data;
> >  
> > -        if (!red_qxl_use_client_monitors_config(now))
> > +        if (!red_qxl_use_client_monitors_config(qxl))
> >              return FALSE;
> >      }
> >      return TRUE;
> > @@ -4159,9 +4158,9 @@ void reds_client_monitors_config(RedsState *reds,
> > VDAgentMonitorsConfig *monitor
> >  {
> >      GList *l;
> >  
> > -    for (l = reds->qxl_states; l != NULL; l = l->next) {
> > -        QXLState *now = l->data;
> > -        if (!red_qxl_client_monitors_config(now, monitors_config)) {
> > +    for (l = reds->qxl_instances; l != NULL; l = l->next) {
> > +        QXLInstance *qxl = l->data;
> > +        if (!red_qxl_client_monitors_config(qxl, monitors_config)) {
> >              /* this is a normal condition, some qemu devices might not
> >              implement it */
> >              spice_debug("QXLInterface::client_monitors_config failed\n");
> >          }
> > @@ -4172,9 +4171,9 @@ void reds_set_mm_time(RedsState *reds, uint32_t
> > mm_time)
> >  {
> >      GList *l;
> >  
> > -    for (l = reds->qxl_states; l != NULL; l = l->next) {
> > -        QXLState *now = l->data;
> > -        red_qxl_set_mm_time(now, mm_time);
> > +    for (l = reds->qxl_instances; l != NULL; l = l->next) {
> > +        QXLInstance *qxl = l->data;
> > +        red_qxl_set_mm_time(qxl, mm_time);
> >      }
> >  }
> >  
> > @@ -4195,10 +4194,10 @@ void reds_on_ic_change(RedsState *reds)
> >      int compression_level = calc_compression_level(reds);
> >      GList *l;
> >  
> > -    for (l = reds->qxl_states; l != NULL; l = l->next) {
> > -        QXLState *q = l->data;
> > -        red_qxl_set_compression_level(q, compression_level);
> > -        red_qxl_on_ic_change(q, spice_server_get_image_compression(reds));
> > +    for (l = reds->qxl_instances; l != NULL; l = l->next) {
> > +        QXLInstance *qxl = l->data;
> > +        red_qxl_set_compression_level(qxl, compression_level);
> > +        red_qxl_on_ic_change(qxl,
> > spice_server_get_image_compression(reds));
> >      }
> >  }
> >  
> > @@ -4207,10 +4206,10 @@ void reds_on_sv_change(RedsState *reds)
> >      int compression_level = calc_compression_level(reds);
> >      GList *l;
> >  
> > -    for (l = reds->qxl_states; l != NULL; l = l->next) {
> > -        QXLState *q = l->data;
> > -        red_qxl_set_compression_level(q, compression_level);
> > -        red_qxl_on_sv_change(q, reds_get_streaming_video(reds));
> > +    for (l = reds->qxl_instances; l != NULL; l = l->next) {
> > +        QXLInstance *qxl = l->data;
> > +        red_qxl_set_compression_level(qxl, compression_level);
> > +        red_qxl_on_sv_change(qxl, reds_get_streaming_video(reds));
> >      }
> >  }
> >  
> > @@ -4218,26 +4217,30 @@ void reds_on_vm_stop(RedsState *reds)
> >  {
> >      GList *l;
> >  
> > -    for (l = reds->qxl_states; l != NULL; l = l->next)
> > -        red_qxl_stop((QXLState*) l->data);
> > +    for (l = reds->qxl_instances; l != NULL; l = l->next) {
> > +        QXLInstance *qxl = l->data;
> > +        red_qxl_stop(qxl);
> > +    }
> >  }
> >  
> >  void reds_on_vm_start(RedsState *reds)
> >  {
> >      GList *l;
> >  
> > -    for (l = reds->qxl_states; l != NULL; l = l->next)
> > -        red_qxl_start((QXLState*) l->data);
> > +    for (l = reds->qxl_instances; l != NULL; l = l->next) {
> > +        QXLInstance *qxl = l->data;
> > +        red_qxl_start(qxl);
> > +    }
> >  }
> >  
> >  uint32_t reds_qxl_ram_size(RedsState *reds)
> >  {
> > -    QXLState *first;
> > -    if (!reds->qxl_states) {
> > +    QXLInstance *first;
> > +    if (!reds->qxl_instances) {
> >          return 0;
> >      }
> >  
> > -    first = reds->qxl_states->data;
> > +    first = reds->qxl_instances->data;
> >      return red_qxl_get_ram_size(first);
> >  }
> >  
> 
> Patch looks good. I actually don't remember when we spoke with
> Jonathon why we decided to go for QXLState instead.
> I'll wait for Jonathon comment.
> 
> Reviewed-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> 

I don't remember either. But this patch looks good to me as well

Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>


> Frediano
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]