[Spice-devel] [PATCH spice-gtk] More cleanup for old protocol support

Frediano Ziglio fziglio at redhat.com
Mon Dec 17 10:53:45 UTC 2018


Support for protocol version 1 was dropped in commit f77a1d50.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 src/channel-base.c |  4 ---
 src/channel-main.c | 69 +++++++++++++++++++---------------------------
 2 files changed, 29 insertions(+), 44 deletions(-)

Patch much smaller seen ignoring space changes.

diff --git a/src/channel-base.c b/src/channel-base.c
index d8fe7692..eb85f8ac 100644
--- a/src/channel-base.c
+++ b/src/channel-base.c
@@ -163,10 +163,6 @@ spice_channel_handle_migrate(SpiceChannel *channel, SpiceMsgIn *in)
     if (mig->flags & SPICE_MIGRATE_NEED_FLUSH) {
         /* if peer version > 1: pushing the mark msg before all other messgages and sending it,
          * and only it */
-        if (c->peer_hdr.major_version == 1) {
-            /* iterate_write is blocking and flushing all pending write */
-            SPICE_CHANNEL_GET_CLASS(channel)->iterate_write(channel);
-        }
         out = spice_msg_out_new(SPICE_CHANNEL(channel), SPICE_MSGC_MIGRATE_FLUSH_MARK);
         spice_msg_out_send_internal(out);
     }
diff --git a/src/channel-main.c b/src/channel-main.c
index 4c6bc704..d902f37f 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -2295,47 +2295,36 @@ static gboolean migrate_connect(gpointer data)
 
     spice_session_set_migration_state(mig->session, SPICE_SESSION_MIGRATION_CONNECTING);
 
-    if ((c->peer_hdr.major_version == 1) &&
-        (c->peer_hdr.minor_version < 1)) {
-        OldRedMigrationBegin *info = (OldRedMigrationBegin *)mig->info;
-        SPICE_DEBUG("migrate_begin old %s %d %d",
-                    info->host, info->port, info->sport);
-        port = info->port;
-        sport = info->sport;
-        host = info->host;
+    SpiceMigrationDstInfo *info = mig->info;
+    SPICE_DEBUG("migrate_begin %u %s %d %d",
+                info->host_size, info->host_data, info->port, info->sport);
+    port = info->port;
+    sport = info->sport;
+    host = (char*)info->host_data;
+
+    if (c->peer_hdr.major_version == 2 && c->peer_hdr.minor_version < 1) {
+        GByteArray *pubkey = g_byte_array_new();
+
+        g_byte_array_append(pubkey, info->pub_key_data, info->pub_key_size);
+        g_object_set(mig->session,
+                     "pubkey", pubkey,
+                     "verify", SPICE_SESSION_VERIFY_PUBKEY,
+                     NULL);
+        g_byte_array_unref(pubkey);
+    } else if (info->cert_subject_size == 0 ||
+               strlen((const char*)info->cert_subject_data) == 0) {
+        /* only verify hostname if no cert subject */
+        g_object_set(mig->session, "verify", SPICE_SESSION_VERIFY_HOSTNAME, NULL);
     } else {
-        SpiceMigrationDstInfo *info = mig->info;
-        SPICE_DEBUG("migrate_begin %u %s %d %d",
-                    info->host_size, info->host_data, info->port, info->sport);
-        port = info->port;
-        sport = info->sport;
-        host = (char*)info->host_data;
-
-        if ((c->peer_hdr.major_version == 1) ||
-            (c->peer_hdr.major_version == 2 && c->peer_hdr.minor_version < 1)) {
-            GByteArray *pubkey = g_byte_array_new();
-
-            g_byte_array_append(pubkey, info->pub_key_data, info->pub_key_size);
-            g_object_set(mig->session,
-                         "pubkey", pubkey,
-                         "verify", SPICE_SESSION_VERIFY_PUBKEY,
-                         NULL);
-            g_byte_array_unref(pubkey);
-        } else if (info->cert_subject_size == 0 ||
-                   strlen((const char*)info->cert_subject_data) == 0) {
-            /* only verify hostname if no cert subject */
-            g_object_set(mig->session, "verify", SPICE_SESSION_VERIFY_HOSTNAME, NULL);
-        } else {
-            gchar *subject = g_alloca(info->cert_subject_size + 1);
-            strncpy(subject, (const char*)info->cert_subject_data, info->cert_subject_size);
-            subject[info->cert_subject_size] = '\0';
-
-            // session data are already copied
-            g_object_set(mig->session,
-                         "cert-subject", subject,
-                         "verify", SPICE_SESSION_VERIFY_SUBJECT,
-                         NULL);
-        }
+        gchar *subject = g_alloca(info->cert_subject_size + 1);
+        strncpy(subject, (const char*)info->cert_subject_data, info->cert_subject_size);
+        subject[info->cert_subject_size] = '\0';
+
+        // session data are already copied
+        g_object_set(mig->session,
+                     "cert-subject", subject,
+                     "verify", SPICE_SESSION_VERIFY_SUBJECT,
+                     NULL);
     }
 
     if (g_getenv("SPICE_MIG_HOST"))
-- 
2.17.2



More information about the Spice-devel mailing list