Commit Graph

660 Commits

Author SHA1 Message Date
Alon Levy
7e3fb815cc server/tests/basic_event_loop: print something on channel_event 2012-02-15 15:09:13 +02:00
Alon Levy
5ec8515508 server, separate SpiceChannelEventInfo from RedStream
fixes rhbz 790749 use after free of SpiceChannelEventInfo.

The lifetime of the SpiceChannelEventInfo was that of RedsStream, but it
is used by main_dispatcher_handle_channel_event after the RedsStream is
freed for the cursor and display channels. Making SCEI allocation be at
RedsStream allocation, and deallocation after the DESTROY event is
processed by core->channel_event, fixes use after free.
2012-02-15 15:04:04 +02:00
Dan McGee
3f303d6014 Remove all usages of bzero()
As recommended by modern C practice, we should just be using memset().

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-02-14 18:19:43 +02:00
Dan McGee
08c514ee85 Remove extra '\n' from red_printf() calls
red_printf() takes care of adding a newline to all messages; remove the
extra newline from all messages and macros that were doubling them up.

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-02-14 18:19:29 +02:00
Alon Levy
e4a92b177a server/tests: use getopt_long 2012-02-14 17:30:50 +02:00
Fabiano Fidêncio
33bd5d2797 Adding image to be used as "correct" in regression tests 2012-02-14 14:53:47 +02:00
Fabiano Fidêncio
1e8e2f9ee0 Adding support to automated tests
As suggested by Alon, a simple automated test to try to find
    regressions in Spice code.
    To use this, compile Spice with --enable-automated-tests and
    run test_display_streaming passing --automated-tests as parameter.
2012-02-14 14:53:44 +02:00
Dan McGee
aebe837d3a Add casts for compatibility purposes
Some non-Linux platforms return a (caddr_t *) result for the return
value of mmap(), which is very unfortunate. Add a (void *) cast to
explicitly avoid the warning when compiling with -Werror.

For the IO vector related stuff, signed vs. unsigned comes into play so
adding a (void *) cast here is technically correct for all platforms.

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-02-14 10:44:49 +02:00
Yonit Halperin
5868c99da6 server: support IPV6 addresses in channel events sent to qemu
RHBZ #788444

CC: Gerd Hoffmann <kraxel@redhat.com>

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
2012-02-12 13:15:18 +02:00
Hans de Goede
8817549795 Release 0.10.1 2012-01-23 15:58:13 +01:00
Alon Levy
459a4dba56 server/red_channel: red_peer_handle_incoming: comment on null check
Signed-off-by: Alon Levy <alevy@redhat.com>
2012-01-23 12:58:30 +02:00
Alon Levy
51d7598a2e server/tests/test_empty_success: fix warning on bzero
Signed-off-by: Alon Levy <alevy@redhat.com>
2012-01-23 12:41:56 +02:00
Nahum Shalman
781706ea0d server: don't complain if setsockopt(SO_PRIORITY) call fails
dc7855967f did this for the TCP_NODELAY and IP_TOS calls; we should do
it for priority as well if necessary.

We also #ifdef the setting of the low-level socket priority based on
whether we have a definition of SO_PRIORITY available. This option is
not available on Illumos/Solaris platforms; however, since we set IP_TOS
anyway it is not a big deal to omit it here.
2012-01-23 12:28:58 +02:00
Dan McGee
89cc196a1b server/inputs_channel: don't set O_ASYNC option on socket
output to send a SIGIO signal to the running program. However, we don't
handle this signal anywhere in the code, so setting the option is
unnecessary.

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-01-23 12:28:58 +02:00
Dan McGee
b0b19f4b25 Update .gitignore with a few more generated files
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-01-23 12:28:58 +02:00
Dan McGee
c4ddc5ba51 Fix git commit hook errors in red_worker
This ensures all line lengths are down below 100 characters as well as
removing some trailing spaces.

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-01-23 12:28:57 +02:00
Dan McGee
046b88ec64 Fix line length errors in main_channel
These are all existing errors; fix them so they don't block future
commits in this file unnecessarily.

    error (1): length @ server/main_channel.c +369
    error (2): length @ server/main_channel.c +444
    error (3): length @ server/main_channel.c +764
    error (4): length @ server/main_channel.c +932
    error (5): length @ server/main_channel.c +1044

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2012-01-23 12:28:57 +02:00
Alon Levy
88f68f5329 server/red_channel: avoid segfault if stream == NULL 2012-01-22 15:13:32 +02:00
Hans de Goede
dc7855967f server: Don't complain if setsockopt NODELAY fails on unix sockets
With Daniel P. Berrange's patches to allow use of pre-supplied fd's
as channels, we can no longer be sure that our connections are TCP
sockets, so it makes no sense to complain if a TCP/IP specific
setsockopt fails with an errno of ENOTSUP.

Note that this extends Daniel's commit 492ddb5d1d
which already added the same check to server/inputs_channel.c

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-01-18 11:14:40 +01:00
Daniel P. Berrange
68c2897e5b Remove trailing whitespace from end of lines 2012-01-13 18:11:59 +02:00
Daniel P. Berrange
7427b23d84 Add missing includes of config.h
Not all files were including config.h
2012-01-13 18:11:59 +02:00
Daniel P. Berrange
d46bc77278 Remove bogus include of strings.h
The tests include strings.h but don't need any of its functions
2012-01-13 18:11:59 +02:00
Daniel P. Berrange
02d56750bd Remove trailing blank lines
Remove any blank lines at the end of all source files
2012-01-13 18:11:59 +02:00
Daniel P. Berrange
8ab7c4535a Remove 'the the' typos 2012-01-13 18:11:59 +02:00
Daniel P. Berrange
9f087ee7f0 Remove unused assert.h include
The assert.h include was never used in any code
2012-01-13 18:11:59 +02:00
Daniel P. Berrange
d262f1d96e Rewrite code to avoid triggering warning about casting param to free()
Since free() takes a void* parameters do not need to be cast.

The existing code here is actally fine, but it trips up the
syntax-check rule, so tweak it to an equivalent construct
which passes the syntax check
2012-01-13 18:11:58 +02:00
Daniel P. Berrange
faf0947ebb Remove useless if() before free()
The free() function allows NULL to be passed in, so any
code which puts a if() before free() is wasting time
2012-01-13 18:11:58 +02:00
Daniel P. Berrange
64f4826b6d Death to all TABs
Source files should all use spaces instead of tabs for
indentation. Update the few files not already in
compliance
2012-01-13 18:11:58 +02:00
Hans de Goede
c6800dacf0 smartcard handling: Fix compilation when ASSERT-s are turned on
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-01-13 15:21:17 +01:00
Yonit Halperin
65c859ba81 server: add support for SPICE_COMMON_CAP_MINI_HEADER
Support for a header without a serial and without sub list.
red_channel: Support the two types of headers.
             Keep a consistent consecutive messages serial.
red_worker: use urgent marshaller instead of sub list.
snd_worker: Sound channels need special support since they still don't use
            red_channel for sending & receiving.
2012-01-12 16:33:36 +02:00
Yonit Halperin
8b64b95c43 server: Limit the access to SpiceDataHeader of messages - only via red_channel. 2012-01-12 16:17:02 +02:00
Yonit Halperin
a54f26d04e server/red_worker: pass remote caps to display/cursor red_channel_client's 2012-01-12 16:17:01 +02:00
Yonit Halperin
b689abe576 server/red_channel: introduce urgent marshaller
When red_channel::red_channel_client_begin_send_message is called,
the message that is pending in the urgent marshaller will be sent before
the one in the main channel.
The urgent marshaller should be used if in the middle of marshalling one message,
you find out you need to send another message before. This functionality
is equivalent to the sub_list messages. It will replace them in the following
patches, when sub_list is removed from Spice data header.
2012-01-12 16:17:00 +02:00
Daniel P. Berrange
492ddb5d1d Do not assume that SPICE is using a TCP socket
If setting the TCP_NODELAY socket option fails with ENOTSUP,
then don't treat this is a fatal error. SPICE is likely just
running over a UNIX socket instead.

* server/inputs_channel.c: Ignore TCP_NODELAY socket opt fails

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-01-09 18:57:57 +01:00
Daniel P. Berrange
bd07dde530 Allow auth to be skipped when attaching to pre-accepted clients
When an applications passes in a pre-accepted socket for a
client, they may well have already performed suitable authentication
out of band. They should thus have the option to request that any
spice authentication is skipped.

* server/reds.c, spice.h: Add flag for skipping auth

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-01-09 18:57:57 +01:00
Daniel P. Berrange
d55b68b6b4 Add APIs for injecting a client connection socket
Allow applications to pass a pre-accepted client socket file
descriptor in. The new APIs are spice_server_add_ssl_client
and spice_server_add_client

* server/reds.c: Implement new APIs
* server/spice.h: Define new APIs

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-01-09 18:57:57 +01:00
Daniel P. Berrange
803be1bea7 Move SSL setup out of reds_accept_ssl_connection
To allow setup of an SSL client, from a passed in client
socket, move all the SSL client initialization code out
of reds_accept_ssl_connection and into a new method called
reds_init_client_ssl_connection

* server/reds.c: Introduce reds_init_client_ssl_connection

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-01-09 18:57:57 +01:00
Daniel P. Berrange
3a3a32ebbc Rename __reds_accept_connection into reds_init_client_connection
Remove the accept() call from __reds_accept_connection and
rename it to reds_init_client_connection. The caller is now
responsible for accepting the new socket. The method
reds_init_client_connection merely initializes it for
usage.

* server/reds.c: Add reds_init_client_connection

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-01-09 18:57:57 +01:00
Daniel P. Berrange
4eb78d39c5 Merge reds_accept_connection into reds_accept
Neither reds_accept_connection or reds_accept are very long,
so the split is pointless & increases code size for no gain.
Merge them together to reduce code size

* server/reds.c: Merge reds_accept_connection into reds_accept

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-01-09 18:57:57 +01:00
Hans de Goede
3435df1234 spicevmc: Set sockopt nodelay for usbredir channels
We want as little latency as possible with usb channels.

Signed-off-by: Hans de goede <hdegoede@redhat.com>
2011-12-22 12:48:10 +01:00
Yonit Halperin
fe001ca19d server: don't reset the display channel when disconnecting all its clients ,FDBZ #43977
The display channel was unnecessarily set to NULL when we disconnect all the clients
(on flush display commands timeout).
As a result, we recreated the display channel when a new client was connected.
The display channel was created with default red_channel.client_cbs, while its
correct client_cbs are the ones that are set by the red_dispatcher when it creates
the first display_channel.
This fix enforces a single creation of the display channel (per qxl), via the red_dispatcher.
2011-12-22 12:58:25 +02:00
Hans de Goede
ffc4de01e6 spicevmc: Fix assert when still connected on session disconnect (fdo#43903)
Currently when the main channel disconnects while a spicevmc channel
(such as a usbredir channel) is still connected, qemu will abort with the
following message:
ring_remove: ASSERT item->next != NULL && item->prev != NULL failed

This is caused by red_client_destroy() first calling:
rcc->channel->client_cbs.disconnect(rcc);
And then calling:
red_channel_client_destroy(rcc);

For each channel. This is fine, but the spicevmc disconnect code does a
red_channel_client_destroy(rcc) itself since as usb devices are added
/ removed, the channels carrying their traffic get connected / disconnected
and they get re-used for new devices, which won't work if the old channel is
still there when the new connection comes in.

This patch fixes the double destroy when there are still spicevmc channels
connected by not doing the red_channel_client_destroy from the spicevmc
disconnect code when not just the channel, but the entire client is
disconnecting.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-12-18 11:20:12 +01:00
Hans de Goede
ee315779a0 server/red_parse_qxl.h: License should be LGPLv2+ rather then GPLv2+
Also fixup the header of server/red_parse_qxl.c, which still contained
some GPL (program rather then library) text in its header.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-12-15 13:12:31 +01:00
Jürg Billeter
dedaa9ac39 server: Move $(Z_LIBS) from INCLUDES to LIBADD in Makefile.am
This fixes undefined references to deflate* when building tests.

Signed-off-by: Jürg Billeter <j@bitron.ch>
2011-11-28 11:05:49 +01:00
Alon Levy
2548cd713d server/mjpeg_encoder: use size_t * consistently
fix another 64 bit-ism. unsigned long != size_t in general.
2011-11-10 16:29:19 +02:00
Alon Levy
6d89b2ba4c server/main_channel: fix pointer-to-int-cast error
64 bit-ism removed.
2011-11-10 16:28:07 +02:00
Alon Levy
ebfa95cd47 server/main_channel: use PRIu64 where needed 2011-11-10 16:25:18 +02:00
Alon Levy
1b8a8b2517 server/spice-server.syms: fix 0.8 compatibility
spice_server_migrate_connect is in 0.8.3 in the released 0.8 branch,
and so should not be changed in 0.10. This doesn't break the 0.9.1
release which didn't contain this symbol at all, only 0.9.2 release
that hopefully no one actually packaged.
2011-11-08 17:10:47 +02:00
Alon Levy
8e049ce3b0 server/red_worker: reuse dispatcher
This patch reuses Dispatcher in RedDispatcher. It adds two helpers
to red_worker to keep RedWorker opaque to the outside. The dispatcher is
abused in three places that use the underlying socket directly:
 once sending a READY after red_init completes
 once for each channel creation, replying with the RedChannel instance
  for cursor and display.

FDO Bugzilla: 42463

rfc->v1:
* move callbacks to red_worker.c including registration (Yonit)
* rename dispatcher to red_dispatcher in red_worker.c and red_dispatcher.c
* add accessor red_dispatcher_get_dispatcher
* s/dispatcher_handle_recv/dispatcher_handle_recv_read/ and change sig to
  just Dispatcher *dispatcher (was the SpiceCoreInterface one)
* remove SpiceCoreInterface parameter from dispatcher_init (Yonit)
* main_dispatcher needed it for channel_event so it has it in
  struct MainDispatcher
* add dispatcher_get_recv_fd for red_worker
2011-11-08 16:23:10 +02:00
Alon Levy
ca5776f40e server/dispatcher: add dispatcher_register_async_done_callback 2011-11-08 16:22:21 +02:00