[Spice-commits] 6 commits - configure.ac server/glz_encoder.c server/red_channel.c server/reds.c spice-common

Christophe Fergau teuf at kemper.freedesktop.org
Fri Apr 10 11:25:30 PDT 2015


 configure.ac         |   19 +++++----------
 server/glz_encoder.c |    3 +-
 server/red_channel.c |   21 +++++++++--------
 server/reds.c        |   62 +++++++++++++++++++++++++++++++++++++--------------
 spice-common         |    2 -
 5 files changed, 66 insertions(+), 41 deletions(-)

New commits:
commit f80eef8f9ca04f923752efbda043ab856801be8a
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Dec 12 16:54:57 2014 +0100

    build-sys: Replace cpu detection error with warning
    
    configure.ac currently errors out when trying to build on
    non-x86/non-ARM CPUs. Since the previous commits improved
    big endian support a lot, this commit replaces the error
    with a warning at configure time to make testing on big
    endian platforms easier.

diff --git a/configure.ac b/configure.ac
index 6cf10bb..7a9fc4b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,21 +61,12 @@ m4_ifndef([AS_VAR_APPEND],
           AC_DEFUN([AS_VAR_APPEND], $1=$$1$2))
 
 # Check for the CPU we are using
-#
-AC_MSG_CHECKING(for x86, x86-64 or armv6+ platform)
 case $host_cpu in
-  i386|i486|i586|i686|i786|k6|k7|armv6|armv6l|armv6hl|armv7|armv7l|armv7hl)
-	variant=32
+  i386|i486|i586|i686|i786|k6|k7|x86_64|armv6|armv6l|armv6hl|armv7|armv7l|armv7hl)
         ;;
-  x86_64)
-	variant=64
-	;;
   *)
-	AC_MSG_RESULT(no)
-	echo Only x86 and x86-64 are supported
-	exit 1
+        arch_warn=1
 esac
-AC_MSG_RESULT($variant bit)
 
 dnl =========================================================================
 dnl Check optional features
@@ -375,6 +366,11 @@ echo "
         Manual:                   ${have_asciidoc}
 "
 
+if test x"$arch_warn" = x1; then
+        AC_MSG_WARN([spice-server on non-x86/x86_64 architectures hasn't been extensively tested])
+        echo ""
+fi
+
 echo \
 "        Now type 'make' to build $PACKAGE
 "
commit 5b813b4340e9b2a8caafe55de4667caf9a4ce59d
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Mon Dec 15 14:58:33 2014 +0100

    build-sys: Remove unused 'X86_64' conditional
    
    X86_64 was defined as an AM_CONDITIONAL, but then nothing was using it.
    This commit gets rid of it.

diff --git a/configure.ac b/configure.ac
index 4e57ef3..6cf10bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,7 +76,6 @@ case $host_cpu in
 	exit 1
 esac
 AC_MSG_RESULT($variant bit)
-AM_CONDITIONAL([X86_64], [test "$variant" = 64])
 
 dnl =========================================================================
 dnl Check optional features
commit 59c6c829e7f67226d838214c7b112b9a478abf53
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Dec 12 17:42:45 2014 +0100

    ppc: Fix glz magic endianess
    
    This is a modified version of a patch initially by Erlon R. Cruz
    <erlon.cruz at br.flextronics.com>

diff --git a/server/glz_encoder.c b/server/glz_encoder.c
index 1ec1f9b..5e1a694 100644
--- a/server/glz_encoder.c
+++ b/server/glz_encoder.c
@@ -18,6 +18,7 @@
 #include <config.h>
 #endif
 
+#include <glib.h>
 #include <pthread.h>
 #include <stdio.h>
 #include "glz_encoder.h"
@@ -261,7 +262,7 @@ int glz_encode(GlzEncoderContext *opaque_encoder,
     encoder->cur_image.id = dict_image->id;
     encoder->cur_image.first_win_seg = dict_image->first_seg;
 
-    encode_32(encoder, LZ_MAGIC);
+    encode_32(encoder, GUINT32_TO_LE(LZ_MAGIC));
     encode_32(encoder, LZ_VERSION);
     if (top_down) {
         encode(encoder, (type & LZ_IMAGE_TYPE_MASK) | (1 << LZ_IMAGE_TYPE_LOG));
commit f55f73b702b881897a7b66fa336ccf4bd7b1c458
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Dec 12 17:42:36 2014 +0100

    ppc: Fixing endianness for channel messages
    
    This is a modified version of a patch initially from
    Erlon R. Cruz <erlon.cruz at br.flextronics.com>

diff --git a/server/red_channel.c b/server/red_channel.c
index eb2419c..6dc9bf1 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -121,47 +121,47 @@ static void red_channel_client_unref(RedChannelClient *rcc);
 
 static uint32_t full_header_get_msg_size(SpiceDataHeaderOpaque *header)
 {
-    return ((SpiceDataHeader *)header->data)->size;
+    return GUINT32_FROM_LE(((SpiceDataHeader *)header->data)->size);
 }
 
 static uint32_t mini_header_get_msg_size(SpiceDataHeaderOpaque *header)
 {
-    return ((SpiceMiniDataHeader *)header->data)->size;
+    return GUINT32_FROM_LE(((SpiceMiniDataHeader *)header->data)->size);
 }
 
 static uint16_t full_header_get_msg_type(SpiceDataHeaderOpaque *header)
 {
-    return ((SpiceDataHeader *)header->data)->type;
+    return GUINT16_FROM_LE(((SpiceDataHeader *)header->data)->type);
 }
 
 static uint16_t mini_header_get_msg_type(SpiceDataHeaderOpaque *header)
 {
-    return ((SpiceMiniDataHeader *)header->data)->type;
+    return GUINT16_FROM_LE(((SpiceMiniDataHeader *)header->data)->type);
 }
 
 static void full_header_set_msg_type(SpiceDataHeaderOpaque *header, uint16_t type)
 {
-    ((SpiceDataHeader *)header->data)->type = type;
+    ((SpiceDataHeader *)header->data)->type = GUINT16_TO_LE(type);
 }
 
 static void mini_header_set_msg_type(SpiceDataHeaderOpaque *header, uint16_t type)
 {
-    ((SpiceMiniDataHeader *)header->data)->type = type;
+    ((SpiceMiniDataHeader *)header->data)->type = GUINT16_TO_LE(type);
 }
 
 static void full_header_set_msg_size(SpiceDataHeaderOpaque *header, uint32_t size)
 {
-    ((SpiceDataHeader *)header->data)->size = size;
+    ((SpiceDataHeader *)header->data)->size = GUINT32_TO_LE(size);
 }
 
 static void mini_header_set_msg_size(SpiceDataHeaderOpaque *header, uint32_t size)
 {
-    ((SpiceMiniDataHeader *)header->data)->size = size;
+    ((SpiceMiniDataHeader *)header->data)->size = GUINT32_TO_LE(size);
 }
 
 static void full_header_set_msg_serial(SpiceDataHeaderOpaque *header, uint64_t serial)
 {
-    ((SpiceDataHeader *)header->data)->serial = serial;
+    ((SpiceDataHeader *)header->data)->serial = GUINT64_TO_LE(serial);
 }
 
 static void mini_header_set_msg_serial(SpiceDataHeaderOpaque *header, uint64_t serial)
@@ -171,7 +171,7 @@ static void mini_header_set_msg_serial(SpiceDataHeaderOpaque *header, uint64_t s
 
 static void full_header_set_msg_sub_list(SpiceDataHeaderOpaque *header, uint32_t sub_list)
 {
-    ((SpiceDataHeader *)header->data)->sub_list = sub_list;
+    ((SpiceDataHeader *)header->data)->sub_list = GUINT32_TO_LE(sub_list);
 }
 
 static void mini_header_set_msg_sub_list(SpiceDataHeaderOpaque *header, uint32_t sub_list)
commit 418a56edc98a0a54d434c37dae5325312bcb8e1f
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Mon Dec 15 11:39:44 2014 +0100

    ppc: Update spice-common for endianness-related fixes
    
    Alexander Wauck (1):
          Make spice_codegen.py work on both Python 2 and 3
    
    Christophe Fergeau (17):
          Remove unused header file
          build-sys: Remove unused X check
          build-sys: Remove unused win32 check
          build-sys: Remove unused WITH_SMARTCARD conditional
          build-sys: Small cleanup of AM_CPPFLAGS
          build-sys: Add fallback for AS_VAR_APPEND
          build-sys: Move posix checks to a separate m4 macro
          build-sys: Move smartcard check to m4 macro
          build-sys: Move celt check to m4 macro
          build-sys: Move opus check to m4 macro
          build-sys: Move opengl check to m4 macro
          build-sys: Move pixman check to m4 macro
          Remove unused 'invers' arg from canvas_get_*
          Remove redundant #if defined(SW_CANVAS_CACHE) ||
    defined(SW_CANVAS_IMAGE_CACHE)
          Remove another redundant (SW_CANVAS_CACHE) ||
    (SW_CANVAS_IMAGE_CACHE) #ifdef
          Get rid of SW_CANVAS_IMAGE_CACHE
          ssl_verify: Move wincrypt.h related #ifdef closer to the include
    
    Erlon Cruz (2):
          ppc: Fix lz magic endianness
          ppc: build-sys: Add big-endian support
    
    Fabiano FidĂȘncio (1):
          Fix typo in pixman_image_get_stride() function
    
    Javier Celaya (6):
          LZ4: Fix output buffer size
          LZ4: Adjust reading the top_down flag
          LZ4: Decode the image format from the stream
          LZ4: Fix the row alignment when it is not on a 32bit boundary
          LZ4: Add support for 24bit pixman surfaces
          LZ4: Do not include arpa/inet.h in Windows builds
    
    Victor Toso (1):
          common: fix build with mingw

diff --git a/spice-common b/spice-common
index 5b3cdad..c6e6dac 160000
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit 5b3cdad921d32c9294377efac61243a09f849d08
+Subproject commit c6e6dacb30b8130a069d522054718d757eefa0db
commit 14b7f5c8cf933643be62843dbfff0fde337f3380
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Jun 10 18:13:13 2014 +0200

    ppc: Fix endianness handling in initial SPICE connection
    
    This commit fixes enough endianness issues that it's possible to
    connect to a spice-server/qemu running on a big-endian box with a client
    running on a little-endian machine.
    
    I haven't tested more than getting to the bios/bootloader and typing a
    bit on the keyboard as I did not manage to boot a distro afterwards :(
    
    This is based on patches send by Erlon R. Cruz
    <erlon.cruz at br.flextronics.com>

diff --git a/server/red_channel.c b/server/red_channel.c
index a968309..eb2419c 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -22,6 +22,7 @@
 #include <config.h>
 #endif
 
+#include <glib.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <netinet/in.h>
diff --git a/server/reds.c b/server/reds.c
index f61d5d3..6d70b68 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1354,13 +1354,14 @@ static int reds_send_link_ack(RedLinkInfo *link)
     BUF_MEM *bmBuf;
     BIO *bio = NULL;
     int ret = FALSE;
+    size_t hdr_size;
 
     header.magic = SPICE_MAGIC;
-    header.size = sizeof(ack);
-    header.major_version = SPICE_VERSION_MAJOR;
-    header.minor_version = SPICE_VERSION_MINOR;
+    hdr_size = sizeof(ack);
+    header.major_version = GUINT32_TO_LE(SPICE_VERSION_MAJOR);
+    header.minor_version = GUINT32_TO_LE(SPICE_VERSION_MINOR);
 
-    ack.error = SPICE_LINK_ERR_OK;
+    ack.error = GUINT32_TO_LE(SPICE_LINK_ERR_OK);
 
     channel = reds_find_channel(link->link_mess->channel_type,
                                 link->link_mess->channel_id);
@@ -1373,10 +1374,12 @@ static int reds_send_link_ack(RedLinkInfo *link)
     reds_channel_init_auth_caps(link, channel); /* make sure common caps are set */
 
     channel_caps = &channel->local_caps;
-    ack.num_common_caps = channel_caps->num_common_caps;
-    ack.num_channel_caps = channel_caps->num_caps;
-    header.size += (ack.num_common_caps + ack.num_channel_caps) * sizeof(uint32_t);
-    ack.caps_offset = sizeof(SpiceLinkReply);
+    ack.num_common_caps = GUINT32_TO_LE(channel_caps->num_common_caps);
+    ack.num_channel_caps = GUINT32_TO_LE(channel_caps->num_caps);
+    hdr_size += channel_caps->num_common_caps * sizeof(uint32_t);
+    hdr_size += channel_caps->num_caps * sizeof(uint32_t);
+    header.size = GUINT32_TO_LE(hdr_size);
+    ack.caps_offset = GUINT32_TO_LE(sizeof(SpiceLinkReply));
     if (!sasl_enabled
         || !red_link_info_test_capability(link, SPICE_COMMON_CAP_AUTH_SASL)) {
         if (!(link->tiTicketing.rsa = RSA_new())) {
@@ -1421,10 +1424,16 @@ static int reds_send_link_ack(RedLinkInfo *link)
         goto end;
     if (!reds_stream_write_all(link->stream, &ack, sizeof(ack)))
         goto end;
-    if (!reds_stream_write_all(link->stream, channel_caps->common_caps, channel_caps->num_common_caps * sizeof(uint32_t)))
-        goto end;
-    if (!reds_stream_write_all(link->stream, channel_caps->caps, channel_caps->num_caps * sizeof(uint32_t)))
-        goto end;
+    for (unsigned int i = 0; i < channel_caps->num_common_caps; i++) {
+        guint32 cap = GUINT32_TO_LE(channel_caps->common_caps[i]);
+        if (!reds_stream_write_all(link->stream, &cap, sizeof(cap)))
+            goto end;
+    }
+    for (unsigned int i = 0; i < channel_caps->num_caps; i++) {
+        guint32 cap = GUINT32_TO_LE(channel_caps->caps[i]);
+        if (!reds_stream_write_all(link->stream, &cap, sizeof(cap)))
+            goto end;
+    }
 
     ret = TRUE;
 
@@ -1440,11 +1449,11 @@ static bool reds_send_link_error(RedLinkInfo *link, uint32_t error)
     SpiceLinkReply reply;
 
     header.magic = SPICE_MAGIC;
-    header.size = sizeof(reply);
-    header.major_version = SPICE_VERSION_MAJOR;
-    header.minor_version = SPICE_VERSION_MINOR;
+    header.size = GUINT32_TO_LE(sizeof(reply));
+    header.major_version = GUINT32_TO_LE(SPICE_VERSION_MAJOR);
+    header.minor_version = GUINT32_TO_LE(SPICE_VERSION_MINOR);
     memset(&reply, 0, sizeof(reply));
-    reply.error = error;
+    reply.error = GUINT32_TO_LE(error);
     return reds_stream_write_all(link->stream, &header, sizeof(header)) && reds_stream_write_all(link->stream, &reply,
                                                                          sizeof(reply));
 }
@@ -1467,6 +1476,7 @@ static void reds_info_new_channel(RedLinkInfo *link, int connection_id)
 
 static void reds_send_link_result(RedLinkInfo *link, uint32_t error)
 {
+    error = GUINT32_TO_LE(error);
     reds_stream_write_all(link->stream, &error, sizeof(error));
 }
 
@@ -2051,6 +2061,7 @@ static void reds_handle_auth_mechanism(void *opaque)
 
     spice_info("Auth method: %d", link->auth_mechanism.auth_mechanism);
 
+    link->auth_mechanism.auth_mechanism = GUINT32_FROM_LE(link->auth_mechanism.auth_mechanism);
     if (link->auth_mechanism.auth_mechanism == SPICE_COMMON_CAP_AUTH_SPICE
         && !sasl_enabled
         ) {
@@ -2082,8 +2093,18 @@ static void reds_handle_read_link_done(void *opaque)
 {
     RedLinkInfo *link = (RedLinkInfo *)opaque;
     SpiceLinkMess *link_mess = link->link_mess;
-    uint32_t num_caps = link_mess->num_common_caps + link_mess->num_channel_caps;
+    uint32_t num_caps;
+    uint32_t *caps;
     int auth_selection;
+    unsigned int i;
+
+    link_mess->caps_offset = GUINT32_FROM_LE(link_mess->caps_offset);
+    link_mess->connection_id = GUINT32_FROM_LE(link_mess->connection_id);
+    link_mess->num_channel_caps = GUINT32_FROM_LE(link_mess->num_channel_caps);
+    link_mess->num_common_caps = GUINT32_FROM_LE(link_mess->num_common_caps);
+
+    num_caps = link_mess->num_common_caps + link_mess->num_channel_caps;
+    caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset);
 
     if (num_caps && (num_caps * sizeof(uint32_t) + link_mess->caps_offset >
                      link->link_header.size ||
@@ -2093,6 +2114,9 @@ static void reds_handle_read_link_done(void *opaque)
         return;
     }
 
+    for(i = 0; i < num_caps;i++)
+        caps[i] = GUINT32_FROM_LE(caps[i]);
+
     auth_selection = red_link_info_test_capability(link,
                                                    SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
 
@@ -2149,6 +2173,10 @@ static void reds_handle_read_header_done(void *opaque)
     RedLinkInfo *link = (RedLinkInfo *)opaque;
     SpiceLinkHeader *header = &link->link_header;
 
+    header->major_version = GUINT32_FROM_LE(header->major_version);
+    header->minor_version = GUINT32_FROM_LE(header->minor_version);
+    header->size = GUINT32_FROM_LE(header->size);
+
     if (header->magic != SPICE_MAGIC) {
         reds_send_link_error(link, SPICE_LINK_ERR_INVALID_MAGIC);
         reds_link_free(link);


More information about the Spice-commits mailing list