3346 Commits
Author SHA1 Message Date
Volker Rümelin 7bef4a939a 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 <[email protected]>
Acked-by: Frediano Ziglio <[email protected]>
(cherry picked from commit a5d1d957d6c16e3fe213e10d0cab4bfe2504ba91)
2026-09-22 18:54:27 -05:00
osy 02cae4922d red-qxl: remove cookie assertion on scanout
The original check ensures we do not have an outstanding GL_DRAW. However,
in QEMU, there is no guarantee that a scanout cannot happen while the async
GL_DRAW has not returned a result yet. This introduces a race where if a
scanout is called while there is an outstanding GL_DRAW, QEMU will crash.

The removal of this check enforces a new contract with the SPICE client.
Every GL_DRAW must be matched with a GL_DONE (i.e. with a call to
`spice_display_channel_gl_draw_done()` in the client) even if the render
context is no longer valid. Otherwise, the assertion crash will happen in
the next call to `spice_qxl_gl_draw_async()`.
2022-12-18 23:20:48 -08:00
osy e32a7ea615 gstreamer-encoder: work without Orc
If Orc is missing, GStreamer will still work.
2022-03-04 20:43:23 -08:00
osy a411fbcb32 reds: always send monitors config
When the Windows VDagent sees a new monitor config, it will trigger a
refresh of the display resolution. This is needed when the device driver
does not have the capability to see the resolution change directly from
QEMU (for example VirtIO GPU) and depends on VDagent to see the change.
2022-03-04 20:43:23 -08:00
osy 740fb04a95 meson: fix build on Darwin 2022-03-04 20:43:19 -08:00
osy 2e6271dbba red-stream: disable socket_set_cork() on Darwin
TCP_NOPUSH is broken and cannot be used.
2022-03-04 19:17:58 -08:00
Frediano Ziglio f93264cb49 Fix compatibility with TCP sockets and Darwin
Using socket pairs and trying to set a TCP level option on the
socket setsockopt returns EINVAL error and not ENOTSUP as
expected.
Check this case and handle as ENOTSUP (ignoring it).

Signed-off-by: Frediano Ziglio <[email protected]>
2022-03-04 19:09:09 -08:00
Frediano Ziglio eb21efe8e5 Fix compatibility with ENOTSUP and Darwin
Darwin uses also the constant EOPNOTSUPP for the same reasons.
In some versions EOPNOTSUPP is defined as ENOTSUP.
Check both values, not only ENOTSUP.

Signed-off-by: Frediano Ziglio <[email protected]>
2022-03-04 19:09:03 -08:00
Frediano Ziglio 20e058fd9b Fix compatibility with TCP_KEEPIDLE and Darwin
Darwin uses for the same setting the TCP_KEEPALIVE option.
Use TCP_KEEPALIVE instead of TCP_KEEPIDLE for Darwin.

Signed-off-by: Frediano Ziglio <[email protected]>
2022-03-04 19:08:57 -08:00
Frediano Ziglio c3ca9e8db1 Fix compatibility with pthread_setname_np and Darwin
On Darwin pthread_setname_np accepts only an argument and
set current thread name.

Signed-off-by: Frediano Ziglio <[email protected]>
2022-03-04 19:08:46 -08:00
Frediano Ziglio c74ae160e3 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 <[email protected]>
2022-03-04 19:08:40 -08:00
Frediano Ziglio 4c589e01fb Use local variable to compute gradual score
Due to aliasing using pointers lead to some sub-optimization.
Use local variable and then write them to output to improve performances.

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Julien Rope <[email protected]>
2020-02-27 07:55:43 +00:00
Victor Toso 9e29b72461 red-channel: no need to call g_type_init()
Since 03d46e9e "build-sys: Raise glib requirement to 2.38" in
2019-02-05

Signed-off-by: Victor Toso <[email protected]>
Acked-by: Frediano Ziglio <[email protected]>
2020-02-26 13:01:51 +00:00
Victor Toso 0b1a87a6d0 Remove unused code since glib bump to 2.38
g_assert_null, g_assert_true and g_assert_false are all defined in
GLib 2.38

Signed-off-by: Victor Toso <[email protected]>
Acked-by: Frediano Ziglio <[email protected]>
2020-02-26 13:01:48 +00:00
Victor Toso e7a2a86779 tests: remove test-glib-compat.c
Basically not run since 03d46e9e "build-sys: Raise glib requirement to
2.38" in 2019-02-05

Signed-off-by: Victor Toso <[email protected]>
Acked-by: Frediano Ziglio <[email protected]>
2020-02-26 13:01:46 +00:00
Victor Toso 7848ee3faf Remove glib-compat.h
Not used since 03d46e9e "build-sys: Raise glib requirement to 2.38" in
2019-02-05

Signed-off-by: Victor Toso <[email protected]>
Acked-by: Frediano Ziglio <[email protected]>
2020-02-26 13:01:43 +00:00
Frediano Ziglio b939e70d9c red-record-qxl: Write record file in the same format under Windows
The record file uses fprintf to record commands and attributes.
On Windows line terminator uses ASCII format ("\r\n") while on
Linux it used UNIX format ("\n"). Open file as binary to use the
same line terminator on both systems.

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Francesco Giudici <[email protected]>
2020-02-26 12:50:27 +00:00
Frediano Ziglio 9bc0aa76f6 red-client: Minor simplification for red_client_get_channel
Remove "ret" variable and just return the value

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Julien Rope <[email protected]>
2020-02-07 17:52:05 +00:00
Frediano Ziglio 1ce119009a Do not crash if channel clients cannot be created
Channel client creation can fail in some situation.
For instance if during a migration the client is disconnected.
In most cases this is ignored (this is usually logged in
red_channel_client_initable_init) but not in case of
CursorChannelClient and StreamChannelClient.

This fixes rhbz#1788757.

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Julien Rope <[email protected]>
2020-02-07 14:57:36 +00:00
Frediano Ziglio 7026f12c1b reds: Small style change in reds_marshall_migrate_data
Store computed value in a variable to shorten code.

Signed-off-by: Frediano Ziglio <[email protected]>
2020-02-06 17:42:34 +00:00
Frediano Ziglio 9d9f4946b8 reds: Reuse "sin" variable
reds->vdagent was just set to "sin".

Signed-off-by: Frediano Ziglio <[email protected]>
2020-01-25 16:59:22 +00:00
Frediano Ziglio f3a97a001b char-device: Use red_char_device_get_device_instance to retrieve character instance
Signed-off-by: Frediano Ziglio <[email protected]>
2020-01-24 21:12:39 +00:00
Frediano Ziglio 1e13fb13c7 test-smartcard: Test invalid reader closes the channel
Signed-off-by: Frediano Ziglio <[email protected]>
2020-01-24 18:31:14 +00:00
Frediano Ziglio ad94d91017 red-channel-client: Reuse red_channel_client_shutdown
red_channel_client_shutdown remove the watch and shutdown the
socket. Reuse in red_channel_client_disconnect.
Calling shutdown will close the connection earlier.

Signed-off-by: Frediano Ziglio <[email protected]>
2020-01-16 13:54:52 +00:00
Frediano Ziglio 321caf8760 char-device: Add a comment to red_char_device_write_buffer_free
It's a bit surprising that buf is not freed too so explain it.

Signed-off-by: Frediano Ziglio <[email protected]>
2020-01-16 13:47:00 +00:00
Frediano Ziglio 5bcfc2b5d5 char-device: Allow send_msg_to_client callback to be NULL
Mostly of the callback dealing with sent messages and tokens
can be NULL.

Signed-off-by: Frediano Ziglio <[email protected]>
2019-12-19 12:33:16 +00:00
Frediano Ziglio 8ec691f056 char-device: Allow to more safely and quickly get device instance
This information is retrieved multiple time.
Avoid to use just g_object_get which is dynamic so potentially
unsafe and slow.

Signed-off-by: Frediano Ziglio <[email protected]>
2019-12-16 15:06:44 +00:00
Frediano Ziglio 5f02dff835 red-client: Automatically set MainChannelClient
This make sure that the RedClient has always an attached
MainChannelClient.

Signed-off-by: Frediano Ziglio <[email protected]>
2019-12-11 12:47:46 +00:00
Frediano Ziglio 59be4f19c4 red-client: Make sure MainChannelClient is freed as last
MainChannelClient is used by other clients to store some data
so should not disappear if other clients are still present.
Keep a owning reference to it and release after RedClient is
released.

Signed-off-by: Frediano Ziglio <[email protected]>
2019-12-11 12:47:46 +00:00
Frediano Ziglio 2e1684eb66 red-client: Avoid stale channel client after disconnection
Disconnecting a single channel from the client caused the server to
keep a stale channel client (RedChannelClient object) till the client
(RedClient object) entirely disconnected, that is the channel client
is disconnected but still in the list preventing new connections.
Calling red_client_remove_channel from red_channel_client_disconnect
fixes this last issue.
An issue was that was not clear how the ownership were managed. When
red_client_destroy was called red_channel_client_destroy was called
which freed the RedChannelClient object so this should imply
ownership.
However same red_channel_client_destroy call was attempted by
RedChannel using its list (red_channel_destroy). Basically the two
pointers (the one from the channel and the one from the client) were
considered as one ownership. To avoid the confusion now the client
list always decrement the counter.

Signed-off-by: Frediano Ziglio <[email protected]>
2019-12-11 12:47:46 +00:00
Frediano Ziglio f4a387f60d red-client: Protect concurrent list accesses
The channels list was not protected by a lock in red_client_destroy.
This could cause for instance a RedChannelClient object to be
created while scanning the list so potentially modifying the
list while scanning with all race issues.

Consider a client which attempt to connect to a new channel and
then for some reason close the main channel:
- the new channel connection is handled by the main thread;
- the relative RCC will be passed to red_channel_connect which
  can decide to continue the initialization in another thread
  (this happens currently for CursorChannelClient and
  DisplayChannelClient);
- the main thread will catch the main channel disconnection and
  call main_dispatcher_client_disconnect
  (from main_channel_client_on_disconnect);
- main thread calls reds_client_disconnect;
- reds_client_disconnect calls red_client_destroy;
- now we have 2 thread which will attempt to change RedClient::channels
  list, one protected by the mutex the other not.

Signed-off-by: Frediano Ziglio <[email protected]>
2019-12-11 12:47:41 +00:00
Frediano Ziglio 7887b1bb8e reds: Remove unused mess_pos field
Signed-off-by: Frediano Ziglio <[email protected]>
2019-12-06 15:04:18 +00:00
Frediano Ziglio cff9d951aa red-channel-client: Always enable latency monitor to keep tcp connection alive
Create some traffic on the connection to avoid potential timeout
on some proxies implementation which require some TCP data traffic.
The timeout used by default is quite big (5 minutes) to reduce network
traffic.
In case connectivity monitoring is enabled or latency monitor is
requested the timeout is reduced to the old default.

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Uri Lublin <[email protected]>
2019-12-04 16:28:24 +00:00
Frediano Ziglio 07200c8c1d red-channel-client: Allows to change timeout for latency_monitor
This is a preparatory patch.
The "latency_monitor" feature allows to measure the latency of a
specific channel client.
Currently the measure is attempted every PING_TEST_TIMEOUT_MS which
is a constant.
To be able to use a different frequency allows to change this for every
channel client.
This feature will be also used to create some traffic on the connection
to allows some sort of keep-alive to overcome some proxy implementation
which requires some TCP data traffic.

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1719736.

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Uri Lublin <[email protected]>
2019-12-04 16:28:24 +00:00
Frediano Ziglio 51d94040b2 red-channel-client: Fix typo in comment
Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Uri Lublin <[email protected]>
2019-12-04 12:15:56 +00:00
Frediano Ziglio 2ca660a2f9 stream-channel: Remove default property
"monitor-latency" is FALSE by default.

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Uri Lublin <[email protected]>
2019-12-04 12:15:56 +00:00
Frediano Ziglio 3b9d1eadf7 red-channel-client: Fix indentation
Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Uri Lublin <[email protected]>
2019-12-04 12:15:56 +00:00
Frediano Ziglio ac41e6097a red-channel-client: Reuse "monitor" variable
"&rcc->priv->connectivity_monitor" is cached in "monitor" variable.

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Uri Lublin <[email protected]>
2019-12-04 12:15:56 +00:00
Frediano Ziglio 0fc5af3a06 Do not check for NULL calling red_watch_remove and red_timer_remove
These functions already check for NULL.
They are used mainly for cleanup, so cold path of code so speed
in case of NULL is not important (and usually should not be NULL).

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Uri Lublin <[email protected]>
2019-12-04 12:15:56 +00:00
Frediano Ziglio 250d4480ff red-channel-client: Reduce indentation in red_channel_client_handle_outgoing
When write fails, all cases of the switch are handled.
Make this clear.

Signed-off-by: Frediano Ziglio <[email protected]>
2019-12-04 12:15:56 +00:00
Frediano Ziglio 7f501b0df1 ci: Fix a typo in comment
Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Uri Lublin <[email protected]>
2019-11-26 09:22:14 +00:00
Frediano Ziglio 9480df32fe ci: Disable leak error from Valgrind
For some reason under Fedora 31 the g_socket_client_connect call
from test-listen test caused Valgrind to detect a leak.
Note that the like at gtype.c (g_socket_client_connect) specifically
marks a memory block as malloc-like. Not sure if it's an issue
with Valgrind or with GLib, as a workaround disable the leak report.

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Uri Lublin <[email protected]>
2019-11-25 16:58:13 +00:00
Frediano Ziglio d0614859cf ci: Fix for test-listen leak detection
This suppression was present in former glib.supp version however
the suppression in glib.supp was updated to only catch "reachable"
leaks.
However in test-listen test the allocation is done in a thread
causing the leak to become "definite".

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Uri Lublin <[email protected]>
2019-11-25 16:58:11 +00:00
Frediano Ziglio 80f16f2f26 ci: Update glib.supp file
Sync with Glib master file.

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Uri Lublin <[email protected]>
2019-11-25 16:58:06 +00:00
Frediano Ziglio 34455d47a9 build: Cleanup old library flags
OpenGL and Slirp requirement were removed much time ago.
OpenGL was removed by c5c176a5c7
(cfr "server: remove OpenGL", Set 2013).
Slirp was removed by ef9a8bf053
(cfr "Remove tunneling support", Oct 2013).

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Eduardo Lima (Etrunko) <[email protected]>
2019-11-25 13:20:18 +00:00
Rosen Penev 1921d57160 reds: Fix compilation without deprecated OpenSSL 1.0.2 APIs
The threading API for 1.0 was replaced with the THREADID API.

Signed-off-by: Rosen Penev <[email protected]>
Acked-by: Frediano Ziglio <[email protected]>
2019-11-06 08:59:13 +00:00
Rosen Penev 5bc932f7a7 reds: Fix compilation without deprecated OpenSSL 1.1 APIs
Missing headers for BN_ and RSA_ functions.

Initialization is deprecated with 1.1.

Signed-off-by: Rosen Penev <[email protected]>
Acked-by: Frediano Ziglio <[email protected]>
2019-11-06 08:59:13 +00:00
Frediano Ziglio cfdb255b41 smart-channel-client: Remove spicec client reference from comment
spicec is an obsolete client.

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Victor Toso <[email protected]>
2019-10-21 09:14:29 +01:00
Frediano Ziglio 5308ab84b9 event-loop: Change internal core interface
Allow to modify/cancel timers/watches without having to retrieve
the code interface.
This will make sure that you are not using the wrong interface.
Simplify code to deal with timers/watches.
Remove the requirement to have the core interface available
for removing timers/watches.

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Victor Toso <[email protected]>
2019-10-10 10:55:52 +01:00
Frediano Ziglio 97d2d1f129 event-loop: Move adapter interface from reds.c
Put more event loop code in event-loop.c.
This is a preparation patch for the next one.

Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Victor Toso <[email protected]>
2019-10-10 10:55:38 +01:00