Commit Graph

2367 Commits

Author SHA1 Message Date
Frediano Ziglio
0c8b059fac replay: Free spice server to detect leaks
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-05 23:27:35 +00:00
Frediano Ziglio
74fa5e3fe4 Free main_dispatcher in spice_server_destroy
Avoid leaking it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-05 23:27:35 +00:00
Frediano Ziglio
492e59842a Free QXL instances in spice_server_destroy
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-05 23:27:35 +00:00
Frediano Ziglio
8dbfd4971a Free inputs_channel in spice_server_destroy
Avoid leaking this channel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-05 23:27:35 +00:00
Frediano Ziglio
e4a17a4875 Call parent finalize at the and of display_channel_finalize
Make finalization of DisplayChannel consistent with other code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-05 23:27:34 +00:00
Pavel Grunt
b53c0d368b test: Ignore too new warnings
There is an explicit check for the version

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-05 12:32:28 +00:00
Frediano Ziglio
f870f0f030 sound: Load marshaller into a variable
Reduce GObject changes coming in the next commit since we'll need to
change how we access the marshaller anyway. This will make the
following commits easier to review.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-05 12:02:59 +00:00
Frediano Ziglio
b8f06e2437 smartcard: Optimise sending data
As data is packae in a single piece of memory send it
altogether.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-12-05 11:54:12 +00:00
Victor Toso
82165c10eb display-channel: reuse function to set video codecs
Including g_clear_pointer() in glib-compat.h and using it to avoid
warnings in odd situations.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-05 11:47:37 +00:00
Frediano Ziglio
c6e8163093 dcc: Avoid to include RedChannelClient private header
Make sure we don't tamper with RedChannelClient internals.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 22:15:02 +00:00
Frediano Ziglio
f191fb4717 sound: Reuse client variable if available
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 21:54:49 +00:00
Frediano Ziglio
815da98f45 sound: Introduce a macro to cast to SndChannelClient
This make easier the transition to GObject.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 21:54:49 +00:00
Frediano Ziglio
852202a049 sound: Change AudioFrame allocation
When qemu (for example) delivers audio samples to the spice server, it
does so by requesting a buffer from the spice server
(spice_server_playback_get_buffer()), filling them with audio data, and
then calling spice_server_playback_put_samples() to send them to the
client. Between the call to _get_buffer() and the call to
_put_samples(), we need to ensure that the buffer remains valid. Since
this buffer is allocated within PlaybackChannelClient, we did this by
incrementing a ref on the PlaybackChannelClient in _get_buffer(), and
decrementing the ref in _put_samples(). This has the effect of
potentially keeping the PlaybackChannelClient alive after the spice
client has disconnected.

This was not a problem when PlaybackChannelClient was a simple helper
class. But we intend to change PlaybackChannelClient so that it
inherits from RedChannelClient. In that case, the reference taken in
_get_buffer() would result in the RedChannelClient (and associated
RedChannel, etc) being kept alive longer than expected. To avoid this,
we add an additional ref-counted adapter class (AudioFrameContainer)
that owns the allocated audio frames and can outlive the
RedChannelClient if necessary. When the client is freed, the
AudioFrameContainer is just unreferenced.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 21:54:49 +00:00
Frediano Ziglio
f301d3efc1 sound: Reuse record_client variable
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 21:54:49 +00:00
Frediano Ziglio
00a701e787 sound: Convert SndChannel to GObject
Stops using the dummy channel.
Data handling still goes through DummyChannelClient which is why
empty implementation of some required vfuncs is working.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 21:03:48 +00:00
Frediano Ziglio
98f6767483 Rearrange object destruction
Try to arrange destruction in the opposite order of the creation

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 17:38:55 +00:00
Frediano Ziglio
87f562d843 Add red_qxl_destroy function
Allows to destroy a QXL object

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 15:53:39 +00:00
Frediano Ziglio
41d52961db gstreamer: Correctly don't allow too limited bit rates
The check to limit too low bit rates was setting encoder->bit_rate
instead of bit_rate. However after some lines bit_rate was used
to set encoder->bit_rate basically removing the lower threshold.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francois Gouget <fgouget@codeweavers.com>
2016-12-02 08:39:51 +00:00
Francois Gouget
f861d2922d streaming: Stop streaming if the client reports a streaming error
By removing the stream's video encoder we force the stream to send
future frames using the fallback code, that is as regular screen
updates.
However note that we keep the stream object: we have to. Otherwise
future frames would trigger the creation of a new stream object with a
new video encoder which would again try to stream the video and fail
again and again.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Victor Toso <victortoso@redhat.com>
2016-12-02 09:02:47 +01:00
Frediano Ziglio
a605a8d4a1 sound: Rename SndWorker to SndChannel
SndWorker has been historically based on RedChannel, initial git commit
has:
struct SndWorker {
     Channel base;
     ...
};

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-01 16:59:08 +00:00
Frediano Ziglio
4867b9e76a sound: Rename {Record,Playback}Channel to *ChannelClient
Make easier to understand that they refer to client and not
all channel.

Specifically:
- RecordChannel -> RecordChannelClient
- PlaybackChannel -> PlaybackChannelClient
- playback_channel -> playback_client
- record_channel -> record_client

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-01 16:26:22 +00:00
Frediano Ziglio
9ba847c2da sound: Rename SndChannel to SndChannelClient
SndWorker has been historically based on RedChannel, initial git commit
has:
struct SndWorker {
     Channel base;
     ...
};

SndChannel, contrary to what its name may imply is more focused on
marshalling/sending of sound data, which is the responsibility of
RedChannelClient for the other SPICE channels.

This commit and following ones make the naming of these 2 types more
consistent with how the rest of the code is structured.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-01 16:26:07 +00:00
Frediano Ziglio
3961d13cd9 sound: Use worker directly
SpicePlaybackState and SpiceRecordState have same structures
changing only slightly the behaviour.
Using SndWorker instead allows some minor simplification and
more code reuse.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-01 16:09:39 +00:00
Frediano Ziglio
8da22558b7 Allows reds_core_timer_remove to accept NULL for timer
Most of the times the check is done externally
so moving inside the function reduce the code.
This is similar to the way free(3) works.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-30 17:35:41 +00:00
Frediano Ziglio
ab77c22ec5 Remove unused red_channel_get_first_socket
This function assume there is only one client.
Was used only by some obsolete functions.
Avoid to use such function in the future.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-30 17:35:41 +00:00
Frediano Ziglio
97eee5a352 Remove unused and obsolete main_channel_close
This function wrongly close the first client.
Wrongly as closing the file descriptor cause a dandling
file descriptor in the object potentially leading
to closing another file descriptor open later.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-30 17:35:41 +00:00
Frediano Ziglio
311a79155d Use red_channel_destroy to free main_channel
This will close all clients and release the channel properly

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-30 17:35:41 +00:00
Frediano Ziglio
f73e8319c6 Move some include from header to source
Now that RedStatFile is private there is no need
to include some headers in stat-file.h.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-30 15:44:28 +00:00
Frediano Ziglio
4eed0bf8ec Return invalid value from very old obsolete functions
These functions are not used since years and are not supporting
multiple clients.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-30 14:10:40 +00:00
Frediano Ziglio
cd57ce246c cursor: Avoid cursor item leak
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-30 13:03:36 +00:00
Frediano Ziglio
e1cc694a72 Avoid to leak timer in InputsChannel
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-30 13:00:12 +00:00
Frediano Ziglio
38ca3467bd Do not leak mig_timer
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-30 12:38:39 +00:00
Frediano Ziglio
af58d24f9b Free state on spice_server_destroy
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-30 12:37:20 +00:00
Frediano Ziglio
47f56a72e0 Free statistic file on spice_server_destroy
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-30 12:36:47 +00:00
Frediano Ziglio
29d6642430 sound: Unify commands
Use same constants for common commands.
This will allow code reuse between Record and Playback.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2016-11-29 12:53:06 +00:00
Frediano Ziglio
7c8272b995 Remove unused fields
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2016-11-29 12:38:43 +00:00
Frediano Ziglio
cb3216aa83 Reuse reds_core_timer_add
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-28 19:21:11 +00:00
Frediano Ziglio
afa3144de5 red_worker: add RED_WORKER_MESSAGE_CLOSE_WORKER message
Allows to close worker thread.
This will be used to destroy cleanly CursorChannel and
DisplayChannel.
CursorChannel and DisplayChannel are run in a different
thread. However deregistration of channels and different
steps of destruction should be done in the same thread
so this make possible to join again the 2 threads to
avoid race conditions.
For the moment there is no correct cleanup.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-28 19:20:09 +00:00
Frediano Ziglio
bb74d7ad47 Use LZ4_compress_fast_continue if available
This make compression faster and avoids a warning on newer
lz4 versions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-28 18:38:22 +00:00
Frediano Ziglio
f275733de3 Add a red_memslot_info_destroy function
Allows to free RedMemSlotInfo structure

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-25 14:36:40 +00:00
Frediano Ziglio
e05cf93a01 tests: Normalize test names
Use dash instead of underscores for file names. This is coherent
with rest of file names.
Rename all tests to test-XXX and remove the spice- prefix when
present. This is coherent with most of the tests.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-25 13:52:39 +00:00
Frediano Ziglio
8fcfd9a4df Rename self field to thread_id
self is usually used for GObject, avoid confusion.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-24 13:32:10 +00:00
Frediano Ziglio
867c3a734a dcc: Remove unneeded private header inclusion
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-24 13:32:02 +00:00
Francois Gouget
97fcad82eb streaming: Always delegate bit rate control to the video encoder
The video encoders already have sophisticated bit rate control code that
can react to both stream reports sent by the client, and server frame
drop notifications. Furthermore they can adjust both the frame rate and
the image quality to best match the network conditions.

But if the client cannot send stream reports all this is bypassed and
instead the streaming code performs its own primitive bit rate control
that can only adjust the frame rate.

So this patch removes the code duplication and lets the video encoders
do their job.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-21 16:47:51 +00:00
Pavel Grunt
5554b1ec95 reds: Replace strncpy with g_strlcpy
strncpy is considered unsafe

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-21 16:47:51 +00:00
Christophe Fergeau
598fb35ec5 smartcard: Remove duplicate accessor
smartcard_channel_client_get_device() is the same as
smartcard_channel_client_get_char_device(). Let's only keep the latter.
2016-11-21 14:40:47 +01:00
Christophe Fergeau
00d2c6f226 smartcard: Fix SmartcardChannelClient creation
The wrong type (RED_TYPE_CHANNEL_CLIENT rather than
TYPE_SMARTCARD_CHANNEL_CLIENT) was used when creating a
SmartcardChannelClient, which meant the _init function was never called,
and SmartcardChannelClient::priv was never initialized.

This caused a crash when trying to connect with --spice-smartcard to a
VM with a smartcard channel configured.
2016-11-21 14:40:47 +01:00
Frediano Ziglio
7615d6ae73 Avoid leaking ping_timer in MainChannelClient
This leaks happen for every connection. Potentially the timer can
be called after the client is closed causing an use after free.
Recently RED_STATISTICS was switched off by default but previous
version have this issue.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-18 12:04:43 +00:00
Pavel Grunt
21b72cd8f0 red-qxl: Remove traling semicolon
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-18 11:54:21 +00:00
Frediano Ziglio
36bf206df8 Avoid use after free
self->priv was deleted and then used

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-18 10:05:16 +00:00