Commit Graph

2759 Commits

Author SHA1 Message Date
Frediano Ziglio
777af4fc5d gstreamer-encoder: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-11 12:52:17 +01:00
Frediano Ziglio
81816e09e6 spicevmc: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-11 12:52:17 +01:00
Frediano Ziglio
972a878c99 stream: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-11 12:52:17 +01:00
Frediano Ziglio
02e74c86cb smartcard: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-11 12:52:17 +01:00
Frediano Ziglio
ca7d588e59 reds-stream: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-11 12:52:17 +01:00
Frediano Ziglio
c9cbbd6196 mjpeg: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-11 12:52:17 +01:00
Frediano Ziglio
cd25ff8b3b lz4-encoder: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-11 12:52:12 +01:00
Christophe Fergeau
657a1d92e8 dcc: Fix seamless migration
Since commit ef4b1bdb "red-channel-client: Prevent too tight loop
waiting for ACKs", after seamless migration, the display is no longer
updated on the client-side, even though the VM is functional (responds
to keyboard input, reconnecting the client restores the display
functionality, ...).

This is mainly caused because after migration,
red_channel_client_waiting_for_ack() will be true until
red_channel_client_ack_zero_messages_window() is called.

What happens is the following:
The dcc is created, and dcc_start() pushes a RED_PIPE_ITEM_TYPE_SET_ACK
message.
This calls prepare_pipe_add(), which will enable write event on the dcc
watch. red_channel_client_event() will be called, which will trigger a
red_channel_client_push(). Since red_channel_client_waiting_for_ack()
returns true, we won't get any item to push, and (because of commit
ef4b1bdb), we will disable write notifications on the watch.
At this point, rcc->priv->pipe is no longer empty, so prepare_pipe_add()
is not going to reenable the write notifications.

Then red_channel_client_ack_zero_messages_window() is finally called as
part of dcc_handle_migrate_data(), so from this point on,
red_channel_client_waiting_for_ack() is no longer true.

However, nothing ever reenables WRITE events, nor empties
rcc->priv->pipe, so nothing ever gets pushed, causing no display updates
at all after a migration, even if the VM is functional (input, ...)
apart from that.

This commit reenables WRITE events in
red_channel_client_ack_zero_messages_window() if we were waiting for
ack.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-10-10 12:35:59 +02:00
Frediano Ziglio
78f1381f14 gl: fix client mouse mode
Since 2.8, QEMU no longer creates QXL primary surfaces when using GL.
This change broke client-side mouse mode, because Spice server relies on
having a primary surface.

When GL is enabled, use GL scanout informations.
Mouse mode is always client when GL surfaces are used.

This patch and most of the message are based on a patch from
Marc-André Lureau, just moving responsibility from reds to RedQxl.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
2017-10-04 10:57:39 +01:00
Christophe Fergeau
67484cd98b tests: Automatically determine free port to use
Currently, the port used by most tests is hardcoded to 5912. However,
the test suite can be run in parallel, so if 2 tests run in parallel,
the 2nd one is not going to be able to bind to port 5912 and will fail.

After this commit, test_new() will try to find a free port between 5912
and 5922 and will abort if it can't find any.

The issue can be reproduced by adding a usleep(1000000) to the beginning
of test_destroy().

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-09-21 17:32:23 +02:00
Frediano Ziglio
5ccad96671 Use GLib memory functions for RedsMigSpice::cert_subject
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-19 16:17:11 +01:00
Frediano Ziglio
b4e05a0398 reds: Use GLib memory functions for RedServerConfig
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-19 16:17:11 +01:00
Frediano Ziglio
f6af788540 reds: Use GLib memory functions for RedServerConfig::mig_spice
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-19 16:17:11 +01:00
Frediano Ziglio
5c4df2f6c3 Use GLib memory functions for RedsMigSpice::host
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-19 16:17:11 +01:00
Frediano Ziglio
30205766b6 reds: Use GLib memory functions for migration data
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-19 16:17:11 +01:00
Frediano Ziglio
e1a8571cea reds: Use GLib memory functions for link
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-19 16:17:11 +01:00
Frediano Ziglio
7922e8c78e reds: Start using GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-19 16:17:11 +01:00
Frediano Ziglio
0da0673bd3 sound: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-19 16:17:11 +01:00
Frediano Ziglio
8626f5bf3e image-encoders: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-19 16:17:10 +01:00
Frediano Ziglio
a99043771a Start using GLib memory allocation
Start reducing the usage of spice_new*/spice_malloc allocations.
They were designed in a similar way to GLib ones.
Now that we use GLib make sense to remove them.
However the versions we support for GLib can use different memory
allocators so we have to match g_free with GLib allocations
and spice_* ones (which uses always malloc allocator) with free().
This patch remove some easy ones.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-19 16:17:10 +01:00
Frediano Ziglio
1de104acfe tests: Add a test to check tight loop during ack waiting
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-19 10:50:39 +01:00
Frediano Ziglio
0952af6bee Introduce a macro to help declaring new GObject
The macro will implement most of the boilerplate needed to declare an
object.
Its usage is similar to GLib G_DECLARE_*_TYPE macros.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-19 10:50:37 +01:00
Frediano Ziglio
ef4b1bdb27 red-channel-client: Prevent too tight loop waiting for ACKs
RedChannelClient has a "handle-acks" feature.
If this feature is enabled, after the configured number of messages it
waits for an ACK from the client.
If is waiting for an ACK it stops sending messages.
However the write notification was not disabled, causing the loop event
to always trigger, as the socket in this case is ready to accept data.
Specifically red_channel_client_event is continuously called.
This is noticeable using slow network environments and having
some additional loop instrumentation.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-19 10:50:32 +01:00
Frediano Ziglio
3da560ae0b red-channel-client: Introduce a helper to update watch event mask
This helper will be reused by following patch.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-19 10:50:30 +01:00
Frediano Ziglio
723c6d5fc0 red-qxl: Reuse red_qxl_async_complete
Now that the function is a wrapper reuse it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-18 17:49:25 +01:00
Frediano Ziglio
eb6c8ba025 red-qxl: Remove AsyncCommand
This structure was used to store the cookie for the async
reply and the message for the generic async callback.
Most async messages do not require extra action beside sending back the
cookie for the reply so instead of having a switch on the message type
in red_qxl_async_complete, this commit moves the message-specific
behaviour to the callers, which allows us to store the cookie directly
in RedWorkerMessageAsync rather than needing an intermediate
AsyncCommand structure.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-18 17:49:25 +01:00
Frediano Ziglio
b524bec574 channel-client: Remove red_channel_client_pipe_add_tail_push
Now the push is done automatically when a PipeItem is added
(cfr commit 5c460de1a3
"worker: push data when clients can receive them"),
forcing a push cause only network fragmentation and is required only if
you are handling data in a polling loop (and thus, you are preventing
the default event loop from running).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-18 17:46:37 +01:00
Christophe Fergeau
f49f04f2be channel: Fix leak in red_channel_remove_client
It was using g_list_remove_link() to remove an element from the
RedChannel::clients list while it really meant to be using
g_list_delete_link() which frees the memory associated with the link.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-09-18 16:30:39 +01:00
Frediano Ziglio
328a4a9b28 tests: Rename stat-main.c to test-stat.c
All main test module have this test-XXXX.c naming, make
test-stat coherent.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-18 13:50:26 +01:00
Frediano Ziglio
c64fe795c9 tests: Separate Makefile.am in sections
Put non-trivial programs in separate sections, which makes it easier to
understand the relationship between macros.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-18 13:49:40 +01:00
Frediano Ziglio
ddec15dea9 tests: Ignore test output results
New automake test harness produce *.log and *.trs files for
each test.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-18 13:15:57 +01:00
Frediano Ziglio
46ede1f83c smartcard: Fix typo in comment
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-18 10:45:28 +01:00
Frediano Ziglio
6ab80b19fa stream: Simplify FOREACH_STREAMS macro
This macro is exactly doing what RING_FOREACH just passing streams
ring.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <cdupontd@redhat.com>
2017-09-13 11:24:08 +01:00
Christophe Fergeau
1e43272ba1 channel: Remove no longer used red_channel_apply_clients{_data,}
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-09-12 18:19:33 +02:00
Christophe Fergeau
1b7fca87b6 channel: Remove red_channel_client_disconnect_if_pending_send()
There is exactly one user in RedChannel, and this can be reimplemented
using already public RedChannelClient API. No need for an extra
function very specialized function with a not great name.

This commit thus removes one method from RedChannelClient public API,
and replaces it with an equivalent private helper in RedChannel.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-09-12 18:19:33 +02:00
Christophe Fergeau
685a6288f3 channel: Call red_channel_disconnect_if_pending_send() from red_channel_wait_all_sent()
red_channel_disconnect_if_pending_send() and red_channel_wait_all_sent() are
always called together, we can remove one of the 2 methods.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-09-12 18:19:33 +02:00
Frediano Ziglio
3dc6bc76f1 tests: Avoid to disable all deprecation warnings just for expect functions
In case GLib don't provide these functions we use replacements so
there's no need to have a warning if these functions are called.
This potentially capture other compatibility issues in the tests
that would be ignored having all deprecation warnings disabled.
Tested with GLib 2.28 and 2.52.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-12 14:17:53 +01:00
Frediano Ziglio
08dd9c4f48 red-worker: Start processing commands as soon as possible
When the worker is started it could take a while to start processing
commands.
The reason is that the dispatcher handler is called after the worker
so GLib will receive a FALSE answer to both prepare and check
callbacks of the RedWorkerSource causing GLib to wait till another
event is received.
This is a regression since the introduction of GLib event loop, before
the command processing was always attempted after any events.
Commands (from QXL interface for cursor and display) are processed
during the RedWorkerSource dispatch so if they are not processed just
when the VM is started they will be processed on next event which
could be from dispatcher (main thread requests), from existing
connections or from pending timers. However in the case there are no
clients connected and no other requests from main thread the worker
thread won't process them.
Setting the event_timeout to 0 cause the prepare callback to return
TRUE so GLib will dispatch the RedWorkerSource.
This was discovered attempting to use the tests in server/tests
directory to reproduce a leak in RedWorker.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-12 14:15:39 +01:00
Frediano Ziglio
14828bfdfc test-gst: Free pipelines
Pipelines are never freed.
These are detected as leaks by leak detector tools like address sanitizer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-12 13:08:10 +01:00
Frediano Ziglio
9bb2388f75 test-gst: Remove options parsing leaks
Command line options are not freed at the end of the program.
These are detected as leaks by leak detector tools like address sanitizer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-12 13:08:10 +01:00
Frediano Ziglio
f35843ee6f test-gst: Remove useless check
encoder_name is never NULL as already initialized with "mjpeg" value.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-12 13:07:51 +01:00
Frediano Ziglio
2e06a6e940 reds: Fix leaks if reds_init_client_ssl_connection fails
If a client is unable to complete the TLS handshake phase
reds_init_client_ssl_connection leaked some memory as the stream is not
correctly freed.
This also causes the stream to send the SPICE_CHANNEL_EVENT_DISCONNECTED
event. Otherwise only SPICE_CHANNEL_EVENT_CONNECTED was sent.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-12 11:58:40 +01:00
Frediano Ziglio
8856d518ee tests: Check leaks in spice_server_add_ssl_client
Currently is possible to trigger a leak by passing an invalid
connection.
This can happen if the client opens a connection and then closes it
without writing or reading any data.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-12 11:58:01 +01:00
Frediano Ziglio
1c83deea98 red-channel-client: Early check for valid stream
The code tests for the presence of RedChannelClient::stream while
initializing RedChannelClient.
However, the check was done too late, and a
RedChannelClient::config_socket implementation (for example
snd_channel_client_config_socket) could have tried to use it before the
check that it's not NULL.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-12 08:54:39 +01:00
Frediano Ziglio
b84d5d0124 mjpeg: Reuse realloc instead of implementing it manually
This potentially can also save the copy if there is enough
space to resize the buffer in place.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-11 21:05:50 +01:00
Frediano Ziglio
d9bb9abb9e reds-stream: Remove shutdown field
This field was used only by RedChannelClient to mark when the socket
was shutdown. This condition can simply be tested by RedChannelClient
checking if there's a watch as is the only condition (beside object
destroying/disconnecting) where the watch is removed.
In any case the shutdown was used to understand if there were possible
data still to read.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-11 21:03:25 +01:00
Frediano Ziglio
b3d239012a red-qxl: Remove unused includes
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-08 16:51:27 +01:00
Frediano Ziglio
3d5859043b red-qxl: Move private declarations to red-worker.h
RedQxl and RedWorker are quite bound together running
CursorChannel and DisplayChannel in a separate thread
marshalling (RedQxl) and unmarshalling and executing
(RedWorker) requests.
Make the communication between them private trying
to facilitate maintaining these two files.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-08 16:51:25 +01:00
Jonathon Jongsma
5a1a6b24af RedChannel: Remove obsolete TODO comment
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-09-08 08:21:59 +01:00
Jonathon Jongsma
a4450f928d Add documentation for Dispatcher 2017-09-07 11:12:45 -05:00