Commit Graph

1896 Commits

Author SHA1 Message Date
Frediano Ziglio
52b9f2e8b3 Remove unused parameter from put_cursor_pipe_item
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:53:02 +01:00
Frediano Ziglio
1b081c17ea Simplify spicevmc_red_channel_release_pipe_item
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:55 +01:00
Frediano Ziglio
1c1facdb4c Simplify smartcard_channel_release_pipe_item
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:36 +01:00
Frediano Ziglio
8dbd52f42a Simplify dcc_release_item
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:33 +01:00
Frediano Ziglio
ce9a770dd9 Simplify release_item_after_push
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:28 +01:00
Frediano Ziglio
767818da66 Handle STREAM_CREATE and STREAM_DESTROY pipe items more coherently
The items of these pipe items were allocated staticaly inside the
StreamAgent structure. All others RedPipeItem are allocated dynamically.
This could solve possible future maintenance as the life of these
item is more easier to understand.
It's more easier to understand why reference where incremented.
It also make the StreamAgent structure a bit smaller.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:06 +01:00
Frediano Ziglio
f94ef59de8 Simplify release of STREAM_CREATE and STREAM_DESTROY pipe items
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:03 +01:00
Frediano Ziglio
68c6d52e32 Simplify release of CREATE_SURFACE and DESTROY_SURFACE pipe items
Putting base as first item the default free function is fine.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:49:24 +01:00
Frediano Ziglio
9ecff9e061 Call red_pipe_item_unref instead of free
This is the standard way to release a RedPipeItem

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:49:16 +01:00
Frediano Ziglio
d26648404a Simplify RED_PIPE_ITEM_TYPE_DRAW item release
Move ring_remove to the function to release this type of item.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:49:05 +01:00
Frediano Ziglio
298c88757e Remove useless assignment
Type was already initialized calling red_pipe_item_init

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:48:44 +01:00
Frediano Ziglio
fa118d5567 Remove unused refs field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:48:12 +01:00
Frediano Ziglio
8e1859a102 remove only written num_mig_target_clients field in RedsState
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-17 16:33:04 +01:00
Frediano Ziglio
550a56b585 remove only written peer_minor_version field in RedsState
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-17 16:32:37 +01:00
Frediano Ziglio
538080da76 use more portable SPICE_OFFSETOF instead of offsetof
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-17 16:31:50 +01:00
Frediano Ziglio
e8017dd366 glz: simplification of PIXEL_DIST calls
Make macro have same prototype even if we need an extra argument.
This avoids having different calls for LZ_PLT.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2016-05-17 16:03:38 +01:00
Frediano Ziglio
aaa5853e39 stats: change image statistics format
Change from %f to %g. This allows printf to choose format based on
order of numbers.
Also increase precision making sure that number of precision is
respected, not matter the order of the number.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-05-17 11:50:52 +01:00
Frediano Ziglio
cd1e1e3d9b stats: simplify printing statistics
Use some utility function to show and compute statistics.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-05-17 09:59:22 +01:00
Frediano Ziglio
2c3fc80e51 fix wrong assert causing streaming to crash
This regression was introduced by commit
18d3876b78
("UpgradeItem: use base PipeItem for refcounting")

This fix https://bugs.freedesktop.org/show_bug.cgi?id=95365.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-13 12:37:54 +01:00
Frediano Ziglio
4585fa9cbd unify header include order
Use this style for include headers inside headers:

  #include <system_headers.h>
  #include <no_spice_no_system_libraries.h>
  #include <spice_protocol.h>
  #include <spice_common.h>

  #include "spice_server.h"

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-12 11:02:54 +01:00
Jonathon Jongsma
c79c37b3c2 Add missing include to red-pipe-item.h
This doesn't cause problems at the moment, because the files that
include this file also include the other files that are needed, but just
for completeness...

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-05-12 10:59:39 +01:00
Marc-André Lureau
79dcba4efa spice-migration.h: un-deprecate set_seamless_migration()
This function was wrongly marked as deprecated in commit b41220b144.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-12 06:34:11 +01:00
Frediano Ziglio
07b7abeb59 fix crash if agent interface is removed
Removing an interface cause SpiceBaseInstance->st to be set to NULL.
This pointer was then deferenced in agent code.
As SpiceBaseInstance should not be used after this call make sure
we don't keep pointers to it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-11 16:57:47 +01:00
Frediano Ziglio
6433d94636 reset pointer to RedCharDeviceWriteBuffer calling red_char_device_write_buffer_release
This code make easier to be sure we don't have dangling pointers
resetting in the function which free the structure.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-10 16:53:33 +01:00
Frediano Ziglio
7c79c0f6a8 char-device: improved comment
- fix typo;
- simplify sentence.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-09 14:21:58 +01:00
Frediano Ziglio
8271168a35 Remove unused definitions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-09 14:21:47 +01:00
Frediano Ziglio
76f643030f remove sw-canvas.h
This include was just including another file

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-05-09 12:45:37 +01: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
Frediano Ziglio
945834b460 remove dangling pointer for RedCharDeviceVDIPort
When a client disconnects remove it from the list of clients connected
to the spice char-device.

This was caused by commit 1cec1c5118
("reds: Make VDIPortState a GObject") as the lifespan of RedCharDevice
was changed.

This could be reproduced with:
- start rhel7 machine
- connect remote viewer (RV)
- RV: login
- connect ssh
- SSH: stop agent
- disconnect RV
- SSH: start agent
- connect to RV

and caused (using address sanitizer):

main_channel_handle_parsed: agent start
=================================================================
==29592==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c00001cff0 at pc 0x7fa85b6e8595 bp 0x7ffde3801940 sp 0x7ffde3801930
READ of size 8 at 0x60c00001cff0 thread T0
    #0 0x7fa85b6e8594 in red_client_get_main /home/freddy/work/spice-server/server/red-channel.c:2190
    #1 0x7fa85b7311e6 in vdi_port_send_msg_to_client /home/freddy/work/spice-server/server/reds.c:880
    #2 0x7fa85b69383e in red_char_device_send_msg_to_client /home/freddy/work/spice-server/server/char-device.c:138
    #3 0x7fa85b69383e in red_char_device_send_msg_to_clients /home/freddy/work/spice-server/server/char-device.c:356
    #4 0x7fa85b69383e in red_char_device_read_from_device /home/freddy/work/spice-server/server/char-device.c:403
    #5 0x55a2633b81c1  (/usr/bin/qemu-system-x86_64+0x5561c1)
    #6 0x55a2633afe7a  (/usr/bin/qemu-system-x86_64+0x54de7a)
    #7 0x55a2634cb7b1  (/usr/bin/qemu-system-x86_64+0x6697b1)
    #8 0x55a2632078d0  (/usr/bin/qemu-system-x86_64+0x3a58d0)
    #9 0x55a26379b2e8  (/usr/bin/qemu-system-x86_64+0x9392e8)
    #10 0x55a26379a7a0  (/usr/bin/qemu-system-x86_64+0x9387a0)
    #11 0x55a26313fb78 in main (/usr/bin/qemu-system-x86_64+0x2ddb78)
    #12 0x7fa85a3cc57f in __libc_start_main (/lib64/libc.so.6+0x2057f)
    #13 0x55a26314b0c8  (/usr/bin/qemu-system-x86_64+0x2e90c8)

0x60c00001cff0 is located 48 bytes inside of 128-byte region [0x60c00001cfc0,0x60c00001d040)
freed by thread T0 here:
    #0 0x7fa869e3667a in __interceptor_free (/lib64/libasan.so.2+0x9867a)
    #1 0x7fa85b6d75f7 in red_client_unref /home/freddy/work/spice-server/server/red-channel.c:2076
    #2 0x7fa85b6ead74 in dispatcher_handle_single_read /home/freddy/work/spice-server/server/dispatcher.c:291
    #3 0x7fa85b6ead74 in dispatcher_handle_recv_read /home/freddy/work/spice-server/server/dispatcher.c:314
    #4 0x55a26379b2e8  (/usr/bin/qemu-system-x86_64+0x9392e8)
    #5 0x55a26379a7a0  (/usr/bin/qemu-system-x86_64+0x9387a0)
    #6 0x55a26313fb78 in main (/usr/bin/qemu-system-x86_64+0x2ddb78)
    #7 0x7fa85a3cc57f in __libc_start_main (/lib64/libc.so.6+0x2057f)

previously allocated by thread T0 here:
    #0 0x7fa869e36b19 in __interceptor_calloc (/lib64/libasan.so.2+0x98b19)
    #1 0x7fa85b7d6858 in spice_malloc0 /home/freddy/work/spice-server/spice-common/common/mem.c:109
    #2 0x7fa85b6e760c in red_client_new /home/freddy/work/spice-server/server/red-channel.c:2053
    #3 0x7fa85b7449e4 in reds_handle_main_link /home/freddy/work/spice-server/server/reds.c:1762
    #4 0x7fa85b7449e4 in reds_handle_link /home/freddy/work/spice-server/server/reds.c:2002
    #5 0x7fa85b745d3a in reds_handle_ticket /home/freddy/work/spice-server/server/reds.c:2056
    #6 0x55a26379b2e8  (/usr/bin/qemu-system-x86_64+0x9392e8)
    #7 0x55a26379a7a0  (/usr/bin/qemu-system-x86_64+0x9387a0)
    #8 0x55a26313fb78 in main (/usr/bin/qemu-system-x86_64+0x2ddb78)
    #9 0x7fa85a3cc57f in __libc_start_main (/lib64/libc.so.6+0x2057f)

SUMMARY: AddressSanitizer: heap-use-after-free /home/freddy/work/spice-server/server/red-channel.c:2190 red_client_get_main
Shadow bytes around the buggy address:
  0x0c187fffb9a0: fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa
  0x0c187fffb9b0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c187fffb9c0: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c187fffb9d0: fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa
  0x0c187fffb9e0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0c187fffb9f0: fa fa fa fa fa fa fa fa fd fd fd fd fd fd[fd]fd
  0x0c187fffba00: fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa
  0x0c187fffba10: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c187fffba20: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c187fffba30: fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa
  0x0c187fffba40: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2016-05-05 18:04:37 +01:00
Pavel Grunt
9d777e427a agent-msg-filter: Move include from header
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-04 14:40:51 +01:00
Frediano Ziglio
3f67f73c94 char-device: remove unused refs field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-05-04 13:09:56 +01:00
Francois Gouget
0e10629d70 server: Enable adding alternative MJPEG video encoders
This replaces the original mjpeg_encoder API with a VideoEncoder base
class which can be reimplemented by other encoders.
This also renames the members and enums from mjpeg_* to video_*.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-04 10:51:55 +01:00
Francois Gouget
8a5ba34c01 server: Correctly handle and trace stream report errors
We may get stream reports after the stream has been closed, and even, in
extreme cases, after a new stream has started reusing the same stream
id. Neither case should cause the server to crash.
So restore dcc_handle_stream_report() to how it was before being moved
to dcc.c.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-05-04 10:49:13 +01:00
Snir Sheriber
69edf8307d Using already exists function instead of SPICE_CONTAINEROF
Using spicevmc_red_channel_client_get_state(rcc) (which already
exists) instead of SPICE_CONTAINEROF(rcc->channel, SpiceVmcState,
channel).

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-04 10:46:35 +01:00
Jonathon Jongsma
a08bf51383 Name MainChannelClient methods consistently
Always use main_channel_client_ prefix instead of just main_channel_ in
some cases.
2016-04-29 15:49:56 -05:00
Jonathon Jongsma
88d76a9faa Call public RedClient API instead of poking internals
Use red_client_during_migrate_at_target() instead of checking
rcc->client->during_target_migrate.
2016-04-29 14:58:21 -05:00
Jonathon Jongsma
f38cddfacf Don't touch RedClient internals from RedChannelClient
Change red_channel_client_set_migration_seamless() so that it returns a
boolean which RedClient can use to update its internal count of
num_migrated_channels rather than having RedChannelClient reaching into
the internals of RedClient
2016-04-29 14:57:34 -05:00
Christophe Fergeau
fb1ccd0f0d audio: Remove global 'playback_compression' variable
This variable belongs to SpiceServerConfig rather than being a static
global variable hidden in sound.c

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-27 10:27:35 -05:00
Christophe Fergeau
8551280d43 Remove dead code in reds_fill_channels()
channels_info->num_of_channels is assigned, its value is not used, and
then it's assigned a different value. The first assignment can be
removed.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-27 10:27:31 -05:00
Christophe Fergeau
8e5bacd8b1 Improve Reds/RedMainChannel interface
Instead of exporting 2 methods to get number of channels, and to fill
channel information, and use that from the main channel code, it's
better to do everything in one go in reds.c, and call that single method
from the main channel code.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-27 10:27:27 -05:00
Christophe Fergeau
b0cc5bfcbd Add _config_ to SpiceServerConfig accessors
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-27 10:27:23 -05:00
Christophe Fergeau
b41220b144 Mark unused public API methods/code as deprecated
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-27 10:27:08 -05:00
Christophe Fergeau
4b45b74144 Add RedServerConfig
This wraps/groups the various parameters that can be set by spice-server
users through the spice_server_set_xxx public API.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-27 10:27:05 -05:00
Jonathon Jongsma
920e117c24 Rename all RedPipeItem subclasses
Use 'Red' prefix to match internal type naming convention

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 10:22:26 -05:00
Jonathon Jongsma
b9720d80e0 Rename PipeItem to RedPipeItem
Following internal type naming conventions

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 10:22:01 -05:00
Christophe Fergeau
64dc3ab244 Use weak gobject ref instead of reds_on_char_device_state_destroy
RedCharDevice implementation had to callback into reds.c in order to let
it know a char device was being destroyed. Now that RedCharDevice is a
gobject, a weak reference can be used instead allowing to remove that
coupling.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-27 09:41:01 -05:00
Christophe Fergeau
d232e92794 Use GQueue for RedCharDevice::send_queue
There was an extra RedCharDeviceMsgToClientItem type whose only
purpose was to manage a linked list of items to send. GQueue has the
same purpose as this type in addition to being generic. As the length of
the send queue is tracked, a GQueue is more appropriate than a GList and
allow to remove RedCharDevice::send_queue_size.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 09:41:01 -05:00
Jonathon Jongsma
18d3876b78 UpgradeItem: use base PipeItem for refcounting
No need to re-implement refcounting in this subclass.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 09:40:57 -05:00
Jonathon Jongsma
50a2c2fce2 Store display in Drawable struct
If the Drawable keeps a pointer to the Display channel that it is
associated with, we can unref it directly and not need to pass the
'display' parameter separately to the unref function

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 09:40:43 -05: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