Qemu with Spice support on Windows10 host: a report

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!

Please excuse my english - I am no natural speaker!

Thank you very much for providing spice! I use it in my daily work on a qemu/kvm debian host.

I am trying to run my debian qemu setup on windows10.
For windows a qemu distribution exists in https://qemu.weilnetz.de/, but it is missing spice support. While reading the changelog of spice 0.14.3 I happily realized that the integration is possible now!

Intention of this posting is to document the issues on my way to a working install and the first steps
testing it. I hope, this is the correct list to send it to...

Using a cygwin64 environment I built qemu with x86_64-w64-mingw32 toolchain.
Resulting qemu seems to work as good as the distribution version.

To integrate spice support into qemu, I used spice-protocol-0.14.3.tar.xz
and spice-0.14.3.tar.bz2 as well as spice-0.14.91.tar.bz2

I was able to build and deploy spice-protocol and spice-server to the x86_64-w64-mingw32 sys-root. For the spice-server build I created a patch and added a compiler flag to get rid of compile
and link errors. After a rebuild of qemu spice-support was enabled.

Starting qemu with "-vga qxl -spice port=5905,addr=127.0.0.1,disable-ticketing" works well!
I start spicy having a xserver in background with
spicy -h 127.0.0.1 -p 5905
and I am able to connect to qemu and my VM desktop is visible.

The mouse seems to act strange when trying to enter the spicy window, but the host mouse pointer
just stays visible, the guest mouse pointer is working.

Sadly problems occur after adding more spice with:
"-device virtio-serial-pci -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 -chardev spicevmc,id=spicechannel0,name=vdagent"
qemu starts logging warnings in a loop and is no longer usable:
D:\cygwin64\x86_64-w64-mingw32\qemu-5.2.0\qemu-system-x86_64.exe: warning: GLib: Too many handles to wait for!

It seems to me this is a problem of qemu which I found independent from spice in the distributed version, too.
It occurs when option "-device virtio-serial-pci" is added.

Below I attach my build path, my patch and reasons for the used compiler flags.
I hope it is useful for improving the ease of build for spice on windows.

Regards, Helge Konetzka.

--------------------------

I deployed spice-protocol and spice-server this way:

spice-protocol-0.14.3$ meson setup builddir
spice-protocol-0.14.3$ meson configure --prefix /usr/x86_64-w64-mingw32/sys-root/mingw builddir
spice-protocol-0.14.3$ meson install -C builddir

# Add -fstack-protector to automatically added FLAGS
spice-0.14.91$ export CFLAGS="-g -O2 -fstack-protector"
spice-0.14.91$ export CXXFLAGS="-g -O2 -fno-exceptions -fno-check-new -fstack-protector"
# Patch to include red-common.h before jpeglib.h
spice-0.14.91$ patch -p1 < ../spice-0.14.3-cygwin64.patch
spice-0.14.91$ ./configure --host=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32/sys-root/mingw \
                --without-sasl --enable-extra-checks --disable-silent-rules
spice-0.14.91$ make -j4
spice-0.14.91$ make install

--------------------------

Patch is necessary, because INT32 is defined twice - in /usr/x86_64-w64-mingw32/sys-root/mingw/include/basetsd.h
and /usr/x86_64-w64-mingw32/sys-root/mingw/include/jmorecfg.h

$ grep "^\s*typedef.*\bINT32\b" /usr/x86_64-w64-mingw32/sys-root/mingw/include/* 2>/dev/null /usr/x86_64-w64-mingw32/sys-root/mingw/include/basetsd.h:  typedef signed int INT32,*PINT32; /usr/x86_64-w64-mingw32/sys-root/mingw/include/jmorecfg.h:typedef long INT32; Both header files are included transitionally. jpeglib.h includes jmorecfg.h, red-common.h includes basetsd.h If basetsd.h is processed first (via red-common.h), "#ifndef _BASETSD_H_" in jmorecfg.h prevents second definition of INT32

$ cat spice-0.14.3-cygwin64.patch
diff -Naur spice-0.14.91.orig/server/jpeg-encoder.c spice-0.14.91.patched/server/jpeg-encoder.c --- spice-0.14.91.orig/server/jpeg-encoder.c    2020-10-26 13:18:53.000000000 +0100 +++ spice-0.14.91.patched/server/jpeg-encoder.c    2021-03-23 12:27:18.696134500 +0100
@@ -17,9 +17,9 @@
 #include <config.h>

 #include <stdio.h>
+#include "red-common.h"
 #include <jpeglib.h>

-#include "red-common.h"
 #include "jpeg-encoder.h"

 struct JpegEncoderContext {
diff -Naur spice-0.14.91.orig/server/mjpeg-encoder.c spice-0.14.91.patched/server/mjpeg-encoder.c --- spice-0.14.91.orig/server/mjpeg-encoder.c    2020-10-26 13:18:53.000000000 +0100 +++ spice-0.14.91.patched/server/mjpeg-encoder.c    2021-03-23 12:27:22.501484000 +0100
@@ -20,9 +20,9 @@
 #include <stdio.h>
 #include <inttypes.h>
 #include <jerror.h>
+#include "red-common.h"
 #include <jpeglib.h>

-#include "red-common.h"
 #include "video-encoder.h"
 #include "utils.h"

---------------------------

Additional Compiler-Flag -fstack-protector is necessary in CFLAGS and CXXFLAGS to get rid of linker errors
see
https://sourceforge.net/p/mingw-w64/mailman/message/36764708/
https://github.com/msys2/MINGW-packages/issues/5803

/usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: ./.libs/libserver.a(sys-socket.o): in function `socket_newpair': /mnt/d/Qemu/src/spice-0.14.91/server/sys-socket.c:284: undefined reference to `__stack_chk_fail' /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: ./.libs/libserver.a(sys-socket.o): in function `socket_win32_init': /mnt/d/Qemu/src/spice-0.14.91/server/sys-socket.c:209: undefined reference to `__stack_chk_fail' /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: ./.libs/libserver.a(sys-socket.o):sys-socket.c:(.rdata$.refptr.__stack_chk_guard[.refptr.__stack_chk_guard]+0x0): undefined reference to `__stack_chk_guard' /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: ./.libs/libserver.a(tree.o):/usr/x86_64-w64-mingw32/sys-root/mingw/include/string.h:208: undefined reference to `__memset_chk' /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: ./.libs/libserver.a(utils.o): in function `red_dump_openssl_errors': /mnt/d/Qemu/src/spice-0.14.91/server/utils.c:128: undefined reference to `__stack_chk_fail' /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: ./.libs/libserver.a(websocket.o): in function `websocket_read': /mnt/d/Qemu/src/spice-0.14.91/server/websocket.c:447: undefined reference to `__stack_chk_fail' /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: ./.libs/libserver.a(websocket.o): in function `memcpy': /usr/x86_64-w64-mingw32/sys-root/mingw/include/string.h:202: undefined reference to `__memcpy_chk' /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: ./.libs/libserver.a(websocket.o): in function `sprintf': /usr/x86_64-w64-mingw32/sys-root/mingw/include/stdio.h:372: undefined reference to `__chk_fail' /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: ./.libs/libserver.a(websocket.o): in function `websocket_new': /mnt/d/Qemu/src/spice-0.14.91/server/websocket.c:792: undefined reference to `__stack_chk_fail'
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:790: libspice-server.la] Error 1
make[4]: Leaving directory '/cygdrive/d/Qemu/src/spice-0.14.91/server'
make[3]: *** [Makefile:942: all-recursive] Error 1
make[3]: Leaving directory '/cygdrive/d/Qemu/src/spice-0.14.91/server'
make[2]: *** [Makefile:704: all] Error 2
make[2]: Leaving directory '/cygdrive/d/Qemu/src/spice-0.14.91/server'
make[1]: *** [Makefile:539: all-recursive] Error 1
make[1]: Leaving directory '/cygdrive/d/Qemu/src/spice

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]