summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Don't truncate SPICE_FOREIGN_MENU_SOCKETChristophe Fergeau2012-03-201-5/+8
| | | | | | | 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.
* Don't limit spice controller socket name to 50 charsChristophe Fergeau2012-03-201-6/+4
| | | | | | | | | | | | | | | | | | 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
* Remove unused Canvas membersChristophe Fergeau2012-03-204-8/+0
| | | | | The various Canvas have _max and _base variables which are not used, better to remove them.
* server/red_worker: don't typedef SpiceWatch twiceAlon Levy2012-03-201-2/+2
| | | | First defined in spice.h, fixes build failure with gcc 4.4.6
* red_worker: Check for NULL watchesHans de Goede2012-03-131-2/+13
| | | | | | | | 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>
* server: remove superfluous checkNahum Shalman2012-03-121-3/+0
| | | | no need to duplicate the check that the fd isn't -1
* server: listen on a pre-opened file descriptorNahum Shalman2012-03-123-0/+23
| | | | | | | Allow applications to pre-open a file descriptor and have spice listen on it. Thanks to Daniel Berrange for his comments
* server: don't fail on ENOPROTOOPT from setsockoptNahum Shalman2012-03-122-2/+2
| | | | | | 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.
* red_channel: remove pre_disconnect hookHans de Goede2012-03-122-4/+0
| | | | | | Now that red_worker's EventListener is gone there are no more users of it. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* red_worker: Rework poll code to use the watch interfaceHans de Goede2012-03-121-91/+79
| | | | | | | | | | | | | | | | | | | | | | | | | Commit 143a1df24e83e9c1e173c16aeb76d61ffdce9598 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>
* red_channel: Use the channel core to remove the stream watch on disconnectHans de Goede2012-03-121-0/+4
| | | | | | | | | | | | | | | | | 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>
* red_worker: Remove ref counting from the EventListener structHans de Goede2012-03-101-34/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Ensure all members of ChannelCbs and ClientCbs are either assigned or NULLHans de Goede2012-03-109-21/+15
| | | | | | | | | | | | | | | While git-bisecting another issue I ended up hitting and not recognizing the bug fixed by commit 7a079b452b026d6ce38f95dcc397fa64b059fffb. 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>
* server/red_worker: fix use after free for listenersAlon Levy2012-03-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>}
* Use SPICE_FOREIGN_MENU_SOCKET if it's availableMarc-André Lureau2012-03-052-2/+8
| | | | | | | | | | | 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.
* Fix spice-protocol referenceMarc-André Lureau2012-03-051-0/+0
|
* Send name & uuid to capable clientsMarc-André Lureau2012-03-059-1/+118
| | | | | | | | | 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.
* demarshal: fixed-size array are missing __nelementsMarc-André Lureau2012-03-051-1/+1
| | | | | | 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.
* server: more logging about certificates usedChristophe Fergeau2012-03-051-4/+10
| | | | | | | This commit adds some log messages indicating which certificates could be loaded (or not). Fixes rhbz#787678
* Add log for invalid/expired ticketsChristophe Fergeau2012-03-051-0/+5
| | | | | | | 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
* mingw: workaround weird openssl build failureChristophe Fergeau2012-03-041-0/+1
| | | | | | 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
* mingw: don't try to redefine allocaChristophe Fergeau2012-03-041-0/+2
| | | | | mingw already has a #define alloca __builtin_alloca so trying to redefine it triggers a warning.
* mingw: fix signed/unsigned comparison warningsChristophe Fergeau2012-03-043-3/+3
|
* mingw: add workaround for _ftime_s issue on mingwChristophe Fergeau2012-03-041-0/+7
| | | | | | | 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.
* mingw: #ifdef unneeded #define in common.hChristophe Fergeau2012-03-041-0/+2
| | | | | | | | | 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.
* mingw: use uintptr_t when converting a pointer to an intChristophe Fergeau2012-03-044-7/+7
| | | | | | 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.
* build-sys: fix make distcheckMarc-André Lureau2012-03-011-2/+2
| | | | | | | - 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
* build-sys: cleanup server/tests/Makefile.amMarc-André Lureau2012-03-011-10/+43
|
* build-sys: use spice-protocol as submoduleMarc-André Lureau2012-03-015-1/+10
|
* build-sys: cleanup, use autoreconfMarc-André Lureau2012-03-012-158/+11
|
* client/windows: fix SetClipboardViewer error handling rhbz#786554Arnon Gilboa2012-03-011-3/+4
| | | | | | | | | | | | | | | 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.
* client X11: support volume keys when evdev is in useYonit Halperin2012-03-011-0/+6
| | | | | | | Add support for sending volume keys scancodes to the guest RHBZ #552539 Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
* client: keyboard - add mapping for volume keysYonit Halperin2012-03-012-0/+6
| | | | | | | | | | Add support for sending volume keys scancodes to the guest RHBZ #552539 A good reference for mapping keymaps to scancodes can be found in spice-gtk/gtk/keymaps.csv Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
* Fix compilation when smartcard support is disabledChristophe Fergeau2012-02-294-0/+8
| | | | | | The addition of smartcard control to the controller doesn't handle the case when smartcard support is disabled at compile time. When this is the case, this causes compile errors.
* controller_test: add READMEAlon Levy2012-02-281-0/+10
|
* client controller_test: reorder parameters since pid isn't needed for linux ↵Alon Levy2012-02-281-3/+3
| | | | client test
* client: handle CONTROLLER_ENABLE_SMARTCARD (rhbz 641828)Alon Levy2012-02-284-1/+11
|
* controller_test: add ENABLE_SMARTCARDAlon Levy2012-02-281-0/+4
|
* server: fix segfault on client disconnectAlon Levy2012-02-261-2/+1
| | | | | ..as a result of missing initialization of newly introduced pre_disconnect in main channel.
* Enabling cursor in server/testsFabiano Fidêncio2012-02-261-31/+48
| | | | | | Now, cursor is being shown in all tests as a white rectangle and is running in the screen doing a diagonal movement. It's a very simple way to test cursor commands and is sufficient for our tests.
* Use standard IOV_MAX definition where applicableDan McGee2012-02-214-9/+15
| | | | | | | | This is provided by <limits.h> on all platforms as long as _XOPEN_SOURCE is defined. On Linux, this is 1024, on Solaris, this is 16, and on any other platform, we now respect the value supported by the OS. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* Respect IOV_MAX if definedDan McGee2012-02-211-1/+26
| | | | | | | | | | | Solaris has a pitiful maximum writev vector size of only 16, so the ping request at initial startup destroyed this call and broke things immediately. Reimplement stream_writev_cb() to respect IOV_MAX and break the writev() calls into chunks as necessary. Care was taken to return the correct values as necessary so the EAGAIN handling logic can determine where to resume the writev call the next time around. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* red_worker: reimplement event loop using poll()Dan McGee2012-02-214-42/+69
| | | | | | | | | | | | | | | | | | This removes the epoll dependency we had in red_worker, which was the last Linux-specific call we were using in the entire Spice server. Given we never have more than 10 file descriptors involved, there is little performance gain had here by using epoll() over poll(). The biggest change is introduction of a new pre_disconnect callback; this is because poll, unlike epoll, cannot automatically remove file descriptors as they are closed from the pollfd set. This cannot be done in the existing on_disconnect callback; that is too late as the stream has already been closed and the file descriptor lost. The on_disconnect callback can not be moved before the close and other operations easily because of some behavior that relies on client_num being set to a certain value. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* Use memcpy call in red_channel_createDan McGee2012-02-211-8/+1
| | | | | | | | | Rather than assign the callbacks one-by-one, we can just memcpy the struct into the one we have allocated in our RedChannel object, which is much more efficient, not to mention future-proof when more callbacks are added. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* Cleanup definitions of disconnect methodsDan McGee2012-02-212-23/+5
| | | | | | | | | We had multiple stub methods that simply called other disconnect methods, making my head hurt with the indirection. Call the right methods at the right time and rip out the stub methods; if they are truely needed later they can be added again. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* red_worker: rename epoll_timeout to event_timeoutDan McGee2012-02-211-10/+11
| | | | | | | | | With future patches in mind that will allow for some other non-Linux-specific event polling sytem to be used, rename this to a more generic name. All of the select/poll/epoll/kqueue family of calls are related to evented I/O, so 'event_' makes sense in this case. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* Add configure-time check for -Wl, --version-script optionDan McGee2012-02-212-4/+18
| | | | | | | | | This is supported by the GNU linker, but not the Solaris linker, which is used as the default on that platform even when compiling with GCC. Omit passing the option to the linker on platforms that do not support it. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* server/spicevmc: Don't destroy the rcc twiceHans de Goede2012-02-203-3/+6
| | | | | | | | | | | | | | | | | | | | | | | spicevmc calls red_channel_client_destroy() on the rcc when it disconnects since we don't want to delay the destroy until the session gets closed as spicevmc channels can be opened, closed and opened again during a single session. This causes red_channel_client_destroy() to get called twice, triggering an assert, when a connected channel gets destroyed. This was fixed with commit ffc4de01e6f9ea0676f17b10e45a137d7e15d6ac for the case where: a spicevmc channel was open on client disconnected, and the main channel disconnect gets handled first. But the channel can also be destroyed when the chardev gets unregistered with the spice-server. This path still triggers the assert. This patch fixes this by adding a destroying flag to the rcc struct, and also moves the previous fix over to the same, more clean, method of detecting this special case. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* server/tests/basic_event_loop: print something on channel_eventAlon Levy2012-02-151-1/+2
|
* server, separate SpiceChannelEventInfo from RedStreamAlon Levy2012-02-153-22/+30
| | | | | | | | | | 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.