Commit Graph

2373 Commits

Author SHA1 Message Date
Jonathon Jongsma
bb6901e7f7 Pass 'reds' as opaque data in vdi port char device
This allows us to access the RedsState variable non-globally without
changing the signature of the callback functions.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-19 09:54:12 +00:00
Jonathon Jongsma
07297dd3d0 Change some functions to take RedsState arg
In preparation for getting rid of the global 'reds' variable, we need to
pass the RedsState variable to all functions where it is needed. For now
the callers just pass in the global reds variable.

Functions changed:
- reds_register_channel;
- reds_unregister_channel;
- reds_get_mouse_mode;
- reds_set_mouse_mode;
- reds_update_mouse_mode;
- reds_agent_remove;
- reds_find_channel;
- reds_mig_cleanup;
- reds_reset_vdp;
- reds_main_channel_connected;
- reds_client_disconnect;
- reds_disconnect;
- reds_mig_disconnect.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-18 16:01:12 +00:00
Frediano Ziglio
e433a6634c replay: better documentation for -C and -S options
Document all possible values

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-15 15:42:19 +00:00
Frediano Ziglio
d80189b5ed replay: add streaming setting option
Add -S to allow to set a video streaming rule.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-15 15:04:52 +00:00
Frediano Ziglio
f103f667bf utils: handle errors writing to bitmap file
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-15 12:30:03 +00:00
Frediano Ziglio
42ce16b7f4 utils: fix endianess issues writing bitmap file
Do not print directly binary data but serialize in a portable way
and then use write functions.

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-15 12:30:00 +00:00
Frediano Ziglio
cb5184af58 utils: use always fwrite to write bitmap
Make easier to check error on next patch

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-15 11:52:19 +00:00
Jonathon Jongsma
8bb265726c Make global 'reds' extern
This allows it to be accessed from other files. This is a temporary step
toward getting rid of the global-ness of this variable, and it allows us
to update the function signature bit-by-bit.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-15 11:51:13 +00:00
Marc-Andre Lureau
47df90a8ce stream-test: add batch test
Check that two consecutive msgfd are read back from two different reads.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-15 11:04:30 +00:00
Frediano Ziglio
eb64b7d739 replay: use spice_malloc(0) instead of raw malloc
These function report memory allocation errors.
spice_malloc0 also reset memory after allocation.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-01-15 10:33:24 +00:00
Marc-Andre Lureau
0db1137dac build-sys: build a noinst libtest.a to link to
Group the test utility in a library, to avoid repeating the same
sources. In this case, automake already figues out what the source of
the programs to build is.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-15 09:58:54 +00:00
Frediano Ziglio
58c5713aa9 replay: remove command line memory leaks
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-15 08:58:12 +00:00
Frediano Ziglio
20fe11d6f7 build-sys: update spice-common
This is an update to fix build issues with spice-protocol.git.
generated_server_demarshallers.c: In function
‘parse_msgc_display_gl_draw_done’:
generated_server_demarshallers.c:767:23: error:
‘SpiceMsgcDisplayGlDrawDone’ undeclared (first use in this function)
     mem_size = sizeof(SpiceMsgcDisplayGlDrawDone);
...

Also needed for upcoming gl-scanout messages.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-14 18:01:19 +00:00
Christophe Fergeau
5a603f2b63 Remove GSlice use
It's being slowly deprecated in glib
https://bugzilla.gnome.org/show_bug.cgi?id=754687

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-14 16:39:36 +00:00
Christophe Fergeau
400a5d13cf Remove compress_buf_new
This commit reworks a bit the management of RedCompressBuf so that
compress_buf_new/compress_buf_free become unneeded.
Since d25d6ca0 and the introduction of encoder_data_reset,
compress_buf_free is already unused outside of dcc-encoders.c and could
be static. This in turn makes compress_buf_new a bit odd as the matching
destructor is never used in dcc.c.
This commit introduces an encoder_data_init() method which is hiding
the initialization of the EncoderData structure from the dcc.c code,
allowing to get rid of compress_buf_new() calls from dcc.c code.

It also uses this as an opportunity to stop using GSlice for
RedCompressBuf.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-14 16:39:30 +00:00
Frediano Ziglio
eff5e83936 channel: simplify red_channel_client_send_item
Acked-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-01-14 14:16:53 +00:00
Marc-Andre Lureau
f438bd6ae9 tests: add fdpass stream test
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-14 11:04:49 +00:00
Marc-André Lureau
5c1073266e reds-stream: add send_msgfd()
A new function to send fd with unix socket anciliary data.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-14 10:55:36 +00:00
Marc-Andre Lureau
2628197b99 build-sys: build a utility libserver.la
This allow tests programs to link with statically built library to access all symbols

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-14 10:53:25 +00:00
Christophe Fergeau
6e66366f9b Update NEWS for 0.13.0 release 2016-01-13 12:51:25 +01:00
Christophe Fergeau
9ea5348efc spicevmc: Drop unsent data on client disconnection
When redirecting a USB webcam over a slow link, it's currently possible
to hit an assertion in spice-server by running cheese (application using
the webcam), killing the client with ctrl+c and then restarting the
client:
qemu-kvm: spicevmc.c:324: spicevmc_red_channel_alloc_msg_rcv_buf:
Assertion `!state->recv_from_client_buf' failed.

This happens when red_peer_handle_incoming tries to allocate memory for
a message using spicevmc:
handler->msg = handler->cb->alloc_msg_buf(handler->opaque, msg_type,
msg_size);

red_peer_handle_incoming() is called when there is client data to be
read, and does
- call alloc_msg_buf() to allocate memory for the message
- read the message
- if the read was partial, return early, the main loop will call again
  red_peer_handle_incoming() when there is more data available for that
  channel
- parse the message
- call release_msg_buf() to free the message

For channels based on spicevmc (usbredir and port), alloc_msg_buf()
stores message data in SpiceVmcState::recv_from_client_buf and before
allocating new memory, it asserts that it's NULL.

This is what causes this crash in the following scenario:
- SpiceVmc::alloc_msg_buf() is called and allocates memory for a new
  message in SpiceVmcState::recv_from_client_buf
- red_peer_handle_incoming() returns early as all the spicevmc message
  data hasn't been received yet
- the client gets killed
- the main channel notices the disconnect and calls
  main_dispatcher_client_disconnect() which will disconnect all the
  channels
- SpiceVmc::on_disconnect is called
- after the new client connects, SpiceVmc::alloc_msg_buf() is called,
  notices that SpiceVmcState::recv_from_client_buf is already set, and
  asserts()

This commit makes sure the partial SpiceVmcState::recv_from_client_buf
data is cleared on disconnect so that the assert does not trigger.

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1264113
2016-01-13 11:45:56 +01:00
Sunny Shin
b9b0590bc0 channel: add option tcp keepalive timeout to channels 2016-01-12 15:10:47 +01:00
Christophe Fergeau
02c8a0f386 stat: Make stat_compress_init/stat_init the same
When COMPRESS_STAT is not set, and RED_WORKER_STAT is set,
stat_time() will be a no-op, but stat_start_time_init() will try to use
stat_info_t::clock. This causes a compile warning on 32 bit arches (not
sure why not on 64 bit builds), as well as an error from valgrind.

Since stat_time() and stat_compress_time() are both doing the same work,
this commit makes them the same function, which ensures
stat_info_t::clock will be set and stat_start_time_init() can be used
regardless of the _init() method which is called.
2016-01-12 11:46:32 +01:00
Francois Gouget
a57f227235 server: Fix conversions between QXLPHYSICAL and pointers
This avoids compilation errors with -Werror on 32 bit systems as the
pointer size differs from that of a QXLPHYSICAL.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2016-01-12 10:57:21 +01:00
Francois Gouget
0de8f7f94e server: Simplify the next chunk initialization in red_replay_data_chunks()
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2016-01-12 10:57:20 +01:00
Francois Gouget
e617a59969 server: Fix a pointer to uint64_t cast in spice_replay_next_cmd()
This avoids a compilation error with -Werror on 32 bit systems as the
pointer size differs from that of an uint64_t.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2016-01-12 10:57:20 +01:00
Frediano Ziglio
77830036e2 channel: use iface parameter to distinguish interface context
Now we can use the iface parameter to distinguish the context instead
of doing strange assumption on opaque and its state.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-11 16:40:17 +00:00
Frediano Ziglio
ba175f9be1 channel: add interface parameters to SpiceCoreInterfaceInternal
This patch and previous ones want to solve the problem of not having a
context in SpiceCoreInterface. SpiceCoreInterface defines a set of
callbacks to handle events in spice-server. These callbacks allow to
handle timers, watch for file descriptors and send channel events.
All these callbacks do not accept a context (usually in C passed as a
void* parameter) so it is hard for them to differentiate the interface
specified.
Unfortunately this structure is used even internally from different
contexts for instance every RedWorker thread has a different context. To
solve this issue some workarounds are used. Currently for timers a variable
depending on the current thread is used while for watches the opaque
parameter to pass to the event callback is used as it currently points just
to RedChannelClient structure.  This however imposes some implicit
maintainance problem in the future. What happens for instance if for some
reason a timer is registered during worker initialization, run in another
thread? What if we decide to register a file descriptor callback for
something not a RedChannelClient?  Could be that the program will run
without any issue till some bytes change and weird things could happen.

The implementation of this solution is done implementing an internal "core"
interface that has context specific and use it to differentiate the
context instead of relying on some other, hard to maintain, detail. Then an
adapter structure (name inpired to the adapter pattern) will provide the
internal core interface using the external, public, definition (in the
future this technique can be used to extend the external interface without
breaking the ABI).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-11 16:40:17 +00:00
Frediano Ziglio
9745ef5f9a channel: build adapter for public core interface
Add wrapper functions for SpiceCoreInterface in order to present
a SpiceCoreInterfaceInternal. These functions just expect
SpiceCoreInterfaceInternal API and forward request to
SpiceCoreInterface.
This allows to change ABI details of internal one.

See comments in "channel: add interface parameters to
SpiceCoreInterfaceInternal" patch.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-11 16:40:12 +00:00
Frediano Ziglio
adc0751950 channel: add a new internal SpiceCoreInterface
Define an internal structure that matches 100% the ABI of the public one.
The structure will be changed by following patches.
See comments in "channel: add interface parameters to
SpiceCoreInterfaceInternal" patch.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-11 16:29:53 +00:00
Frediano Ziglio
26c7e33de3 stats: use CLOCK_THREAD_CPUTIME_ID for cpu statistics
Use CLOCK_THREAD_CPUTIME_ID instead of getting the clock
with pthread_getcpuclockid.
This avoids to call red_worker_get_clockid. This function returns
uninitialized value at the time DisplayChannel is built resulting in setting
statistics to CLOCK_REALTIME (which is 0) instead to cpu time as expected.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-11 16:29:08 +00:00
Frediano Ziglio
1b6af4779a dcc: avoid to report errors triggered by client
Client can always send report even if a stream is not available.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-11 14:45:02 +00:00
Frediano Ziglio
d3b5d2c97e add some tests for cursors parsing
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 18:16:47 +00:00
Frediano Ziglio
6ea345b820 add test for QXL parsing functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 18:16:47 +00:00
Frediano Ziglio
f84239a035 check properly if red_get_data_chunks fails or not
Instead of returning 0 which could be a valid value returns an invalid
one and check on the caller.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 18:16:42 +00:00
Frediano Ziglio
2571cec5eb prevent integer overflow in red_get_clip_rects
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 16:33:27 +00:00
Frediano Ziglio
d25d6ca0f2 dcc: write and use a new encoder_data_reset function to clean buffers
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 16:25:37 +00:00
Frediano Ziglio
bd8c74d7a4 dcc: free glz buffer after zlib compression
For zlib+glz compression image if first compressed with glz then the
resulting buffer is compressed again with zlib then the buffer from
zlib is returned to the caller.
However the temporary glz buffer was not freed resulting in a memory
leak.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 16:25:25 +00:00
Eduardo Lima (Etrunko)
8c6dcc5eaf server: Fix tests Makefile
As reported in https://bugs.freedesktop.org/show_bug.cgi?id=93520, the
build from git is failing in Archlinux systems with undefined
references to glib symbols.

This patch fixes the problem by simply reordering the order libraries
will be linked. Also, removes duplicate $(GLIB_LIBS) variable.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-08 12:23:54 +00:00
Pavel Grunt
2decbd2116 syntax-check: Fix sc_cast_of_argument_to_free
red_replay_qxl.c was renamed in 525cd67be7

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 11:24:17 +00:00
Pavel Grunt
952aaca3d7 syntax-check: Remove empty line at EOF
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 11:24:14 +00:00
Pavel Grunt
1a158ce728 syntax-check: Fix missing AUTHORS
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 11:23:44 +00:00
Frediano Ziglio
cc5fa8fa9b replay: better help for -s option
-s accepts an option to delay command queueing.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Marc-André Lureau <mlureau@redhat.com>
2015-12-22 16:45:48 +00:00
Marc-André Lureau
9a0efecd93 reds-stream: add reds_stream_is_plain_unix()
Utility function used in follow-up code.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-21 13:20:53 +00:00
Pavel Grunt
2db3868864 build-sys: Use sasl check from spice-common
Support only libsasl2 providing libsasl2.pc file

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2015-12-21 13:40:19 +01:00
Marc-Andre Lureau
3364af70a3 tests: remove test_util.h
Replace ASSERT() with spice_assert().

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-21 11:44:34 +00:00
Frediano Ziglio
f5f103b8d7 tests: remove unused macro
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-21 10:39:56 +00:00
Lukas Venhoda
6c4f11191c dcc: Don't disconnect channel, when compression is not supported
Don't disconnect the display channel, when unsupported compression is
requested from the client. Not changing the compression is enough.

https://bugs.freedesktop.org/show_bug.cgi?id=92821
Acked-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-17 12:29:52 +01:00
Christophe Fergeau
bc1adb5ccf build: Remove unused SPICEC_STATIC_LINKAGE_BSTATIC
A left-over from the client code.
2015-12-16 14:44:09 +01:00
Marc-Andre Lureau
e64135179f stream: consitify reds_stream_get_family() argument
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-16 10:16:43 +00:00