Commit Graph

2738 Commits

Author SHA1 Message Date
Frediano Ziglio
f75b69fdc8 make red_pipe_item_ref more typesafe
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
8d764488ca make red_pipe_item_init_full more typesafe
Use a proper type for free callback

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
e960e00392 Use a marker instead of checking a RedPipeItem presence
This avoids having to retain a pointer just to check item is still in
the queue with ring_item_is_linked(&item->link).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
f12464b2f1 Call dcc_send_item directly
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
27145ed9aa Handle reference for RedPipeItem in RedChannel
Remove the need to release the item inside send_item callbacks.
This looks like a partial rollback of previous patch but is
to make clear the intention of the change.
The lifetime of items could extend a bit further but there
are no cases this small lag should cause problems.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
138a11a163 Remove RedChannel::hold_item callback
This is quite confusing and prone to errors.
Use RedPipeItem reference counting instead.
To compensate for the additional reference due to red_pipe_item_ref
in RedChannel sub class with empty hold_item have to add a
red_pipe_item_unref call in send_item.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Jonathon Jongsma
17526096aa Remove 'peer' from name of channel client methods
There is some inconsistent naming of RedChannelClient methods. Some
include the word 'peer' (which normally seems to refer to RedsStream).
Remove the 'peer' terminology from those functions that are basically
RedChannelClient methods.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-20 16:12:09 -05:00
Frediano Ziglio
c037c779df let compiler manage the copy in a more typesafe way
Do not use memcpy but just copy the data

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-05-20 09:17:11 -05:00
Jonathon Jongsma
a11b785f19 Move MainChannelClient to separate file
Preparation for converting to GObject

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-20 09:16:47 -05:00
Uri Lublin
b028c2e38a glz: simplification of do_match and PIXEL_ID
Following commit e8017dd366 here
are some more ifdef simplification.

For PIXEL_ID and PIXEL_DIST macros,
the ifndef LZ_PLT defines are special cases of the LZ_PLT
(#else) defines, when pix_per_byte is 1

Now do_match can accept pix_per_byte param for all different
definitions (implementations).

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-05-20 11:46:30 +01:00
Frediano Ziglio
79292edd56 Fix typo in comment
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2016-05-20 05:53:57 +01:00
Frediano Ziglio
a3c0859122 style: Add an abbreviation
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2016-05-20 05:53:57 +01:00
Jonathon Jongsma
f7a17f81ea Add red_client_seamless_migration_done_for_channel()
This is a public RedClient API that handles updating itself rather than
having the RedChannelClient poke around at the internal structure in
rec_channel_client_seamless_migration_done().
2016-05-19 14:27:36 -05:00
Jonathon Jongsma
2e326085ad Simplify DisplayChannel hold_item()
Since all pipe items implement refcounting now, just call
red_pipe_item_ref() and eliminate the switch statement.
2016-05-19 14:04:57 -05:00
Jonathon Jongsma
6b0eabc903 Remove unnecessary cursor_pipe_item_ref()
Use the base red_pipe_item_ref() instead of adding an additional static
wrapper function.
2016-05-19 13:54:14 -05:00
Frediano Ziglio
1be06f188e make spice-server-replay use dynamic spice-server library
spice-server-replay is built with the same settings as tests.
Currently the tests links to a convenience spice-server library.
A convenience library is a static library build with object file
for a dynamic library.
This make all tests contain all spice-server library code and not
linking to the spice-server dynamic library (the .so).
It's not a problem for most tests however this make impossible for
spice-server-replay utility to be used with a dynamic spice-server
library (you have to recompile it including the library).
This is a pity as you could for instance compare your system
library behavior with the library you are developing.
Also if we decide to install in a future the utility for testing
we would have lot of code duplication.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-18 14:57:06 +01:00
Frediano Ziglio
fa0c32f120 remove a warning building a test
With my compile switches (which are mostly derived from RedHat spec
file) I'm getting this warning:

stream-test.c: In function 'sock_fd_read':
stream-test.c:66:43: warning: dereferencing type-punned pointer will
break strict-aliasing rules [-Wstrict-aliasing]
             *fd = *((int *) CMSG_DATA(cmsg));
                                           ^

memcpy could decrease performance but as this is a test it's not
an issue.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-18 14:52:10 +01:00
Frediano Ziglio
fb10f5bf52 Simplify #ifdef/#endif in glz code
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-18 00:24:37 +01:00
Frediano Ziglio
3349610652 char-device: Update function names in documentation
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-18 00:24:37 +01:00
Frediano Ziglio
f36c3887ba Make sure all headers are independent
Make sure is possible to include any headers alone.

I used this script to check independence (run under server directory):
----
#!/bin/bash

set -e

# check not already modified
if grep -q libheaders.la Makefile.am; then
    echo "Header library already prepared" >&2
    exit 1
fi

add_lib() {
    local hdr="$1"

    hdr=${hdr%.h}
    c="mao_${hdr}.c"
    echo "#include \"${hdr}.h\"" > $c
    echo -e "\t$c \\" >&3
}

# add library to compile all headers alones
exec 3>> Makefile.am
echo "
noinst_LTLIBRARIES += libheaders.la
libheaders_la_SOURCES =				\\" >&3
for hdr in *.h; do
    case $hdr in
    spice-bitmap-utils.h)
        add_lib $hdr
        ;;
    spice*.h)
        ;;
    *)
        add_lib $hdr
        ;;
    esac
done
echo -e "\t\$(NULL)" >&3
exec 3>&-
----

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-18 00:24:37 +01:00
Frediano Ziglio
9fd82215d1 style: Add some documentation for names
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-18 00:24:37 +01:00
Frediano Ziglio
e72fec2289 Use more reference counting on RedPipeItem
This is the continuation of Christophe patches using reference
counting for RedPipeItem.
Extend it's usage.
This for instance leads to the removal of release_item callback.
2016-05-18 00:22:43 +01:00
Frediano Ziglio
c6fa38f468 Use reference counting for RedPipeItem
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:55:07 +01:00
Frediano Ziglio
879b280049 Reuse red_channel_client_release_sent_item function
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:54:53 +01:00
Frediano Ziglio
7f570579e5 Make red_channel_client_clear_sent_item static
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:54:16 +01:00
Frediano Ziglio
b1476746d4 Remove red_channel_client_release_item
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:54:06 +01:00
Frediano Ziglio
fef7bec4a9 Remove release_item callback
Just a call to red_pipe_item_unref.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:53:58 +01:00
Frediano Ziglio
7b49fc836b Remove main_channel_release_pipe_item
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:53:49 +01:00
Frediano Ziglio
5b6adf091c Simplify main_channel_release_pipe_item
Reuse RedPipeItem facilities.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:53:41 +01:00
Frediano Ziglio
33883bd163 Use a default release_item implementation in RedChannel
Avoid having to provide a lot of empty implementations

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:53:34 +01:00
Frediano Ziglio
44352ca846 Remove dcc_release_item
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:53:27 +01:00
Frediano Ziglio
6db1afd262 Simplify pipe items release in CursorChannel
All RedPipeItems can be freed with red_pipe_item_unref.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:53:17 +01:00
Frediano Ziglio
da39bb1b12 Reuse RedPipeItem facilities for RedCursorPipeItem
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:53:05 +01:00
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