Commit Graph

3384 Commits

Author SHA1 Message Date
Frediano Ziglio
9af182b67a red-channel: Move alloc_recv_buf and release_recv_buf to RedChannelClient
These vfuncs are more appropriate in RedChannelClient.
The buffer they allocated are related to the client stream
which is managed directly by RedChannelClient.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-04 14:58:15 +00:00
Frediano Ziglio
68c3e1f51d Introduce CommonGraphicsChannelClient
This prepare for the next patch.
The network recieve buffer should be per-client rather than per-channel.
The following patch will make this change, but this common base class
will allow the cursor client and the display client to share a common
implementation.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-04 14:58:05 +00:00
Frediano Ziglio
62f961624a sound: Remove header dependency
Sound code is not using Qxl interface.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-04 01:06:35 +00:00
Frediano Ziglio
5c0c9c6975 red-channel: Move byte statistic to RedChannelClient
As the counters are shared there is no reason why not
handling the byte count from RedChannelClient directly.
This remove a dependency and avoid some function calls.
The only visible difference at user level is that the
counters are created when a client connects.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-04 01:04:44 +00:00
Frediano Ziglio
256479c53c red-channel-client: Add message counters to statistics
Show messages sent to clients.
This is useful to understand the message number as an high
message number can affects performance and is not easy to
understand the message count from the byte count (which is
available).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-04 01:04:30 +00:00
Frediano Ziglio
a22a76371e tests: Reuse GLib compatibility code
Instead of disabling the code use the compatibility functions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-03 16:49:43 +00:00
Frediano Ziglio
73f8a65d06 tests: Move some specific GLib compatibility to compatibility file
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-03 16:49:41 +00:00
Frediano Ziglio
b7a7ed3900 tests: Move some glib compatibility code to a separate file
Allow to reuse this code in other tests.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-03 16:49:36 +00:00
Frediano Ziglio
cf3a9183a4 Use variable values instead of computing again
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-03-03 15:32:38 +00:00
Victor Toso
5ba0bc6663 dcc: handle preferred video codec message
[0] SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE

This message provides a list of video codecs based on client's order
of preference.

We duplicate the video codecs array from reds.c and sort it using the
order of codecs as reference.

This message will not change an ongoing streaming but it could change
newly created streams depending the rank value of each video codec
that can be set by spice_server_set_video_codecs()

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-02 17:48:17 +00:00
Frediano Ziglio
0bbfe733b8 record: Allocate recording file globally from reds.c
Allows to use recording function for multiple purposes.
This will allow to register multiple screen VM or recording
additional stuff like sound.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-02 16:14:10 +00:00
Frediano Ziglio
ab6ace6b66 record: Use reference counting for recording
Allows to share the recording object.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-02 15:37:40 +00:00
Frediano Ziglio
e0a5e4f0d0 record: Synchronize write to record file
The synchronization code is required to avoid mixing writing
from multiple threads.
Following patches will add this feature.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-02 15:37:40 +00:00
Frediano Ziglio
afc4171c98 red-channel: Use RedChannelCapabilities directly to pass capabilities
For each channel there are two set of capabilities, one
for the common ones and one for the specific ones.
A single set were almost always passed using 2 arguments,
a number of elements and an array but then before using
these were converted to a GArray.
Use a single structure (already available) to pass all
channel capabilites using a single argument.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-02 15:34:58 +00:00
Frediano Ziglio
89a722ce03 red-channel: Separate RedChannelCapabilities
Add function to initialize and destroy this type.
Add GType type for boxing it.
These changes a in preparation for next patch.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-02 15:32:16 +00:00
Frediano Ziglio
5b3f79f8a7 red-channel-client: Make capabilities property write only
These properties are not read and code is broken (the content of
the array would be uninitialized).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-02 11:55:02 +00:00
Frediano Ziglio
b2d1a38d13 red-channel: Remove unused type definition
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-02 11:51:35 +00:00
Frediano Ziglio
cdd1e69b28 main-dispatcher: Remove watch leak
Watch was added but never removed.
The added basic_event_loop_destroy() addition allows to see that
this leak is gone).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-02 11:15:28 +00:00
Christophe Fergeau
be4ceb4e24 test-vdagent: Make test case more useful
This switches the test to using the GTest API, and add several tests
related to https://bugzilla.redhat.com/show_bug.cgi?id=1411194

This uses some API not available in glib 2.28, so this checks we have a
new enough glib before building this test, and disables warnings when
using too new glib API when building it.

The "multiple-vmc-devices" is based off code written by Frediano Ziglio.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-01 18:02:37 +01:00
Christophe Fergeau
4633ea6d87 Use spice_debug rather than spice_info in library code
Using spice_info() gets in the way of tests using
g_test_expect_message() as all the messages emitted using
a non-debug log level must be listed as expected, otherwise we get a
critical about an expected message not having been logged.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-01 18:01:25 +01:00
Christophe Fergeau
2650867f30 reds: Close sockets when using spice_server_destroy()
Currently, the network sockets opened by reds_init_net() are not closed
on destruction, in other words they are leaked.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-03-01 18:00:27 +01:00
Christophe Fergeau
c8f8ea2224 test: Add test_destroy()
This allows to chain several test cases by using
test_new()/test_destroy().

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-03-01 18:00:27 +01:00
Frediano Ziglio
f66b7bffc7 tests: Add basic spice_server_init()/spice_server_destroy()
This can be used for very basic leak checks.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-01 16:06:57 +00:00
Frediano Ziglio
a6f7aeb5d8 reds: Free remaining configuration
Free security, migration, sasl and name stuff.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-01 16:06:51 +00:00
Frediano Ziglio
67b1513f87 display-channel: Clean more stuff on finalize
Release surfaces, cache and monitor configurations.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-28 23:10:31 +00:00
Frediano Ziglio
e4d06191ee stream: Remove region leak
clip_in_draw_dest was not freed correctly.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-28 23:05:39 +00:00
Frediano Ziglio
0b39aecb26 reds: Check that we do not free the wrong agent device
Do not assume the device passed as an argument to
spice_server_char_device_remove_interface() is the same as the current
Reds::vdagent instance. This commit adds a check that this is the case,
and returns early if not.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-28 16:35:49 +00:00
Frediano Ziglio
0d76ad8b5b Remove reds_stream_set_info_flag
Encapsulate into reds_stream_set_channel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-28 14:20:52 +00:00
Frediano Ziglio
47ba429a8f spicevmc: Use spice_new instead of spice_malloc
spice_new is a bit more safe as return a properly typed pointer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-28 14:17:56 +00:00
Frediano Ziglio
9855eebd2f sound: Avoid unused IOV_MAX definition
The usage was removed with commit 7ea1f2c133
("sound: Use RedChannelClient to receive/send data").

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-02-28 14:15:56 +00:00
Frediano Ziglio
7e395c3984 style: Change boolean style convention
Following
https://lists.freedesktop.org/archives/spice-devel/2017-February/035800.html
, the consensus was to use 'bool' rather than 'gboolean', and to use
true/false rather than TRUE/FALSE. New code should attempt to follow
the new style.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-27 12:35:25 +00:00
Christophe de Dinechin
be727eb822 Remove X == TRUE tests for non-boolean values
Using X == TRUE is fragile, since the input value is a uint8_t. It would be
surprising if the value was set to 2 or 0xFF and the test failed.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-27 12:00:52 +00:00
Frediano Ziglio
5277ac8921 style: Group together indentation sections
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-27 11:53:37 +00:00
Frediano Ziglio
73e6d88b20 Fix minor inconsistencies with declaration and definition
Declaration used gboolean while definition used int.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-02-16 10:28:52 +00:00
Frediano Ziglio
4838f317a9 rcc: Make some functions/macros private
Some constants/macros/function prototypes are defined in
red-channel-client.h while they are only used by red-channel-client.c.
This commit moves them to the .c file to make them private.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-15 16:49:50 +00:00
Frediano Ziglio
10654d34a4 rcc: Remove unused RedChannelClient::{is_connected,disconnect} vfuncs
RedChannelClient is responsible for talking to the client so it knows
if is connected or not.
These vfuncs where used by DummyChannel used by SoundChannel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-15 16:49:34 +00:00
Frediano Ziglio
fb4fe2d832 rcc: Use class name in comment
red_channel seems a variable name.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-15 16:49:26 +00:00
Frediano Ziglio
9724381afa Make RedChannel::config_socket() optional
Most channels don't need to do specific settings for the client socket
so avoid the need to do this setting making easier to setup the client
channnel.

Some improvements and commit subject suggested by Christophe Fergeau.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-15 12:40:38 +00:00
Frediano Ziglio
01c25074dc Do not set TCP_NODELAY flag twice
TCP_NODELAY flag is set by default for all connection inside
reds.c so there's no need to set again for the single
client channel.

Note that there are still some calls to setsockopt to change this
option.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-15 12:38:30 +00:00
Frediano Ziglio
e8643204aa Clear "msg" pointers after releasing
Avoid possible dangling pointers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-15 11:59:10 +00:00
Christophe Fergeau
c02ae9835e gstreamer: Add #ifdef around zero_copy()
Since c3d237 "gstreamer: Avoid memory copy if strides are different" is
only needed when zero copy is disabled. This moves the function
definition to an already existing #ifdef block.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-02-15 11:57:59 +00:00
Christophe Fergeau
f5494cfa9b test-playback: Pass proper types to spice_server_add_interface
This is a revert of b76e561d.
For a SpicePlaybackInstance, the base interface must be a
SpicePlaybackInterface instance, not a SpiceBaseInterface instance, or
spice-server code will end up reading out of bounds.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-15 12:13:55 +01:00
Christophe Fergeau
1afa86c3ee test-display-base: Pass proper types to spice_server_add_interface
This is a revert of 93b4f4050^ and 93b4f4050.
For a SpiceCharDeviceInstance, the base interface must be a
SpiceCharDeviceInterface instance, not a SpiceBaseInterface instance, or
spice-server code will end up reading out of bounds.

vmc_state/vmc_write/vmc_read implementations also have to be provided.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-15 12:13:55 +01:00
Christophe Fergeau
14b2f053ab test-vdagent: Pass proper types to spice_server_add_interface
This is a revert of 93b4f4050^ and 93b4f4050.
For a SpiceCharDeviceInstance, the base interface must be a
SpiceCharDeviceInterface instance, not a SpiceBaseInterface instance, or
spice-server code will end up reading out of bounds.

vmc_state/vmc_write/vmc_read implementations also have to be provided.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-15 12:13:55 +01:00
Christophe Fergeau
e87d0a3a84 gstreamer: Remove unused function
rate_control_is_active() is static and not used in gstreamer-encoder.c

Not needed since 97fcad82eb.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-02-15 10:50:27 +00:00
Frediano Ziglio
5a922af9e6 spicevmc: Add some statistics
Allows to see compressed/uncompressed ratio

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-15 10:16:16 +00:00
Frediano Ziglio
ce06958fb8 Improve statistic code interface
Use new structures and functions to implement the statistics code.
Use inline functions instead of macros for increased type-safety.
If statistics are disabled, the structures and functions become
empty. This confines the configuration-specific #defines to the
statistics implementation itself and avoids the need for #defines in
the calling functions. This greatly reduces the chance of accidentally
breaking the build for one configuration or the other. The reds option
was removed from stat_inc_counter() as it was not used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-15 10:13:48 +00:00
Frediano Ziglio
469b94eb4e Do not set not blocking flag twice
Non blocking flag is set for all connection inside reds.c so
there's no need to set again for the single client channel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-15 10:08:24 +00:00
Frediano Ziglio
f603f17317 red-channel-client: Pass array size to red_channel_client_prepare_out_msg
Do not make it assume vec contains IOV_MAX elements.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-15 10:02:27 +00:00
Frediano Ziglio
317457221d red-channel-client: Remove vec field from OutgoingHandler
This was always set to vec_buf.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-15 10:02:22 +00:00