Commit Graph

77 Commits

Author SHA1 Message Date
Frediano Ziglio
fe4723d176 build: Remove support for GStreamer 0.10
Deprecated since 2016.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-09-17 10:00:41 +01:00
Frediano Ziglio
e625a10a7a Update OpenSSL call
SSLv23_method call was deprecated in favour of TLS_method.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-05-10 11:17:47 +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
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
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
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
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
Frediano Ziglio
84e1788d3a reds: Fix closure of SpiceServer in case of connected clients
When spice_server_destroy is called with pending clients (currently
not a big issue, usually the programs using SPICE server are
exiting then), some leaks can happen.
This is due to the fact that some dispatcher messages are queued
to handle some serialization but then they are neved executed as
the entire system is closed.
Close all connections and handle all main dispatcher messages
to remove these leaks.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-06-01 21:47:29 +01:00
Rosen Penev
4b56942bf5 reds: Remove FOREACH_QXL_INSTANCE macro
Since the conversion to a for range loop, there's no point to this
macro.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-06-01 09:02:32 +01:00
Rosen Penev
115260e4e5 Manual algorithm changes
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-05-31 08:08:26 +01:00
Rosen Penev
8104fc3456 Manual algorithm changes
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-05-23 10:32:07 +01:00
Rosen Penev
51092046f7 Remove several usages of SPICE_N_ELEMENTS
It's simpler to just use a for range loop.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-05-23 10:01:39 +01:00
Rosen Penev
0bc7e80ec6 clang-tidy: convert C casts to C++ ones
Found with google-readability-casting

https://google.github.io/styleguide/cppguide.html#Casting

Makes the operation clearer.

This commit uses const_cast where needed.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-05-05 07:03:55 +01:00
Frediano Ziglio
8c458fa35e Fix g_memdup deprecation warning with glib >= 2.68
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-05-05 06:35:56 +01:00
Rosen Penev
5f8d49efaa clang-tidy: remove pointless move
Found with performance-move-const-arg

Allows better optimization as the compiler does not have to deal with an
rvalue reference. Especially in C++17 where std::move can prevent copy
elision.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-04-14 13:07:40 +01:00
Rosen Penev
8af176b15e clang-tidy: use nullptr
Found with modernize-use-nullptr

NULL in C++ is 0 whereas it is a void pointer in C. Avoids implicit
conversions.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-04-12 06:50:05 +01:00
Rosen Penev
24dfe33c06 clang-tidy: use const reference for loop
Found with performance-for-range-copy

Avoids unnecessary copying when the loop does not modify the variable.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-04-12 06:50:03 +01:00
Rosen Penev
fc9ca6c71a clang-tidy: do not use else after return
Found with readability-else-after-return

Easier to read.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-04-11 07:49:21 +01:00
Rosen Penev
944dc8662e clang-tidy: use auto
Found with modernize-use-auto

auto is shorter and can sometimes disambiguate pointer constness.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-04-11 07:44:42 +01:00
Rosen Penev
68b0f3029d clang-tidy: use const reference for loop
Found with performance-for-range-copy

Avoids unnecessary copying when the loop does not modify the variable.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-04-09 08:21:19 +01:00
Rosen Penev
f64e61e44d clang-tidy: use override and remove virtual
Found with modernize-use-override

This can be useful as compilers can generate a compile time error when:
	The base class implementation function signature changes.
        The user has not created the override with the correct
	signature.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-04-09 08:20:06 +01:00
Rosen Penev
76f4dc436a clang-tidy: add explicit to single argument constructors
Found with google-explicit-constructor

Explicit prevents type conversions for safety reasons.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-04-08 16:21:10 +01:00
Rosen Penev
11374b28b4 clang-tidy: remove pointless void
Found with modernize-redundant-void-arg

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-04-08 16:18:17 +01:00
Rosen Penev
9f1514b804 clang-tidy: use using
Found with modernize-use-using

Also manually removed a bunch of typedefs as they are no longer useful
in C++.

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rt-using

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-04-08 16:18:02 +01:00
Marc-André Lureau
c23cbd6fa8 reds: start QXL devices if VM is running
Like char devices, QXL devices need to be explicily started.

For some historical reason, char devices are started when in running
state. See commi bf1d9007b. Reading that commit comments, there was a
plan to provide an API to stop/start devices invidually, but that never
happened. Whether that API would really be useful now, I wonder.

For now, just follow the char devices behaviour and start QXL devices
added when vm_running.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.uuuuucom>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-01-29 10:03:24 +00:00
Julien Ropé
ca5bbc5692 With OpenSSL 1.1: Disable client-initiated renegotiation.
Fixes issue #49
Fixes BZ#1904459

Signed-off-by: Julien Ropé <jrope@redhat.com>
Reported-by: BlackKD
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-12-07 14:43:24 +00:00
Frediano Ziglio
de5c20531e reds: Check VDAgentMonitorsConfig using spice-common code
Reduce code duplication.
Also this improve support for big endian machines as
agent_check_message fix also message endianess.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-10-25 20:02:16 +00:00
Frediano Ziglio
587c04f79e Improve big endian support for agent messages
Big endian machines on server are not officially supported but won't
hurt.
Messages from client are always encoded as little endian (as all
SPICE protocol).
Convert fields from little endian to host endian on some places
where numbers are used and not just binary copied.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-10-25 20:01:54 +00:00
Marc-André Lureau
d1bea58002 reds: fix vdagent monitor flag filtering
Fixes commit 828c881bd0a8d73a5c2038bdf22cb8ae7c793482 ("agent/qxl: add
monitors physical dimensions handling").

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-09-17 06:43:48 +01:00
Frediano Ziglio
f1e89573b6 reds: Specify virtual functions override RedCharDevice functions
Remove some possible warning, like

reds.cpp:216:18: warning: 'remove_client' overrides a member function but is not marked 'override' [clang-diagnostic-inconsistent-missing-override]
    virtual void remove_client(RedCharDeviceClientOpaque *opaque);
                 ^

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-09-16 14:34:17 +01:00
Marc-André Lureau
828c881bd0 agent/qxl: add monitors physical dimensions handling
Requires
https://gitlab.freedesktop.org/spice/spice-protocol/-/merge_requests/24

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-09-14 14:35:12 +01:00
Frediano Ziglio
5223aeed32 reds: Use g_strlcpy instead of strlen/strcpy
Some compiler could generate some warning, like

reds.cpp:2678:5: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
    strcpy(buf, pass);
    ^

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Jakub Janků <jjanku@redhat.com>
2020-09-13 19:47:20 +01:00
Frediano Ziglio
dd9b78fd78 Use smart pointers for RedPipeItem
Reduces usage of manual reference counting.
Avoids usage of new and use instead red::make_shared to both
create and own pipe items.
Use move semantic to reduce useless copies.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:48:08 +01:00
Frediano Ziglio
fa404f73d8 main-channel-client: Pass directly a RedPipeItem from VDI
Provides a base class to allows RedCharDeviceVDIPort to pass
a RedPipeItem to MainChannelClient instead of having to wrap
into another item.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:47:58 +01:00
Frediano Ziglio
d55c8837f8 red-pipe-item: Add and use a small utility class for easier initialization
Most of the times each class has an associated constant so
allows to be able to define the constant at declaration time.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:47:55 +01:00
Frediano Ziglio
a30df693cf red-pipe-item: Use inheritance on RedPipeItem
This allows to:
- reuse reference counting;
- avoid having to manually call g_free to release item memory;
- assure item is initialized;
- avoids some manual casts.

It will also allows to use smart pointers.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:47:53 +01:00
Frediano Ziglio
24c8692e5f Remove useless "common/ring.h" include
Not used directly by these source files.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-29 08:56:36 +01:00
Frediano Ziglio
0acf650afa reds: Remove not used preprocessor macros
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-27 06:29:53 +01:00
Frediano Ziglio
4a34111711 reds: Avoid a "end" label just to free password
"password" is pretty small, allocate on stack directly.
RSA is currently 1024 bits, that is more or less 128 bytes.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Kevin Pouget <kpouget@redhat.com>
2020-06-26 10:06:40 +01:00
Frediano Ziglio
69640d1054 reds: Remove useless label and goto statements
Not needed anymore.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-06-25 16:09:25 +01:00
Frediano Ziglio
a10e496c46 char-device: Remove "sin" parameter from read_one_msg_from_device
Not much used, can be retrieved from the class if needed.

There are some apparent test removal on reds.cpp.
The test "if (!reds->vdagent)" apparently disappeared but it's included in
the while.
reds->agent_dev cannot be NULL as SPICE server allows only one agent and we
are into a member of an object so it must be reds->agent_dev.get() == this.
As there's only an agent and as the interface (sin) is extracted from that
agent it must be reds->agent_dev.get() == sin->st and either reds->vdagent
== sin or reds->vdagent == NULL.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-23 12:49:43 +01:00
Frediano Ziglio
479a1a74a2 Reuse RedCharDevice::read
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-23 12:49:41 +01:00
Frediano Ziglio
8875e79c7c reds: Use socket_close instead of close
socket_close is mapped to close under Unix but under Windows
you should call closesocket instead so call socket_close which
will map to the proper close function on both environments.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-06-18 16:57:50 +01:00
Frediano Ziglio
f03d094942 reds: Remove usage of "this"
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@redhat.com>
2020-06-08 10:00:43 +01:00
Frediano Ziglio
ee4cf6a07c Fix compatibility with MSG_NOSIGNAL and Darwin
Darwin does not have MSG_NOSIGNAL but allows to set a SO_NOSIGPIPE
option to disable sending SIGPIPE writing to closed socket.
Note that *BSD has the SO_NOSIGPIPE option but does not affect all
write calls so instead continue to use MSG_NOSIGNAL instead on
that systems.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-19 10:01:47 +01:00
Frediano Ziglio
fd06625ba1 red-stream-device: Better encapsulation
Remove all members public, set correct access and create
missing methods.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
1e9205a3b8 char-device: Remove GObject from RedCharDevice
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00