[Spice-commits] 8 commits - server/display-channel.c server/red-replay-qxl.c server/reds.c server/tests

Frediano Ziglio fziglio at kemper.freedesktop.org
Mon Dec 5 23:28:14 UTC 2016


 server/display-channel.c |    4 ++--
 server/red-replay-qxl.c  |    6 ++++++
 server/reds.c            |   18 ++++++++++++++++++
 server/tests/replay.c    |   21 ++++++++++++++++++---
 4 files changed, 44 insertions(+), 5 deletions(-)

New commits:
commit 6c33b69e1554c38ec6fac05b1d16cdea35a2d4cb
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Nov 18 12:53:18 2016 +0000

    Support QXL remove on spice_server_remove_interface
    
    Allow to dynamically remove QXL interfaces. This could be used to
    support hot swapping of QXL cards.
    This code is actually not used in any way.
    QXL interfaces are destroyed by spice_server_destroy automatically.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index d350331..6064a6d 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3321,6 +3321,13 @@ SPICE_GNUC_VISIBLE int spice_server_remove_interface(SpiceBaseInstance *sin)
         SpiceCharDeviceInstance *char_device = SPICE_CONTAINEROF(sin, SpiceCharDeviceInstance, base);
         reds = red_char_device_get_server(char_device->st);
         spice_server_char_device_remove_interface(reds, sin);
+    } else if (strcmp(interface->type, SPICE_INTERFACE_QXL) == 0) {
+        QXLInstance *qxl;
+
+        qxl = SPICE_CONTAINEROF(sin, QXLInstance, base);
+        reds = red_qxl_get_server(qxl->st);
+        reds->qxl_instances = g_list_remove(reds->qxl_instances, qxl);
+        red_qxl_destroy(qxl);
     } else {
         spice_warning("VD_INTERFACE_REMOVING unsupported");
         return -1;
commit b9e8105d16ea26812c1bd3d81c82119d2645d05c
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sun Nov 20 17:06:57 2016 +0000

    Free properly primary surface during replay
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/server/red-replay-qxl.c b/server/red-replay-qxl.c
index 2176068..aeaa545 100644
--- a/server/red-replay-qxl.c
+++ b/server/red-replay-qxl.c
@@ -48,6 +48,7 @@ struct SpiceReplay {
     GArray *id_map; // record id -> replay id
     GArray *id_map_inv; // replay id -> record id
     GArray *id_free; // free list
+    uint8_t *primary_mem;
     int nsurfaces;
     int end_pos;
 
@@ -1254,6 +1255,8 @@ static void replay_handle_create_primary(QXLWorker *worker, SpiceReplay *replay)
     }
     read_binary(replay, "data", &size, &mem, 0);
     surface.group_id = 0;
+    free(replay->primary_mem);
+    replay->primary_mem = mem;
     surface.mem = QXLPHYSICAL_FROM_PTR(mem);
     worker->create_primary_surface(worker, 0, &surface);
 }
@@ -1269,6 +1272,8 @@ static void replay_handle_dev_input(QXLWorker *worker, SpiceReplay *replay,
     case RED_WORKER_MESSAGE_DESTROY_PRIMARY_SURFACE:
         replay->created_primary = FALSE;
         worker->destroy_primary_surface(worker, 0);
+        free(replay->primary_mem);
+        replay->primary_mem = NULL;
         break;
     case RED_WORKER_MESSAGE_DESTROY_SURFACES:
         replay->created_primary = FALSE;
@@ -1454,6 +1459,7 @@ SPICE_GNUC_VISIBLE void spice_replay_free(SpiceReplay *replay)
     g_array_free(replay->id_map, TRUE);
     g_array_free(replay->id_map_inv, TRUE);
     g_array_free(replay->id_free, TRUE);
+    free(replay->primary_mem);
     fclose(replay->fd);
     free(replay);
 }
commit 4f301ea0e440d7e256303656eba9011f90423c3f
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sun Nov 20 15:32:04 2016 +0000

    Free replay queues
    
    There could be still some data pending.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/server/tests/replay.c b/server/tests/replay.c
index 23d4125..8ec65d6 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -302,6 +302,21 @@ static gboolean progress_timer(gpointer user_data)
     return TRUE;
 }
 
+static void free_queue(GAsyncQueue *queue)
+{
+    for (;;) {
+        QXLCommandExt *cmd = g_async_queue_try_pop(queue);
+        if (cmd == GINT_TO_POINTER(-1)) {
+            continue;
+        }
+        if (!cmd) {
+            break;
+        }
+        spice_replay_free_cmd(replay, cmd);
+    }
+    g_async_queue_unref(queue);
+}
+
 int main(int argc, char **argv)
 {
     GError *error = NULL;
@@ -440,9 +455,9 @@ int main(int argc, char **argv)
         g_print("Counted %d commands\n", ncommands);
 
     spice_server_destroy(server);
+    free_queue(display_queue);
+    free_queue(cursor_queue);
     end_replay();
-    g_async_queue_unref(display_queue);
-    g_async_queue_unref(cursor_queue);
 
     /* FIXME: there should be a way to join server threads before:
      * g_main_loop_unref(loop);
commit 0c8b059fac6e495bc5c588aae6d76533442ca821
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Nov 18 12:56:36 2016 +0000

    replay: Free spice server to detect leaks
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/tests/replay.c b/server/tests/replay.c
index f32fa2f..23d4125 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -221,7 +221,6 @@ static void end_replay(void)
         kill(client_pid, SIGINT);
         waitpid(client_pid, &child_status, 0);
     }
-    exit(0);
 }
 
 static void release_resource(QXLInstance *qin, struct QXLReleaseInfoExt release_info)
@@ -440,6 +439,7 @@ int main(int argc, char **argv)
     if (print_count)
         g_print("Counted %d commands\n", ncommands);
 
+    spice_server_destroy(server);
     end_replay();
     g_async_queue_unref(display_queue);
     g_async_queue_unref(cursor_queue);
commit 74fa5e3fe49724f0f1056189c6cad15234d58414
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Dec 5 12:13:38 2016 +0000

    Free main_dispatcher in spice_server_destroy
    
    Avoid leaking it.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index 95295c8..d350331 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3602,6 +3602,11 @@ SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds)
         red_channel_destroy(RED_CHANNEL(reds->main_channel));
     }
     reds_core_timer_remove(reds, reds->mig_timer);
+
+    if (reds->main_dispatcher) {
+        g_object_unref(reds->main_dispatcher);
+    }
+
     reds_cleanup(reds);
 #ifdef RED_STATISTICS
     stat_file_free(reds->stat_file);
commit 492e59842a55847676a233aaa5d5c45c04f7195b
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Dec 5 12:13:15 2016 +0000

    Free QXL instances in spice_server_destroy
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index 17e5ada..95295c8 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3592,6 +3592,8 @@ SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds)
     servers = g_list_remove(servers, reds);
     pthread_mutex_unlock(&global_reds_lock);
 
+    g_list_free_full(reds->qxl_instances, (GDestroyNotify)red_qxl_destroy);
+
     if (reds->inputs_channel) {
         reds_unregister_channel(reds, RED_CHANNEL(reds->inputs_channel));
         red_channel_destroy(RED_CHANNEL(reds->inputs_channel));
commit 8dbfd4971a1bf4605d7496a058923a5838142b69
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Dec 2 17:35:07 2016 +0000

    Free inputs_channel in spice_server_destroy
    
    Avoid leaking this channel.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index 479a815..17e5ada 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3592,6 +3592,10 @@ SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds)
     servers = g_list_remove(servers, reds);
     pthread_mutex_unlock(&global_reds_lock);
 
+    if (reds->inputs_channel) {
+        reds_unregister_channel(reds, RED_CHANNEL(reds->inputs_channel));
+        red_channel_destroy(RED_CHANNEL(reds->inputs_channel));
+    }
     if (reds->main_channel) {
         red_channel_destroy(RED_CHANNEL(reds->main_channel));
     }
commit e4a17a487509eceeec908ef15a33f84f04cf12a6
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Dec 2 17:38:22 2016 +0000

    Call parent finalize at the and of display_channel_finalize
    
    Make finalization of DisplayChannel consistent with other code.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/display-channel.c b/server/display-channel.c
index 061a99d..bd9d2be 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -75,10 +75,10 @@ display_channel_finalize(GObject *object)
 {
     DisplayChannel *self = DISPLAY_CHANNEL(object);
 
-    G_OBJECT_CLASS(display_channel_parent_class)->finalize(object);
-
     g_array_unref(self->priv->video_codecs);
     g_free(self->priv);
+
+    G_OBJECT_CLASS(display_channel_parent_class)->finalize(object);
 }
 
 static void drawable_draw(DisplayChannel *display, Drawable *drawable);


More information about the Spice-commits mailing list