[Spice-devel] [PATCH spice-server v2 11/12] Move image_compression field from RedWorker to DisplayChannel

Frediano Ziglio fziglio at redhat.com
Tue Mar 26 19:10:37 UTC 2019


Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/display-channel-private.h |  1 +
 server/display-channel.c         | 10 ++++++++--
 server/display-channel.h         |  2 ++
 server/red-worker.c              |  7 +++----
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/server/display-channel-private.h b/server/display-channel-private.h
index 58179531..4cdae8dc 100644
--- a/server/display-channel-private.h
+++ b/server/display-channel-private.h
@@ -87,6 +87,7 @@ struct DisplayChannelPrivate
     MonitorsConfig *monitors_config;
 
     uint32_t renderer;
+    SpiceImageCompression image_compression;
     int enable_jpeg;
     int enable_zlib_glz_wrap;
 
diff --git a/server/display-channel.c b/server/display-channel.c
index c2129c71..7b833e4c 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2273,6 +2273,7 @@ display_channel_init(DisplayChannel *self)
     /* must be manually allocated here since g_type_class_add_private() only
      * supports structs smaller than 64k */
     self->priv = g_new0(DisplayChannelPrivate, 1);
+    self->priv->image_compression = SPICE_IMAGE_COMPRESSION_AUTO_GLZ;
     self->priv->pub = self;
 
     image_encoder_shared_init(&self->priv->encoder_shared_data);
@@ -2611,10 +2612,9 @@ display_channel_connect(RedChannel *channel, RedClient *client,
 
     spice_debug("connect new client");
 
-    // FIXME not sure how safe is reading directly from reds
     SpiceServer *reds = red_channel_get_server(channel);
     dcc = dcc_new(display, client, stream, migration, caps,
-                  spice_server_get_image_compression(reds), reds_get_jpeg_state(reds),
+                  display->priv->image_compression, reds_get_jpeg_state(reds),
                   reds_get_zlib_glz_state(reds));
     if (!dcc) {
         return;
@@ -2656,3 +2656,9 @@ static void display_channel_migrate(RedChannelClient *rcc)
     DisplayChannel *display = DISPLAY_CHANNEL(red_channel_client_get_channel(rcc));
     red_migrate_display(display, rcc);
 }
+
+void display_channel_set_image_compression(DisplayChannel *display,
+                                           SpiceImageCompression image_compression)
+{
+    display->priv->image_compression = image_compression;
+}
diff --git a/server/display-channel.h b/server/display-channel.h
index 8dfdf523..6af9e129 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -159,6 +159,8 @@ void display_channel_reset_image_cache(DisplayChannel *self);
 void display_channel_debug_oom(DisplayChannel *display, const char *msg);
 
 void display_channel_update_qxl_running(DisplayChannel *display, bool running);
+void display_channel_set_image_compression(DisplayChannel *display,
+                                           SpiceImageCompression image_compression);
 
 G_END_DECLS
 
diff --git a/server/red-worker.c b/server/red-worker.c
index 7382e24d..bc63fc34 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -76,8 +76,6 @@ struct RedWorker {
 
     RedMemSlotInfo mem_slots;
 
-    SpiceImageCompression image_compression;
-
     uint32_t process_display_generation;
     RedStatNode stat;
     RedStatCounter wakeup_counter;
@@ -684,7 +682,7 @@ static void handle_dev_set_compression(void *opaque, void *payload)
     RedWorker *worker = opaque;
     SpiceImageCompression image_compression = msg->image_compression;
 
-    worker->image_compression = image_compression;
+    display_channel_set_image_compression(worker->display_channel, image_compression);
 
     display_channel_compress_stats_print(worker->display_channel);
     display_channel_compress_stats_reset(worker->display_channel);
@@ -1078,7 +1076,6 @@ RedWorker* red_worker_new(QXLInstance *qxl)
         dispatcher_register_universal_handler(dispatcher, worker_dispatcher_record);
     }
 
-    worker->image_compression = spice_server_get_image_compression(reds);
     worker->driver_cap_monitors_config = 0;
     char worker_str[SPICE_STAT_NODE_NAME_MAX];
     snprintf(worker_str, sizeof(worker_str), "display[%d]", worker->qxl->id & 0xff);
@@ -1120,6 +1117,8 @@ RedWorker* red_worker_new(QXLInstance *qxl)
                                                   init_info.n_surfaces);
     channel = RED_CHANNEL(worker->display_channel);
     red_channel_init_stat_node(channel, &worker->stat, "display_channel");
+    display_channel_set_image_compression(worker->display_channel,
+                                          spice_server_get_image_compression(reds));
 
     return worker;
 }
-- 
2.20.1



More information about the Spice-devel mailing list