Skip to contentSkip to conversation

spice: fix simple display on bigendian hosts

PATCH In review Gerd Hoffmann 3 participants 8 messages Apr 14, 2015 – Apr 15, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spice: fix simple display on bigendian hosts

Denis Kirjanov is busy getting spice run on ppc64 and trapped into this one. Spice wire format is little endian, so we have to explicitly say we want little endian when letting pixman convert the data for us.

---
 include/ui/qemu-pixman.h | 2 ++
 ui/spice-display.c       | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
include/ui/qemu-pixman.h +2 -0
index 5d7a9ac..e34c4ef 100644
@@ -35,6 +35,7 @@
 # define PIXMAN_BE_r8g8b8a8   PIXMAN_r8g8b8a8
 # define PIXMAN_BE_x8b8g8r8   PIXMAN_x8b8g8r8
 # define PIXMAN_BE_a8b8g8r8   PIXMAN_a8b8g8r8
+# define PIXMAN_LE_x8r8g8b8   PIXMAN_b8g8r8x8
 #else
 # define PIXMAN_BE_r8g8b8     PIXMAN_b8g8r8
 # define PIXMAN_BE_x8r8g8b8   PIXMAN_b8g8r8x8
@@ -45,6 +46,7 @@
 # define PIXMAN_BE_r8g8b8a8   PIXMAN_a8b8g8r8
 # define PIXMAN_BE_x8b8g8r8   PIXMAN_r8g8b8x8
 # define PIXMAN_BE_a8b8g8r8   PIXMAN_r8g8b8a8
+# define PIXMAN_LE_x8r8g8b8   PIXMAN_x8r8g8b8
 #endif
 
 /* -------------------------------------------------------------------- */
ui/spice-display.c +1 -1
index 1644185..1a64e07 100644
@@ -178,7 +178,7 @@ static void qemu_spice_create_one_update(SimpleSpiceDisplay *ssd,
     image->bitmap.palette = 0;
     image->bitmap.format = SPICE_BITMAP_FMT_32BIT;
 
-    dest = pixman_image_create_bits(PIXMAN_x8r8g8b8, bw, bh,
+    dest = pixman_image_create_bits(PIXMAN_LE_x8r8g8b8, bw, bh,
                                     (void *)update->bitmap, bw * 4);
     pixman_image_composite(PIXMAN_OP_SRC, ssd->surface, NULL, ssd->mirror,
                            rect->left, rect->top, 0, 0,
Signature · 1 line
1.8.3.1
#1 lore raw

Hey,

Quoted 3 lines · Gerd Hoffmann

Denis Kirjanov is busy getting spice run on ppc64 and trapped into this one. Spice wire format is little endian, so we have to explicitly say we want little endian when letting pixman convert the data for us.

This patch looks good to me, would be nice to get some testing from Denis first though.

Christophe

#2 lore raw
In reply to Gerd Hoffmann
Quoted 7 lines · Gerd Hoffmann

Denis Kirjanov is busy getting spice run on ppc64 and trapped into this one. Spice wire format is little endian, so we have to explicitly say we want little endian when letting pixman convert the data for us.

---

Yeah, that fixes the issue. Thanks Gerd!

Quoted 46 lines
 include/ui/qemu-pixman.h | 2 ++
 ui/spice-display.c       | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
include/ui/qemu-pixman.h +2 -0
index 5d7a9ac..e34c4ef 100644
@@ -35,6 +35,7 @@
 # define PIXMAN_BE_r8g8b8a8   PIXMAN_r8g8b8a8
 # define PIXMAN_BE_x8b8g8r8   PIXMAN_x8b8g8r8
 # define PIXMAN_BE_a8b8g8r8   PIXMAN_a8b8g8r8
+# define PIXMAN_LE_x8r8g8b8   PIXMAN_b8g8r8x8
 #else
 # define PIXMAN_BE_r8g8b8     PIXMAN_b8g8r8
 # define PIXMAN_BE_x8r8g8b8   PIXMAN_b8g8r8x8
@@ -45,6 +46,7 @@
 # define PIXMAN_BE_r8g8b8a8   PIXMAN_a8b8g8r8
 # define PIXMAN_BE_x8b8g8r8   PIXMAN_r8g8b8x8
 # define PIXMAN_BE_a8b8g8r8   PIXMAN_r8g8b8a8
+# define PIXMAN_LE_x8r8g8b8   PIXMAN_x8r8g8b8
 #endif
 
 /* -------------------------------------------------------------------- */
ui/spice-display.c +1 -1
index 1644185..1a64e07 100644
@@ -178,7 +178,7 @@ static void
 qemu_spice_create_one_update(SimpleSpiceDisplay *ssd,
     image->bitmap.palette = 0;
     image->bitmap.format = SPICE_BITMAP_FMT_32BIT;
 
-    dest = pixman_image_create_bits(PIXMAN_x8r8g8b8, bw, bh,
+    dest = pixman_image_create_bits(PIXMAN_LE_x8r8g8b8, bw, bh,
                                     (void *)update->bitmap, bw * 4);
     pixman_image_composite(PIXMAN_OP_SRC, ssd->surface, NULL, ssd->mirror,
                            rect->left, rect->top, 0, 0,

--
1.8.3.1

_______________________________________________
Spice-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/spice-devel

Signature · 2 lines
Regards,
Denis
#3 lore raw
Quoted 9 lines · Denis Kirjanov
Quoted 7 lines · Gerd Hoffmann

Denis Kirjanov is busy getting spice run on ppc64 and trapped into this one. Spice wire format is little endian, so we have to explicitly say we want little endian when letting pixman convert the data for us.

---

Yeah, that fixes the issue. Thanks Gerd!

Looks like that the patch fixes the half of the problem: the inverted colors appear on client reconnect to vm

Quoted 55 lines
Quoted 40 lines
 include/ui/qemu-pixman.h | 2 ++
 ui/spice-display.c       | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
include/ui/qemu-pixman.h +2 -0
index 5d7a9ac..e34c4ef 100644
@@ -35,6 +35,7 @@
 # define PIXMAN_BE_r8g8b8a8   PIXMAN_r8g8b8a8
 # define PIXMAN_BE_x8b8g8r8   PIXMAN_x8b8g8r8
 # define PIXMAN_BE_a8b8g8r8   PIXMAN_a8b8g8r8
+# define PIXMAN_LE_x8r8g8b8   PIXMAN_b8g8r8x8
 #else
 # define PIXMAN_BE_r8g8b8     PIXMAN_b8g8r8
 # define PIXMAN_BE_x8r8g8b8   PIXMAN_b8g8r8x8
@@ -45,6 +46,7 @@
 # define PIXMAN_BE_r8g8b8a8   PIXMAN_a8b8g8r8
 # define PIXMAN_BE_x8b8g8r8   PIXMAN_r8g8b8x8
 # define PIXMAN_BE_a8b8g8r8   PIXMAN_r8g8b8a8
+# define PIXMAN_LE_x8r8g8b8   PIXMAN_x8r8g8b8
 #endif
 
 /* --------------------------------------------------------------------

*/

ui/spice-display.c +1 -1
index 1644185..1a64e07 100644
@@ -178,7 +178,7 @@ static void
 qemu_spice_create_one_update(SimpleSpiceDisplay *ssd,
     image->bitmap.palette = 0;
     image->bitmap.format = SPICE_BITMAP_FMT_32BIT;
 
-    dest = pixman_image_create_bits(PIXMAN_x8r8g8b8, bw, bh,
+    dest = pixman_image_create_bits(PIXMAN_LE_x8r8g8b8, bw, bh,
                                     (void *)update->bitmap, bw * 4);
     pixman_image_composite(PIXMAN_OP_SRC, ssd->surface, NULL,

ssd->mirror,

Quoted 9 lines
                            rect->left, rect->top, 0, 0,

--
1.8.3.1

_______________________________________________
Spice-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/spice-devel

--
Regards,
Denis

Signature · 2 lines
Regards,
Denis
#4 lore raw
Quoted 6 lines · Denis Kirjanov
Quoted 5 lines · Denis Kirjanov
Quoted 4 lines · Gerd Hoffmann

Denis Kirjanov is busy getting spice run on ppc64 and trapped into this one. Spice wire format is little endian, so we have to explicitly say we want little endian when letting pixman convert the data for us.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

---

Yeah, that fixes the issue. Thanks Gerd!

Looks like that the patch fixes the half of the problem: the inverted colors appear on client reconnect to vm

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff4e10258 in ?? () from /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 (gdb) bt
#0 0x00007ffff4e10258 in ?? () from /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 #1 0x00007ffff4e10239 in pixman_image_unref () from /usr/lib/x86_64-linux-gnu/libpixman-1.so.0
#2 0x00007ffff78e4117 in canvas_get_quic (canvas=canvas@entry=0x7ceb80, image=image@entry=0xae2720,
want_original=want_original@entry=0) at
../spice-common/common/canvas_base.c:390
#3 0x00007ffff78e686d in canvas_get_image_internal (canvas=canvas@entry=0x7ceb80, image=0xae2720,
want_original=want_original@entry=0, real_get=real_get@entry=1) at
../spice-common/common/canvas_base.c:1146
#4 0x00007ffff78e83fd in canvas_get_image (want_original=0, image=<optimized out>, canvas=0x7ceb80)

    at ../spice-common/common/canvas_base.c:1309
#5  canvas_draw_copy (spice_canvas=0x7ceb80, bbox=0xae26c4,
clip=<optimized out>, copy=0xae26e8)
    at ../spice-common/common/canvas_base.c:2281

#6 0x00007ffff78c98db in display_handle_draw_copy (channel=0x7c59b0, in=0x841f00) at channel-display.c:1563
#7 0x00007ffff78bfe7c in spice_channel_handle_msg (channel=0x7c59b0, msg=0x841f00) at spice-channel.c:2858
#8 0x00007ffff78bce6c in spice_channel_recv_msg (channel=0x7c59b0, msg_handler=0x7ffff78bfd9f <spice_channel_handle_msg>,

    data=0x0) at spice-channel.c:1869

#9 0x00007ffff78bd4f3 in spice_channel_iterate_read (channel=0x7c59b0) at spice-channel.c:2106
#10 0x00007ffff78bd6fd in spice_channel_iterate (channel=0x7c59b0) at spice-channel.c:2144
#11 0x00007ffff78be4ad in spice_channel_coroutine (data=0x7c59b0) at spice-channel.c:2430
#12 0x00007ffff78ea6ff in coroutine_trampoline (cc=0x7c5058) at coroutine_ucontext.c:63
#13 0x00007ffff78ea4c9 in continuation_trampoline (i0=<optimized out>, i1=<optimized out>) at continuation.c:55
#14 0x00007ffff63278b0 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 #15 0x00000000007c5420 in ?? ()
#16 0x0000000000000000 in ?? ()

Quoted 60 lines
Quoted 43 lines
Quoted 43 lines
 include/ui/qemu-pixman.h | 2 ++
 ui/spice-display.c       | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
include/ui/qemu-pixman.h +2 -0
index 5d7a9ac..e34c4ef 100644
@@ -35,6 +35,7 @@
 # define PIXMAN_BE_r8g8b8a8   PIXMAN_r8g8b8a8
 # define PIXMAN_BE_x8b8g8r8   PIXMAN_x8b8g8r8
 # define PIXMAN_BE_a8b8g8r8   PIXMAN_a8b8g8r8
+# define PIXMAN_LE_x8r8g8b8   PIXMAN_b8g8r8x8
 #else
 # define PIXMAN_BE_r8g8b8     PIXMAN_b8g8r8
 # define PIXMAN_BE_x8r8g8b8   PIXMAN_b8g8r8x8
@@ -45,6 +46,7 @@
 # define PIXMAN_BE_r8g8b8a8   PIXMAN_a8b8g8r8
 # define PIXMAN_BE_x8b8g8r8   PIXMAN_r8g8b8x8
 # define PIXMAN_BE_a8b8g8r8   PIXMAN_r8g8b8a8
+# define PIXMAN_LE_x8r8g8b8   PIXMAN_x8r8g8b8
 #endif
 
 /* --------------------------------------------------------------------

*/

ui/spice-display.c +1 -1
index 1644185..1a64e07 100644
@@ -178,7 +178,7 @@ static void
 qemu_spice_create_one_update(SimpleSpiceDisplay *ssd,
     image->bitmap.palette = 0;
     image->bitmap.format = SPICE_BITMAP_FMT_32BIT;
 
-    dest = pixman_image_create_bits(PIXMAN_x8r8g8b8, bw, bh,
+    dest = pixman_image_create_bits(PIXMAN_LE_x8r8g8b8, bw, bh,
                                     (void *)update->bitmap, bw * 4);
     pixman_image_composite(PIXMAN_OP_SRC, ssd->surface, NULL,

ssd->mirror,

                            rect->left, rect->top, 0, 0,

--
1.8.3.1

Quoted 11 lines
Quoted 5 lines

_______________________________________________
Spice-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/spice-devel

--
Regards,
Denis

--
Regards,
Denis

Signature · 2 lines
Regards,
Denis
#5 lore raw
Quoted 15 lines · Denis Kirjanov
Quoted 6 lines · Denis Kirjanov
Quoted 5 lines · Denis Kirjanov
Quoted 4 lines · Gerd Hoffmann

Denis Kirjanov is busy getting spice run on ppc64 and trapped into this one. Spice wire format is little endian, so we have to explicitly say we want little endian when letting pixman convert the data for us.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

---

Yeah, that fixes the issue. Thanks Gerd!

Looks like that the patch fixes the half of the problem: the inverted colors appear on client reconnect to vm

Quoted 10 lines

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff4e10258 in ?? () from /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 (gdb) bt
#0 0x00007ffff4e10258 in ?? () from /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 #1 0x00007ffff4e10239 in pixman_image_unref () from /usr/lib/x86_64-linux-gnu/libpixman-1.so.0
#2 0x00007ffff78e4117 in canvas_get_quic (canvas=canvas@entry=0x7ceb80, image=image@entry=0xae2720,
want_original=want_original@entry=0) at
../spice-common/common/canvas_base.c:390

spice client crash?
is this spice client running on big endian or little endian machine?

cheers,
Gerd

#6 lore raw
Quoted 31 lines · Gerd Hoffmann
Quoted 17 lines · Denis Kirjanov
Quoted 8 lines · Denis Kirjanov
Quoted 7 lines · Denis Kirjanov
Quoted 6 lines · Gerd Hoffmann

Denis Kirjanov is busy getting spice run on ppc64 and trapped into this
one. Spice wire format is little endian, so we have to explicitly say
we want little endian when letting pixman convert the data for us.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

---

Yeah, that fixes the issue. Thanks Gerd!

Looks like that the patch fixes the half of the problem: the inverted colors appear on client reconnect to vm

Quoted 12 lines

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff4e10258 in ?? () from /usr/lib/x86_64-linux-gnu/libpixman-1.so.0
(gdb) bt
#0 0x00007ffff4e10258 in ?? () from /usr/lib/x86_64-linux-gnu/libpixman-1.so.0
#1 0x00007ffff4e10239 in pixman_image_unref () from /usr/lib/x86_64-linux-gnu/libpixman-1.so.0
#2 0x00007ffff78e4117 in canvas_get_quic (canvas=canvas@entry=0x7ceb80, image=image@entry=0xae2720,
want_original=want_original@entry=0) at
../spice-common/common/canvas_base.c:390

Quoted 2 lines

spice client crash?
is this spice client running on big endian or little endian machine?

it's running on x86_64 as shown in the stack trace.

Quoted 5 lines

cheers,
Gerd

Signature · 2 lines
Regards,
Denis
#7 lore raw
Quoted 32 lines · Denis Kirjanov
Quoted 31 lines · Gerd Hoffmann
Quoted 29 lines · Denis Kirjanov
Quoted 8 lines · Denis Kirjanov
Quoted 7 lines · Denis Kirjanov
Quoted 6 lines · Gerd Hoffmann

Denis Kirjanov is busy getting spice run on ppc64 and trapped into this
one. Spice wire format is little endian, so we have to explicitly say
we want little endian when letting pixman convert the data for us.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

---

Yeah, that fixes the issue. Thanks Gerd!

Looks like that the patch fixes the half of the problem: the inverted colors appear on client reconnect to vm

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff4e10258 in ?? () from /usr/lib/x86_64-linux-gnu/libpixman-1.so.0
(gdb) bt
#0 0x00007ffff4e10258 in ?? () from /usr/lib/x86_64-linux-gnu/libpixman-1.so.0
#1 0x00007ffff4e10239 in pixman_image_unref () from /usr/lib/x86_64-linux-gnu/libpixman-1.so.0
#2 0x00007ffff78e4117 in canvas_get_quic (canvas=canvas@entry=0x7ceb80, image=image@entry=0xae2720,
want_original=want_original@entry=0) at
../spice-common/common/canvas_base.c:390

Quoted 4 lines
Quoted 2 lines

spice client crash?
is this spice client running on big endian or little endian machine?

it's running on x86_64 as shown in the stack trace.

Hmm. spice client should not crash no matter what.

But beside that it is entirely possible that there is a byteswap missing somewhere in either qemu or spice-server where bigendian is sent instead of little endian, which in turn triggers the bug in the client.

IIRC spice protocol support was added to wireshark a while back, so it should be possible to run tests and compare traces to le + be hosts to see whenever there is something wrong in the wire format. Which should help tracing down the bug in the source code.

HTH,
Gerd