Commit Graph

259 Commits

Author SHA1 Message Date
Frediano Ziglio
f00fe84cc3 Prevent possible future buffer overflow
event_type should come only with specific values but
this in theory can change in the future.
To prevent overflows (just for logging) check value size
against lookup array.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <cdupontd@redhat.com>
2017-07-26 08:52:15 +01:00
Frediano Ziglio
8512940e53 fix format string for Visual Studio
The "z" size specifier is not supported by Visual Studio.
Cast to unsigned long and use "l" specifier as the type has
enough precision for this vector.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-24 17:18:23 +01:00
Frediano Ziglio
78099ae2bf log: add comment to make code clearer
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-24 16:45:38 +01:00
Frediano Ziglio
1a0bc10cbe log: rewrite log_version using config.h definitions
Instead of having to get the version information from the
executable resources get from the build configuration file.
The same version is used to build the version information
resource.
This also remove a bug in log_version where "throw" statements
were used to raise again a not existing exception on case
of failures.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-24 13:42:01 +01:00
Frediano Ziglio
8f47080fa8 Remove small memory leak in log_version
log_version() declares 2 info_buf variables, the inner one is used to
hold allocated memory, but then we free the outer one, which is NULL.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-22 09:34:36 +01:00
Frediano Ziglio
cf7a929655 Use single variable for path computations
This saves some stack memory not reducing any readability.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-21 14:59:55 +01:00
Frediano Ziglio
b15e525702 Split long if statement
Instead of having a long if statement with checks and assignment
split in two.
The conditions where used to compute 2 different path, this does
not help much with code readability.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-07-19 13:10:31 +01:00
Uri Lublin
64f771fef1 event_dispatcher: vd_printf calls -- remove __func__
vd_printf adds __FUNCTION__

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-07-14 11:16:48 +01:00
Uri Lublin
32bb5cbeb0 clipboard: log format used
Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-07-14 11:16:42 +01:00
Frediano Ziglio
61830ede2d Avoid log_level warning using a static const
Compiler warnings for unused static variable.
Not for constants.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-07-10 13:20:35 +01:00
Frediano Ziglio
e1786ee7f6 Enable debug information build on spec file
The spec file cause the generation of debuginfo packages however
the build fails as the executables are not compiled with debugging
information.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-07-10 13:20:30 +01:00
Frediano Ziglio
b2c8665777 Store agent process handle instead of using PROCESS_INFORMATION
We just need the handle of the process.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-08 08:23:20 +01:00
Frediano Ziglio
babef14b8c Use process handle to mark agent existence
Avoid extra field that could be out of sync.
Having a valid process handle is enough.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-08 08:23:18 +01:00
Frediano Ziglio
143f6e55ee Close agent thread handle
This is not needed so we can close it

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-08 08:23:16 +01:00
Frediano Ziglio
cf829d09ef Make some functions static
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-08 08:22:36 +01:00
Frediano Ziglio
ea9d41586c Update project URL
Uses secure version https://www.spice-space.org.
Avoid not secure and use same full name.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-07-07 09:45:28 +01:00
kunming.xie
f80ee415c1 Fix hdesk handle leak in vdagent
Signed-off-by: kunming.xie <kunming.xie@hotmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-05-23 16:35:04 +01:00
Frediano Ziglio
65f1c5e31a spec: Add missing mingwXX-winpthreads-static dependency
Without this dependency mock builds fails to build.
Tried Fedora 25, Fedora 26 and Rawhide (all x86-64) and all
mock builds are failing with "cannot find -lpthread" error.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-05-23 16:21:12 +01:00
Jakub Janků
3b1d9ab0a0 Use sprintf_s instead of sprintf to not crash
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-05-18 11:03:55 +01:00
Frediano Ziglio
241425b7da Support file transfer for existing files
Previously, if the user attempted to transfer a file that had the same
name as a file that already exists on the guest, we would just fail the
transfer. This patch tries to match the behavior of the linux vdagent
where we try to append an integer onto the name of the new file to make
it unique. For example, if you tried to transfer 'file.doc' to the guest
and that file already existed, it would try to create 'file (1).doc'
instead. If that also failed, it would attempt 'file (2).doc', etc, up
to 63.

Resolves: rhbz#1410181
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-05-02 14:49:36 -05:00
Jonathon Jongsma
a2b4da90a1 Don't exit vdagent when a client disconnects
Previously, when a client disconnects, the vdagent executable exited.
The agent was restarted immediately in order to be ready for the next
client to reconnect.

This is generally fine, but there are certain situations
where it causes issues. For example, if client A is connected to a guest
and client B connects to the same guest, client A will be forcibly
disconnected and causes the the vdagent to restart. This scenario is
racy because the agent can take some time to exit and restart. Client B
may think that the agent is connected at startup and may send agent
messages to the guest.  At some point the server will recieve
notification that the agent has exited and send an AGENT_DISCONNECTED
message to client B. After the agent has been fully restarted, an
AGENT_CONNECTED message will be sent to the client, but any messages
sent between client connection and the AGENT_DISCONNECTED message will
be lost. This causes problems especially with fullscreen mode in
virt-viewer.

The solution is to not exit and restart the agent when a client
disconnects. This is how the linux vdagent behaves. Instead, we simply
cancel all ongoing file transfers and reset the clipboard when a client
is disconnected.

Fixes: rhbz#1064495
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-04-05 10:30:00 -05:00
Uri Lublin
6d2ccaf7d2 vdservice: drop "RHEV" from service name
Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-12-22 20:14:37 +02:00
Frediano Ziglio
86cd88b1f8 build: Package zip file
zip files are better supported under Windows, this make
possible for instance to copy directly the file on a Windows
machine without having to use additional tools.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-17 13:17:23 +00:00
Frediano Ziglio
a814ff95c1 build: Automatically update version/copyright in version.rc
The versions/copyright in version.rc are very outdated.
Updating them automatically at configure time should ensure they are
updated more often.
Looks a bit weird to distribute config.h file however in this
case it contain only version information and the file is
useful to compile under Windows.

This patch is inspired by a work of Christophe Fergeau

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-17 13:17:20 +00:00
Frediano Ziglio
4fbd7b485e Move common resource code to a common file
Allows to reuse code. Differences between the two
version information are managed using additional defines
in the top rc files.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-17 13:17:18 +00:00
Frediano Ziglio
4d51e5709f Convert resource information to English
They don't contain Hebrew so avoid to say so.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-17 13:17:12 +00:00
Christophe Fergeau
0966c38c0d Update NEWS for 0.8.0 release 2016-10-28 10:51:34 +02:00
Frediano Ziglio
debf1fe981 Make CCD::load_api throw exception on its own
Avoid to use two different ways to handle errors.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Sameeh Jubran <sameeh@daynix.com>
2016-09-02 16:56:09 +01:00
Frediano Ziglio
b24a935335 Fails CCD initialisation if get_config_buffers detect WDDM is not present
There's no point continuing without WDDM as CCD cannot work without it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Sameeh Jubran <sameeh@daynix.com>
2016-09-02 16:55:54 +01:00
Frediano Ziglio
67b63fe6f7 Do not print function calling vd_printf
vd_printf already print the current function

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-02 15:26:27 +01:00
Frediano Ziglio
75a0033f42 Use simpler classes for mutex handling
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-01 15:50:14 +01:00
Frediano Ziglio
ec0a2352b1 Use std::vector for agent capabilities
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-01 15:50:14 +01:00
Frediano Ziglio
25ef634202 Make some members constant
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-01 15:46:50 +01:00
Frediano Ziglio
2cb102280a Make static and constant some lookup arrays
Make clipboard_formats and image_types static and constant.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-01 15:46:50 +01:00
Frediano Ziglio
7555e21545 Reuse SPICE_N_ELEMENTS macro
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-01 15:46:50 +01:00
Frediano Ziglio
89445cd1b4 Make session_events static and const
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-01 15:46:50 +01:00
Frediano Ziglio
9ed7be6445 Make DisplayMode setter methods const
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-01 15:45:19 +01:00
Frediano Ziglio
011d60e628 Fix include syntax
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-01 15:45:17 +01:00
Frediano Ziglio
6bdd83d780 Remove small possible buffer overflow
wcsncpy requires number of characters, not bytes.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-01 15:45:11 +01:00
Sameeh Jubran
3616a7ed38 Implementing WDDM interface to support multiple monitors and arbitrary resolution
The Direct3D 9 API operates on either the Windows XP display driver
model (XPDM) or the Windows Vista display driver model (WDDM), depending
on the operating system installed.

This patch implements the WDDM interface while using the CCD API to do
so. Moreover it introduces multiple monitors support and arbitrary
resolution for Windows 10 while preserving backward compatiblity with
previous versions of Windows.

Based on a patch by Sandy Stutsman <sstutsma at redhat.com>

Signed-off-by: Dmitry Fleytman <dfleytma at redhat.com>
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-01 12:32:59 +01:00
Sameeh Jubran
9c561ca8fe Update the displays only when needed
This patch updates the display configurations only when needed.
Currently vdagent updates the display configurations almost on every
"VD_AGENT_MONITORS_CONFIG" request, this approach is redundant as some
"VD_AGENT_MONITORS_CONFIG" requests don't apply any change to the
display configurations.

A good example of why this is needed, is the 'resize-guest' feature of
the spice-widget which when enabled causes the client to send periodic
"VD_AGENT_MONITORS_CONFIG" requests in order to resize the guest even
when no change is required. Prior to this patch the screen would
periodically flicker when using Virt-manager or Spicy due to this issue.

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-08-30 17:15:11 +01:00
Sameeh Jubran
3856b1147a Initialize buffers before querying display config
The buffers and buffer sizes should be initialized and allocated. This
patch fixes a possible case where vdagent can get stuck, as the
function _pfnQueryDisplayConfig can return ERROR_INVALID_PARAMETER
if the buffers aren't intialized.
The call to free_config_buffers is superfluous because it is called
inside get_config_buffers.

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-08-30 14:22:56 +01:00
Frediano Ziglio
efcd07af8b Avoid to use _singleton for VDService
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-08-16 15:43:23 +01:00
Frediano Ziglio
f96d575659 Pass class pointer using thread parameter
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-08-16 15:43:21 +01:00
Frediano Ziglio
2ab513267b Don't use _singleton if we already have the right this pointer
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-08-16 15:43:19 +01:00
Frediano Ziglio
2a2390df7e Pass class pointer using control context
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-08-16 15:43:13 +01:00
Sameeh Jubran
d81d8cdbde Encapsulating XPDM implementation
The Direct3D 9 API operates on either the Windows XP display driver
model (XPDM) or the Windows Vista display driver model (WDDM), depending
on the operating system installed.

This patch encapsulates the current XPDM interface implementation into
XPDMInterface class which inherits DisplayConfig class. This patch
makes it easier to introduce WDDM interface to Vdagent in future
patches.

Based on a patch by Sandy Stutsman <sstutsma@redhat.com>

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-08-16 11:19:02 +01:00
Sameeh Jubran
588a7134df Introducing Windows CCD API
The Connecting and Configuring Displays (CCD) Win32 APIs
provide more control over the desktop display setup. The CCD APIs
move away from using Windows Graphics Device Interface (GDI)
concepts like view name and toward Windows Display Driver Model
(WDDM) concepts like adapter, source, and target identifiers.
More info on the CCD API can be found here:
https://msdn.microsoft.com/en-us/library/windows/hardware/ff539590(v=vs.85).aspx

This patch introduces partial functionality from the CCD API
needed by vdagent. It is needed by vdagent in order to support
multiple monitors and arbitrary resolution on Windows 10.

Based on a patch by Sandy Stutsman <sstutsma@redhat.com>

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-08-16 11:19:00 +01:00
Sameeh Jubran
714801261f Update monitor state when it is detached
The monitor detached state is being set but not updated, in order to update it
we should call ChangeDisplaySettingsEx after setting the appropriate
flags along with width and height that are set to 0.

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-08-16 06:37:12 +01:00
Victor Toso
3bddbd19fd vdagent: rework on event_dispatcher
As _stop_event is not mandatory, we are initializing the events array
with something that might be NULL. The problem is with the following
patch as I'm introducing a new non mandatory event and logic starts to
get a bit hard to follow.

So this patch makes explicit if we are setting or receiving a
_stop_event or not and uses an auxiliary enum and array 'actions' to
work around this non mandatory events and the return value of
MsgWaitForMultipleObjectsEx()

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-08-13 17:47:49 +02:00