Commit Graph

2339 Commits

Author SHA1 Message Date
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
Pavel Grunt
39b6b65421 Do not crash on NULL codecs
Reviewed-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-17 11:13:04 +00:00
Pavel Grunt
5c311ea8a1 Add test for codecs parsing
With Glib2.34 test invalid codec strings

Reviewed-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-17 11:12:21 +00:00
Frediano Ziglio
e31c108417 Make sure statistic file are initialized even if init is not called
This caused a NULL pointer dereference executing some tests
calling spice_server_destroy.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-17 11:08:40 +00:00
Frediano Ziglio
973cbb4df2 Revert "replay: Replicate wakeups properly"
This reverts commit c6881ad1a0.

This patch cause the replay utility run at full speed
to slow down a lot and in some cases getting stuck.
I don't understand the reason and when I tested was working
but as we are going to release would be a pity if this test utility
won't work as useful to get feedback and reports.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-17 11:03:51 +00:00
Jonathon Jongsma
a7829c9609 Fix build when builddir != srcdir
The following build error occurs when building outside of the source
directory:

glib-mkenums --template spice-server-enums.tmpl.c ../../server/spice-server.h > spice-server-enums.c
Can't open spice-server-enums.tmpl.c: No such file or directory
Makefile:1111: recipe for target 'spice-server-enums.c' failed

Make/Automake uses VPATH to determine that the spice-server-enums.tmpl.c
file listed in the prerequisites for the rule is located in the srcdir.
When we use an automatic variable (e.g. $<), the full path to the
resolved file is used. But when we use the literal filename directly
within the rule definition, this won't happen. So we need to explicitly
specify that the input template file is located in srcdir.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-16 10:47:26 -06:00
Frediano Ziglio
002c7c9eeb Make RedStatFile private inside stat-file.c
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-16 16:38:32 +00:00
Frediano Ziglio
41c042ca36 Avoid leaking file descriptor for statistics
mmap memory area will remain even if the descriptor is closed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-16 16:38:30 +00:00
Frediano Ziglio
d163f17a36 Use g_strdup_printf instead of manually malloc/snprintf
Make the code easier and shorter.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-16 16:38:27 +00:00
Frediano Ziglio
5209d33977 Add a base test for statistic file
Create a file and add/remove some nodes.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-16 16:38:24 +00:00
Frediano Ziglio
fe543c6b45 Fix node removal
Avoid to produce loop in the tree removing and adding nodes.
Unlink the node from the containing tree.
This possibly will create unlinked trees if a parent node is
deleted.

What was happening is that the creation of loops inside
the tree caused some statistical function to go into an
infinite loop (and reds_stat tool too).

Nodes were only invalidated but still linked so when reused
the new node could point to an already existing node (like a
sibling) which pointed to the new reused one.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-16 16:38:21 +00:00
Frediano Ziglio
f9ccabfaea Separate code to manage statistic file
Code is quite independent so move in separate file.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-16 16:38:13 +00:00
Pavel Grunt
99eff8500b Do not use gstreamer in default codecs if not available
Avoid the following warning when build with disabled gstreamer:
Spice-WARNING **: reds.c:3660:reds_set_video_codecs: spice: unsupported video encoder gstreamer

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-16 14:33:48 +00:00
Frediano Ziglio
1b4e8855ea Remove core_public and core_interface_adapter globals usage
Avoid not constant globals.

We started encapsulating all global state into RedsState however
there are still some global variable. This patch remove the
core_public global variable.

To implement this a new SpiceCoreInterface *public_interface
field is added to SpiceCoreInterfaceInternal and the
SpiceCoreInterfaceInternal* argument is passed to callbacks to
understand which external interface to use.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-15 16:49:09 +00:00
Frediano Ziglio
de27dc034d Handle top down bitmaps dumping
The top down flag can be specified using negative heights.

According to
https://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx:

"The height of the bitmap, in pixels. If biHeight is positive, the
bitmap is a bottom-up DIB and its origin is the lower-left corner.
If biHeight is negative, the bitmap is a top-down DIB and its origin
is the upper-left corner."

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-15 14:12:25 +00:00
Frediano Ziglio
2e34c83391 spicevmc: Remove some duplicate typedefs
These cause compiler errors using RHEL6.
These typedefs are defined in the same file some lines above.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-15 11:50:27 +00:00
Frediano Ziglio
ffb47ecd88 gstreamer: Use pthread to avoid Glib compatibility issues with RHEL6
GCond/GMutex interface is different between Glib 2.32 and
previous versions. Use pthread for compatibility.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-15 10:41:00 +00:00
Frediano Ziglio
1a68768415 sound: Remove sin field from SpicePlaybackState and SpiceRecordState
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-14 21:56:57 +00:00
Frediano Ziglio
e4a1b5a9e6 sound: Reuse code for spice_server_get_best_{record,playback}_rate
These function were really similar.
Factor out a new snd_get_best_rate to avoid code duplication.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-14 21:56:57 +00:00
Frediano Ziglio
20c984d769 sound: Move frequency field to SndWorker
This field is common to SpicePlaybackState and SpiceRecordState
which are based on SndWorker.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-14 21:56:51 +00:00
Frediano Ziglio
d1fac9e646 sound: Free worker volume in common function
The common function is supposed to clear the state of SndWorker
so clear even volume which now is in SndWorker

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-14 21:50:31 +00:00
Frediano Ziglio
b900147870 Fix header include order for some files
Include common and libraries includes before local ones as
stated by style.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-14 17:48:21 +00:00
Frediano Ziglio
eb02c0653d syntax-check: Use templates for glib-mkenums
Syntax checker complained about autoconf variable expansion used
inside Makefile.am.
This patch uses template files instead of options.
This also reduces quoting making template code more readable.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-14 17:45:32 +00:00
Frediano Ziglio
c18b696f1c Use SPICE_VERIFY macro for RHEL6 compatibility
The verify macro used currently has some problem
as it raise a warning in RHEL6.
Use new SPICE_VERIFY macro defined in spice-common
to avoid this issue.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-14 17:22:02 +00:00
Jonathon Jongsma
e86f9521db char-device: add 'self' param to vfuncs
Add a 'self' parameter to all of the char device virtual functions so
that we don't have to play games with the 'opaque' pointer.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-14 14:30:47 +00:00
Frediano Ziglio
81dbb18ccd Fix typo in comment
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-12 09:59:17 +00:00
Frediano Ziglio
37b7c6dd7a replay: Update comment
Function just return the command, has no ext_cmd parameter to fill.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-12 09:58:09 +00:00
Jonathon Jongsma
590acf3c55 Sound: change on_new_*_channel() signatures
Pass the new sound channel to these functions rather than setting
worker->connection before calling the function and expecting it to be
set when the function is called. The fewer unenforced assumptions that
must be true for a function to work properly, the easier it will be to
maintain.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-12 09:55:47 +00:00
Frediano Ziglio
eef0e07a0f sound: Peep hole optimisation
Reduce SpiceVolumeState structure size on 64 architectures
swapping the order of two fields.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-12 09:39:28 +00:00