qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] guest agent: Fixes for windows guest agent building on msys2


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH] guest agent: Fixes for windows guest agent building on msys2/mingw
Date: Tue, 15 Sep 2020 19:55:02 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

On 9/15/20 7:41 PM, 罗勇刚(Yonggang Luo) wrote:
> On Wed, Sep 16, 2020 at 12:41 AM Philippe Mathieu-Daudé
> <philmd@redhat.com <mailto:philmd@redhat.com>> wrote:
>>
>> On 9/15/20 6:33 PM, Yonggang Luo wrote:
>> > error message:
>> > "cc" "-Iqga/qemu-ga.exe.p" "-Iqga" "-I../qga" "-I." "-Iqapi"
> "-Itrace" "-Iui" "-Iui/shader" "-IC:/CI-Tools/msys64/mingw64/include"
> "-IC:/CI-Tools/msys64/mingw64/include/glib-2.0"
> "-IC:/CI-Tools/msys64/mingw64/lib/glib-2.0/include"
> "-fdiagnostics-color=auto" "-pipe" "-Wall" "-Winvalid-pch" "-Werror"
> "-std=gnu99" "-g" "-m64" "-mcx16" "-D_GNU_SOURCE"
> "-D_FILE_OFFSET_BITS=64" "-D_LARGEFILE_SOURCE" "-Wstrict-prototypes"
> "-Wredundant-decls" "-Wundef" "-Wwrite-strings" "-Wmissing-prototypes"
> "-fno-strict-aliasing" "-fno-common" "-fwrapv" "-Wold-style-declaration"
> "-Wold-style-definition" "-Wtype-limits" "-Wformat-security"
> "-Wformat-y2k" "-Winit-self" "-Wignored-qualifiers" "-Wempty-body"
> "-Wnested-externs" "-Wendif-labels" "-Wexpansion-to-defined"
> "-Wno-missing-include-dirs" "-Wno-shift-negative-value" "-Wno-psabi"
> "-fstack-protector-strong" "-iquote" "/c/work/xemu/qemu/tcg/i386"
> "-iquote" "." "-iquote" "/c/work/xemu/qemu" "-iquote"
> "/c/work/xemu/qemu/accel/tcg" "-iquote" "/c/work/xemu/qemu/include"
> "-iquote" "/c/work/xemu/qemu/disas/libvixl" "-pthread" "-mms-bitfields"
> -MD -MQ qga/qemu-ga.exe.p/commands-win32.c.obj -MF
> "qga/qemu-ga.exe.p/commands-win32.c.obj.d" -o
> qga/qemu-ga.exe.p/commands-win32.c.obj "-c" ../qga/commands-win32.c -MP
>> > ../qga/commands-win32.c:62:24: error: redundant redeclaration of
> 'CM_Get_DevNode_PropertyW' [-Werror=redundant-decls]
>> >    62 | CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(
>> >       |                        ^~~~~~~~~~~~~~~~~~~~~~~~
>> > In file included from ../qga/commands-win32.c:26:
>> >
> C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/cfgmgr32.h:840:26:
> note: previous declaration of 'CM_Get_DevNode_PropertyW' was here
>> >   840 |   CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(DEVINST
> dnDevInst, const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType,
> PBYTE PropertyBuffer, PULONG PropertyBufferSize, ULONG ulFlags);
>> >       |                          ^~~~~~~~~~~~~~~~~~~~~~~~
>> > cc1.exe: all warnings being treated as errors
>> > make: [Makefile.ninja:5143:qga/qemu-ga.exe.p/commands-win32.c.obj]
> 错误 1 (已忽略)
>> >
>> > This error comes from qemu configure didn't add predefined macro
> -DUNICODE -D_UNICODE in QEMU_CFLAGS,
>> > and these too macro are standard config for win32 if using windows
> wide api.
>> >
>> > in cfgmgr32.h
>> >   CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(DEVINST dnDevInst,
> const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PBYTE
> PropertyBuffer, PULONG PropertyBufferSize, ULONG ulFlags);
>> > #ifdef UNICODE
>> > #define CM_Get_DevNode_Property CM_Get_DevNode_PropertyW
>> > #endif
>> >
>> > macro CM_Get_DevNode_Property defined only when UNICODE are defined.
>> > and in win32, UNICODE and _UNICODE should be defined at the same time
>> >
>> > #endif
>> >
>> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com
> <mailto:luoyonggang@gmail.com>>
>> > ---
>> >  configure | 1 +
>> >  1 file changed, 1 insertion(+)
>> >
>> > diff --git a/configure b/configure
>> > index 9f141891ea..f5d661af4a 100755
>> > --- a/configure
>> > +++ b/configure
>> > @@ -812,6 +812,7 @@ MINGW32*)
>> >    mingw32="yes"
>> >    hax="yes"
>> >    whpx=""
>> > +  QEMU_CFLAGS="-DUNICODE -D_UNICODE $QEMU_CFLAGS"
>>
>> What about declaring them in include/qemu/osdep.h
>> instead?
> That's a good idea.
> But more compiling error warns me that the windows version of qemu are
> not in a good situation.

:)

> On Win32, all API should call the wide version so that support for
> Unicode properly.
> But obviously the currently qemu didn't do that
> 
> ```
[...]
> ../util/qemu-sockets.c: In function 'socket_sockaddr_to_address_inet':
> C:/work/xemu/qemu/include/qapi/error.h:319:25: error: format '%s'
> expects argument of type 'char *', but argument 6 has type 'WCHAR *'
> {aka 'short unsigned int *'} [-Werror=format=]
>   319 |                         (fmt), ## __VA_ARGS__)
>       |                         ^~~~~
> ../util/qemu-sockets.c:1235:9: note: in expansion of macro 'error_setg'
>  1235 |         error_setg(errp, "Cannot format numeric socket address: %s",
>       |         ^~~~~~~~~~
> In file included from ../io/dns-resolver.c:26:
> ../io/dns-resolver.c: In function 'qio_dns_resolver_lookup_sync_inet':
> C:/work/xemu/qemu/include/qapi/error.h:319:25: error: format '%s'
> expects argument of type 'char *', but argument 8 has type 'WCHAR *'
> {aka 'short unsigned int *'} [-Werror=format=]
>   319 |                         (fmt), ## __VA_ARGS__)
>       |                         ^~~~~
> ../io/dns-resolver.c:93:9: note: in expansion of macro 'error_setg'
>    93 |         error_setg(errp, "address resolution failed for %s:%s: %s",
>       |         ^~~~~~~~~~
> cc1.exe: all warnings being treated as errors
> make: [Makefile.ninja:756:io/libio.fa.p/dns-resolver.c.obj] 错误 1 (已
> 忽略)
> cc1.exe: all warnings being treated as errors
> make: [Makefile.ninja:697:libqemuutil.a.p/util_qemu-sockets.c.obj] 错误
> 1 (已忽略)
> Linking static target io/libio.fa
> C:\CI-Tools\msys64\mingw64\bin\ar.exe: io/libio.fa.p/dns-resolver.c.obj:
> No such file or directory
> make: [Makefile.ninja:764:io/libio.fa] 错误 1 (已忽略)
> ../net/tap-win32.c: In function 'is_tap_win32_dev':
> ../net/tap-win32.c:62:21: error: passing argument 2 of 'RegOpenKeyExW'
> from incompatible pointer type [-Werror=incompatible-pointer-types]
>    62 | #define ADAPTER_KEY
> "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
>       |                    
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>       |                     |
>       |                     const char *
> ../net/tap-win32.c:62:21: note: in definition of macro 'ADAPTER_KEY'
>    62 | #define ADAPTER_KEY
> "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
>       |                    
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from
> C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:76,
>                  from
> C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/winsock2.h:23,
>                  from C:/work/xemu/qemu/include/sysemu/os-win32.h:29,
>                  from C:/work/xemu/qemu/include/qemu/osdep.h:119,
>                  from ../net/tap-win32.c:29:
> C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/winreg.h:195:57:
> note: expected 'LPCWSTR' {aka 'const short unsigned int *'} but argument
> is of type 'const char *'
>   195 |   WINADVAPI LONG WINAPI RegOpenKeyExW(HKEY hKey,LPCWSTR
> lpSubKey,DWORD ulOptions,REGSAM samDesired,PHKEY phkResult);
>       |                                                 ~~~~~~~~^~~~~~~~
> ../net/tap-win32.c:229:13: error: passing argument 3 of 'RegEnumKeyExW'
> from incompatible pointer type [-Werror=incompatible-pointer-types]
>   229 |             enum_name,
>       |             ^~~~~~~~~
>       |             |
>       |             char *
> In file included from
> C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:76,
>                  from
> C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/winsock2.h:23,
>                  from C:/work/xemu/qemu/include/sysemu/os-win32.h:29,
>                  from C:/work/xemu/qemu/include/qemu/osdep.h:119,
>                  from ../net/tap-win32.c:29:
> C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/winreg.h:184:70:
> note: expected 'LPWSTR' {aka 'short unsigned int *'} but argument is of
> type 'char *'
>   184 |   WINADVAPI LONG WINAPI RegEnumKeyExW(HKEY hKey,DWORD
> dwIndex,LPWSTR lpName,LPDWORD lpcchName,LPDWORD lpReserved,LPWSTR
> lpClass,LPDWORD lpcchClass,PFILETIME lpftLastWriteTime);
>       |                                                              
> ~~~~~~~^~~~~~
> ../net/tap-win32.c:247:13: error: passing argument 2 of 'RegOpenKeyExW'
> from incompatible pointer type [-Werror=incompatible-pointer-types]
>   247 |             unit_string,
>       |             ^~~~~~~~~~~
>       |             |
>       |             char *

I'm not sure fixing all these warnings would produce a
maintainable code base. I'd rather disable these 2 warning
classes on Windows.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]