Commit Graph

1335 Commits

Author SHA1 Message Date
Aric Stewart
3cd2f843b5 update windows client generate.bat and generate1.bat
the python script is now in spice-common and client_marshallers.h needs
to be included instead of marshallers.h
2012-04-17 10:24:19 +03:00
Alon Levy
2ec2dbc78a server: allow failure in getvirt
This patch changed getvirt to continue working even if spice_critical
doesn't abort (i.e. SPICE_ABORT_LEVEL != -1). This is in preparation to
make getvirt not abort at all. The reason is that getvirt is run on
guest provided memory, so a bad driver can crash the vm.
2012-04-05 18:28:49 +03:00
Christophe Fergeau
2439c0dc90 Replace sprintf with snprintf use
The hotkey parser was generating a string with sprintf and data it got
from the controller socket (ie data which can have an arbitrary
length). Using sprintf there is a bad idea, replace it with snprintf.
2012-04-02 12:14:55 +02:00
Marc-André Lureau
8cd92109d4 spice-common: update to fix quic-encode warnings 2012-03-28 14:04:14 +02:00
Alon Levy
5dd5b70223 server: export spice_server_is_server_mouse predicate
To be used by qemu query-spice / info spice commands.
2012-03-26 14:41:03 +02:00
Marc-André Lureau
3fc870ad55 Remove files moved to spice-common 2012-03-26 02:40:17 +02:00
Marc-André Lureau
4d8f39020a Copy common/win/my_getopt-1.5/my_getopt client/windows 2012-03-25 19:00:00 +02:00
Marc-André Lureau
b34fd7432d Use the spice-common logging functions
It will abort by default for critical level messages. That behaviour
can be tuned at runtime.
2012-03-25 19:00:00 +02:00
Marc-André Lureau
359fc1cb5d Use the spice-common submodule
This patch will replace the common/ directory with the spice-common
project. It is for now a simple project subdirectory shared with
spice-gtk, but the goal is to make it a proper library later on.

With this change, the spice-server build is broken. The following
commits fix the build, and have been seperated to ease the review.

v2
- moves all the generated marshallers to spice-common library
- don't attempt to fix windows VS build, which should somehow be
  splitted with spice-common (or built from tarball only to avoid
  generation tools/libs deps)
v3
- uses libspice-common-client
- fix a mutex.h inclusion reported by Alon
2012-03-25 18:59:10 +02:00
Marc-André Lureau
4df135c858 sasl: small refactoring, check memcheck != NULL 2012-03-23 13:10:54 +01:00
Marc-André Lureau
d4ba4ee690 Use spice_strdup() to avoid crashing on NULL
qemu can call spice_server_set_name(s, NULL) when the name is not
given. Let's not crash in this case
2012-03-23 13:10:54 +01:00
Alon Levy
a7d3f1de82 server/tests: add resolution changes tester 2012-03-22 11:18:37 +02:00
Alon Levy
a6f9797c79 server/tests/test_display_base: add Command
add parameters to the commands used for display tests.
2012-03-22 11:18:37 +02:00
Alon Levy
c36bf55971 server/tests/test_display_base: remove 64bit arch assumptions 2012-03-21 17:58:25 +02:00
Alon Levy
aef7eaf9bb server/red_memslots: don't assume 64 bit environment
assumption that unsigned long == QXLPHYSICAL causes get_virt to compute
the wrong slot. Fix by replacing addr variables to be of type
QXLPHYSICAL.
2012-03-21 17:58:25 +02:00
Alon Levy
07f55e49f5 server/red_worker: fix for case where ASSERT is compiled out 2012-03-21 17:58:25 +02:00
Alon Levy
5391736c29 server/red_memslots: use QXLPHYSICAL for addresses
Cannot assume unsigned long == QXLPHYSICAL, not true for 32 bit
architectures.
2012-03-21 17:57:32 +02:00
Alon Levy
f360273614 server/red_memslots: drop two unused functions
cb_get_virt and cb_validate_virt have disappeared a long time ago,
not needed since:

commit 5ac88aa79f
Author: Gerd Hoffmann <kraxel@redhat.com>
Date:   Thu Jul 1 17:55:33 2010 +0200

    Properly parse QXLImage to the new-world SpiceImage

    SpiceImage now replaces RedImage and has all image types in it.
    All image data are now chunked (and as such not copied when demarshalling).
2012-03-21 17:56:39 +02:00
Christophe Fergeau
64e0974114 Don't truncate SPICE_FOREIGN_MENU_SOCKET
When we get the socket name for the foreign menu socket from
an environment variable, we cannot make assumptions about its length.
Currently, we are strncpying to a 50 byte buffer which is easily
too small.
2012-03-20 16:53:50 +01:00
Christophe Fergeau
3d452a312b Don't limit spice controller socket name to 50 chars
The spice controller socket name used to be hardcoded to
/tmp/SpiceController-%lu.uds and generated using snprintf. A 50 bytes
buffer was enough for that, but this was changed in commit 79fffbf95
because this was predictable and allowed other users on the system
to sniff the browser/client communication. spicec now uses the value
of the environment SPICE_XPI_SOCKET as the name of the socket to use.
However, since the name that is used is no longer generated by spicec,
no assumption can be made about its size. Currently, the socket is
created inside the user home directory, which means that if the
user name is too long, spicec will not be able to read the controller
socket name.
This commit directly uses the string from getenv as he name of the
controller socket (on Linux) instead of limiting its size to 50 characters,
which should fix this issue.
This fixes rhbz #804561
2012-03-20 16:53:40 +01:00
Christophe Fergeau
01c6f4d2c6 Remove unused Canvas members
The various Canvas have _max and _base variables which are not
used, better to remove them.
2012-03-20 16:53:35 +01:00
Alon Levy
910a3f8419 server/red_worker: don't typedef SpiceWatch twice
First defined in spice.h, fixes build failure with gcc 4.4.6
2012-03-20 15:39:02 +02:00
Hans de Goede
914e50814f red_worker: Check for NULL watches
If we run out of watches slots, we return NULL from watch_add, which
means that the other watch_foo functions may get called with a NULL
parameter, protect them against this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-03-13 16:41:02 +01:00
Nahum Shalman
42ac95e125 server: remove superfluous check
no need to duplicate the check that the fd isn't -1
2012-03-12 22:58:49 +02:00
Nahum Shalman
198ffb92d4 server: listen on a pre-opened file descriptor
Allow applications to pre-open a file descriptor and have spice listen
on it.

Thanks to Daniel Berrange for his comments
2012-03-12 12:33:20 +01:00
Nahum Shalman
20c7323c9e server: don't fail on ENOPROTOOPT from setsockopt
If we allow listening on arbitrary sockets like unix sockets,
we can get ENOPROTOOPT errors from setsockopt calls that set TCP
specific options.  This should be allowed to happen.
2012-03-12 12:32:58 +01:00
Hans de Goede
9a41e55296 red_channel: remove pre_disconnect hook
Now that red_worker's EventListener is gone there are no more users of it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-03-12 12:10:51 +01:00
Hans de Goede
a7841325b2 red_worker: Rework poll code to use the watch interface
Commit 143a1df24e changed red_worker_main
from epoll to poll. But epoll has edge triggered semantics (when requested
and we requested them), where as poll is always level triggered. And
red_worker was relying on the edge triggered semantics, as it was always
polling for POLLOUT, which, when edge triggered, would only cause poll
to register an event after we had blocked on a write. But after the
switch to regular poll, with its level triggered semantics, the POLLOUT
condition would almost always be true, causing red_worker_main to not
block on the poll and burn CPU as fast as it can as soon as a client was
connected.

Luckily we already have a mechanism to switch from polling for read only
to polling for read+write and back again in the form of watches. So this
patch changes the red_worker dummy watch implementation into a proper watch
implementation, and drops the entire EventListener concept since that then is
no longer needed.

This fixes spice-server using 400% CPU on my quad core machine as soon as
a client was connected to a multi head vm, and as an added bonus is a nice
cleanup IMHO.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-03-12 12:10:51 +01:00
Hans de Goede
b023f85ebd red_channel: Use the channel core to remove the stream watch on disconnect
We allow channels to have different core implementations, but we were
relying on reds_stream_free to remove the stream watch on disconnect,
and reds_stream_free always uses the qemu core implementation.

So far we were getting away with this since all the alternative core
implementations always return NULL from watch_add.

But:
1) The code before this patch clearly was not correct, since it was matching
   a channel-core watch_add with a qemu-core watch_remove
2) I plan to move red_worker over to actually using an alternative watch
   implementation at which point this becomes a real problem

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-03-12 12:10:22 +01:00
Hans de Goede
63e1514ccb red_worker: Remove ref counting from the EventListener struct
The red_worker EventListener struct is either embedded in one of:
1) DisplayChannelClient
2) CursorChannelClient
3) RedWorker

And as such gets destroyed when these get destroyed, in case 1 & 2 through
a call to red_channel_client_destroy().

So free-ing it when the ref-count becomes 0 is wrong, for cases:
1) and 2) this will lead to a double free;
3) this will lead to passing memory to free which was not returned by malloc.

This is not causing any issues as the ref-count never gets decremented, other
then in red_worker_main where it gets incremented before it gets decremented,
so it never becomes 0.

So we might just as well completely remove it.

Notes:
1) This is mainly a preparation patch for fixing issues introduced by
   the move from epoll to poll
2) Since removing the ref-counting removes the one code path where listeners
   would get set to NULL, this patch moves the setting of NULL to
   pre_disconnect, where it should have been done in the first place since
   red_client_destroy calls red_channel_client_disconnect
   (through the dispatcher) followed by red_channel_client_destroy, so
   after pre_disconnect the listener may be gone.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-03-10 13:56:29 +01:00
Hans de Goede
f24203e122 Ensure all members of ChannelCbs and ClientCbs are either assigned or NULL
While git-bisecting another issue I ended up hitting and not recognizing
the bug fixed by commit 7a079b452b.

While fixing this (again) I noticed that (even after the fix) not all
users of ChannelCbs first zero it. So this patch ensures that all users of
ChannelCbs first zero it, and does the same for ClientCbs while at it.

Since before this patch there were multiple zero-ing styles, some using
memset and other using a zero initializer this patch also unifies all
the zero-ing to use a NULL initializer for the first element.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-03-10 11:51:54 +01:00
Alon Levy
1029e7fd4d server/red_worker: fix use after free for listeners
This fixes a core dumped observed once by repeated migration. So far 100
migrations and no recurrence.

Core was generated by `/home/alon/spice/upstream/bin/qemu-system-x86_64 --enable-kvm -qmp unix:/tmp/mi'.
Program terminated with signal 11, Segmentation fault.
11197	                if (evt_listener && evt_listener->refs > 1) {
Missing separate debuginfos, use: debuginfo-install bluez-libs-4.98-3.fc17.x86_64 brlapi-0.5.6-4.fc17.x86_64 bzip2-libs-1.0.6-4.fc17.x86_64 cryptopp-5.6.1-6.fc17.x86_64 keyutils-libs-1.5.5-2.fc17.x86_64 libssh2-1.4.0-1.fc17.x86_64 nss-softokn-freebl-3.13.1-20.fc17.x86_64 xen-libs-4.1.2-11.fc17.x86_64 xz-libs-5.1.1-2alpha.fc17.x86_64
(gdb) bt
(gdb) l
11192	        for (i = 0; i < MAX_EVENT_SOURCES; i++) {
11193	            struct pollfd *pfd = worker.poll_fds + i;
11194	            if (pfd->revents) {
11195	                EventListener *evt_listener = worker.listeners[i];
11196
11197	                if (evt_listener && evt_listener->refs > 1) {
11198	                    evt_listener->action(evt_listener, pfd);
11199	                    if (--evt_listener->refs) {
11200	                        continue;
11201	                    }
(gdb) p evt_listener
$1 = (EventListener *) 0x7f15a9a5d1e0
(gdb) p *evt_listener
Cannot access memory at address 0x7f15a9a5d1e0
(gdb) p i
$2 = 2
(gdb) p worker.listeners
$3 = {0x7f15bc832520, 0x7f15a406e1a0, 0x7f15a9a5d1e0, 0x0 <repeats 17 times>}
2012-03-06 16:45:12 +02:00
Marc-André Lureau
1ab589f39e Use SPICE_FOREIGN_MENU_SOCKET if it's available
If specified, use SPICE_FOREIGN_MENU_SOCKET environment variable over
snprintf(pipe_name, PIPE_NAME_MAX_LEN, PIPE_NAME,
Platform::get_process_id()); since it's impossible to guess the client
pid when spice-xpi launches the client as a grand-child (via script
etc).

This is also more aligned with the way we handle SPICE_XPI_SOCKET
location.
2012-03-05 22:52:27 +01:00
Marc-André Lureau
01d565ff54 Fix spice-protocol reference 2012-03-05 19:36:25 +01:00
Marc-André Lureau
36d8da6283 Send name & uuid to capable clients
Add spice_server_set_name() and spice_server_set_uuid() that allows
the client to identify a Spice server (useful to associate settings
with a particular server)

The SPICE_MSG_MAIN_NAME and SPICE_MSG_MAIN_UUID messages are only sent
to capable clients, announcing SPICE_MAIN_CAP_NAME_AND_UUID.
2012-03-05 18:19:07 +01:00
Marc-André Lureau
f0ff2e383e demarshal: fixed-size array are missing __nelements
A message with a fixed-size array, such as uint8 uuid[16] will
generate an invalid code, missing the __nelements variable. Make sure
that variable is defined.
2012-03-05 18:19:07 +01:00
Christophe Fergeau
15808ea7f5 server: more logging about certificates used
This commit adds some log messages indicating which certificates
could be loaded (or not).

Fixes rhbz#787678
2012-03-05 10:14:36 +01:00
Christophe Fergeau
8f8e73986b Add log for invalid/expired tickets
Currently, when a ticket has already expired, or is invalid, there is
no qemu log to tell what went wrong. This commit adds such a log.

Fixes rhbz#787669
2012-03-05 10:14:36 +01:00
Christophe Fergeau
735f8e2837 mingw: workaround weird openssl build failure
If X509_NAME isn't undefined before including x509v3.h, very
weird compilation error occurs. It seems to be caused by duplicate
definitions for this symbols coming from wincrypto.h
2012-03-04 10:50:39 +02:00
Christophe Fergeau
0f94e897b5 mingw: don't try to redefine alloca
mingw already has a #define alloca __builtin_alloca so trying to
redefine it triggers a warning.
2012-03-04 10:50:39 +02:00
Christophe Fergeau
32cd24be0a mingw: fix signed/unsigned comparison warnings 2012-03-04 10:50:38 +02:00
Christophe Fergeau
58b9aa9853 mingw: add workaround for _ftime_s issue on mingw
mingw has a _ftime_s prototype in its headers, but no corresponding
symbol available at link time. Workaround this issue for now by
 #defining it to _ftime. This is untested on win64 where the workaround
may not be needed.
2012-03-04 10:50:38 +02:00
Christophe Fergeau
4ec9ac20fc mingw: #ifdef unneeded #define in common.h
common.h has some #define when doing win32 build to workaround a few
missing functions on these systems. However, since mingw32 has some
of these, this causes either warnings about redefining preprocessor
symbols or wreak havoc in mingw headers trying to use these symbols.
This commit wraps these symbols in an #ifndef __MINGW32__ to avoid
using them on this platform.
2012-03-04 10:50:38 +02:00
Christophe Fergeau
5989e2d1c4 mingw: use uintptr_t when converting a pointer to an int
win64 uses 32 bit long, so we cannot use a long to hold a 64 bit
pointer. Thankfully, there's a [u]intptr_t type available exactly
for these uses.
2012-03-04 10:50:38 +02:00
Marc-André Lureau
534b71dfaa build-sys: fix make distcheck
- Do not refer to .c files managed by another makefile (this will fail
  make distclean)
- Do not refer to files by relative path (should use $top_srcdir for ex)
- Use LDADD for object linking instead of LDFLAGS, for linker flags
2012-03-01 16:24:10 +01:00
Marc-André Lureau
22ee470d4e build-sys: cleanup server/tests/Makefile.am 2012-03-01 16:24:10 +01:00
Marc-André Lureau
5d57fb4d1b build-sys: use spice-protocol as submodule 2012-03-01 16:24:10 +01:00
Marc-André Lureau
5077ab60f8 build-sys: cleanup, use autoreconf 2012-03-01 16:24:10 +01:00
Arnon Gilboa
f605e2774d client/windows: fix SetClipboardViewer error handling rhbz#786554
MSDN says the following about SetClipboardViewer(): "If an error occurs or there
are no other windows in the clipboard viewer chain, the return value is NULL".
Seems like the buggy case was "no other windows in the clipboard viewer chain",
which explains the 3rd party clipboard manager workaround detailed in the bug
description.

It also seems like SetClipboardViewer() does not clear the error state on
succcess. Calling SetLastError(0) before SetClipboardViewer() seems to solves
this issue.

Since we could not reproduce the bug on our env, the customer has verified on
several of their systems that a private build resolved the issue.
2012-03-01 14:16:49 +02:00
Yonit Halperin
d2cd7b2b02 client X11: support volume keys when evdev is in use
Add support for sending volume keys scancodes to the guest
RHBZ #552539

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
2012-03-01 08:59:19 +02:00