[Spice-commits] server/main-channel-client.c server/main-channel.c server/main-channel.h

Frediano Ziglio fziglio at kemper.freedesktop.org
Tue Oct 18 17:04:00 UTC 2016


 server/main-channel-client.c |   24 +++++++++++-------------
 server/main-channel.c        |   16 ++++++++++++++++
 server/main-channel.h        |    3 +++
 3 files changed, 30 insertions(+), 13 deletions(-)

New commits:
commit bf7375d834ddb1540e93911993369e531b09f6c1
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Oct 13 16:49:15 2016 -0500

    Improve MainChannel encapsulation
    
    Encapsulate MainChannel a bit better in preparation for proting to
    GObject.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index 0913028..b47b1e0 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -439,11 +439,7 @@ void main_channel_client_handle_migrate_connected(MainChannelClient *mcc,
 
         mcc->priv->mig_wait_connect = FALSE;
         mcc->priv->mig_connect_ok = success;
-        spice_assert(main_channel->num_clients_mig_wait);
-        spice_assert(!seamless || main_channel->num_clients_mig_wait == 1);
-        if (!--main_channel->num_clients_mig_wait) {
-            reds_on_main_migrate_connected(channel->reds, seamless && success);
-        }
+        main_channel_on_migrate_connected(main_channel, success, seamless);
     } else {
         if (success) {
             spice_printerr("client %p MIGRATE_CANCEL", client);
@@ -876,7 +872,7 @@ static void main_channel_marshall_notify(RedChannelClient *rcc,
 static void main_channel_fill_migrate_dst_info(MainChannel *main_channel,
                                                SpiceMigrationDstInfo *dst_info)
 {
-    RedsMigSpice *mig_dst = &main_channel->mig_target;
+    const RedsMigSpice *mig_dst = main_channel_get_migration_target(main_channel);
     dst_info->port = mig_dst->port;
     dst_info->sport = mig_dst->sport;
     dst_info->host_size = strlen(mig_dst->host) + 1;
@@ -935,17 +931,19 @@ static void main_channel_marshall_migrate_switch(SpiceMarshaller *m, RedChannelC
     RedChannel *channel = red_channel_client_get_channel(rcc);
     SpiceMsgMainMigrationSwitchHost migrate;
     MainChannel *main_ch;
+    const RedsMigSpice *mig_target;
 
     spice_printerr("");
     red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST, item);
     main_ch = SPICE_CONTAINEROF(channel, MainChannel, base);
-    migrate.port = main_ch->mig_target.port;
-    migrate.sport = main_ch->mig_target.sport;
-    migrate.host_size = strlen(main_ch->mig_target.host) + 1;
-    migrate.host_data = (uint8_t *)main_ch->mig_target.host;
-    if (main_ch->mig_target.cert_subject) {
-        migrate.cert_subject_size = strlen(main_ch->mig_target.cert_subject) + 1;
-        migrate.cert_subject_data = (uint8_t *)main_ch->mig_target.cert_subject;
+    mig_target = main_channel_get_migration_target(main_ch);
+    migrate.port = mig_target->port;
+    migrate.sport = mig_target->sport;
+    migrate.host_size = strlen(mig_target->host) + 1;
+    migrate.host_data = (uint8_t *)mig_target->host;
+    if (mig_target->cert_subject) {
+        migrate.cert_subject_size = strlen(mig_target->cert_subject) + 1;
+        migrate.cert_subject_data = (uint8_t *)mig_target->cert_subject;
     } else {
         migrate.cert_subject_size = 0;
         migrate.cert_subject_data = NULL;
diff --git a/server/main-channel.c b/server/main-channel.c
index a1b8e31..201c573 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -419,3 +419,19 @@ int main_channel_migrate_src_complete(MainChannel *main_chan, int success)
    }
    return semi_seamless_count;
 }
+
+void main_channel_on_migrate_connected(MainChannel *main_channel,
+                                       gboolean success, gboolean seamless)
+{
+        spice_assert(main_channel->num_clients_mig_wait);
+        spice_assert(!seamless || main_channel->num_clients_mig_wait == 1);
+        if (!--main_channel->num_clients_mig_wait) {
+            reds_on_main_migrate_connected(red_channel_get_server(RED_CHANNEL(main_channel)),
+                                           seamless && success);
+        }
+}
+
+const RedsMigSpice* main_channel_get_migration_target(MainChannel *main_chan)
+{
+    return &main_chan->mig_target;
+}
diff --git a/server/main-channel.h b/server/main-channel.h
index e0858d0..73c8a94 100644
--- a/server/main-channel.h
+++ b/server/main-channel.h
@@ -78,7 +78,10 @@ void main_channel_migrate_switch(MainChannel *main_chan, RedsMigSpice *mig_targe
 int main_channel_migrate_connect(MainChannel *main_channel, RedsMigSpice *mig_target,
                                  int try_seamless);
 void main_channel_migrate_cancel_wait(MainChannel *main_chan);
+const RedsMigSpice* main_channel_get_migration_target(MainChannel *main_chan);
 /* returns the number of clients for which SPICE_MSG_MAIN_MIGRATE_END was sent*/
 int main_channel_migrate_src_complete(MainChannel *main_chan, int success);
+void main_channel_on_migrate_connected(MainChannel *main_channel,
+                                       gboolean success, gboolean seamless);
 
 #endif


More information about the Spice-commits mailing list