Commit Graph

4808 Commits

Author SHA1 Message Date
Frediano Ziglio
9213308fd3 ci: Fix compile error using new GStreamer library
Using Fedora 38 the compilation fails due to this warning:

    In file included from /usr/include/gstreamer-1.0/gst/video/video.h:202,
                     from ../../server/gstreamer-encoder.c:27:
    /usr/include/gstreamer-1.0/gst/video/video-sei.h:39:21: error: 'H265_MISP_NANOSECONDS' defined but not used [-Werror=unused-const-variable=]
       39 | static const guint8 H265_MISP_NANOSECONDS[] = {
          |                     ^~~~~~~~~~~~~~~~~~~~~

Ignore the warning for Gstreamer includes.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-05-10 11:14:35 +01:00
Frediano Ziglio
6089c90a62 ci: Fix check-valgrind job
Avoid downgrading gstreamer1-plugins-good, no longer necessary.
Add suppression for pthread_create leak.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-05-10 10:56:42 +01:00
Frediano Ziglio
d8cc54159d ci: Add missing packages for CentOS job
"cmp" and "diff" were not available.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-05-10 10:55:42 +01:00
Frediano Ziglio
71a1b11221 ci: Fix websocket-autobahn job
Last wsaccel library fails to install on the container.
This test has not been maintained for a while so libraries
are getting pretty old anyway.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-05-10 10:55:08 +01:00
Frediano Ziglio
956cd26dbf build: Update syntax for Autoconf script
Used autoupdate and some manual changes.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-05-10 10:53:54 +01:00
Frediano Ziglio
95702f1588 syntax-check: Add missing contributor name to AUTHORS
For previous commit a5d1d957d6
(cfr "sound: Fix pointer arithmetic in snd_record_handle_write()")

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-05-10 10:52:47 +01:00
Volker Rümelin
a5d1d957d6 sound: Fix pointer arithmetic in snd_record_handle_write()
The variable 'now' counts in audio sample frames, but the variable
'data' is of type uint8_t *. Multiply 'now' by the size of an audio
sample frame to get the correct source pointer.

This improves the quality of audio recordings in QEMU a little bit.

Fixes: 5d5a7bd181 ("sound: Avoid cast that could cause alignment problems")

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2022-10-22 20:58:02 +01:00
Frediano Ziglio
c7b313ba31 build: Prepare for 0.15.1 release
Lot of build and compatibility updates since 0.15.
See CHANGELOG.md.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-09-13 14:59:22 +01:00
Frediano Ziglio
f9682ed121 Temporary workaround issue with gstreamer1-plugins-good package
Downgrading this package seems to solve Valgrind tests.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-08-03 19:06:00 +01:00
Frediano Ziglio
a225ebe921 test-leaks: Load DH parameters to test this part of code
Just loding the file is enough to test code in reds.cpp.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-08-03 19:03:08 +01:00
Frediano Ziglio
2cd6766b0d Adapt to new OpenSSL with less conditional code
Reduce conditional code using new OpenSSL interface and implement
missing APIs.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-08-03 19:03:08 +01:00
Marc-André Lureau
dc40a18092 Fix OpenSSL 3.0 API deprecations
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-03 19:03:08 +01:00
Marc-André Lureau
36f501ef75 Generate a random connection ID with g_random_int()
Spice uses rand() to generate the random id, but qemu (at least in the case
of qemu-system-x86) fails to initialize the RNG seed (with e.g. srand()).

The result is, that every SPICE session started (by e.g. libvirtd) has the
same client_id. Usually, this is not a problem, but running something like
a SPICE proxy, relying on the client_id to correctly route connections,
this creates problems.

Fixes:
https://gitlab.com/qemu-project/qemu/-/issues/163

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-19 14:41:39 +04:00
Frediano Ziglio
3153ce81f8 ci: Fix Windows
Provides LANG to avoid error detecting encoding.
Install all Wine package, installing only core is not enough.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-07-19 10:13:25 +01:00
Frediano Ziglio
acfa6f6bf8 Fix C++ compatibility issue
Remove deprecation warnings like

In file included from ../../server/char-device.cpp:28:
../../server/safe-list.hpp:108:43: error: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' is deprecated [-Werror=deprecated-declarations]
  108 | class safe_list<T>::iterator: public std::iterator<std::forward_iterator_tag, T>
      |                                           ^~~~~~~~

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-07-19 10:11:55 +01:00
Frediano Ziglio
a32b4b5084 Exclude a warning causing new compiler to fail
Due to 0-size array you can have warnings like

c++ -Iserver/libspice-server.so.1.14.1.p -Iserver -I../server -I. -I.. -Isubprojects/spice-common -I../subprojects/spice-common -Isubprojects/spice-common/common -I/usr/include/spice-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/pixman-1 -I/usr/include/opus -I/usr/include/cacard -I/usr/include/nss3 -I/usr/include/nspr4 -I/usr/include/PCSC -I/usr/include/gstreamer-1.0 -I/usr/include/orc-0.4 -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -O3 -DSPICE_SERVER_INTERNAL '-DG_LOG_DOMAIN="Spice"' -Wno-sign-compare -Wno-unused-parameter -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_38 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_38 -fno-exceptions -Wno-suggest-final-methods -Wno-suggest-final-types -Wno-array-bounds -Wno-narrowing -Wno-missing-field-initializers -Wno-deprecated-declarations -Wshadow -fPIC -pthread -MD -MQ server/libspice-server.so.1.14.1.p/red-channel-client.cpp.o -MF server/libspice-server.so.1.14.1.p/red-channel-client.cpp.o.d -o server/libspice-server.so.1.14.1.p/red-channel-client.cpp.o -c ../server/red-channel-client.cpp
In file included from /usr/include/c++/12/bits/shared_ptr_atomic.h:33,
                 from /usr/include/c++/12/memory:78,
                 from ../server/utils.hpp:24,
                 from ../server/red-pipe-item.h:27,
                 from ../server/red-channel-client.h:24,
                 from ../server/red-channel-client.cpp:37:
In member function 'std::__atomic_base<_IntTp>::__int_type std::__atomic_base<_IntTp>::operator++() [with _ITp = int]',
    inlined from 'void red::shared_ptr_add_ref(shared_ptr_counted*)' at ../server/utils.hpp:280:5,
    inlined from 'red::shared_ptr<T>::shared_ptr(T*) [with T = RedChannelClient]' at ../server/utils.hpp:143:31,
    inlined from 'void RedChannelClient::receive()' at ../server/red-channel-client.cpp:1123:52,
    inlined from 'void red_channel_client_event(int, int, RedChannelClient*)' at ../server/red-channel-client.cpp:739:21:
/usr/include/c++/12/bits/atomic_base.h:385:34: error: 'unsigned int __atomic_add_fetch_4(volatile void*, unsigned int, int)' writing 4 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
  385 |       { return __atomic_add_fetch(&_M_i, 1, int(memory_order_seq_cst)); }
      |                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-07-19 10:10:26 +01:00
Frediano Ziglio
736d79949e Update spice-common submodule
This brings in the following changes:

Frediano Ziglio (4):
      Find Python3 installation correctly on MacOS
      build: Correctly check for Python modules
      ci: Set WINEPATH during Windows build
      Replace EVP_PKEY_cmp with EVP_PKEY_eq

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-07-19 10:07:06 +01:00
Marc-André Lureau
e8cb170509 Fix std::array<> has initializer but incomplete type
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-07-19 10:04:51 +01:00
Frediano Ziglio
4a1e9a03f4 ci: Workaround a bug in Fedora 35 mingw64-make script
mingw64-make is a bash script that wraps make command passing
additional arguments and setup in order to cross compiler for
MingW (to target Windows).
In Fedora 35 the script passes the arguments we provide
twice. So if we pass (like in this case)
"LOG_COMPILE=wine -C server check" the final make command will
receive
"LOG_COMPILE=wine -C server check LOG_COMPILE=wine -C server check"
arguments.
This for some arguments it's not a problem but passing "-C <dir>"
twice causes make to attempt to change directory twice.
This causes a

    make: *** server: No such file or directory.  Stop.

error. Use cd command before invoking mingw64-make to avoid
having to pass "-C" option.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-03-24 12:37:26 +00:00
Frediano Ziglio
a73b82fc18 ci: Set WINEPATH before executing tests for Windows
Without it on Fedora 35 Wine is not able to find DLLs installed
on the system.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-03-24 12:37:26 +00:00
Frediano Ziglio
dd4c11ae98 ci: Exclude a system leak in Fedora 35
This leak causes a CI failure running test-listen test with
Valgrind.
Note that "check-valgrind" CI job will still fail but with
less issues.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-03-23 15:03:23 +00:00
Uri Lublin
9106365d3e ci: centos: run on centos stream 8 image from quay.io
The default centos:latest image can not install packages anymore.
The makecheck-centos test fails with the following error:
  $ dnf install -y 'dnf-command(config-manager)'
  Error: Failed to download metadata for repo 'appstream' \
         Cannot prepare internal mirrorlist: No URLs in mirrorlist

Replace it with a centos stream 8 image from quay.io to make
the makecheck-centos test pass

Signed-off-by: Uri Lublin <uril@redhat.com>
2022-03-23 15:00:58 +00:00
Antonio Larrosa
46e3a57ccd Fix build with gstreamer 1.20.x
gstreamer-plugins-base 1.20 includes a new member in the
GstAppSinkCallbacks struct:

 gboolean      (*new_event)        (GstAppSink *appsink, gpointer user_data);

So it has to be initialized in order to build test-gst.cpp
successfully.

(added in
0a657d6db5
)

Acked-by: Frediano Ziglio <freddy77@gmail.com>
2022-03-23 13:39:52 +00:00
Christian Ehrhardt
ab9ad87c5f
Revert "reds: start QXL devices if VM is running" (fix race)
Due to reds->vm_running being initialized to TRUE (since c302e12c
"spice.h: add entries for tracking vm state") the assumption in c23cbd6f
"reds: start QXL devices if VM is running" was wrong and we can't check
on vm_running until that initialization isn't on TRUE (it is that way for
backward compatibility).

Without this revert on qemu initializing spice we will have the
display_init side of qemu not yet ready and therefore respond badly when
spice sends an event as reaction to `red_qxl_start`:
   "qxl_send_events: spice-server bug: guest stopped, ignoring."

At least with qemu > v2.0 as a spice consumer is not showing issues as
`red_qxl_start` will be called just after the qemu side is ready
`qemu_spice_display_start` -> `spice_server_vm_start`  ... `red_qxl_start`.

Therefore - for now to avoid the current regression - Revert c23cbd6f
"reds: start QXL devices if VM is running" until that old (2012)
initialization is updated (probably an ABI change and therefore taking
some time).

Fixes: https://gitlab.freedesktop.org/spice/spice/-/issues/64

This reverts commit c23cbd6fa8.
2022-03-21 11:37:11 +01:00
Frediano Ziglio
b24e2ea68e ci: Fix compile error using new GStreamer library
Using Fedora 35 the compilation fails due to this warning:

    ../server/gstreamer-encoder.c: In function 'create_pipeline':
    ../server/gstreamer-encoder.c:994:5: error: braces around scalar initializer [-Werror]
     994 |     GstAppSinkCallbacks appsink_cbs = {NULL, NULL, &new_sample, {NULL}};
         |     ^~~~~~~~~~~~~~~~~~~
    ../server/gstreamer-encoder.c:994:5: note: (near initialization for 'appsink_cbs.new_event')
    ../server/gstreamer-encoder.c:994:5: error: missing initializer for field '_gst_reserved' of 'GstAppSinkCallbacks' [-Werror=missing-field-initializers]
    In file included from ../server/gstreamer-encoder.c:26:
    /usr/include/gstreamer-1.0/gst/app/gstappsink.h:81:16: note: '_gst_reserved' declared here
       81 |   gpointer     _gst_reserved[GST_PADDING - 1];
          |                ^~~~~~~~~~~~~
    cc1: all warnings being treated as errors

Change structure initialisation to avoid the warning.
The same syntax is already used in server/tests/test-gst.cpp.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-01-29 16:25:43 +00:00
Geoffrey McRae
cf061597b6 Report name/uuid and agent connected tokens support.
A well behaved client implementing the SPICE protocol should check to see
if the server supports the capabilities it needs. This implementation of
the spice-server supports `SPICE_MAIN_CAP_NAME_AND_UUID` and `
SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS` so it should report this to the
client.

Acked-by: Frediano Ziglio <freddy77@gmail.com>
2022-01-04 10:16:19 +00:00
Simon Chopin
3d32295f9e test-leaks: fix the test with OpenSSL3
In OpenSSL3, the SSL_accept call now emits proper errors, which we dump
*before* emitting the expected "SSL_accept failed" error message. The
g_test_expect_message framework doesn't really allow us to discard
messages AFAICT, so instead we add a new expectation with fairly loose
criteria.

Fixes #63

Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-11-11 09:23:51 +00:00
Rosen Penev
e2848118bf clang-tidy: use C++ casting
Found with google-readability-casting

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-09-28 09:36:49 +01:00
Frediano Ziglio
d17e7878cb Remove useless typedefs
Just use forward declaration if needed.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2021-08-26 20:59:41 +01:00
Frediano Ziglio
55897eba0f Remove some constant usage, use size from arrays
Makes more clear that we are scanning entire arrays or
checking for some container boundaries.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2021-08-26 09:02:41 +01:00
Frediano Ziglio
e0dab7f4ef reds: Use proper maximum constant for time_t
Some systems use 32-bits, other 64-bits.
Some systems use signed integers, other unsigned integers.
Compute maximum constant based on time_t type.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2021-08-26 07:37:51 +01:00
Rosen Penev
5513bce73e clang-tidy: replace C headers with C++
Found with modernize-deprecated-headers

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-08-26 07:35:09 +01:00
Rosen Penev
24f67439e4 several conversions to std::array
These conversions allowed extra conversions to for range loops in
addition to replacing macro usage with .size().

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-08-23 10:41:11 +01:00
Frediano Ziglio
258fda6290 Remove now useless check
display_channel_surface_id_unref resets the surface so
display_channel_surface_has_canvas will return false.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:46:15 +01:00
Frediano Ziglio
d8bca15f2b Allows surfaces to be updated without having to wait
Store pointers to surface object in "surfaces" and allows to
have different surfaces with same ID in memory.
The surface was keep "busy" if there was pending drawing around.

Consider the following case:
 1- receive drawing command
 2- queue command on DCCs
 3- destroy surface
 4- send draw
Previously at point 4) you would have to use a surface from
"surfaces" which was destroyed, that is we would have to maintain
the pointer (and canvas) to the surface until reference counter
was 0.

However consider this case:
 1- receive drawing command
 2- queue command on DCCs
 3- destroy surface
 4- create surface
 5- send draw
What would happen in point 4) ?
We could not change the surface as it will be used by point 5).
To avoid this the code attempts to wait the commands to release the
surface. However this can be an issue, you can't force the clients
to receive pending data if network is slow.

So this patch change this allowing to create surfaces while the old
version will still be used.

This is also more clean from the reference pointer prospective,
as the reference is increased for a specific surface.

Note that now instead of checking for canvas to not be NULL a
simple check for surface pointer is enough.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:46:12 +01:00
Frediano Ziglio
f5c2043143 Remove last direct surface IDs usages
Mostly left on dcc-send.cpp.
Other minor too.

The change in BitmapData seems odd but the id for cached image
was not used so the only information left was the surface.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:46:09 +01:00
Frediano Ziglio
4434c6fb96 Change validate_surface to return surface pointer
Instead of computing the value inside the function to then
compute also in the caller return it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:46:07 +01:00
Frediano Ziglio
1d123192e7 Use directly surface instead of id
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:46:05 +01:00
Frediano Ziglio
74c660ddad Pass surface directly to dcc_push_surface_image
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:46:04 +01:00
Frediano Ziglio
3b790b8ad6 Pass surface directly to dcc_create_surface
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:46:02 +01:00
Frediano Ziglio
78bc3a637a New function to pass surface directly to display_channel_draw
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:46:01 +01:00
Frediano Ziglio
5a5d1e21b5 Pass surface directly calling display_channel_current_flush
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:45:59 +01:00
Frediano Ziglio
58a612a039 Pass surface directly calling dcc_clear_surface_drawables_from_pipe
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:45:57 +01:00
Frediano Ziglio
2b219cace5 Pass surface directly calling draw_depend_on_me and display_channel_destroy_surface
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:45:55 +01:00
Frediano Ziglio
493077d080 Pass surface directly in is_primary_surface
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:45:54 +01:00
Frediano Ziglio
f418bbb522 Pass surface directly to display_channel_surface_unref
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:45:52 +01:00
Frediano Ziglio
977e72eb48 Pass surface directly to current_remove_all
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:45:51 +01:00
Frediano Ziglio
19eb9995b2 Pass surface directly for surface_read_bits
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:45:48 +01:00
Frediano Ziglio
6933c6dd14 Use direct pointers for surface and surface dependencies from Drawable
As we use reference counting is more direct to use direct pointers.
Also this will allow to have a surface in a "released state"
reducing the complexity of code destroying a surface.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-07 07:45:38 +01:00
Frediano Ziglio
708cd97212 red-parse-qxl: Encapsulate QXL resource management
Reuse code.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-04 13:01:14 +01:00