Commit Graph

88 Commits

Author SHA1 Message Date
Frediano Ziglio
b009a7ff34 Prevent setting invalid image compression values
In case of invalid value the original compression is unchanged.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-26 10:11:47 +01:00
Frediano Ziglio
d06fd6a2f9 worker: Do not check surface twice
validate_surface already do the same checks.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-22 09:10:05 +01:00
Frediano Ziglio
6d4db4f0bf Base FOREACH_DCC on GLIST_FOREACH
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:24 +01:00
Frediano Ziglio
9b5f93d1a7 Base FOREACH_CLIENT on GLIST_FOREACH
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:22 +01:00
Frediano Ziglio
3fa2f12c1f Use proper FOREACH_DCC instead of FOREACH_CLIENT
FOREACH_DCC should be more DisplayChannel related.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:20 +01:00
Jonathon Jongsma
46c83dfe1f Rename display_channel_set_monitors_config_to_primary()
Since this function is a DisplayChannel method, use a name consistent
with naming conventions.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-16 13:40:09 -05:00
Jonathon Jongsma
5e74387d25 Add DisplayChannelPrivate struct
Move all of the DisplayChannel data memembers into a private struct to
encapsulate things better. This necessitated a few new 'public' methods
and a small bit of refactoring to avoid poking into DisplayChannel
internals from too many places. The DisplayChannel and the
DisplayChannelClient are still far too intertwined to completely avoid
accessing private data, so at the moment the private struct is defined
in display-channel.h and the DisplayChannelClient implementation
still accesses it sometimes.
2016-09-16 13:40:09 -05:00
Jonathon Jongsma
fede3f38c5 Improve encapsulation of DisplayChannel
Add a couple new functions to the header so that they can be called by
other objects rather than poking into the internals of the struct.
2016-09-16 13:40:09 -05:00
Jonathon Jongsma
d5d59d0858 Add red_channel_client_get_channel()
Don't poke into the structure to get the channel

This prepares for encapsulating RedChannelClient a bit more and
separating it into its own source file.
2016-08-30 16:53:29 -05:00
Frediano Ziglio
cbc86e7a1f move is_low_bandwidth to DisplayChannelClient
The field is only used by DisplayChannelClient, not by CursorChannelClient

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-08-09 10:22:46 -05:00
Frediano Ziglio
5d61659bba remove common_graphics_channel_new_client function
The function was just calling another function with same parameters

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-08-09 10:22:46 -05:00
Frediano Ziglio
eef8d0d8a3 move during_target_migrate out of common_graphics_channel_new_client
This reduces the number of arguments that need to be passed to the
function, and also avoids changing a different object within a function
that is supposed to just create a new object

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-08-09 10:22:46 -05:00
Frediano Ziglio
c699e4db3d move channel window setting to config_socket
Make common_graphics_channel_new_client smaller

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-08-09 10:22:46 -05:00
Frediano Ziglio
2d1c724301 Rename encoder_globals to encoder_shared_data
Was missing due to a mistake.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-16 21:02:54 +01:00
Pavel Grunt
58ed103636 Fix missing prototypes
Signed-off-by: Pavel Grunt <pgrunt@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-06-15 15:02:42 +01:00
Francois Gouget
497fcbb0a3 streaming: Let the administrator pick the video encoder and codec
The Spice server administrator can specify the encoder and codec
preferences to optimize for CPU or bandwidth usage. Preferences are
described in a semi-colon separated list of encoder:codec pairs.
The server has a default preference list which can explicitly be
selected by specifying 'auto'.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2016-06-14 17:04:40 +02:00
Frediano Ziglio
108d11f4aa Move others glz fields to dcc-encoders
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-14 15:07:31 +01:00
Frediano Ziglio
aed25d8407 record: Use spice_get_monotonic_time_ns instead of stat_now(CLOCK_MONOTONIC)
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-08 15:27:55 +01:00
Frediano Ziglio
69628ea137 improve primary surface parameter checks
Primary surface, as additional surfaces, can be used to access
host memory from the guest using invalid parameters.

The removed warning is not enough to prevent all cases. Also a warning
is not enough to stop an escalation to happen.
The red_validate_surface do different checks to make sure surface
request is valid and not cause possible buffer/integer overflows:
- format is valid;
- width is not large to cause overflow compared to stride;
- stride is not -2^31 (a number which negate is still <0);
- stride * height does not overflow.

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

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-06-08 09:59:54 +01:00
Frediano Ziglio
52f9850be8 worker: Record cursor commands
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-06 09:29:12 +01:00
Frediano Ziglio
a1715a01d4 channel: Remove clients_num and use g_list_length
This fixes a regression introduced by
4028fb1c79, where clients_num
was not updated correctly anymore.

There is no reason to cache the number of elements on that list,
as the expected number of clients is quite small.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2016-06-01 16:56:16 +01:00
Frediano Ziglio
20373582ac Avoid double conversion
Avoid converting from RedChannelClient* to DisplayChannelClient* and
DisplayChannelClient* to RedChannelClient* just to use RedChannelClient*
('display_channel->clients' is a list of RedChannelClients).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2016-05-26 16:43:31 +01:00
Frediano Ziglio
8f7419a711 replay: rename red_record_dev_input_primary_surface_create
Rename red_record_dev_input_primary_surface_create to
red_record_primary_surface_create.
Name is more concise and was not clear what "dev_input" was supposed
to specify.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-26 16:29:06 +01:00
Frediano Ziglio
751a0aeb51 replay: better record encapsulation
Remove global/static from red_record_qxl.c.
Defined a structure and use it to hold record state.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-26 16:28:43 +01:00
Frediano Ziglio
1d3cd7d617 Hide CursorChannelClient implementation details
The existence of this class can be hidden to user of CursorChannel class

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-26 11:02:53 +01:00
Frediano Ziglio
c0a8b69822 Move cursor_connect to CursorChannel
This function was handling mainly CursorChannel state

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-26 10:23:33 +01:00
Jonathon Jongsma
a31efd7e75 RedChannel: Add FOREACH_CLIENT and use it to iterate
Remove the custom FOREACH_DCC macro and use the more generic
FOREACH_CLIENT macro and use it for all channels.
2016-05-24 14:56:45 -05:00
Jonathon Jongsma
4028fb1c79 Replace RedChannel::clients with GList
Instead of using a Ring, use a GList to store the list of channel
clients. This allows us to iterate the clients without poking inside of
the client struct to get the channel_link. This is required in order to
make the RedChannelClient struct private.
2016-05-24 14:56:45 -05:00
Frediano Ziglio
1e4800507b use #include<> style for spice-common header inclusions.
The include directory is specified with the -I which is the directory
used directly by #include<>.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-05-09 12:45:27 +01:00
Marc-André Lureau
c6b1fc3551 worker: remove check for canvas during cursor connect
We want the cursor to be initialized even if there is no canvas,
especially when using a GL scanout. This solves some client warnings
when using qemu with GL scanout-only (patches under review on qemu ML).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-26 16:29:04 +01:00
Frediano Ziglio
4c5c9f6b69 dispatcher: move channel final initialization to red-worker
CursorChannel and DisplayChannel was initialized half in red_worker_new
and half in red_dispatcher_init using some accessor for RedWorker
(red_worker_get_cursor_channel and red_worker_get_display_channel).
Moving directly into red_worker_new make easier to follow code path.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-03-29 09:26:23 +01:00
Frediano Ziglio
5c48cdc61d declare and use message for RED_WORKER_MESSAGE_GL_SCANOUT
All other messages (even empty ones) have a structure defined.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-03-23 14:09:53 +00:00
Christophe Fergeau
fe9977c469 Use red_qxl_check_qxl_version in red-worker
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-17 16:26:58 +00:00
Christophe Fergeau
ae931c7dab Add more red_qxl_ methods
Add red_qxl_ methods wrapping the QXLInterface vfuncs. This allows to
remove most of the qxl_get_interface() use outside of red-qxl.c

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-17 16:26:56 +00:00
Christophe Fergeau
e45ab9cf23 Use QXLInstance instead of QXLState in red_qxl_*
This seems to make more sense this way, QXLInstance is the 'main' object
with QXLState being its private data. External users then use QXLInstance
rather than passing a pointer to the private data to red-qxl.h methods.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-17 16:26:33 +00:00
Jonathon Jongsma
df214cd031 Remove use of global 'reds' within RedWorker
Get the server variable from the QXLState instead of using the
global variable

Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-05 10:29:26 +00:00
Frediano Ziglio
95fa8bfb13 worker: remove useless qxl_state
qxl_state can be extracted easily from qxl.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-03-04 15:47:50 +00:00
Frediano Ziglio
e9ed125dbd use QXLState instead of RedDispatcher
Considering that:
- QXLState is the state of QXLInstance implementation;
- RedDispatcher is the implementation of QXL;
- qif (QXLInterface*) field can be computed really easy from QXLInstance;
- most of its state is private.
Make all structure private and use QXLState instead of RedDispatcher.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-03-04 15:47:45 +00:00
Frediano Ziglio
a8ff771ee8 rename red_dispatcher_ functions to red_qxl_
RedDispatcher is basically implementing QXLInstance.
After some internal discussion we decided to use QXLState structure
and red_qxl_ as function prefix.
This is the first of 3 patches that rename functions, structure
and files.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-03-04 15:27:39 +00:00
Frediano Ziglio
3fdc1775a6 optimize handle_dev_input call
Pass directly dispatcher to handle_dev_input callback.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-03-04 14:24:57 +00:00
Jonathon Jongsma
3644783e24 CommonChannel -> CommonGraphicsChannel
Rename this struct to make it clear that it's only the base class for
graphics channels (e.g. display and cursor), not all channels.

Also renamed CommonChannelClient to CommonGraphicsChannelClient.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-17 12:58:40 +00:00
Frediano Ziglio
c111bfa8c3 worker: removed unused red_worker_get_qxl function
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-16 13:09:33 +00:00
Frediano Ziglio
0ebd3b0d04 dcc: move id from CommonChannelClient to DisplayChannelClient
Was not used by CursorChannelClient but only by DisplayChannelClient.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-16 13:07:08 +00:00
Christophe Fergeau
7870c27fca display-channel: Remove extra group_id arguments
They are now carried in the appropriate command through
QXLReleaseInfoExt, so we don't need to pass them around explicitly.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:18 +00:00
Christophe Fergeau
705be34b5e Remove CursorItem::group_id
Now that the group_id is known to RedCursorCmd, we don't need to store
it separately in CursorItem.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:16 +00:00
Christophe Fergeau
8091df87b3 red-parse-qxl: Use QXLReleaseInfoExt instead of QXLReleaseInfo
This should allow to avoid moving the group_id separately from the QXL
commands all over the code.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:15 +00:00
Christophe Fergeau
e213f09c38 Simplify red_drawable_unref()
Now it no longer needs external state in order to destroy the
RedDrawable instance when needed, so we can remove this from the
prototype.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:08 +00:00
Christophe Fergeau
650ef63782 Add group_id to RedDrawable
Storing a QXLReleaseInfoExt rather than a QXLReleaseInfo in RedDrawable
gives us a place to store group_id for free. Since we are building a
QXLReleaseInfoExt from QXLReleaseInfo and group_id when destroying a
RedDrawable instance, this is a move in the right direction.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:06 +00:00
Christophe Fergeau
7b3bdbfdda Add QXLInstance member to RedDrawable
This allows to get rid of the DisplayChannel parameter to
red_drawable_unref()

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:04 +00:00
Christophe Fergeau
f8617db67a Remove DisplayChannel::red_drawable_count
It's only used in a few debug printfs. If we want these stats, we'll
have to find a better way than forcing a dependency on a high-level
class in a lower-level _unref method just to maintain the stats.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:01 +00:00