Allows to build out-of-tree and have a clean working directory.
Autoconf used to work with out-of-tree and "config.h" in the
build directory as a "common" directory in the build directory
was created, so including "../config.h" in version.rc and having
"-I $(top_builddir)/common" used to work.
CMake does not create "common" under the build directory so the
"../config.h" inclusion fails.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
GetVersionEx was deprecated by Microsoft in favour of utilities
in versionhelpers.h.
The new function returns the same results as:
- GetVersionEx returns maximum 6.2 version and also 6.0 version
is Vista, not Windows 7 so SYS_VER_WIN_7_CLASS was returned
for all system from Windows Vista;
- We don't support version earlier than Windows XP and no Windows
versions had version >= 5.2 and < 6.0 so SYS_VER_WIN_XP_CLASS
was returned from Windows XP;
- we don't support any system before Windows XP.
Tested under Windows XP, 7 and 10.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This has different advantages:
- code is shorter and more readable;
- does not need to open the file and close;
- works on files bigger than 4gb.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
_ftime_s, vdagent_strcat_s and vdagent_strcpy_s are not used.
Code is using different string functions.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
The GetLocalTime function already returns all information we
need for the log, no needs to call multiple C functions.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
As log type is passed as constant in some macros and the lockup
is basically using this name without the prefix pass to the macro
the name without the prefix.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This complicated macro was used as an helper for LOG macro
which expand PRINT_LINE macro twice. Now that LOG expand PRINT_LINE
only once there's no need to have this macro which make logging code
more complicated.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
VDLog::printf is called only using a VDLog pointer.
Since this class is a singleton, there can only be one instance of it,
so LOG() does not really need to deal with it, VDLog::printf can
do that instead.
This simplifies LOG macros by not having to choose between printf and
VDLog::printf.
The manual GNU __attribute__ is used as the format to use is
not the standard __printf__ format used in SPICE_GNUC_PRINTF
but you need to use the gnu_printf format. For instance the "%llu"
syntax is accepted by gnu_print format but not by __printf__ one.
MinGW C++ by default uses gnu_printf format for all formatting
functions.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
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>
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>
Compiler warnings for unused static variable.
Not for constants.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
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>
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>
For some reason this call does not behave correctly.
This was causing vdservice to fail to run the agent if compiled
with MingW.
Provide a proper swprintf_s replacement.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
We currently have macros silently replacing use of strncpy/strcat with
strcpy_s/strcat_s when using MSVC++. However, these macros can have
unexpected effects as they use sizeof to find out the maximum size of
the destination string. This is a very significant difference from
strncpy/strcat, which can lead to subtle bugs as the behaviour is
different between mingw and MSVC++.
Now that we have our implementation of strcpy_s/strcat_s, we don't need
these #defines.
These security functions are available when building with MSVC++. With
mingw, they can be used at build time, but their availability will
depend on the version of MSVCRT the user has installed on their system.
In particular, a default install of Windows XP will not have a new
enough MSVCRT version, causing runtime failures as the binary built with
mingw and using strcat_s will not be able to find the necessary entry
point in the MSVCRT runtime.
This commit adds some strcat_s/strcpy_s-like functions used with mingw
which will always be available.
This is a follow-up to commits 492ee05a6b and 4b9e9b1d28
Visual Studio complains:
.\file_xfer.cpp(90) : warning C4996: 'strcat': This function or variable
may be unsafe. Consider using strcat_s instead.
To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
See online help for details.
And a similar complain for sscanf.
Replace them with the secure function when compiling with Visual Studio.
Note that the size provided is sizeof(d), which means all calls to
sscanf and strcat must be done with the first param (destination) being
an array and not a pointer.
Visual Studio complains:
vdagent\file_xfer.h(28) : warning C4996: 'strncpy': This function or variable may
Consider using strncpy_s instead.
To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
See online help for details.
Replace strncpy with strcpy_s when building with Visual Studio.
Adjust parameter order and difference in meaning of length:
- length param is last in strncpy and second in strcpy_s
- many calls to strncpy are given length param n-1, as
strncpy does not guarantee that destination ends with '\0'
- it's safer to set length param not larger than sizeof(d)
(assuming d is an array not a pointer)
Trying to use strcpy_s for both Visual Studio and mingw
failed as strcpy_s is missing from the default msvcrt.dll
on WinXP (See OLDMSVCRT in common/vdcommon.h).
This commit is an addition to 4b9e9b1d28
Building with Visual Studio breaks as snprintf is not implemented:
vdagent\file_xfer.cpp(198) : error C3861: 'snprintf': identifier not found
Replace it with sprintf_s for Visual Studio.
Trying to use sprintf_s for both Visual Studio and mingw
failed for mingw64 (build succeeds but runtime error appears).
Fixes the following error:
====
In file included from vdagent/vdagent.cpp:18:0:
./common/vdcommon.h:51:0: warning: "_ftime_s" redefined
#define _ftime_s(timeb) _ftime(timeb)
^
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/sys/timeb.h:124:0,
=====
Terminate agent politely instead of ugly TerminateProcess(), so now
VD_AGENT_CLIPBOARD_RELEASE is sent (if guest owned the clipboard),
followed by cleanup.
rhbz #903379
Aliasing _ftime_s to _ftime when OLDMSVCRT is defined makes it
possible to remove the timestamp-less implementation of LOG()
while still getting a binary working on Windows XP. I've tested
this with a MinGW build, hopefully this won't break VC++ builds...
vdlog.cpp has an #ifdef check for OLDMSVC to choose between using
swprintf or swprintf_s. Since vdcommon.h provides a compat #define
for swprintf_s when OLDMSVC is set, it's better to use this one.
Apparently, it comes with a recent version of C library (msvcrt90?),
but I don't know if we can/should ship also a MS dll. Probably it used
to work with an inlined version with VS headers.
The build can be tweaked to use the -non-_s variant with -DOLDMSVCRT
CFLAGS.
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.
This patch is a little dirty due to EOL convertion to windows format.
+ add pci_vdi_port with PCIVDIPort taken from last commit before
changing to virtio-serial (a17ccbf323)
+ move handle_error to VDIPort (identical in VIRTIOVDIPort and PCIVDIPort)
+ make VDService create first a virtio, then init, the pci, then init,
stopping when the first init succeeds, and reporting to log which was
created.
The configuration is received from Spice client.
The main usage of this option is for disabling display features in order to accelerate Spice performance over limited network connections.