Commit Graph

3709 Commits

Author SHA1 Message Date
Frediano Ziglio
b2fa6ec66c red-channel-client: Avoid weird memory references using MarkerPipeItem
Instead of having MarkerPipeItem pointing to an external variable with
the possibility to forget to reset it and have a dangling pointer, this
commit takes a reference on the item to keep it alive after it was sent.
This item is placed into the queue to understand when it was sent. The
current implementation detects the unqueue when the item is destroyed so
we currently store a pointer to an external variable in the item, this
way we can use a variable which will still be alive after the item is
released/destroyed.
This change updates the variable (stored in the item) when we try to
send the item, rather than at destruction time. The destruction happened
at the end of red_channel_client_send_item(), so we don't mark
item_in_pipe much earlier than before.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-29 16:49:24 +00:00
Frediano Ziglio
8a9c51bd4f mjpeg-encoder: Fix some typos
unexected -> unexpected
esitimation -> estimation

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-29 11:17:21 +00:00
Frediano Ziglio
529ab49382 ci: Detect if code compile with SASL disabled
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Snir Sheriber <ssheribe@redhat.com>
2017-11-28 08:36:46 +00:00
Frediano Ziglio
137d9ec8e9 test-stream-device: Check incomplete reads of StreamMsgFormat
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-11-27 21:38:02 +00:00
Jonathon Jongsma
61aa6ac8aa StreamDevice: Handle incomplete reads of StreamMsgFormat
This is currently unlikely to happen since we communicate over a pipe
and the pipe buffer is sufficiently large to avoid splitting the
message. But for completeness, we should handle this scenario.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-11-27 21:37:53 +00:00
Uri Lublin
49234be2dd red-stream: fix build without SASL
put red_stream_disable_writev in an #ifdef HAVE_SASL block.
red_stream_disable_writev is only called from functions
that are already in an #ifdef HAVE_SASL block.

Currently when building with SASL disabled, I get:
  CC       red-stream.lo
red-stream.c:441:13: error: 'red_stream_disable_writev'
           defined but not used [-Werror=unused-function]

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-11-27 10:13:11 +00:00
Frediano Ziglio
9575713dfb inputs-channel: Remove reds argument from inputs_channel_set_tablet
All other inputs_channel_set_* functions do not have this
parameter and get it from the channel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-11-27 10:11:53 +00:00
Frediano Ziglio
d61fce91ee inputs-channels: Remove leak using tablet device
Current code does not free allocated tablet resources.
When a tablet is added some resources are allocated.
Resources should be released either removing the tablet or
freeing spice server object.
Added a test to check these conditions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-22 16:44:09 +00:00
Frediano Ziglio
cb1211a6ca reds: Do not get time if not needed
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-22 13:59:51 +00:00
Frediano Ziglio
d57b61a584 tests: Add a test for streaming devices
Currently create device, open it and pass some messages checking
they are handled.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-21 10:02:50 +00:00
Frediano Ziglio
223bfed649 Reuse SPICE_DECLARE_TYPE macro
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-21 08:38:44 +00:00
Frediano Ziglio
de5b166b71 Remove common/mem.h includes
common/mem.h contains mainly memory allocation functions.
As we decided to move to Glib calls directly avoid to include
function declaration we should not use anymore.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-21 08:27:09 +00:00
Frediano Ziglio
fb3e061a8e utils: Check we list all channel names
This prevent future problems supporting new channels.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-11-09 10:58:13 +00:00
Frediano Ziglio
3269451ae6 Use constant variables for image operations
This reduce the attack surface moving some data into read-only
sections.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-08 15:23:49 +00:00
Frediano Ziglio
ef166f3158 build: Update spice-common submodule
Frediano Ziglio (6):
      Make the compiler work out better way to write unaligned memory
      test-marshallers: Use unaligned structure
      test-marshallers: Test demarshalling
      ring: Remove __ring_remove function
      ring: Remove short living temporary variable
      canvas_base: Allow to specify constant operations

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-08 15:23:43 +00:00
Frediano Ziglio
ece4263055 utils: Fill in all possible channel names
Missing some names cause some debugging messages to be
generated and some of our tests to fail.

This patch was written by Christophe Fergeau.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-08 11:33:43 +00:00
Frediano Ziglio
7dda006c98 ci: Install python3 packages to fix compile on new Fedora
Fedora 26 removed dependency from python-pyparsing/python-six
to python but we require the executable to run some scripts

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-11-07 17:32:03 +00:00
Jonathon Jongsma
1980dd5dd1 StreamDevice: Fix incomplete header reads
The code for reading a StreamDevice message from the streaming agent has
code to handle a situation where you only read a part of the header. If
we've read only a part of the header, we will try to read the remaining
n bytes of the header within a loop until the full header is read.
However, when we try to read the last n bytes, we store it at beginning
of the header struct, which will overwrite the first part of the header.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-10-31 09:19:43 +00:00
Jonathon Jongsma
3165247886 Make stream-channel.h self-contained
Include protocol header file defining StreamMsgFormat which is used in a
function signature in this header.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
Reviewed-by: Frediano Ziglio <fziglio@redhat.com>
2017-10-30 12:01:24 +01:00
Christophe Fergeau
bf61342e9b channel: Introduce logging helpers
This commit adds red_channel_{debug,warning,printerr}() helpers which
will prepend the log message with "channel-name:id (%p)". It also
changes various locations which were doing this manually.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-10-23 20:29:31 +01:00
Christophe Fergeau
699a94ca8f utils: Introduce helpers to map channel types to names
spice_server_set_channel_security() is already mostly doing that. We can
make its code more generic, and introduce a red_channel_get_name()
method. This method will then be used to make debug messages more
readable by showing the actual channel name rather than its type as
an int.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-10-23 20:29:28 +01:00
Jonathon Jongsma
a5aa2a2261 Use standard "Red" namespace
The objects RedsStream and RedsSASL are currently using the namespace
"Reds" rather than the standard "Red" namespace used throughout the rest
of the project. Change these to be consistent. This also means changing
method names and some related enumeration types.

The files were also renamed to reflect the change:
  reds-stream.[ch] -> red-stream.[ch]

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-10-21 08:47:02 +01:00
Jonathon Jongsma
8de82e5818 RedsStream: make some functions static
These were not used outside of reds-stream.c, so make them static and
remove them from the header.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-10-19 08:07:26 +01:00
Frediano Ziglio
5553dec9a6 reds-stream: Remove useless debug
There are already other debugging code showing channel closure.
Not closed file descriptors can easily be detected with other
tools (like netstat or /proc file system).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-18 16:07:14 +01:00
Frediano Ziglio
d0b3707fa2 reds-stream: Removed unused "username" field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-18 16:07:07 +01:00
Frediano Ziglio
63f44a61bf red-qxl: Enforce boolean for QXLDevSurfaceCreate::mouse_mode
In some cases mouse_mode is a bit field.
However for this structure is used always as a boolean
value.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-17 21:56:28 +01:00
Frediano Ziglio
b83eb77c30 red-qxl: Remove surface_create field
This field was used just to store a value and retrieve again
while we can just pass it instead.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-17 21:56:20 +01:00
Frediano Ziglio
7b7a842a4e stream-channel: Activate streaming report from client
Setting the capability is not enough, each stream must be enabled
so do so if client support them.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
a8afcfef6b stream-device: Limit sending queue from guest to server
Do not allow the guest to fill host memory.
Also having a huge queue mainly cause to have a higher video
latency.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
b7c3636151 stream-device: Create channel when needed
This allows a better id allocation as devices are created after
fixed ones.
Also will allow to support more easily multiple monitor.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
82769e5dfc stream-device: Start supporting resetting device when close/open on guest
When guest close the device the host device has to be reset too.
This make easier to restart the guest device which can happen in case
of reboot, agent issues or if we want to update the agent.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
7131e35300 char-device: Do not stop and clear interface on reset
Currently, red_char_device_reset() stops the device, clears all pending
messages, and clears its device instance. After this function is called,
the char device will not work again until it is assigned a new device
instance and restarted. This is fine for the vdagent char device, which
is currently the only user of this function. But for the stream device,
we want to be able to reset the char device to a working state (e.g.
clear all pending messages, etc) without stopping or disabling the char
device. So this function will now only reset the char device to a clean
working state, and the _stop() and _reset_dev_instance() calls will be
moved up to the caller.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
9ea16ff4a0 stream-channel: Do not show an empty blank screen on start
Start showing something when we have a surface and stream
instead of showing a blank screen which is now not useful.
Was useful for debugging purposes to understand that the
new channel was sending messages correctly to client and
client could handle them.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
633e04b40c stream-channel: Support client connection/disconnection
When a new client is connected we must restart the stream so new
clients can receive correct data without having to wait for the
next full screen (which on idle screen could take ages).
On disconnection we should tell the guest to stop streaming
not wasting resources to stream not needed data.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
3cf09bd5b3 stream-channel: Allows to register callback to get new stream request
The channel needs to communicate when it receive a new
stream request from the guest.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
bc906737bc stream-channel: Allows not fixed size
Remove the fixed size stream and support any display size.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
60104d818c stream-device: Handle streaming data from device to channel
Handle stream data from device sending to the channel.
The StreamChannel will forward the data to the clients using standard
DisplayChannel messages, and will create and destroy streams as
necessary.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
09ddeff804 stream-device: Create channel for stream device
So can be used by the device to communicate with the clients.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
14bc15f656 stream-channel: Start implementing DisplayChannel properly
Handle messages from clients.
Send some messages to clients.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
efcb765d0a stream-channel: Write a base channel to implement the streaming
Currently only compile, not used and not much sense

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
58e6781d8a stream-device: Start parsing new protocol from guest
Parse the data sent from the guest to the streaming device.
At the moment, the data is simply discarded after it is parsed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
a0c184e89b stream-device: Add device to handle streaming
Add a stub device in guest.
The aim of this device is to make it possible for the guest to send a
stream through a DisplayChannel (in the sense of protocol channel).
This stub allows the guest to send some data and you can see some debug
lines of data arrived on host logs.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:59:14 +01:00
Frediano Ziglio
e216c4b4bd Notify client of the creation of new channels dynamically
This allows the server to add channels after the client is connected.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-16 19:58:45 +01:00
Frediano Ziglio
e16d7788db tests: Check leaks registering migration interface
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-10-13 17:10:59 +01:00
Frediano Ziglio
343ac9f78d reds: Remove leak allocating migration state
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-10-13 17:10:53 +01:00
Frediano Ziglio
7a3bfedfbe red-channel: Remove red_channel_init_outgoing_messages_window
This function does not make much sense anymore.
Is called by RedVmcChannel which doesn't use RedChannelClient ACKs
so the variable changed are not used.
Moreover, at red_vmc_channel_constructed() time, there will be no
clients yet, so red_channel_init_outgoing_messages() will be a no-op.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-10-12 16:37:14 +01:00
Frediano Ziglio
617479413e inputs-channel: Check message size handling migration data
Prevent possible buffer reading overflow.
Note that message pointer must be valid and data are checked
value by value so even on overflow you just get an error.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-10-12 16:14:41 +01:00
Frediano Ziglio
dd51cef748 red-pipe-item: 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
f14ab204e5 parse-qxl: 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
f536ca9f30 pixmap-cache: 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